|
|
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);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|