WeightCheckHandleServiceImpl.java
8.5 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package com.sy.service.impl;
import com.sy.logic.LiftBar;
import com.sy.service.WeightCheckHandleService;
import com.sy.utils.FileTool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
@Service
public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
private static final Logger logger = LoggerFactory.getLogger(LiftBar.class);
//从配置文件中读取货物重差可控范围
private static String checkWt = FileTool.readProperties("grossWt");
/**
* 校验载重和称重是否在合理的范围
*
* @param grossWt 地磅称重,也称出场过磅重量
* @param wt 车辆自重
* @param goodsWt 货物总重
* @param inWt 进场过磅重量
* @return 获取运单重量
*/
/**
* 进场卸货误差判定
* 出场重量 = 进场重量 - 货物重量
* 首先计算 进出场差值数 ABS(进场重量-货物重量-出场重量)/出场重量, 计算出出场误差百分比
* (出场重量 - 车辆备案重量) /出场重量 空车离场
* (出场重量 - (车辆备案重量+货物重量)/出场重量 进场提货(涉及业务,普货提货,调拨,分拨,转关提货)
* (出场重量 - (进场重量+货物重量)/出场重量
*/
@Override
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;
}
/**
* 出口普货送货业务重量校验,可支持 带货送货,不支持送货提货
* 进场重量-载货重量 = 出场重量 (此逻辑已包含空车离场判定)
* @param grossWt 地磅称重,也称出场过磅重量
* @param wt 车辆自重
* @param goodsWt 货物总重
* @param inWt 进场过磅重量
* 误差计算方式 (应该出场重量 - 出场重量) / 出场重量 与 误差比对,超过误差则不放行
* @return 返回校验结果 true 通过,false 不通过
*/
@Override
public boolean checkExportDownLoading(double grossWt, double wt, double goodsWt, double inWt){
DecimalFormat df = new DecimalFormat("0.00");
boolean flag = false;
//卸货判定
double result= 0.0;
//以防万一 空车离场判定
double result2= 0.0;
if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
result = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / grossWt));
result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / grossWt));
logger.info("[WEIGHT-CHECK]-进出场比对差值:{},空车出场差值:{},进出场比对重量差:{},空车比对重量差:{}",result,result2,Math.abs(inWt - goodsWt - grossWt),Math.abs(grossWt-wt));
}
double range = valueDob();
if (result <= range || result2 <= range) {
flag = true;
}
return flag;
}
/**
* 进口普货提货业务重量校验,可支持 带货提货,不支持卸货提货
* 进口转关业务重量校验
* 进场重量+载货重量 = 出场重量
* @param grossWt 地磅称重,也称出场过磅重量
* @param wt 车辆自重
* @param goodsWt 货物总重
* @param inWt 进场过磅重量
* 误差计算方式 (应该出场重量 - 出场重量) / 出场重量 与 误差比对,超过误差则不放行
* @return 返回校验结果 true 通过,false 不通过
*/
@Override
public boolean checkImportDlv(double grossWt, double wt, double goodsWt,double inWt){
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;
if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
//进场过磅重量+带货重量 = 出场过磅重量
result = Double.parseDouble(df.format(Math.abs((inWt + goodsWt - grossWt)) / grossWt));
//todo:这里没有加空车离场判定,暂时不加,进口提货业务空车离场走空车验放判定系统.
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));
}
double range = valueDob();
logger.info("[WEIGHT-CHECK]-进出场比对差值:{},提货离场差值:{},进出场比对重量差:{}",result,result1,Math.abs(inWt - grossWt));
if (result <= range) {
flag = true;
}
//车辆备案重量+货物重量 = 出场过磅重量,测试用,生产关闭
if (result1 <= range || result2 <= range || emptyOut <= range) {
return true;
}
return flag;
}
/**
* 分拨/调拨业务重量校验
* 进场重量+载货重量 = 出场重量 (装载场站装货离场)
* 或者 空车出场 (最后卸货离场)
* 或者 进场重量-载货重量 = 出场重量 (目的场站卸货离场)
* @param grossWt 地磅称重,也称出场过磅重量
* @param wt 车辆自重
* @param goodsWt 货物总重
* @param inWt 进场过磅重量
* 误差计算方式 (应该出场重量 - 出场重量) / 出场重量 与 误差比对,超过误差则不放行
* @return 返回校验结果 true 通过,false 不通过
*/
@Override
public boolean checkAllocateOrDispatch(double grossWt, double wt, double goodsWt,double inWt){
//todo:调拨分拨中的第二.三...场站的如卡口判断 都应该以带货入场进行判定.离场都应该以空车进行判定.
DecimalFormat df = new DecimalFormat("0.00");
boolean flag = false;
//载货离场判定
double result= 0.00;
//空车离场判定
double result2= 0.00;
//卸货离场判定
double result3= 0.00;
if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(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((inWt - goodsWt - grossWt)) / grossWt));
System.out.println("进场提货离场差值:"+result);
System.out.println("空车离场差值:"+result2);
System.out.println("进场卸货离场差值:"+result3);
}
double range = valueDob();
if (result <= range || result2 <= range || result3 <= range ) {
flag = true;
}
return flag;
}
/**
* 判断备案车重与运单重量和地磅称重是否在合理范围
*
* @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进行小数转化
private 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();
}
}