作者 朱兆平

规则引擎+加验放规则动态配置

@@ -21,3 +21,5 @@ @@ -21,3 +21,5 @@
21 ###### 测试代码 21 ###### 测试代码
22 ##### pom.xml 22 ##### pom.xml
23 ###### maven引入jar所在 23 ###### maven引入jar所在
  24 +
  25 +# 北货金二项目并且加规则引擎验证模式
@@ -21,6 +21,10 @@ spring.mvc.view.prefix=.jsp @@ -21,6 +21,10 @@ spring.mvc.view.prefix=.jsp
21 21
22 spring.redis.host=192.168.1.53 22 spring.redis.host=192.168.1.53
23 spring.redis.port=6379 23 spring.redis.port=6379
  24 +#spring.redis.database=2
  25 +spring.redis.lettuce.pool.max-active=16
  26 +spring.redis.lettuce.pool.min-idle=16
  27 +spring.redis.lettuce.pool.max-wait=5000
24 28
25 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 29 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
26 # 测试环境 30 # 测试环境
@@ -72,6 +76,8 @@ feign.httpclient.connection-timeout=3000 @@ -72,6 +76,8 @@ feign.httpclient.connection-timeout=3000
72 #logback日志配置 76 #logback日志配置
73 77
74 logging.config=config/logback-dev.xml 78 logging.config=config/logback-dev.xml
  79 +logging.level.org.basis=info
  80 +logging.level.org.basis.groovy.mapper=debug
75 # 这个是刷新接口 81 # 这个是刷新接口
76 #curl -X POST http://localhost:8080/actuator/refresh 82 #curl -X POST http://localhost:8080/actuator/refresh
77 management.endpoints.web.exposure.include=refresh 83 management.endpoints.web.exposure.include=refresh
@@ -88,3 +94,18 @@ custom.receptDirectory= bw/read/ @@ -88,3 +94,18 @@ custom.receptDirectory= bw/read/
88 interface.lock.url=http://127.0.0.1:8848 94 interface.lock.url=http://127.0.0.1:8848
89 devdebug=true 95 devdebug=true
90 g2.onoff=false 96 g2.onoff=false
  97 +
  98 +# 规则引擎相关配置
  99 +# 脚本检查更新周期(单位:秒),(默认300L)
  100 +enhance.groovy.engine.polling-cycle=10000
  101 +# 开启功能
  102 +enhance.groovy.engine.enable=true
  103 +# 缓存过期时间(默认600L分钟)
  104 +enhance.groovy.engine.cache-expire-after-write=20
  105 +#缓存初始容量(默认100)
  106 +enhance.groovy.engine.cache-initial-capacity=50
  107 +# 缓存最大容量(默认500)
  108 +enhance.groovy.engine.cache-maximum-size=50
  109 +# 开启基于Redis加载groovy脚本
  110 +enhance.groovy.engine.redis-loader.namespace=kako-release-check
  111 +enhance.groovy.engine.redis-loader.enable=true
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 5
6 <groupId>com.sy</groupId> 6 <groupId>com.sy</groupId>
7 <artifactId>analysis_imf</artifactId> 7 <artifactId>analysis_imf</artifactId>
8 - <version>4.0-LOCK-SNAPSHOT</version> 8 + <version>4.5-ENGINE-SNAPSHOT</version>
9 <packaging>jar</packaging> 9 <packaging>jar</packaging>
10 <name>analysis_imf</name> 10 <name>analysis_imf</name>
11 <description>北货集成金二抬杆指令判定</description> 11 <description>北货集成金二抬杆指令判定</description>
@@ -133,6 +133,29 @@ @@ -133,6 +133,29 @@
133 <version>3.3.0</version> 133 <version>3.3.0</version>
134 </dependency> 134 </dependency>
135 135
  136 + <!--规则引擎-核心依赖-->
  137 +<!-- <dependency>-->
  138 +<!-- <artifactId>enhance-groovy-engine-core</artifactId>-->
  139 +<!-- <groupId>org.basis.enhance</groupId>-->
  140 +<!-- <version>1.0-SNAPSHOT</version>-->
  141 +<!-- </dependency>-->
  142 + <!--加载Redis下的groovy脚本loader依赖-->
  143 + <dependency>
  144 + <artifactId>enhance-groovy-redis-loader</artifactId>
  145 + <groupId>org.basis.enhance</groupId>
  146 + <version>1.0-SNAPSHOT</version>
  147 + </dependency>
  148 + <!--加载classpath下的groovy脚本loader依赖-->
  149 +<!-- <dependency>-->
  150 +<!-- <artifactId>enhance-groovy-classpath-loader</artifactId>-->
  151 +<!-- <groupId>org.basis.enhance</groupId>-->
  152 +<!-- <version>1.0-SNAPSHOT</version>-->
  153 +<!-- </dependency>-->
  154 + <!--Apache的 common-pool2(至少是2.2)提供连接池,供redis客户端使用-->
  155 + <dependency>
  156 + <groupId>org.apache.commons</groupId>
  157 + <artifactId>commons-pool2</artifactId>
  158 + </dependency>
