WeightCheckImportDlvLitle.groovy
5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.sy.groovy
import com.sy.model.GatherInfo
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO
import com.sy.model.LandBusinessTypeList
import com.sy.service.WeightCheckHandleService
import com.sy.service.impl.GatherInfoHandle
import org.basis.enhance.groovy.entity.ExecuteParams
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import java.text.DecimalFormat
/**
* 重量验放
* 提货验放
*/
class WeightCheckImportDlvLitle extends Script implements ChannelCheckScript {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final String GROWSSEXCETION = "禁止通行,重量不在可控范围";
/**x21指令判定
* 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
* 车辆备案实体
* 从redis读取的申请表体实体
* 适用于进口转关,进口提货业务类型
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
Double selfWt = (Double) executeParams.get("selfWt");
Double goodsWt = (Double) executeParams.get("goodsWt");
Double inAisleWT = (Double) executeParams.get("inAisleWT");
List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
//3.车辆备案验证
// 调用方法
ApplicationContext context = getContext();
// 获取容器中的bean
GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());
if (checkImportDlv(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){
return true;
}else {
logger.error("[进口提货]-出场重量未通过校验:"+GROWSSEXCETION);
gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos);
return false;
}
}catch (Exception e){
e.printStackTrace();
logger.error("[DLV_WEIGHT-CHECK-ERROR]:",e);
return false;
}
}
@Override
Object run() {
return null
}
// 获取spring容器
ApplicationContext getContext() {
// 获取spring IOC容器
ApplicationContext context = applicationContext;
return context;
}
boolean checkImportDlv(double grossWt, double wt, double goodsWt,double inWt){
// 调用方法
ApplicationContext context = getContext();
//重量校验算法
WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);
grossWt = Double.parseDouble(String.format("%.1f", grossWt));
DecimalFormat df = new DecimalFormat("0.00");
boolean flag = false;
double result= 0.00;
double result1= 0.00;
double result2= 0.00;
double emptyOut= 0.00;
double goodCheckResult= 0.00;
double goodCheckResultAdd= 0.00;
double goodCheckResultSub= 0.00;
double goodCheckResult1= 0.00;
//针对轻量货物 加减20KG
double addAndSub = 20.00;
if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
//进场过磅重量+带货重量 = 出场过磅重量
// result = Double.parseDouble(df.format(Math.abs((inWt + goodsWt - grossWt)) / grossWt));
result = Double.parseDouble(df.format(Math.abs((grossWt-wt-goodsWt)) / goodsWt));
//带货提货,不提货判定,非空车离场
result2 = Double.parseDouble(df.format(Math.abs((inWt - grossWt)) / grossWt));
//个别原因不提货了,空车离场
emptyOut = Double.parseDouble(df.format(Math.abs((wt - grossWt)) / grossWt));
//车辆备案重量+货物重量 = 出场过磅重量,测试用,生产关闭
result1 = Double.parseDouble(df.format(Math.abs((wt + goodsWt - grossWt)) / grossWt));
//带货提货,货重误差
goodCheckResult = Double.parseDouble(df.format(Math.abs((grossWt-inWt-goodsWt)) / goodsWt));
//带货提货,货重误差 加20
goodCheckResultAdd = Double.parseDouble(df.format(Math.abs((grossWt-inWt-goodsWt+addAndSub)) / goodsWt));
//带货提货,货重误差 减20
goodCheckResultSub = Double.parseDouble(df.format(Math.abs((grossWt-inWt-goodsWt-addAndSub)) / goodsWt));
goodCheckResult1 = Double.parseDouble(df.format(Math.abs((grossWt-inWt-goodsWt))));
double range = weightCheckHandleService.valueDob();
logger.info("[WEIGHT-CHECK]-实际离场拉货重量:{},申请离场拉货重量:{},货重差值:{},货重误差:{}",grossWt-inWt,goodsWt,grossWt-inWt-goodsWt,goodCheckResult);
logger.info("[WEIGHT-CHECK]-进出场比对差值:{},提货离场差值:{},进出场比对重量差:{}",result,result1,Math.abs(inWt - grossWt));
if (goodCheckResult<=range || goodCheckResultAdd<=range || goodCheckResultSub<=range || goodCheckResult1<=addAndSub) {
flag = true;
}
}
return flag;
}
}