...
|
...
|
@@ -8,6 +8,7 @@ import com.sy.relation.VeManifestRelation; |
|
|
import com.sy.service.*;
|
|
|
import com.sy.socket.CommandClient;
|
|
|
import com.sy.utils.FileTool;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.HttpResponse;
|
|
|
import org.apache.http.client.HttpClient;
|
...
|
...
|
@@ -52,6 +53,10 @@ public class LiftBar { |
|
|
private BusnesslistinfoService busnesslistinfoService;
|
|
|
@Autowired
|
|
|
BusnessViewService busnessViewService;
|
|
|
|
|
|
@Autowired
|
|
|
WeightCheckHandleService weightCheckHandleService;
|
|
|
|
|
|
@Value("${wharf.interface.host}")
|
|
|
private String wharfHost;
|
|
|
|
...
|
...
|
@@ -59,12 +64,12 @@ public class LiftBar { |
|
|
private String nmmsHost;
|
|
|
|
|
|
private static LiftBar logic = new LiftBar();
|
|
|
//从配置文件中读取货物重差可控范围
|
|
|
private static String checkWt = FileTool.readProperties("grossWt");
|
|
|
|
|
|
//逻辑判断后的返回信息定义
|
|
|
private static String PERMITTHOUGH = "直接放行";
|
|
|
private static String GROWSSEXCETION = "禁止通行,重量不在可控范围";
|
|
|
private static String NORECORD = "车辆未备案或者识别错误,车牌号:";
|
|
|
private static String NO_CHEPAI = "未识别到车牌号:";
|
|
|
private static String INPUTSTATION = "此车辆未做进站申请";
|
|
|
private static String ENTERSTATION = "此车辆未做出站申请";
|
|
|
private static String ISVALID = "二维码数据异常,请使用正确的二维码数据";
|
...
|
...
|
@@ -74,6 +79,7 @@ public class LiftBar { |
|
|
|
|
|
@Autowired
|
|
|
private FeignService feignService;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
logic = this;
|
...
|
...
|
@@ -84,8 +90,10 @@ public class LiftBar { |
|
|
logic.feignService=this.feignService;
|
|
|
logic.busnesslistinfoService=this.busnesslistinfoService;
|
|
|
logic.busnessViewService=this.busnessViewService;
|
|
|
logic.weightCheckHandleService=this.weightCheckHandleService;
|
|
|
logic.wharfHost=this.wharfHost;
|
|
|
logic.nmmsHost=this.nmmsHost;
|
|
|
logic.feignService=this.feignService;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -98,50 +106,60 @@ public class LiftBar { |
|
|
boolean result = false;
|
|
|
//获取过磅重量
|
|
|
double growssWt = info.getGrosswt().doubleValue();
|
|
|
|
|
|
//初始化装载货物重量
|
|
|
double goodsWt=0.0,inWt=0.0,diffVal=0.0;
|
|
|
//取车牌号,判定卡口是否取到车牌号
|
|
|
String vaName = info.getVename();
|
|
|
//若无车牌号,返回未识别错误
|
|
|
|
|
|
//1. 若无车牌号,返回未识别错误
|
|
|
if (vaName.length() <= 0) {
|
|
|
CommandClient.Client(info, NORECORD + vaName);
|
|
|
CommandClient.Client(info, NO_CHEPAI + vaName);
|
|
|
logger.error(NO_CHEPAI+vaName);
|
|
|
return result;
|
|
|
}
|
|
|
//校验车辆是否备案
|
|
|
|
|
|
//2. 校验车辆是否备案
|
|
|
LandRoadVe ve = logic.veService.selectByFrameNo(vaName);
|
|
|
//若无备案信息,返回车辆未备案或者识别错误
|
|
|
if (ve == null) {
|
|
|
logger.error(NORECORD+vaName);
|
|
|
CommandClient.Client(info, NORECORD + vaName);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 车牌号,二维码,场站ID/号,通道ID/号,进出业务类型标识I/E
|
|
|
* 3. 车牌号,二维码,场站ID/号,通道ID/号,进出业务类型标识I/E
|
|
|
* 查询是否已有此场站通道的申请
|
|
|
*/
|
|
|
//通过车牌号,二维码,场站,通道号,进出类型查询进出场站申请列表
|
|
|
LandBusinessTypeList list = logic.listService.selectForOne(info.getVename(), info.getBarcode(), info.getAreaid(), info.getChnlno(), info.getIetype());
|
|
|
//若查询结果为null,返回无相对应进出场申请
|
|
|
//4. 若查询结果为null,返回无相对应进出场申请
|
|
|
if (list == null) {
|
|
|
logger.error(vaName+IEPORSE);
|
|
|
CommandClient.Client(info, IEPORSE);
|
|
|
return result;
|
|
|
}
|
|
|
//判断进出场申请二维码是否已经失效,若失效,sendError
|
|
|
|
|
|
//5. 判断进出场申请二维码是否已经失效,若失效,sendError ,0 未失效
|
|
|
if ("0".equals(list.getIsvalid())) {
|
|
|
//校验重量开始
|
|
|
//6. 校验重量开始
|
|
|
boolean checkResult = false;
|
|
|
boolean check = false;
|
|
|
boolean checkMainfest =false;
|
|
|
|
|
|
//判断是进场申请还是出场申请
|
|
|
//7. 判断是进场申请还是出场申请
|
|
|
if("I".equals(info.getIetype())){
|
|
|
//进场申请宽进
|
|
|
checkResult=true;
|
|
|
} else {
|
|
|
//出场判定
|
|
|
|
|
|
}
|
|
|
else{
|
|
|
//获取对应场站进场申请的货物重量,进场过磅重量
|
|
|
//进出场重量差值计算
|
|
|
//获取对应场站进场申请的货物重量,进场过磅重量,
|
|
|
List<LandBusinessTypeList> listWt=logic.listService.selectwt(list.getTrailerFrameNo(),list.getBarcode(),list.getEndstation(),"I");
|
|
|
for(LandBusinessTypeList typeList:listWt){
|
|
|
if(typeList.getRemark()!=null && typeList.getRemark()!=""){
|
|
|
if(StringUtils.isNotEmpty(typeList.getRemark())){
|
|
|
//货物重量
|
|
|
goodsWt=Double.parseDouble(typeList.getRemark());
|
|
|
}
|
...
|
...
|
@@ -151,13 +169,60 @@ public class LiftBar { |
|
|
}
|
|
|
diffVal = inWt- growssWt;
|
|
|
}
|
|
|
//判断场站出场是否要重量校验
|
|
|
|
|
|
//判断场站出场是否要重量校验,配置文件中配置的场站直接抬杆放行.
|
|
|
if(FileTool.readProperties("station").equals(list.getEndstation())||FileTool.readProperties("stationsf").equals(list.getEndstation())){
|
|
|
checkResult=true;
|
|
|
}else if(!"普通货".equals(list.getCocode())){
|
|
|
//货物类型判断,直接放行的.todo:这个逻辑比较强大,后期要看怎么处理
|
|
|
}else if(!"普通货物".equals(list.getCocode()) && !"转关货物".equals(list.getCocode())){
|
|
|
logger.info("车辆装载货物为:"+list.getCocode());
|
|
|
checkResult=true;
|
|
|
}else {
|
|
|
check = logic.checkResult(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt);
|
|
|
// 出场校验根据业务类型
|
|
|
switch (list.getBusinesstype()){
|
|
|
case "出口送货":
|
|
|
if (logic.weightCheckHandleService.checkExportDownLoading(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
|
|
|
checkResult=true;
|
|
|
}else{
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
return false;
|
|
|
}
|
|
|
break;
|
|
|
case "进口转关":
|
|
|
case "进口提货":
|
|
|
if (logic.weightCheckHandleService.checkImportDlv(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
|
|
|
checkResult=true;
|
|
|
//检查运单放行
|
|
|
if (logic.resMessageService.checkManifestRelease(list.getMasterList())){
|
|
|
checkResult=true;
|
|
|
}else {
|
|
|
//有运单未放行
|
|
|
CommandClient.Client(info, FANGXING);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//todo:装载运单历史数据累加超重判定
|
|
|
}else{
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
return false;
|
|
|
}
|
|
|
break;
|
|
|
case "分拨业务":
|
|
|
case "调拨业务":
|
|
|
if (logic.weightCheckHandleService.checkAllocateOrDispatch(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
|
|
|
checkResult=true;
|
|
|
}else{
|
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
return false;
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
checkResult=false;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
check = logic.weightCheckHandleService.checkResult(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt);
|
|
|
if("出口送货".equals(list.getBusinesstype())){
|
|
|
if(check){
|
|
|
checkResult=true;
|
...
|
...
|
@@ -165,6 +230,7 @@ public class LiftBar { |
|
|
CommandClient.Client(info, GROWSSEXCETION);
|
|
|
}
|
|
|
}else{
|
|
|
//其他业务的装载运单放行判断
|
|
|
checkMainfest = logic.checkManifest(list.getMasterList());
|
|
|
if(checkMainfest){
|
|
|
checkResult=check || checkMainfest;
|
...
|
...
|
@@ -175,33 +241,47 @@ public class LiftBar { |
|
|
}
|
|
|
|
|
|
}
|
|
|
if(logic.sendBw(info, checkResult)){//发送抬杆儿报文
|
|
|
|
|
|
//发送抬杆指令
|
|
|
// boolean commandResult = logic.sendBw(info, checkResult);
|
|
|
//fortest 正式环境删除
|
|
|
boolean commandResult = true;
|
|
|
if(commandResult){//发送抬杆儿报文
|
|
|
if ("I".equals(info.getIetype())) {
|
|
|
//过卡重量
|
|
|
list.setAislewt(info.getGrosswt().doubleValue());
|
|
|
list.setUpdateDate(new Date());
|
|
|
//list.setRemark(String.format("%.1f", goodsWt));
|
|
|
//车辆备案重量
|
|
|
list.setRemark2(ve.getSelfWt());
|
|
|
list.setContrastflag("已进站");
|
|
|
logic.checkData(list);
|
|
|
// logic.checkData(list);
|
|
|
} else {
|
|
|
LandRoadVe veName = logic.veService.selectByFrameNo(vaName);
|
|
|
list.setAislewt(info.getGrosswt().doubleValue());
|
|
|
list.setUpdateDate(new Date());
|
|
|
//装载货物总重量
|
|
|
list.setRemark(String.format("%.1f", goodsWt));
|
|
|
//进出差值
|
|
|
list.setRemark1(String.format("%.1f", diffVal));
|
|
|
list.setRemark2(veName.getSelfWt());
|
|
|
list.setContrastflag("已出站");
|
|
|
logic.checkData(list);
|
|
|
// logic.checkData(list);
|
|
|
}
|
|
|
logic.listService.updateById(list);//更新进出场申请业务表
|
|
|
|
|
|
//更新进出场申请业务表
|
|
|
logic.listService.updateById(list);
|
|
|
|
|
|
//进出场申请业务表对应场站的卡口失效
|
|
|
logic.listService.updateisvalid(list.getTrailerFrameNo(),list.getBarcode(),list.getEndstation(),list.getTurnoverflag());
|
|
|
|
|
|
//判断是否为最后一个场站,若是最后个场站申请为出,二维码失效
|
|
|
int count=logic.listService.selectlaststation(list.getTrailerFrameNo(),list.getBarcode());
|
|
|
//二维码失效
|
|
|
if(count==0){
|
|
|
buildBarCode.cancleBarCode(vaName);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提前运抵判断
|
|
|
* 如果有提前运抵标识,判断是否分批,不分批直接通知
|
...
|
...
|
@@ -239,7 +319,8 @@ public class LiftBar { |
|
|
logic.inOrUpEnterCancel(list);
|
|
|
}
|
|
|
}
|
|
|
//绑定车单关系
|
|
|
|
|
|
//绑定车单关系,生成车单关系报文
|
|
|
if(list.getMasterList().length()>0){
|
|
|
boolean flag = VeManifestRelation.createFile(list);
|
|
|
if(flag){
|
...
|
...
|
@@ -248,15 +329,19 @@ public class LiftBar { |
|
|
}
|
|
|
|
|
|
} else {
|
|
|
sendError(info);
|
|
|
logger.error("------->>>>>>>二维码数据异常,请使用正确的二维码数据<<<<<<<-----");
|
|
|
sendError(info);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 校验重量并发送报文
|
|
|
* 校验重量后并发送抬杆指令报文
|
|
|
* @param info 车辆过卡信息
|
|
|
* @param check 是否放行抬杆
|
|
|
*/
|
|
|
|
|
|
public boolean sendBw(GatherInfo info, boolean check) {
|
|
|
logger.info(String.format("开始发送指令:车牌%s,场站%s,通道%s,重量%s",info.getVename(),info.getAreaid(),info.getChnlno(),info.getGrosswt()));
|
|
|
boolean flag = false;
|
...
|
...
|
@@ -270,12 +355,13 @@ public class LiftBar { |
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 给码头发送卡口数据
|
|
|
*
|
|
|
* @param stationCode
|
|
|
* @param carNo
|
|
|
* @param IEtype
|
|
|
* @param stationCode 场站编号
|
|
|
* @param carNo 车牌
|
|
|
* @param IEtype 进出
|
|
|
*/
|
|
|
public static void sendData(String stationCode, String carNo, boolean IEtype) {
|
|
|
String url = logic.wharfHost+"air-api/car/channelCar?stationCode=" + stationCode + "&carNo=" + carNo + "&isPickup=" + IEtype;
|
...
|
...
|
@@ -291,10 +377,11 @@ public class LiftBar { |
|
|
logger.info(e.toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 给码头发送卡口数据
|
|
|
*
|
|
|
* @param list
|
|
|
* @param list 进出场申请数据
|
|
|
*/
|
|
|
public void checkData(LandBusinessTypeList list) {
|
|
|
String sationCode = null;
|
...
|
...
|
@@ -319,15 +406,21 @@ public class LiftBar { |
|
|
logger.info("码头发送消息异常---"+e.toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询运单是否全部放行
|
|
|
*
|
|
|
* @param manifestList
|
|
|
* @param manifestList 运单号数组
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean checkManifest(String manifestList) {
|
|
|
if (manifestList.length() < 1) return false;
|
|
|
if (manifestList.length() < 1) {
|
|
|
return false;
|
|
|
}
|
|
|
manifestList = manifestList.replace("-", "");
|
|
|
//中文逗号替换
|
|
|
manifestList = manifestList.replace(",", ",");
|
|
|
String[] maifest = manifestList.split(",");
|
|
|
boolean flag = false;
|
|
|
int count = 0;
|
...
|
...
|
@@ -336,45 +429,22 @@ public class LiftBar { |
|
|
if (resmessage != null) {
|
|
|
if ("11".equals(resmessage.getResponsecode())) {
|
|
|
count++;
|
|
|
}else {
|
|
|
logger.error("车辆装载运单未有放行信息---" + maifest[i]);
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
logger.error("车辆装载运单未有放行信息---" + maifest[i]);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (count == maifest.length) {
|
|
|
flag = true;
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
/**
|
|
|
* 校验载重和称重是否在合理的范围
|
|
|
*
|
|
|
* @Param grossWt 地磅称重
|
|
|
* @Param wt 车辆自重
|
|
|
* @Param goodsWt 货物总重
|
|
|
* @Result 获取运单重量
|
|
|
*/
|
|
|
/**
|
|
|
* 进场卸货误差判定
|
|
|
* 出场重量 = 进场重量 - 货物重量
|
|
|
* 首先计算 进出场差值数 ABS(进场重量-货物重量-出场重量)/出场重量, 计算出出场误差百分比
|
|
|
* (出场重量 - 车辆备案重量) /出场重量
|
|
|
* (出场重量 - (车辆备案重量+货物重量)/出场重量
|
|
|
* (出场重量 - (进场重量+货物重量)/出场重量
|
|
|
*/
|
|
|
public boolean checkResult(double grossWt, double wt, double goodsWt,double inWt) {
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
boolean flag = false;
|
|
|
double result= 0.0,result2= 0.0,result3= 0.0,result4= 0.0;
|
|
|
if(grossWt>0){
|
|
|
result = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / grossWt));
|
|
|
result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / grossWt));
|
|
|
result3 = Double.parseDouble(df.format(Math.abs((grossWt-wt-goodsWt)) / grossWt));
|
|
|
result4 = Double.parseDouble(df.format(Math.abs((inWt + goodsWt)) / grossWt));
|
|
|
}
|
|
|
if (result <= valueDob() ||result2 <= valueDob() || result3 <= valueDob() || result4 <= valueDob()) {
|
|
|
flag = true;
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -454,34 +524,8 @@ public class LiftBar { |
|
|
return bg;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断备案车重与运单重量和地磅称重是否在合理范围
|
|
|
*
|
|
|
* @param grossWt
|
|
|
* @param wt
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean checkFlag(double grossWt, double wt) {
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
boolean flag = false;
|
|
|
double reult = Double.parseDouble(df.format(Math.abs((grossWt - wt)) / grossWt));
|
|
|
if (reult <= valueDob()) {
|
|
|
flag = true;
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
//将获取的checkWt进行小数转化
|
|
|
public static double valueDob() {
|
|
|
NumberFormat nf = NumberFormat.getPercentInstance();
|
|
|
Number m = null;
|
|
|
try {
|
|
|
m = nf.parse(checkWt);//将百分数转换成Number类型
|
|
|
} catch (ParseException e) {
|
|
|
logger.info("重量校验消息异常---"+e.toString());
|
|
|
logger.info(e.getMessage());
|
|
|
}
|
|
|
return m.doubleValue();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生成或者更新货物冻结标识
|
|
|
*
|
...
|
...
|
|