WeightCheckHandleServiceImpl.java
11.3 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
package com.sy.service.impl;
import com.sy.service.WeightCheckHandleService;
import com.sy.utils.FileTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
@Slf4j
@Service
public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
//从配置文件中读取货物重差可控范围
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){
/**
* 异常情况判定
* 送货业务的入场重量必须大于离场重量
* 比如申请单申请的时候本来是进口提货 申请成出口送货
*/
if (inWt<grossWt){
log.info("出区重量比入区重量大,信息异常");
return false;
}
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)) / wt));
log.info("[WEIGHT-CHECK]-进出场比对差值:{},空车出场差值:{},进出场比对重量差:{},空车比对重量差:{}",result,result2,Math.abs(inWt - goodsWt - grossWt),Math.abs(grossWt-wt));
}
double range = valueDob();
//车辆离场重量与车辆备案重量验放,只允许空车离场
if (result2 <= range) {
flag = true;
}
//
// if (result <= range || result2 <= range) {
// flag = true;
// }
return flag;
}
@Override
public boolean checkImportAtCheckIN(double grossWt, double wt, double goodsWt, double inWt){
double emptyIN= 0.00;
DecimalFormat df = new DecimalFormat("0.00");
if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
//空车入场判定,入场重量-车辆备案重量
emptyIN = Double.parseDouble(df.format(Math.abs((wt - grossWt)) / wt));
double range = valueDob();
if (emptyIN <= range) {
log.info("[WEIGHT-CHECK]-进口提货入口重量验放:入场重量{},车辆备案重量:{},差值:{}",grossWt,wt,emptyIN);
return true;
}
}
return false;
}
/**
* 进口普货提货业务重量校验,可支持 带货提货,不支持卸货提货
* 进口转关业务重量校验
* 进场重量+载货重量 = 出场重量
* @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;
double goodCheckResult= 0.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));
double range = valueDob();
log.info("[WEIGHT-CHECK]-实际离场拉货重量:{},申请离场拉货重量:{},货重差值:{},货重误差:{}",grossWt-inWt,goodsWt,grossWt-inWt-goodsWt,goodCheckResult);
log.info("[WEIGHT-CHECK]-进出场比对差值:{},提货离场差值:{},进出场比对重量差:{}",result,result1,Math.abs(inWt - grossWt));
if (goodCheckResult<=range
// || 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;
double result4= 0.00;
if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
//带货出,入场重量+带货重量 = 离场重量
result = Double.parseDouble(df.format(Math.abs((grossWt-inWt-goodsWt)) / goodsWt));
//带货出,用车辆备案重量对碰,车辆备案重量+带货重量 = 离场重量
// result4 = Double.parseDouble(df.format(Math.abs((wt + goodsWt - grossWt)) / grossWt));
result4 = Double.parseDouble(df.format(Math.abs((grossWt-wt-goodsWt)) / goodsWt));
//空车出,过磅重量 = 车辆备案重量
result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / wt));
//卸货出,入场重量-卸货重量 = 离场重量
result3 = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / goodsWt));
System.out.println("进场提货离场差值:"+result);
System.out.println("空车离场差值:"+result2);
System.out.println("进场卸货离场差值:"+result3);
System.out.println("备案重量进场装载货物离场差值:"+result4);
}
double range = valueDob();
if (result2 <= range
|| result <= range
|| result3 <= range
|| result4 <= range
) {
flag = true;
}
return flag;
}
/**
* 判断备案车重与地磅称重是否在合理范围
*
* @param grossWt
* @param wt
* @return
*/
@Override
public boolean checkEmpty(double grossWt, double wt) {
DecimalFormat df = new DecimalFormat("0.00");
boolean flag=false;
double reult = Double.parseDouble(df.format(Math.abs((grossWt - wt)) / wt));
if (reult <= valueDob()) {
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) {
log.info("重量校验消息异常---"+e.toString());
log.info(e.getMessage());
}
return m.doubleValue();
}
}