EnginTest.java
7.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
package com.sy.engin;
import com.alibaba.fastjson.JSONArray;
import com.sy.model.GatherInfo;
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
import com.sy.model.LandBusinessTypeList;
import com.sy.model.LandRoadVe;
import com.sy.service.BusnesslistinfoService;
import com.sy.service.LandBusListService;
import com.sy.service.LandRoadVeService;
import com.sy.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.basis.enhance.groovy.entity.EngineExecutorResult;
import org.basis.enhance.groovy.entity.ExecuteParams;
import org.basis.enhance.groovy.entity.ScriptQuery;
import org.basis.enhance.groovy.executor.EngineExecutor;
import org.basis.enhance.groovy.helper.RefreshScriptHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class EnginTest {
private static String IEPORSE = "无相对应进出场申请";
private static String CHANEL_ERR= "无对应通道流转申请,走错通道";
@Autowired
private EngineExecutor engineExecutor;
@Autowired
private BusnesslistinfoService busnesslistinfoService;
@Autowired
private LandBusListService landBusListService;
@Autowired
private RedisService redisService;
@Autowired
private LandBusListService listService;
@Autowired
LandRoadVeService veService;
/**
* 过磅x21报文实体
*/
ExecuteParams buildGatherInfoParams(){
GatherInfo gatherInfo = new GatherInfo();
gatherInfo.setAreaid("4604600000");
gatherInfo.setChnlno("4604601010");
gatherInfo.setBarcode("edb-4ebc-919b-7d7b118da052");
gatherInfo.setGrosswt(new BigDecimal("6478"));
gatherInfo.setSeqno("20220630184441000028");
gatherInfo.setIetype("I");
gatherInfo.setVename("豫A61CR8");
ExecuteParams executeParams = new ExecuteParams();
//初始化
executeParams.put("gatherInfo", gatherInfo);
executeParams.put("formList", null);
executeParams.put("ChanelFormInfo", null);
executeParams.put("ChanelFormBillLists", null);
executeParams.put("LandRoadVe", null);
executeParams.put("inAisleWT", 0.0);
executeParams.put("diffVal", 0.0);
executeParams.put("selfWt", 0.0);
executeParams.put("goodsWt", 0.0);
//车辆备案信息
LandRoadVe ve = veService.selectByFrameNo(gatherInfo.getVename());
if (ve != null) {
//车辆备案重量
Double selfWt=Double.parseDouble(ve.getSelfWt());
executeParams.put("LandRoadVe", ve);
executeParams.put("selfWt", selfWt);
}
//获取申请单表体
log.info("[FORM-CACHE-GET]:车辆-{}核碰缓存",gatherInfo.getVename());
String landBusinessJson = redisService.get(gatherInfo.getVename());
if (StringUtils.isNotEmpty(landBusinessJson)) {
//这个是申请单表体
List<LandBusinessTypeList> list = JSONArray.parseArray(landBusinessJson, LandBusinessTypeList.class);
executeParams.put("formList", list);
//通道对应申请信息
LandBusinessTypeList chanelFormInfo = landBusListService.getLandBusinessTypeListByGather(gatherInfo);
executeParams.put("ChanelFormInfo", chanelFormInfo);
if (chanelFormInfo!= null){
executeParams.put("goodsWt", chanelFormInfo.getRemark());
}
//查询申请单运单列表
List<LAND_BUSINEESTYPE_LIST_INFO> chanelFormBillLists= busnesslistinfoService.selectmanilist(gatherInfo.getBarcode());
executeParams.put("ChanelFormBillLists", chanelFormBillLists);
}
//对应场站入场信息重量
if ("E".equals(gatherInfo.getIetype())){
List<LandBusinessTypeList> stationInChanleInfo= listService.selectwt(gatherInfo.getVename(),gatherInfo.getBarcode(),gatherInfo.getAreaid(),"I");
if (stationInChanleInfo.isEmpty()){
log.info("未查询到车辆:{}的入场信息",gatherInfo.getVename());
}else {
for(LandBusinessTypeList typeList:stationInChanleInfo){
if(typeList.getAislewt()!=null){
//对应场站进场过磅重量
Double inAisleWT = typeList.getAislewt();
executeParams.put("inAisleWT", inAisleWT);
//离场与入场重量差值
Double diffVal = inAisleWT- gatherInfo.getGrosswt().doubleValue();
executeParams.put("diffVal", diffVal);
}
}
//TODO:进场校验 增加 车辆备案重量要 <= 进场过磅重量 ,要有误差判定
}
}
return executeParams;
}
@Test
public void x21Check() {
long time = System.currentTimeMillis(); //do something that takes some time... long completedIn = System.currentTimeMillis() - time;
System.out.println("验证开始"+time);
String scriptName = "x21-check";
// String scriptName = "form-check";
// 构建参数
ExecuteParams executeParams = buildGatherInfoParams();
// 执行脚本中指定的方法 changeProduct
EngineExecutorResult executorResult = engineExecutor.execute(
"baseCheck", new ScriptQuery("x21-check"), executeParams);
log.info("使用groovy脚本来验证过卡判定放行结果=========>>>>>>>>>>>执行结果:{}", executorResult);
EngineExecutorResult formCheckResult = engineExecutor.execute(
"formCheck", new ScriptQuery("form-check"), executeParams);
EngineExecutorResult veCheckResult = engineExecutor.execute(
"veCheck", new ScriptQuery("ve-check"), executeParams);
EngineExecutorResult releaseCheckResult = engineExecutor.execute(
"releaseCheck", new ScriptQuery("form-release"), executeParams);
log.info("success");
System.out.println("验证结束"+(System.currentTimeMillis()-time));
}
@Test
public void arrTest(){
String[] busType = new String[] {"区内分拨","区内调拨"};
String[] goodsType = new String[] {"普通货物","转关货物","退库货物","换单货物","查验货物"};
String[] rules = new String[] {"基本验放规则","核销判定"};
int i = 0;
for (String bus : busType) {
for (String good : goodsType) {
for (String rule : rules) {
log.info("插入一条数据:业务类型-[{}]-货物类型:[{}]-验放规则:[{}]",bus,good,rule);
i++;
}
}
}
String[] busType1 = new String[] {"区内分拨"};
String[] goodsType1 = new String[] {"快件货物"};
String[] rules1 = new String[] {"关锁判定"};
for (String bus : busType1) {
for (String good : goodsType1) {
for (String rule : rules1) {
log.info("插入一条数据:业务类型-[{}]-货物类型:[{}]-验放规则:[{}]",bus,good,rule);
i++;
}
}
}
log.info("共插入{}条规则",i);
}
}