...
|
...
|
@@ -2,6 +2,7 @@ package com.sy.logic; |
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sy.crossDomain.buildBarCode;
|
|
|
import com.sy.model.*;
|
|
|
import com.sy.relation.VeManifestRelation;
|
...
|
...
|
@@ -23,6 +24,7 @@ import org.springframework.stereotype.Component; |
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStreamReader;
|
...
|
...
|
@@ -41,6 +43,7 @@ import java.util.Map; |
|
|
@Component
|
|
|
public class LiftBar {
|
|
|
private static final Logger logger = Logger.getLogger(LiftBar.class);
|
|
|
private static final org.slf4j.Logger log4 = org.slf4j.LoggerFactory.getLogger(LiftBar.class);
|
|
|
@Autowired
|
|
|
private LandBusListService listService;//进出场申请表
|
|
|
@Autowired
|
...
|
...
|
@@ -76,10 +79,18 @@ public class LiftBar { |
|
|
private static String ERRORWT = "出起始场站的重量和进目的场站的重量不一致";
|
|
|
private static String IEPORSE = "无相对应进出场申请";
|
|
|
private static String FANGXING="有运单未放行";
|
|
|
private static String FENBO = "装载运单的分拨申请舱单未通过校验";
|
|
|
|
|
|
//分拨申请回执
|
|
|
private static String ALLOCATE_01 = "39301 分拨申请审核通过。";
|
|
|
private static String ALLOCATE_04 = "39103 分拨申请重复传输,海关审核不通过。";
|
|
|
|
|
|
@Autowired
|
|
|
private FeignService feignService;
|
|
|
|
|
|
@Autowired
|
|
|
private NmmsService nmmsService;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
logic = this;
|
...
|
...
|
@@ -94,13 +105,14 @@ public class LiftBar { |
|
|
logic.wharfHost=this.wharfHost;
|
|
|
logic.nmmsHost=this.nmmsHost;
|
|
|
logic.feignService=this.feignService;
|
|
|
logic.nmmsService=this.nmmsService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Param info 卡口采集数据
|
|
|
* @Result 计算卡口采集数据并发送报文
|
|
|
*/
|
|
|
public static boolean liftBar(GatherInfo info) throws InterruptedException {
|
|
|
public boolean liftBar(GatherInfo info) throws InterruptedException {
|
|
|
PropertyConfigurator.configure("config/log4j.properties");
|
|
|
//默认返回值
|
|
|
boolean result = false;
|
...
|
...
|
@@ -114,8 +126,9 @@ public class LiftBar { |
|
|
|
|
|
//1. 若无车牌号,返回未识别错误
|
|
|
if (vaName.length() <= 0) {
|
|
|
CommandClient.Client(info, NO_CHEPAI + vaName);
|
|
|
logger.error(NO_CHEPAI+vaName);
|
|
|
CommandClient.Client(info, NO_CHEPAI + vaName);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -170,20 +183,25 @@ public class LiftBar { |
|
|
diffVal = inWt- growssWt;
|
|
|
}
|
|
|
|
|
|
log4.info("[CHECK-INFO]-出场过磅重量:{}-申报装载货物重量:{}-入场过磅重量:{}-进出差值:{}-车重:{}",growssWt,goodsWt,inWt,diffVal,ve.getSelfWt());
|
|
|
|
|
|
//判断场站出场是否要重量校验,配置文件中配置的场站直接抬杆放行.
|
|
|
if(FileTool.readProperties("station").equals(list.getEndstation())||FileTool.readProperties("stationsf").equals(list.getEndstation())){
|
|
|
checkResult=true;
|
|
|
//货物类型判断,直接放行的.todo:这个逻辑比较强大,后期要看怎么处理
|
|
|
}else if(!"普通货物".equals(list.getCocode()) && !"转关货物".equals(list.getCocode())){
|
|
|
//todo:比如货物类型为快件货物,只走重量校验,不走放行信息等校验.
|
|
|
logger.info("车辆装载货物为:"+list.getCocode());
|
|
|
checkResult=true;
|
|
|
}else {
|
|
|
// 出场校验根据业务类型
|
|
|
logger.info("[进出场申请]-业务类型为:"+list.getCocode()+list.getBusinesstype());
|
|
|
switch (list.getBusinesstype()){
|
|
|
case "出口送货":
|
|
|
if (logic.weightCheckHandleService.checkExportDownLoading(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
|
|
|
checkResult=true;
|
|
|
}else{
|
|
|
logger.error("[出口送货]-出场重量未通过校验:"+GROWSSEXCETION);
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -197,21 +215,50 @@ public class LiftBar { |
|
|
checkResult=true;
|
|
|
}else {
|
|
|
//有运单未放行
|
|
|
logger.error("[进口提货]-出场未通过校验:"+FANGXING+list.getMasterList());
|
|
|
CommandClient.Client(info, FANGXING);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//todo:装载运单历史数据累加超重判定
|
|
|
}else{
|
|
|
logger.error("[进口提货]-出场重量未通过校验:"+GROWSSEXCETION);
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
return false;
|
|
|
}
|
|
|
break;
|
|
|
case "分拨业务":
|
|
|
if (logic.weightCheckHandleService.checkAllocateOrDispatch(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
|
|
|
//todo:检查分拨申请
|
|
|
boolean allocatCheck = checkNmmsAllocate(list.getMasterList());
|
|
|
if(!allocatCheck){
|
|
|
logger.error("[分拨业务]-分拨申请舱单未通过校验:"+FENBO);
|
|
|
CommandClient.Client(info, FENBO);
|
|
|
return false;
|
|
|
}
|
|
|
checkResult=true;
|
|
|
//todo:分拨运抵通知,重车入场视为运抵
|
|
|
}else{
|
|
|
logger.error("[分拨业务]-出场重量未通过校验:"+GROWSSEXCETION);
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
return false;
|
|
|
}
|
|
|
break;
|
|
|
case "调拨业务":
|
|
|
if (logic.weightCheckHandleService.checkAllocateOrDispatch(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
|
|
|
checkResult=true;
|
|
|
//检查运单放行
|
|
|
if (logic.resMessageService.checkManifestRelease(list.getMasterList())){
|
|
|
checkResult=true;
|
|
|
}else {
|
|
|
//有运单未放行
|
|
|
logger.error("[调拨业务]-出场未通过校验:"+FANGXING+list.getMasterList());
|
|
|
CommandClient.Client(info, FANGXING);
|
|
|
return false;
|
|
|
}
|
|
|
//todo:检查ULD放行.
|
|
|
}else{
|
|
|
logger.error("[调拨业务]-出场未通过校验:"+GROWSSEXCETION);
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -222,22 +269,25 @@ public class LiftBar { |
|
|
}
|
|
|
|
|
|
|
|
|
check = logic.weightCheckHandleService.checkResult(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt);
|
|
|
if("出口送货".equals(list.getBusinesstype())){
|
|
|
if(check){
|
|
|
checkResult=true;
|
|
|
}else{
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
}
|
|
|
}else{
|
|
|
//其他业务的装载运单放行判断
|
|
|
checkMainfest = logic.checkManifest(list.getMasterList());
|
|
|
if(checkMainfest){
|
|
|
checkResult=check || checkMainfest;
|
|
|
}else{
|
|
|
CommandClient.Client(info, FANGXING);//有运单未放行
|
|
|
}
|
|
|
}
|
|
|
//旧业务逻辑,不启用了
|
|
|
// check = logic.weightCheckHandleService.checkResult(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt);
|
|
|
// if("出口送货".equals(list.getBusinesstype())){
|
|
|
// if(check){
|
|
|
// checkResult=true;
|
|
|
// }else{
|
|
|
// CommandClient.Client(info, GROWSSEXCETION);
|
|
|
// }
|
|
|
// }else{
|
|
|
// //其他业务的装载运单放行判断
|
|
|
// checkMainfest = logic.checkManifest(list.getMasterList());
|
|
|
// if(checkMainfest){
|
|
|
// checkResult=check || checkMainfest;
|
|
|
// }else{
|
|
|
// CommandClient.Client(info, FANGXING);//有运单未放行
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -279,7 +329,8 @@ public class LiftBar { |
|
|
int count=logic.listService.selectlaststation(list.getTrailerFrameNo(),list.getBarcode());
|
|
|
//二维码失效
|
|
|
if(count==0){
|
|
|
buildBarCode.cancleBarCode(vaName);
|
|
|
//测试注释掉
|
|
|
// buildBarCode.cancleBarCode(vaName);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -482,14 +533,17 @@ public class LiftBar { |
|
|
if (!(waybill.indexOf("-") != -1)) {
|
|
|
waybill = waybill.substring(0, 3) + "-" + waybill.substring(3);
|
|
|
}
|
|
|
String url = logic.nmmsHost+"orig/orig?waybill=" + waybill + "&imp=" + imp;
|
|
|
// String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp;
|
|
|
// String url = logic.nmmsHost+"orig/orig?waybill=" + 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();
|
|
|
//设置接口超时
|
|
|
yc.setReadTimeout(5000);
|
|
|
yc.setConnectTimeout(3000);
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream(), "utf-8"));
|
|
|
String inputLine = null;
|
|
|
while ((inputLine = in.readLine()) != null) {
|
...
|
...
|
@@ -577,6 +631,7 @@ public class LiftBar { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 为提前运抵服务发送数据
|
|
|
*
|
...
|
...
|
@@ -594,5 +649,57 @@ public class LiftBar { |
|
|
Map<String,Object> map=logic.feignService.sendMessage(arrive);
|
|
|
logger.info(""+map);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新舱单分拨申请数据查询
|
|
|
* @param waybill 查询的运单号
|
|
|
* @return
|
|
|
*/
|
|
|
public Map nmmsAllocate(@NotNull String waybill){
|
|
|
logger.info("新舱单查询分拨申请数据开始");
|
|
|
Map map = logic.nmmsService.getAllocate(waybill,0,10);
|
|
|
logger.info(""+map);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
public boolean checkNmmsAllocate(String waybill){
|
|
|
if (waybill.length() < 1) {
|
|
|
return false;
|
|
|
}
|
|
|
waybill = waybill.replace("-", "");
|
|
|
//中文逗号替换
|
|
|
waybill = waybill.replace(",", ",");
|
|
|
String[] maifest = waybill.split(",");
|
|
|
logger.info("运单列表:" + waybill);
|
|
|
boolean flag = false;
|
|
|
|
|
|
for (String awb : maifest) {
|
|
|
Map map= nmmsAllocate(awb);
|
|
|
if (map.containsKey("reslut")){
|
|
|
String result = map.get("reslut").toString();
|
|
|
JSONObject jsonObject = JSON.parseObject(result);
|
|
|
if (jsonObject.containsKey("ds")) {
|
|
|
JSONArray ds = jsonObject.getJSONArray("ds");
|
|
|
JSONObject awbinfo = ds.getJSONObject(0);
|
|
|
if (awbinfo.containsKey("RECEIPTINFORMATION")){
|
|
|
if (awbinfo.getString("RECEIPTINFORMATION").contains("39301") || awbinfo.getString("RECEIPTINFORMATION").contains("39103")){
|
|
|
log4.info("运单:{},分拨回执查询结果:{}",awb,awbinfo.getString("RECEIPTINFORMATION"));
|
|
|
}else {
|
|
|
log4.info("运单{}分拨申请回执不正常:{}",awb,awbinfo.getString("RECEIPTINFORMATION"));
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
log4.info("运单:{}分拨申请回执未查询到,或未进行分拨申请",awb);
|
|
|
return false;
|
|
|
}
|
|
|
}else{
|
|
|
log4.info("运单:{}分拨申请回执未查询到,或未进行分拨申请",awb);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|