...
|
...
|
@@ -4,10 +4,8 @@ package com.sy.logic; |
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.sy.crossDomain.buildBarCode;
|
|
|
import com.sy.model.GatherInfo;
|
|
|
import com.sy.model.LandBusinessTypeList;
|
|
|
import com.sy.model.LandRoadVe;
|
|
|
import com.sy.model.RESMESSAGE;
|
|
|
import com.sy.model.*;
|
|
|
import com.sy.service.EnterCancelServer;
|
|
|
import com.sy.service.LandBusListService;
|
|
|
import com.sy.service.LandRoadVeService;
|
|
|
import com.sy.service.ResMessageService;
|
...
|
...
|
@@ -52,7 +50,10 @@ public class LogicOperation { |
|
|
@Autowired
|
|
|
private ResMessageService resMessageService;
|
|
|
|
|
|
private static LogicOperation logic;
|
|
|
@Autowired
|
|
|
private EnterCancelServer enterCancelServer;
|
|
|
|
|
|
private static LogicOperation logic = new LogicOperation();
|
|
|
|
|
|
//读取配置文件里的载重与称重的可控范围
|
|
|
private static String checkWt = FileTool.readProperties("grossWt");
|
...
|
...
|
@@ -64,8 +65,8 @@ public class LogicOperation { |
|
|
private static String INPUTSTATION = "此车辆未做进站申请";
|
|
|
private static String ENTERSTATION = "此车辆未做出站申请";
|
|
|
private static String ISVALID = "二维码数据异常,请使用正确的二维码数据";
|
|
|
private static String ERRORWT="出起始场站的重量和进目的场站的重量不一致";
|
|
|
private static String IEPORSE="无相对应进出场申请";
|
|
|
private static String ERRORWT = "出起始场站的重量和进目的场站的重量不一致";
|
|
|
private static String IEPORSE = "无相对应进出场申请";
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
...
|
...
|
@@ -73,6 +74,7 @@ public class LogicOperation { |
|
|
logic.listService = this.listService;
|
|
|
logic.veService = this.veService;
|
|
|
logic.resMessageService = this.resMessageService;
|
|
|
logic.enterCancelServer = this.enterCancelServer;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -96,7 +98,7 @@ public class LogicOperation { |
|
|
}
|
|
|
LandBusinessTypeList list = logic.listService.selectForOne(info.getVename(), info.getBarcode(), info.getAreaid
|
|
|
(), info.getChnlno(), info.getIetype());
|
|
|
if(list == null) {
|
|
|
if (list == null) {
|
|
|
CommandClient.Client(info, IEPORSE);
|
|
|
return result;
|
|
|
}
|
...
|
...
|
@@ -113,14 +115,13 @@ public class LogicOperation { |
|
|
type = "E";
|
|
|
}
|
|
|
logger.info("=======================>>>>>>>>>>" + type + "<<<<<<<<<<========================");
|
|
|
goodsWt = GoodsWt(list.getMasterList(), type);
|
|
|
goodsWt = logic.GoodsWt(list.getMasterList(), type);
|
|
|
}
|
|
|
//车自重
|
|
|
double selfWt = Double.parseDouble(ve.getSelfWt());
|
|
|
|
|
|
|
|
|
|
|
|
if (!logic.checkFlag(growssWt, (selfWt+goodsWt))) {
|
|
|
if (!logic.checkFlag(growssWt, (selfWt + goodsWt))) {
|
|
|
List<LandBusinessTypeList> typeLists = logic.listService.selectMessageId(list.getMassageId());
|
|
|
for (int i = 0; i < typeLists.size(); i++) {
|
|
|
|
...
|
...
|
@@ -133,14 +134,14 @@ public class LogicOperation { |
|
|
}
|
|
|
}
|
|
|
|
|
|
if ("出口送货".equals(list.getBusinesstype())){
|
|
|
if ("出口送货".equals(list.getBusinesstype())) {
|
|
|
if ("E".equals(list.getTurnoverflag())) {
|
|
|
if ("I".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getContrastflag() != null) {
|
|
|
if("1".equals(list.getIsfull())){
|
|
|
if(list.getMasterList().length()>0){
|
|
|
selfWt = typeLists.get(i).getAislewt()-Double.parseDouble(typeLists.get(i).getRemark());
|
|
|
}else {
|
|
|
selfWt=growssWt;
|
|
|
if ("1".equals(list.getIsfull())) {
|
|
|
if (list.getMasterList().length() > 0) {
|
|
|
selfWt = typeLists.get(i).getAislewt() - Double.parseDouble(typeLists.get(i).getRemark());
|
|
|
} else {
|
|
|
selfWt = growssWt;
|
|
|
}
|
|
|
}
|
|
|
break;
|
...
|
...
|
@@ -148,8 +149,8 @@ public class LogicOperation { |
|
|
}
|
|
|
}
|
|
|
|
|
|
if(list.getBusinesstype().endsWith("流转")){
|
|
|
if(list.getMasterList().length()>0){
|
|
|
if (list.getBusinesstype().endsWith("业务")) {
|
|
|
if (list.getMasterList().length() > 0) {
|
|
|
if ("E".equals(list.getTurnoverflag())) {
|
|
|
if ("I".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getContrastflag() != null) {
|
|
|
selfWt = typeLists.get(i).getAislewt() > 1 ? typeLists.get(i).getAislewt() : selfWt;
|
...
|
...
|
@@ -158,7 +159,7 @@ public class LogicOperation { |
|
|
}
|
|
|
if ("I".equals(list.getTurnoverflag())) {
|
|
|
if ("E".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getContrastflag() != null) {
|
|
|
if(!logic.checkFlag(growssWt,typeLists.get(i).getAislewt())){
|
|
|
if (!logic.checkFlag(growssWt, typeLists.get(i).getAislewt())) {
|
|
|
logger.info("-------->>>>>>>>出起始场站的重量和进目的场站的总量不一致<<<<<<<<--------");
|
|
|
CommandClient.Client(info, ERRORWT);
|
|
|
return result;
|
...
|
...
|
@@ -167,11 +168,10 @@ public class LogicOperation { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
boolean check = checkResult(growssWt, selfWt, goodsWt);
|
|
|
boolean check = logic.checkResult(growssWt, selfWt, goodsWt);
|
|
|
boolean checkMainfest = logic.checkManifest(list.getMasterList());
|
|
|
boolean checkResult = false;
|
|
|
|
...
|
...
|
@@ -187,25 +187,37 @@ public class LogicOperation { |
|
|
checkResult = true;
|
|
|
}
|
|
|
}
|
|
|
logger.info("重量校验结果:"+check+",运单校验结果:"+checkMainfest+",最终校验结果:"+checkResult);
|
|
|
logger.info("重量校验结果:" + check + ",运单校验结果:" + checkMainfest + ",最终校验结果:" + checkResult);
|
|
|
|
|
|
if (sendBw(info, checkResult)) {
|
|
|
if (logic.sendBw(info, checkResult)) {
|
|
|
if ("I".equals(info.getIetype())) {
|
|
|
System.out.println(info.getGrosswt().doubleValue());
|
|
|
// LandRoadVe veName = logic.veService.selectByFrameNo(vaName);
|
|
|
list.setAislewt(info.getGrosswt().doubleValue());
|
|
|
list.setUpdateDate(new Date());
|
|
|
list.setRemark(String.format("%.1f",goodsWt));
|
|
|
list.setRemark(String.format("%.1f", goodsWt));
|
|
|
list.setRemark2(ve.getSelfWt());
|
|
|
list.setContrastflag("已进站");
|
|
|
logic.checkData(list);
|
|
|
} else {
|
|
|
List<LandBusinessTypeList> typeLists = logic.listService.selectMessageId(list.getMassageId());
|
|
|
//进出相差重量
|
|
|
double diffVal = 0;
|
|
|
for (int i = 0; i < typeLists.size(); i++) {
|
|
|
if ("I".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getEndstation().equals(list.getEndstation())) {
|
|
|
diffVal = typeLists.get(i).getAislewt() - growssWt;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
LandRoadVe veName = logic.veService.selectByFrameNo(vaName);
|
|
|
list.setAislewt(info.getGrosswt().doubleValue());
|
|
|
list.setUpdateDate(new Date());
|
|
|
list.setRemark(String.format("%.1f",goodsWt));
|
|
|
list.setRemark(String.format("%.1f", goodsWt));
|
|
|
list.setRemark1(String.format("%.1f", diffVal));
|
|
|
list.setRemark2(veName.getSelfWt());
|
|
|
list.setContrastflag("已出站");
|
|
|
logic.checkData(list);
|
|
|
}
|
|
|
int row = logic.listService.updateById(list);
|
|
|
System.out.println(row);
|
|
|
List<LandBusinessTypeList> businessTypeLists = logic.listService.selectByBarcode(info.getBarcode());
|
|
|
int count = 0;
|
|
|
for (int i = 0; i < businessTypeLists.size(); i++) {
|
...
|
...
|
@@ -215,6 +227,7 @@ public class LogicOperation { |
|
|
}
|
|
|
}
|
|
|
if (list.getBusinesstype().indexOf("业务") > 0) {
|
|
|
logic.inOrUpEnterCancel(list);
|
|
|
if (count == 4) {
|
|
|
buildBarCode.cancleBarCode(vaName);
|
|
|
logic.listService.updateByBarcode(info.getBarcode());
|
...
|
...
|
@@ -255,7 +268,7 @@ public class LogicOperation { |
|
|
* @Param goodsWt 货物总重
|
|
|
* @Result 获取运单重量
|
|
|
*/
|
|
|
public static boolean checkResult(double grossWt, double wt, double goodsWt) {
|
|
|
public boolean checkResult(double grossWt, double wt, double goodsWt) {
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
boolean flag = false;
|
|
|
double result = 0.0;
|
...
|
...
|
@@ -275,90 +288,95 @@ public class LogicOperation { |
|
|
* @Param ietype 进出标志
|
|
|
* 获取货物总重
|
|
|
*/
|
|
|
public static double GoodsWt(String mainifast, String ietype) {
|
|
|
public double GoodsWt(String mainifast, String ietype) {
|
|
|
Double sum = 0.0;
|
|
|
if (mainifast.length() > 0) {
|
|
|
String[] mainifastList = mainifast.split(",");
|
|
|
for (String mainBill : mainifastList) {
|
|
|
sum = sum += getGrossWt(mainBill, ietype);
|
|
|
sum += getGrossWt(mainBill, ietype);
|
|
|
}
|
|
|
}
|
|
|
return sum;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询运单是否全部放行
|
|
|
*
|
|
|
* @param manifestList
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean checkManifest(String manifestList) {
|
|
|
if (manifestList.length() < 1) return false;
|
|
|
manifestList = manifestList.replace("-", "");
|
|
|
String[] maifest = manifestList.split(",");
|
|
|
boolean flag = false;
|
|
|
int count = 0;
|
|
|
for (int i = 0; i < maifest.length; i++) {
|
|
|
RESMESSAGE resmessage = logic.resMessageService.selectByManifest(maifest[i]);
|
|
|
if(resmessage !=null){
|
|
|
if ("11".equals(resmessage.getResponsecode())) {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (count == maifest.length) {
|
|
|
flag = true;
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Param waybill 主单号
|
|
|
* @Param imp 进出港标识
|
|
|
* @Result 获取运单重量
|
|
|
*/
|
|
|
public static double getGrossWt(String waybill, String imp) {
|
|
|
// logger.info("进入获取重量action");
|
|
|
public double getGrossWt(String waybill, String imp) {
|
|
|
logger.info("进入获取重量action");
|
|
|
if (!(waybill.indexOf("-") != -1)) {
|
|
|
waybill = waybill.substring(0, 3) + "-" + waybill.substring(3);
|
|
|
}
|
|
|
String url = "http://10.50.3.64:8080/tj/orig/orig?waybill=" + waybill + "&imp=" + imp;
|
|
|
// String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig=" + waybill + "&imp=" + imp;
|
|
|
// String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp;
|
|
|
StringBuilder json = new StringBuilder();
|
|
|
Map map = null;
|
|
|
double bg = 0;
|
|
|
try {
|
|
|
URL Url = new URL(url);
|
|
|
URLConnection yc = Url.openConnection();
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream(), "utf-8"));
|
|
|
String inputLine = null;
|
|
|
while ((inputLine = in.readLine()) != null) {
|
|
|
json.append(inputLine);
|
|
|
}
|
|
|
// logger.info("返回数据:" + json);
|
|
|
logger.info("返回数据:" + json);
|
|
|
JSONArray array = JSONArray.parseArray(json.toString());
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
map = JSON.parseObject(array.getString(i));
|
|
|
System.out.println(map);
|
|
|
if(map.containsKey("receiptinformation")){
|
|
|
if (map.containsKey("receiptinformation")) {
|
|
|
if (map.get("receiptinformation").toString().startsWith("41301") || map.get("receiptinformation")
|
|
|
.toString().startsWith("41106") || map.get("receiptinformation")
|
|
|
.toString().startsWith("31301") || map.get("receiptinformation")
|
|
|
.toString().startsWith("31106") || map.get("receiptinformation")
|
|
|
.toString().indexOf("提运单放行")!=-1) {
|
|
|
.toString().indexOf("提运单放行") != -1) {
|
|
|
logger.info(map);
|
|
|
bg = Double.parseDouble((String) map.get("totalweight"));
|
|
|
logger.info("for循环取重量:" + bg);
|
|
|
return bg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// logger.info("访问返回的数据重量:" + bg);
|
|
|
logger.info("访问返回的数据重量:" + bg);
|
|
|
in.close();
|
|
|
} catch (MalformedURLException e) {
|
|
|
// logger.info(e.toString());
|
|
|
e.printStackTrace();
|
|
|
logger.error(e);
|
|
|
} catch (IOException e) {
|
|
|
// logger.info(e.toString());
|
|
|
e.printStackTrace();
|
|
|
logger.error(e);
|
|
|
}
|
|
|
return bg;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询运单是否全部放行
|
|
|
*
|
|
|
* @param manifestList
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean checkManifest(String manifestList) {
|
|
|
if (manifestList.length() < 1) return false;
|
|
|
manifestList = manifestList.replace("-", "");
|
|
|
String[] maifest = manifestList.split(",");
|
|
|
boolean flag = false;
|
|
|
int count = 0;
|
|
|
for (int i = 0; i < maifest.length; i++) {
|
|
|
RESMESSAGE resmessage = logic.resMessageService.selectByManifest(maifest[i]);
|
|
|
if (resmessage != null) {
|
|
|
if ("11".equals(resmessage.getResponsecode())) {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (count == maifest.length) {
|
|
|
flag = true;
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 给码头发送卡口数据
|
...
|
...
|
@@ -411,7 +429,7 @@ public class LogicOperation { |
|
|
* 校验重量并发送报文
|
|
|
*/
|
|
|
|
|
|
public static boolean sendBw(GatherInfo info, boolean check) {
|
|
|
public boolean sendBw(GatherInfo info, boolean check) {
|
|
|
boolean flag = false;
|
|
|
if (check) {
|
|
|
CommandClient.Client(info, PERMITTHOUGH);
|
...
|
...
|
@@ -448,5 +466,55 @@ public class LogicOperation { |
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成或者更新货物冻结标识
|
|
|
*
|
|
|
* @param landBusinessTypeList
|
|
|
*/
|
|
|
public void inOrUpEnterCancel(LandBusinessTypeList landBusinessTypeList) {
|
|
|
if (landBusinessTypeList.getMasterList().length() < 1) return;
|
|
|
String[] list = landBusinessTypeList.getMasterList().split(",");
|
|
|
String flag = null;
|
|
|
for (int i = 0; i < list.length; i++) {
|
|
|
if("调拨业务".equals(landBusinessTypeList.getBusinesstype())){
|
|
|
flag = "E";
|
|
|
}else {
|
|
|
flag = "I";
|
|
|
}
|
|
|
double wt = getGrossWt(list[i],flag);
|
|
|
|
|
|
ENTERCANCCEL entercanccel = logic.enterCancelServer.selectByManifest(list[i]);
|
|
|
if (entercanccel != null) {
|
|
|
if ("0".equals(entercanccel.getIsfreeze())) {
|
|
|
entercanccel.setIsfreeze("1");
|
|
|
entercanccel.setEndport(landBusinessTypeList.getEndstation());
|
|
|
entercanccel.setUpdateBy(landBusinessTypeList.getCreateBy());
|
|
|
entercanccel.setUpdateTime(new Date());
|
|
|
logic.enterCancelServer.updateByPermaryKey(entercanccel);
|
|
|
}
|
|
|
}else {
|
|
|
if("E".equals(landBusinessTypeList.getTurnoverflag())){
|
|
|
ENTERCANCCEL canccel = new ENTERCANCCEL();
|
|
|
canccel.setIsfreeze("0");
|
|
|
canccel.setVename(landBusinessTypeList.getTrailerFrameNo());
|
|
|
canccel.setId(String.valueOf(System.currentTimeMillis()));
|
|
|
canccel.setVeCompanyName(landBusinessTypeList.getAgentno());
|
|
|
canccel.setBusinesstype(landBusinessTypeList.getBusinesstype());
|
|
|
canccel.setManifest(list[i]);
|
|
|
canccel.setAgentname(landBusinessTypeList.getAgentname());
|
|
|
canccel.setStartport(landBusinessTypeList.getEndstation());
|
|
|
canccel.setGrosswt(landBusinessTypeList.getAislewt());
|
|
|
canccel.setCreateBy(landBusinessTypeList.getCreateBy());
|
|
|
canccel.setCreateTime(new Date());
|
|
|
canccel.setUpdateBy(landBusinessTypeList.getCreateBy());
|
|
|
canccel.setUpdateTime(new Date());
|
|
|
canccel.setWeight(wt);
|
|
|
logic.enterCancelServer.insertEntry(canccel);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|