136 <!--IMF need jar--> 159 <!--IMF need jar-->
137 <dependency> 160 <dependency>
138 <groupId>org.apache.xmlbeans</groupId> 161 <groupId>org.apache.xmlbeans</groupId>
@@ -18,7 +18,7 @@ public class IMF_Tesk { @@ -18,7 +18,7 @@ public class IMF_Tesk {
18 public static IMFClient client = null; 18 public static IMFClient client = null;
19 19
20 //todo:测试关,生产开 20 //todo:测试关,生产开
21 - @Scheduled(fixedRate = 5000) 21 +// @Scheduled(fixedRate = 5000)
22 private static void start() { 22 private static void start() {
23 //尝试catch SDK异常 23 //尝试catch SDK异常
24 try{ 24 try{
  1 +package com.sy.controller;
  2 +
  3 +import com.sy.model.GatherInfo;
  4 +import lombok.extern.slf4j.Slf4j;
  5 +import org.basis.enhance.groovy.entity.EngineExecutorResult;
  6 +import org.basis.enhance.groovy.entity.ExecuteParams;
  7 +import org.basis.enhance.groovy.entity.ScriptQuery;
  8 +import org.basis.enhance.groovy.executor.EngineExecutor;
  9 +import org.basis.enhance.groovy.helper.RefreshScriptHelper;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.web.bind.annotation.GetMapping;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import java.math.BigDecimal;
  16 +
  17 +@RestController
  18 +@Slf4j
  19 +@RequestMapping("/v1/load-from-redis")
  20 +public class EnginTestController {
  21 +
  22 +
  23 + @Autowired
  24 + private EngineExecutor engineExecutor;
  25 +
  26 + @Autowired
  27 + private RefreshScriptHelper refreshScriptHelper;
  28 +
  29 + @GetMapping("/x21-check")
  30 + public String x21Check(String scriptName) {
  31 + // 构建参数
  32 + ExecuteParams executeParams = buildGatherInfoParams();
  33 + // 执行脚本中指定的方法 changeProduct
  34 + EngineExecutorResult executorResult = engineExecutor.execute(
  35 + "baseCheck", new ScriptQuery(scriptName), executeParams);
  36 + log.info("使用groovy脚本来动态修改闪屏信息=========>>>>>>>>>>>执行结果:{}", executorResult);
  37 +
  38 + return "success";
  39 + }
  40 +
  41 + @GetMapping("/form-check")
  42 + public String formCheck(String scriptName) {
  43 + // 构建参数
  44 + ExecuteParams executeParams = buildGatherInfoParams();
  45 + // 执行脚本中指定的方法 changeProduct
  46 + EngineExecutorResult executorResult = engineExecutor.execute(
  47 + "formCheck", new ScriptQuery(scriptName), executeParams);
  48 + log.info("使用groovy脚本来动态修改闪屏信息=========>>>>>>>>>>>执行结果:{}", executorResult);
  49 +
  50 + return "success";
  51 + }
  52 +
  53 + /**
  54 + * 过磅x21报文实体
  55 + */
  56 + public ExecuteParams buildGatherInfoParams(){
  57 + GatherInfo gatherInfo = new GatherInfo();
  58 + gatherInfo.setAreaid("4604600000");
  59 + gatherInfo.setChnlno("4604601010");
  60 + gatherInfo.setBarcode("fe3-4c1b-befe-afa4a68d80c1");
  61 + gatherInfo.setGrosswt(new BigDecimal("6478"));
  62 + gatherInfo.setSeqno("20220630184441000028");
  63 + gatherInfo.setIetype("I");
  64 + gatherInfo.setVename("豫A61CR7");
  65 +
  66 + ExecuteParams executeParams = new ExecuteParams();
  67 + executeParams.put("gatherInfo", gatherInfo);
  68 +
  69 + return executeParams;
  70 + }
  71 +
  72 + @GetMapping("/refreshCache")
  73 + public String refresh(String scriptName) {
  74 + // 手动刷新脚本到内存
  75 + boolean flag = refreshScriptHelper.refresh(new ScriptQuery(scriptName), true);
  76 + System.out.println("是否刷新成功:" + flag);
  77 + return String.valueOf(flag);
  78 + }
  79 +
  80 + /**
  81 + * 手动刷新所有脚本到内存
  82 + * url: http://localhost:1234/v1/refresh/test02
  83 + */
  84 + @GetMapping("/refreshCacheAll")
  85 + public String refreshAll() throws Exception {
  86 + // 手动刷新所有脚本到内存
  87 + boolean flag = refreshScriptHelper.refreshAll();
  88 + System.out.println("是否刷新成功:" + flag);
  89 + return String.valueOf(flag);
  90 + }
  91 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LandBusinessTypeList
  5 +import com.sy.service.impl.GatherInfoHandle
  6 +import org.basis.enhance.groovy.entity.ExecuteParams
  7 +import org.slf4j.Logger
  8 +import org.slf4j.LoggerFactory
  9 +import org.springframework.context.ApplicationContext
  10 +
  11 +//通道申请信息验放
  12 +class BaseFormCacheCheck extends Script {
  13 +
  14 + private final Logger logger = LoggerFactory.getLogger(getClass());
  15 + private final String CHANEL_ERR= "无对应通道流转申请,走错通道";
  16 + private final String IEPORSE = "无相对应进出场申请";
  17 +
  18 + /**x21指令判定
  19 + * 传入gatherInfo
  20 + *
  21 + * 传入从redis读取的申请表体实体,验证
  22 + * 进行通道比对
  23 + */
  24 + Boolean check(ExecuteParams executeParams) {
  25 + try{
  26 + // 获取product对象
  27 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  28 + LandBusinessTypeList chanelFormInfo = (LandBusinessTypeList) executeParams.get("chanelFormInfo");
  29 +
  30 + // 调用方法
  31 + ApplicationContext context = getContext();
  32 + // 获取容器中的bean
  33 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  34 +
  35 + if (chanelFormInfo==null){
  36 + logger.error("[FORM-CHECK-ERR]:车辆-{}的流转申请校验失败,无对应通道流转申请信息",gatherInfo.getVename());
  37 + gatherInfoHandle.sendBw(gatherInfo,false, gatherInfo.getVename()+IEPORSE,null,null);
  38 + return false;
  39 + }
  40 + logger.info("[FORM-CHECK]:车辆-{}的流转申请校验通过",gatherInfo.getVename());
  41 + return true;
  42 + }catch (Exception e){
  43 + e.printStackTrace();
  44 + logger.error("[CACHE-PARSE-ERROR]:",e);
  45 + return false;
  46 + }
  47 + }
  48 +
  49 + @Override
  50 + Object run() {
  51 + return false;
  52 + }
  53 +
  54 + // 获取spring容器
  55 + ApplicationContext getContext() {
  56 + // 获取spring IOC容器
  57 + ApplicationContext context = applicationContext;
  58 + return context;
  59 + }
  60 +
  61 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LandRoadVe
  5 +import com.sy.service.LandRoadVeService
  6 +import com.sy.service.impl.GatherInfoHandle
  7 +import org.apache.commons.lang3.StringUtils
  8 +import org.basis.enhance.groovy.entity.ExecuteParams
  9 +import org.slf4j.Logger
  10 +import org.slf4j.LoggerFactory
  11 +import org.springframework.context.ApplicationContext
  12 +
  13 +//基本信息验放
  14 +class BaseVeCheck extends Script {
  15 +
  16 + private final Logger logger = LoggerFactory.getLogger(getClass());
  17 + private final String NORECORD = "车辆未备案或者识别错误,车牌号:";
  18 + private final String VE_RECORD_WEIGHT_ERR = "车辆备案信息异常";
  19 +
  20 + private final String BLACKLIST= "车辆已被拉进黑名单,不允许出区";
  21 +
  22 + /**x21指令判定
  23 + * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
  24 + * 车辆备案实体
  25 + * 从redis读取的申请表体实体
  26 + */
  27 + Boolean check(ExecuteParams executeParams) {
  28 + try{
  29 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  30 + LandRoadVe ve = (LandRoadVe) executeParams.get("LandRoadVe");
  31 +
  32 + //3.车辆备案验证
  33 + // 调用方法
  34 + ApplicationContext context = getContext();
  35 + // 获取容器中的bean
  36 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  37 + //若无备案信息或者黑名单,返回车辆未备案或者识别错误,
  38 + if (ve == null) {
  39 + logger.error(NORECORD+gatherInfo.getVename());
  40 + gatherInfoHandle.sendBw(gatherInfo,false,NORECORD + gatherInfo.getVename(),null,null);
  41 + return false;
  42 + }
  43 + logger.info("[VE-CHECK-SUCCESS]:{}:备案验证通过",gatherInfo.getVename());
  44 + //车辆备案重量
  45 + Double selfWt=Double.parseDouble(ve.getSelfWt());
  46 + if (!(selfWt>0)){
  47 + logger.error(VE_RECORD_WEIGHT_ERR+gatherInfo.getVename());
  48 + gatherInfoHandle.sendBw(gatherInfo,false,gatherInfo.getVename()+VE_RECORD_WEIGHT_ERR,null,null);
  49 + return false;
  50 + }
  51 + logger.info("[VE-CHECK-SUCCESS]:{}备案重量[{}]验证通过",gatherInfo.getVename(),selfWt)
  52 +
  53 + //车辆黑名单校验
  54 + if (!veBlackListCheck(ve)){
  55 + logger.error(BLACKLIST+gatherInfo.getVename());
  56 + gatherInfoHandle.sendBw(gatherInfo,false,gatherInfo.getVename()+BLACKLIST,null,null);
  57 + return false;
  58 + }
  59 + logger.info("[VE-CHECK-SUCCESS]:{}黑名单验证通过",gatherInfo.getVename());
  60 +
  61 + //todo:车辆备案信息缓存,在哪里做申请提运单列表缓存?
  62 +
  63 + logger.info("[VE-CHECK-SUCCESS]:{}车辆信息验证通过",gatherInfo.getVename());
  64 + return true;
  65 + }catch (Exception e){
  66 + e.printStackTrace();
  67 + logger.error("[VE-CHECK-ERROR]:",e);
  68 + return false;
  69 + }
  70 + }
  71 +
  72 + @Override
  73 + Object run() {
  74 + return null
  75 + }
  76 +
  77 + // 获取spring容器
  78 + ApplicationContext getContext() {
  79 + // 获取spring IOC容器
  80 + ApplicationContext context = applicationContext;
  81 + return context;
  82 + }
  83 +
  84 + Boolean veBlackListCheck(LandRoadVe ve){
  85 + //Y 是拉黑了
  86 + if("Y".equals(ve.getVeState())){
  87 + return false;
  88 + }
  89 + return true;
  90 + }
  91 +
  92 +
  93 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.service.impl.GatherInfoHandle
  5 +import org.apache.commons.lang3.StringUtils
  6 +import org.basis.enhance.groovy.entity.ExecuteParams
  7 +import org.slf4j.Logger
  8 +import org.slf4j.LoggerFactory
  9 +import org.springframework.context.ApplicationContext
  10 +
  11 +//基本信息验放
  12 +class BaseX21GatherInfoCheck extends Script {
  13 +
  14 + private final Logger logger = LoggerFactory.getLogger(getClass());
  15 + private final String X21_WEIGHT_ERR = "车辆过卡重量异常";
  16 +
  17 + /**x21指令判定
  18 + * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
  19 + */
  20 + Boolean check(ExecuteParams executeParams) {
  21 + try{
  22 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  23 +
  24 + // 获取容器中的bean
  25 + // 调用方法
  26 + ApplicationContext context = getContext();
  27 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  28 +
  29 + if (gatherInfo == null){
  30 + logger.error("[ENGIN-BASE-CHECK-ERR]-过卡信息未获取到");
  31 + return false;
  32 + }
  33 + //基本验放信息
  34 + //2.车牌号验证,从过卡信息读取
  35 + if(StringUtils.isEmpty(gatherInfo.getVename())){
  36 + logger.error("[ENGIN-BASE-CHECK-ERR]-车牌信息未获取到");
  37 + return false;
  38 + }
  39 + if(StringUtils.isEmpty(gatherInfo.getBarcode())){
  40 + logger.error("[ENGIN-BASE-CHECK-ERR]-二维码信息未获取到");
  41 + return false;
  42 + }
  43 +
  44 + //4.车辆过卡重量验证,重量大于0 就正常
  45 + if (!(gatherInfo.grosswt>0)){
  46 + logger.error(X21_WEIGHT_ERR+gatherInfo.getVename());
  47 + gatherInfoHandle.sendBw(gatherInfo,false,X21_WEIGHT_ERR,null,null);
  48 + return false;
  49 + }
  50 +
  51 + logger.info("[BASE-CHECK-SUCCESS]:{}过卡基本信息验证通过",gatherInfo.getVename());
  52 + return true;
  53 + }catch (Exception e){
  54 + e.printStackTrace();
  55 + logger.error("[BASE-CHECK-ERROR]:",e);
  56 + return false;
  57 + }
  58 + }
  59 +
  60 + @Override
  61 + Object run() {
  62 + return null
  63 + }
  64 +
  65 + // 获取spring容器
  66 + ApplicationContext getContext() {
  67 + // 获取spring IOC容器
  68 + ApplicationContext context = applicationContext;
  69 + return context;
  70 + }
  71 +
  72 +
  73 +}
  1 +package com.sy.groovy;
  2 +
  3 +import org.basis.enhance.groovy.entity.ExecuteParams;
  4 +
  5 +/**
  6 + * @author mrz
  7 + * @date 2023-05-01
  8 + * 规则脚本对应通道验放规则接口类声明
  9 + * 通道规则验放必须包含check方法,且方法结果为布尔类型,验放通过为true.否则为false
  10 + */
  11 +public abstract class ChannelCheckScript {
  12 + public abstract Boolean check(ExecuteParams executeParams);
  13 +}
  1 +package com.sy.groovy
  2 +
  3 +/**
  4 + * 关锁验放规则
  5 + */
  6 +class CustomsLockCheck extends Script {
  7 +
  8 + @Override
  9 + Object run() {
  10 + return null
  11 + }
  12 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO
  5 +import com.sy.model.LandBusinessTypeList
  6 +import com.sy.service.ResMessageService
  7 +import com.sy.service.WeightCheckHandleService
  8 +import com.sy.service.impl.GatherInfoHandle
  9 +import org.basis.enhance.groovy.entity.ExecuteParams
  10 +import org.slf4j.Logger
  11 +import org.slf4j.LoggerFactory
  12 +import org.springframework.context.ApplicationContext
  13 +
  14 +//过卡单证验放-放行验放
  15 +class ReleaseCheck extends Script {
  16 +
  17 + private final Logger logger = LoggerFactory.getLogger(getClass());
  18 + private final String FANGXING= "有运单未放行";
  19 +
  20 + /**x21指令判定
  21 + * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
  22 + * 车辆备案实体
  23 + * 从redis读取的申请表体实体
  24 + * 适用于进口转关,进口提货业务类型
  25 + */
  26 + Boolean check(ExecuteParams executeParams) {
  27 + try{
  28 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  29 + LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
  30 + List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
  31 +
  32 + //3.车辆备案验证
  33 + // 调用方法
  34 + ApplicationContext context = getContext();
  35 + // 获取容器中的bean
  36 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  37 + //重量校验算法
  38 + ResMessageService resMessageService = context.getBean(ResMessageService.class);
  39 +
  40 + if (listinfos!=null && !listinfos.isEmpty() && resMessageService.checkManifestRelease(gatherInfo,listinfos)){
  41 + return true;
  42 + }else {
  43 + //有运单未放行
  44 + logger.error("[Release-check]-单证未通过校验:"+FANGXING+landBusinessTypeList.getMasterList());
  45 + gatherInfoHandle.sendBw(gatherInfo,false,FANGXING,landBusinessTypeList,listinfos);
  46 + return false;
  47 + }
  48 + }catch (Exception e){
  49 + e.printStackTrace();
  50 + logger.error("[Release-check-ERROR]:",e);
  51 + return false;
  52 + }
  53 + }
  54 +
  55 + @Override
  56 + Object run() {
  57 + return null
  58 + }
  59 +
  60 + // 获取spring容器
  61 + ApplicationContext getContext() {
  62 + // 获取spring IOC容器
  63 + ApplicationContext context = applicationContext;
  64 + return context;
  65 + }
  66 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO
  5 +import com.sy.model.LandBusinessTypeList
  6 +import com.sy.service.WeightCheckHandleService
  7 +import com.sy.service.impl.GatherInfoHandle
  8 +import org.basis.enhance.groovy.entity.ExecuteParams
  9 +import org.slf4j.Logger
  10 +import org.slf4j.LoggerFactory
  11 +import org.springframework.context.ApplicationContext
  12 +
  13 +//过卡重量验放-分拨调拨验放
  14 +class WeightCheckAllocateOrDispatch extends Script {
  15 +
  16 + private final Logger logger = LoggerFactory.getLogger(getClass());
  17 + private final String GROWSSEXCETION = "禁止通行,重量不在可控范围";
  18 +
  19 + /**过磅重量判定
  20 + * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
  21 + * 适用于分拨业务或者调拨业务
  22 + */
  23 + Boolean check(ExecuteParams executeParams) {
  24 + try{
  25 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  26 + LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
  27 + Double selfWt = (Double) executeParams.get("selfWt");
  28 + Double goodsWt = (Double) executeParams.get("goodsWt");
  29 + Double inAisleWT = (Double) executeParams.get("inAisleWT");
  30 + List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
  31 +
  32 + //3.车辆备案验证
  33 + // 调用方法
  34 + ApplicationContext context = getContext();
  35 + // 获取容器中的bean
  36 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  37 + //重量校验算法
  38 + WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);
  39 +
  40 + logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());
  41 + if (weightCheckHandleService.checkAllocateOrDispatch(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){
  42 + return true;
  43 + }else {
  44 + gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos);
  45 + return false;
  46 + }
  47 + }catch (Exception e){
  48 + e.printStackTrace();
  49 + logger.error("[ExportUnloadWeightCheck-ERROR]:",e);
  50 + return false;
  51 + }
  52 + }
  53 +
  54 + @Override
  55 + Object run() {
  56 + return null
  57 + }
  58 +
  59 + // 获取spring容器
  60 + ApplicationContext getContext() {
  61 + // 获取spring IOC容器
  62 + ApplicationContext context = applicationContext;
  63 + return context;
  64 + }
  65 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO
  5 +import com.sy.model.LandBusinessTypeList
  6 +import com.sy.service.WeightCheckHandleService
  7 +import com.sy.service.impl.GatherInfoHandle
  8 +import org.basis.enhance.groovy.entity.ExecuteParams
  9 +import org.slf4j.Logger
  10 +import org.slf4j.LoggerFactory
  11 +import org.springframework.context.ApplicationContext
  12 +
  13 +//过卡重量验放-提货验放
  14 +class WeightCheckEmpty extends Script {
  15 +
  16 + private final Logger logger = LoggerFactory.getLogger(getClass());
  17 + private final String GROWSSEXCETION = "禁止通行,重量不在可控范围";
  18 +
  19 + /**x21指令判定
  20 + * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
  21 + * 车辆备案实体
  22 + * 从redis读取的申请表体实体
  23 + * 适用于进口转关,进口提货业务类型
  24 + */
  25 + Boolean check(ExecuteParams executeParams) {
  26 + try{
  27 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  28 + LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
  29 + Double selfWt = (Double) executeParams.get("selfWt");
  30 + Double goodsWt = (Double) executeParams.get("goodsWt");
  31 + Double inAisleWT = (Double) executeParams.get("inAisleWT");
  32 + List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
  33 +
  34 + //3.车辆备案验证
  35 + // 调用方法
  36 + ApplicationContext context = getContext();
  37 + // 获取容器中的bean
  38 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  39 + //重量校验算法
  40 + WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);
  41 +
  42 + logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());
  43 + if (weightCheckHandleService.checkEmpty(gatherInfo.getGrosswt(), selfWt)){
  44 + return true;
  45 + }else {
  46 + logger.error("[空车业务]-出场重量未通过校验:"+GROWSSEXCETION);
  47 + gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos);
  48 + return false;
  49 + }
  50 + }catch (Exception e){
  51 + e.printStackTrace();
  52 + logger.error("[VE-CHECK-ERROR]:",e);
  53 + return false;
  54 + }
  55 + }
  56 +
  57 + @Override
  58 + Object run() {
  59 + return null
  60 + }
  61 +
  62 + // 获取spring容器
  63 + ApplicationContext getContext() {
  64 + // 获取spring IOC容器
  65 + ApplicationContext context = applicationContext;
  66 + return context;
  67 + }
  68 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO
  5 +import com.sy.model.LandBusinessTypeList
  6 +import com.sy.service.WeightCheckHandleService
  7 +import com.sy.service.impl.GatherInfoHandle
  8 +import org.basis.enhance.groovy.entity.ExecuteParams
  9 +import org.slf4j.Logger
  10 +import org.slf4j.LoggerFactory
  11 +import org.springframework.context.ApplicationContext
  12 +
  13 +//过卡重量验放-送货验放
  14 +class WeightCheckExportUnload extends Script {
  15 +
  16 + private final Logger logger = LoggerFactory.getLogger(getClass());
  17 + private final String GROWSSEXCETION = "禁止通行,重量不在可控范围";
  18 +
  19 + /**x21指令判定
  20 + * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
  21 + * 车辆备案实体
  22 + * 从redis读取的申请表体实体
  23 + * 适用于出口送货,出口转关
  24 + */
  25 + Boolean check(ExecuteParams executeParams) {
  26 + try{
  27 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  28 + LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
  29 + Double selfWt = (Double) executeParams.get("selfWt");
  30 + Double goodsWt = (Double) executeParams.get("goodsWt");
  31 + Double inAisleWT = (Double) executeParams.get("inAisleWT");
  32 + List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
  33 +
  34 + //3.车辆备案验证
  35 + // 调用方法
  36 + ApplicationContext context = getContext();
  37 + // 获取容器中的bean
  38 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  39 + //重量校验算法
  40 + WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);
  41 +
  42 + logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());
  43 + if (weightCheckHandleService.checkExportDownLoading(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){
  44 + return true;
  45 + }else {
  46 + logger.error("[ExportUnloadWeightCheck]-出场重量未通过校验:"+GROWSSEXCETION);
  47 + gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos);
  48 + return false;
  49 + }
  50 + }catch (Exception e){
  51 + e.printStackTrace();
  52 + logger.error("[ExportUnloadWeightCheck-ERROR]:",e);
  53 + return false;
  54 + }
  55 + }
  56 +
  57 + @Override
  58 + Object run() {
  59 + return null
  60 + }
  61 +
  62 + // 获取spring容器
  63 + ApplicationContext getContext() {
  64 + // 获取spring IOC容器
  65 + ApplicationContext context = applicationContext;
  66 + return context;
  67 + }
  68 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO
  5 +import com.sy.model.LandBusinessTypeList
  6 +import com.sy.service.WeightCheckHandleService
  7 +import com.sy.service.impl.GatherInfoHandle
  8 +import org.basis.enhance.groovy.entity.ExecuteParams
  9 +import org.slf4j.Logger
  10 +import org.slf4j.LoggerFactory
  11 +import org.springframework.context.ApplicationContext
  12 +
  13 +//过卡重量验放-提货验放
  14 +class WeightCheckImportDlv extends Script {
  15 +
  16 + private final Logger logger = LoggerFactory.getLogger(getClass());
  17 + private final String GROWSSEXCETION = "禁止通行,重量不在可控范围";
  18 +
  19 + /**x21指令判定
  20 + * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
  21 + * 车辆备案实体
  22 + * 从redis读取的申请表体实体
  23 + * 适用于进口转关,进口提货业务类型
  24 + */
  25 + Boolean check(ExecuteParams executeParams) {
  26 + try{
  27 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  28 + LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
  29 + Double selfWt = (Double) executeParams.get("selfWt");
  30 + Double goodsWt = (Double) executeParams.get("goodsWt");
  31 + Double inAisleWT = (Double) executeParams.get("inAisleWT");
  32 + List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
  33 +
  34 + //3.车辆备案验证
  35 + // 调用方法
  36 + ApplicationContext context = getContext();
  37 + // 获取容器中的bean
  38 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  39 + //重量校验算法
  40 + WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);
  41 +
  42 + logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());
  43 + if (weightCheckHandleService.checkImportDlv(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){
  44 + return true;
  45 + }else {
  46 + logger.error("[进口提货]-出场重量未通过校验:"+GROWSSEXCETION);
  47 + gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos);
  48 + return false;
  49 + }
  50 + }catch (Exception e){
  51 + e.printStackTrace();
  52 + logger.error("[VE-CHECK-ERROR]:",e);
  53 + return false;
  54 + }
  55 + }
  56 +
  57 + @Override
  58 + Object run() {
  59 + return null
  60 + }
  61 +
  62 + // 获取spring容器
  63 + ApplicationContext getContext() {
  64 + // 获取spring IOC容器
  65 + ApplicationContext context = applicationContext;
  66 + return context;
  67 + }
  68 +}
  1 +package com.sy.groovy
  2 +
  3 +import com.sy.model.GatherInfo
  4 +import com.sy.model.LandBusinessTypeList
  5 +import com.sy.service.impl.GatherInfoHandle
  6 +import org.basis.enhance.groovy.entity.ExecuteParams
  7 +import org.slf4j.Logger
  8 +import org.slf4j.LoggerFactory
  9 +import org.springframework.context.ApplicationContext
  10 +import java.util.stream.Collectors
  11 +
  12 +//申请单核销判定
  13 +class X21FormReleaseCheck extends Script {
  14 +
  15 + private final Logger logger = LoggerFactory.getLogger(getClass());
  16 +
  17 +
  18 + /**x21指令判定
  19 + * 传入gatherInfo
  20 + *
  21 + * 传入从redis读取的申请表体实体,验证
  22 + * 进行通道比对
  23 + */
  24 + void releaseCheck(ExecuteParams executeParams) {
  25 + try{
  26 + // 获取product对象
  27 + GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
  28 + List<LandBusinessTypeList> formList = (List<LandBusinessTypeList>) executeParams.get("formList");
  29 +
  30 + // 调用方法
  31 + ApplicationContext context = getContext();
  32 + // 获取容器中的bean
  33 + GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
  34 +
  35 + List<LandBusinessTypeList> temp = new ArrayList<>(formList);
  36 + //二维码已出区的记录
  37 + List<LandBusinessTypeList> havenCrossList = gatherInfoHandle.listService.selectByBarcodeWithE(gatherInfo.getBarcode());
  38 +
  39 + if (formList == null && formList.isEmpty() ){
  40 + logger.error("[FORM-RELEASE-CHECK]-车辆进出场对应申请缓存数据为空:{}",gatherInfo.getBarcode());
  41 + return;
  42 + }
  43 +
  44 + if (havenCrossList.isEmpty()){
  45 + logger.error("[FORM-RELEASE-CHECK]{}:车辆无离场数据,不核销",gatherInfo.getVename());
  46 + return;
  47 + }
  48 + logger.info("[FORM-RELEASE-CHECK]:已过卡数量:[{}]",havenCrossList.size())
  49 + //申请核销判定,已出区的记录与流转申请数据核碰.如果流转申请列表核碰完,还剩下的需要出区的场站则不核销.
  50 + for (LandBusinessTypeList businessTypeList : havenCrossList) {
  51 + List<LandBusinessTypeList> r = formList.stream().filter({item ->
  52 + //判断还有没有没有出区的场站,还有没有出区的场站就不核销
  53 + logger.debug("[releaseFormCheck-Stream-loop]-缓存与已出核碰,缓存元素场站:[{}],已出记录场站:[{}]",item.getEndstation(),businessTypeList.getEndstation());
  54 + //解决缓存那里存储有不一样的把人错的的有问题的点,二维码不一致也把缓存删除
  55 + if (!item.getBarcode().equals(businessTypeList.getBarcode())){
  56 + return true;
  57 + }
  58 + if(item.getEndstation().equals(businessTypeList.getEndstation())) {
  59 + logger.info("[releaseFormCheck-Stream-loop]-缓存元素场站:[{}],已出记录场站:[{}]-核销判定对碰成功",item.getEndstation(),businessTypeList.getEndstation());
  60 + return true;
  61 + }else {
  62 + return false;
  63 + }
  64 + }).collect(Collectors.toList());
  65 + temp.removeAll(r);
  66 + }
  67 + logger.info("[FORM-RELEASE-CHECK]-核销判定结果:{}",temp.size());
  68 + if (temp.isEmpty()){
  69 + //todo:流转申请状态核销
  70 + logger.info("[进出场申请]-流转申请开始核销:"+gatherInfo.getVename());
  71 + //二维码核销
  72 +// gatherInfoHandle.releaseBarCode();
  73 + logger.info("[进出场申请]-流转申请已核销:"+gatherInfo.getVename());
  74 + }
  75 + }catch (Exception e){
  76 + e.printStackTrace();
  77 + logger.error("[FORM-RELEASE-ERROR]:",e);
  78 + }
  79 + }
  80 +
  81 + @Override
  82 + Object run() {
  83 + return false;
  84 + }
  85 +
  86 + // 获取spring容器
  87 + ApplicationContext getContext() {
  88 + // 获取spring IOC容器
  89 + ApplicationContext context = applicationContext;
  90 + return context;
  91 + }
  92 +
  93 +}
@@ -606,7 +606,7 @@ public class GatherInfoHandle implements GatherInfoService { @@ -606,7 +606,7 @@ public class GatherInfoHandle implements GatherInfoService {
606 case "调拨业务": 606 case "调拨业务":
607 if (gatherInfoHandle.weightCheckHandleService.checkAllocateOrDispatch(growssWt, selfWt, goodsWt,inWt)){ 607 if (gatherInfoHandle.weightCheckHandleService.checkAllocateOrDispatch(growssWt, selfWt, goodsWt,inWt)){
608 /** 608 /**
609 - * 调拨业务如果空车出,可出.(就是申请不带运单的) 609 + * 调拨业务如果空车出,可出.(就是申请不带运单的,比如综保区的车辆)
610 */ 610 */
611 if (listinfos!=null && listinfos.isEmpty()){ 611 if (listinfos!=null && listinfos.isEmpty()){
612 log.info("[调拨-空车]-{}空车离场",info.getVename()); 612 log.info("[调拨-空车]-{}空车离场",info.getVename());
@@ -717,7 +717,7 @@ public class GatherInfoHandle implements GatherInfoService { @@ -717,7 +717,7 @@ public class GatherInfoHandle implements GatherInfoService {
717 /** 717 /**
718 * 二维码失效核销->判定及失效通知. 718 * 二维码失效核销->判定及失效通知.
719 */ 719 */
720 - private void releaseBarCode(){ 720 + public void releaseBarCode(){
721 //是否有未驶离的流转记录二维码判定 721 //是否有未驶离的流转记录二维码判定
722 int count=gatherInfoHandle.listService.selectlaststation(info.getVename(),info.getBarcode()); 722 int count=gatherInfoHandle.listService.selectlaststation(info.getVename(),info.getBarcode());
723 //二维码失效通知,已进入场站的与缓存比较. 723 //二维码失效通知,已进入场站的与缓存比较.
@@ -766,7 +766,7 @@ public class GatherInfoHandle implements GatherInfoService { @@ -766,7 +766,7 @@ public class GatherInfoHandle implements GatherInfoService {
766 * @param list_infos 流转申请表体信息 766 * @param list_infos 流转申请表体信息
767 * @return 调试模式 直接返回true,生产模式按业务走 767 * @return 调试模式 直接返回true,生产模式按业务走
768 */ 768 */
769 - private boolean sendBw(GatherInfo info, boolean check, String reason, LandBusinessTypeList land, List<LAND_BUSINEESTYPE_LIST_INFO> list_infos) { 769 + public boolean sendBw(GatherInfo info, boolean check, String reason, LandBusinessTypeList land, List<LAND_BUSINEESTYPE_LIST_INFO> list_infos) {
770 //调试模式 直接返回true 770 //调试模式 直接返回true
771 if (gatherInfoHandle.debug){ 771 if (gatherInfoHandle.debug){
772 if (check) { 772 if (check) {
@@ -116,7 +116,7 @@ public class LandBusListServiceImpl implements LandBusListService { @@ -116,7 +116,7 @@ public class LandBusListServiceImpl implements LandBusListService {
116 } 116 }
117 117
118 /** 118 /**
119 - * 根据gatherInfo获取对应的流转申请 119 + * 根据gatherInfo获取对应的通道流转申请,没有对应通道的流转申请,则不抬杆放行.
120 * @return 流转申请信息 120 * @return 流转申请信息
121 */ 121 */
122 @Override 122 @Override
@@ -17,6 +17,7 @@ import java.util.concurrent.TimeUnit; @@ -17,6 +17,7 @@ import java.util.concurrent.TimeUnit;
17 @Slf4j 17 @Slf4j
18 public class BeihuoTests { 18 public class BeihuoTests {
19 19
  20 + String ffm = "";
20 21
21 private static ThreadPoolExecutor threadPoolEs = XMLThreadPoolFactory.instance("kakou"); 22 private static ThreadPoolExecutor threadPoolEs = XMLThreadPoolFactory.instance("kakou");
22 private AnalysisRoute analysisRoute=new AnalysisRoute(); 23 private AnalysisRoute analysisRoute=new AnalysisRoute();
  1 +package com.sy.engin;
  2 +
  3 +import com.alibaba.fastjson.JSONArray;
  4 +import com.sy.model.GatherInfo;
  5 +import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
  6 +import com.sy.model.LandBusinessTypeList;
  7 +import com.sy.model.LandRoadVe;
  8 +import com.sy.service.BusnesslistinfoService;
  9 +import com.sy.service.LandBusListService;
  10 +import com.sy.service.LandRoadVeService;
  11 +import com.sy.service.RedisService;
  12 +import lombok.extern.slf4j.Slf4j;
  13 +import org.apache.commons.lang.StringUtils;
  14 +import org.basis.enhance.groovy.entity.EngineExecutorResult;
  15 +import org.basis.enhance.groovy.entity.ExecuteParams;
  16 +import org.basis.enhance.groovy.entity.ScriptQuery;
  17 +import org.basis.enhance.groovy.executor.EngineExecutor;
  18 +import org.basis.enhance.groovy.helper.RefreshScriptHelper;
  19 +import org.junit.Test;
  20 +import org.junit.runner.RunWith;
  21 +import org.springframework.beans.factory.annotation.Autowired;
  22 +import org.springframework.boot.test.context.SpringBootTest;
  23 +import org.springframework.test.context.junit4.SpringRunner;
  24 +
  25 +import java.math.BigDecimal;
  26 +import java.util.ArrayList;
  27 +import java.util.List;
  28 +
  29 +@RunWith(SpringRunner.class)
  30 +@SpringBootTest
  31 +@Slf4j
  32 +public class EnginTest {
  33 +
  34 + private static String IEPORSE = "无相对应进出场申请";
  35 + private static String CHANEL_ERR= "无对应通道流转申请,走错通道";
  36 +
  37 +
  38 + @Autowired
  39 + private EngineExecutor engineExecutor;
  40 +
  41 + @Autowired
  42 + private BusnesslistinfoService busnesslistinfoService;
  43 +
  44 + @Autowired
  45 + private LandBusListService landBusListService;
  46 +
  47 + @Autowired
  48 + private RedisService redisService;
  49 +
  50 + @Autowired
  51 + private LandBusListService listService;
  52 +
  53 + @Autowired
  54 + LandRoadVeService veService;
  55 +
  56 +
  57 +
  58 + /**
  59 + * 过磅x21报文实体
  60 + */
  61 + ExecuteParams buildGatherInfoParams(){
  62 + GatherInfo gatherInfo = new GatherInfo();
  63 + gatherInfo.setAreaid("4604600000");
  64 + gatherInfo.setChnlno("4604601010");
  65 + gatherInfo.setBarcode("edb-4ebc-919b-7d7b118da052");
  66 + gatherInfo.setGrosswt(new BigDecimal("6478"));
  67 + gatherInfo.setSeqno("20220630184441000028");
  68 + gatherInfo.setIetype("I");
  69 + gatherInfo.setVename("豫A61CR8");
  70 +
  71 + ExecuteParams executeParams = new ExecuteParams();
  72 + //初始化
  73 + executeParams.put("gatherInfo", gatherInfo);
  74 + executeParams.put("formList", null);
  75 + executeParams.put("ChanelFormInfo", null);
  76 + executeParams.put("ChanelFormBillLists", null);
  77 + executeParams.put("LandRoadVe", null);
  78 + executeParams.put("inAisleWT", 0.0);
  79 + executeParams.put("diffVal", 0.0);
  80 + executeParams.put("selfWt", 0.0);
  81 + executeParams.put("goodsWt", 0.0);
  82 +
  83 + //车辆备案信息
  84 + LandRoadVe ve = veService.selectByFrameNo(gatherInfo.getVename());
  85 + if (ve != null) {
  86 + //车辆备案重量
  87 + Double selfWt=Double.parseDouble(ve.getSelfWt());
  88 + executeParams.put("LandRoadVe", ve);
  89 + executeParams.put("selfWt", selfWt);
  90 + }
  91 +
  92 + //获取申请单表体
  93 + log.info("[FORM-CACHE-GET]:车辆-{}核碰缓存",gatherInfo.getVename());
  94 + String landBusinessJson = redisService.get(gatherInfo.getVename());
  95 + if (StringUtils.isNotEmpty(landBusinessJson)) {
  96 + //这个是申请单表体
  97 + List<LandBusinessTypeList> list = JSONArray.parseArray(landBusinessJson, LandBusinessTypeList.class);
  98 + executeParams.put("formList", list);
  99 +
  100 + //通道对应申请信息
  101 + LandBusinessTypeList chanelFormInfo = landBusListService.getLandBusinessTypeListByGather(gatherInfo);
  102 + executeParams.put("ChanelFormInfo", chanelFormInfo);
  103 + if (chanelFormInfo!= null){
  104 + executeParams.put("goodsWt", chanelFormInfo.getRemark());
  105 + }
  106 +
  107 + //查询申请单运单列表
  108 + List<LAND_BUSINEESTYPE_LIST_INFO> chanelFormBillLists= busnesslistinfoService.selectmanilist(gatherInfo.getBarcode());
  109 + executeParams.put("ChanelFormBillLists", chanelFormBillLists);
  110 +
  111 + }
  112 +
  113 + //对应场站入场信息重量
  114 + if ("E".equals(gatherInfo.getIetype())){
  115 + List<LandBusinessTypeList> stationInChanleInfo= listService.selectwt(gatherInfo.getVename(),gatherInfo.getBarcode(),gatherInfo.getAreaid(),"I");
  116 + if (stationInChanleInfo.isEmpty()){
  117 + log.info("未查询到车辆:{}的入场信息",gatherInfo.getVename());
  118 + }else {
  119 + for(LandBusinessTypeList typeList:stationInChanleInfo){
  120 + if(typeList.getAislewt()!=null){
  121 + //对应场站进场过磅重量
  122 + Double inAisleWT = typeList.getAislewt();
  123 + executeParams.put("inAisleWT", inAisleWT);
  124 + //离场与入场重量差值
  125 + Double diffVal = inAisleWT- gatherInfo.getGrosswt().doubleValue();
  126 + executeParams.put("diffVal", diffVal);
  127 + }
  128 + }
  129 + //TODO:进场校验 增加 车辆备案重量要 <= 进场过磅重量 ,要有误差判定
  130 + }
  131 + }
  132 +
  133 +
  134 +
  135 +
  136 +
  137 + return executeParams;
  138 + }
  139 +
  140 + @Test
  141 + public void x21Check() {
  142 + long time = System.currentTimeMillis(); //do something that takes some time... long completedIn = System.currentTimeMillis() - time;
  143 + System.out.println("验证开始"+time);
  144 +
  145 + String scriptName = "x21-check";
  146 +// String scriptName = "form-check";
  147 + // 构建参数
  148 + ExecuteParams executeParams = buildGatherInfoParams();
  149 + // 执行脚本中指定的方法 changeProduct
  150 + EngineExecutorResult executorResult = engineExecutor.execute(
  151 + "baseCheck", new ScriptQuery("x21-check"), executeParams);
  152 + log.info("使用groovy脚本来验证过卡判定放行结果=========>>>>>>>>>>>执行结果:{}", executorResult);
  153 +
  154 + EngineExecutorResult formCheckResult = engineExecutor.execute(
  155 + "formCheck", new ScriptQuery("form-check"), executeParams);
  156 +
  157 + EngineExecutorResult veCheckResult = engineExecutor.execute(
  158 + "veCheck", new ScriptQuery("ve-check"), executeParams);
  159 +
  160 + EngineExecutorResult releaseCheckResult = engineExecutor.execute(
  161 + "releaseCheck", new ScriptQuery("form-release"), executeParams);
  162 +
  163 + log.info("success");
  164 + System.out.println("验证结束"+(System.currentTimeMillis()-time));
  165 +
  166 + }
  167 +
  168 + @Test
  169 + public void arrTest(){
  170 + String[] busType = new String[] {"区内分拨","区内调拨"};
  171 + String[] goodsType = new String[] {"普通货物","转关货物","退库货物","换单货物","查验货物"};
  172 + String[] rules = new String[] {"基本验放规则","核销判定"};
  173 + int i = 0;
  174 + for (String bus : busType) {
  175 + for (String good : goodsType) {
  176 + for (String rule : rules) {
  177 + log.info("插入一条数据:业务类型-[{}]-货物类型:[{}]-验放规则:[{}]",bus,good,rule);
  178 + i++;
  179 +
  180 + }
  181 + }
  182 + }
  183 +
  184 +
  185 + String[] busType1 = new String[] {"区内分拨"};
  186 + String[] goodsType1 = new String[] {"快件货物"};
  187 + String[] rules1 = new String[] {"关锁判定"};
  188 + for (String bus : busType1) {
  189 + for (String good : goodsType1) {
  190 + for (String rule : rules1) {
  191 + log.info("插入一条数据:业务类型-[{}]-货物类型:[{}]-验放规则:[{}]",bus,good,rule);
  192 + i++;
  193 +
  194 + }
  195 + }
  196 + }
  197 +
  198 + log.info("共插入{}条规则",i);
  199 + }
  200 +
  201 +}