作者 朱兆平

优化部分验放规则脚本

@@ -3,11 +3,16 @@ server.port=8848 @@ -3,11 +3,16 @@ server.port=8848
3 3
4 #eureka.client.service-url.defaultZone=http://10.50.3.82:19527/eureka/ 4 #eureka.client.service-url.defaultZone=http://10.50.3.82:19527/eureka/
5 eureka.client.service-url.defaultZone=http://192.168.1.53:12345/eureka/ 5 eureka.client.service-url.defaultZone=http://192.168.1.53:12345/eureka/
6 -  
7 -spring.application.name=kako_analysisforstation  
8 -spring.cloud.service-registry.auto-registration.enabled=false  
9 -spring.cloud.discovery.client.health-indicator.enabled=false  
10 -spring.cloud.service-registry.auto-registration.register-management=false 6 +eureka.client.registry-fetch-interval-seconds=30
  7 +eureka.instance.status-page-url=http://${eureka.instance.hostname}:${server.port}/
  8 +eureka.instance.prefer-ip-address=true
  9 +eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port}
  10 +eureka.instance.hostname=${spring.cloud.client.ip-address}
  11 +
  12 +spring.application.name=kako-analysisforstation
  13 +spring.cloud.service-registry.auto-registration.enabled=true
  14 +spring.cloud.discovery.client.health-indicator.enabled=true
  15 +spring.cloud.service-registry.auto-registration.register-management=true
11 spring.cloud.features.enabled=false 16 spring.cloud.features.enabled=false
12 spring.cloud.discovery.enabled=false 17 spring.cloud.discovery.enabled=false
13 spring.cloud.config.enabled=false 18 spring.cloud.config.enabled=false
@@ -23,8 +28,8 @@ spring.mvc.view.prefix=.jsp @@ -23,8 +28,8 @@ spring.mvc.view.prefix=.jsp
23 spring.redis.host=192.168.1.53 28 spring.redis.host=192.168.1.53
24 spring.redis.port=6379 29 spring.redis.port=6379
25 #spring.redis.database=2 30 #spring.redis.database=2
26 -spring.redis.lettuce.pool.max-active=16  
27 -spring.redis.lettuce.pool.min-idle=16 31 +spring.redis.lettuce.pool.max-active=40
  32 +spring.redis.lettuce.pool.min-idle=20
28 spring.redis.lettuce.pool.max-wait=5000 33 spring.redis.lettuce.pool.max-wait=5000
29 34
30 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 35 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
@@ -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>5.0.0-ENGIN-SNAPSHOT</version> 8 + <version>6.0.0-ENGIN-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>
@@ -35,14 +35,16 @@ class BillAllocateCheck extends Script implements ChannelCheckScript { @@ -35,14 +35,16 @@ class BillAllocateCheck extends Script implements ChannelCheckScript {
35 LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo"); 35 LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
36 List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists"); 36 List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
37 37
  38 +
38 // 调用方法 39 // 调用方法
39 ApplicationContext context = getContext(); 40 ApplicationContext context = getContext();
40 // 获取容器中的bean 41 // 获取容器中的bean
41 GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class); 42 GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
42 43
43 - boolean allocatCheck = checkNmmsAllocate(landBusinessTypeList.getMasterList()); 44 +// boolean allocatCheck = checkNmmsAllocate(landBusinessTypeList.getMasterList());
  45 + boolean allocatCheckByList = checkNMMSAllocateByList(listinfos);
44 46
45 - if(!allocatCheck){ 47 + if(!allocatCheckByList){
46 logger.error("[分拨业务]-分拨申请舱单未通过校验:"+FENBO); 48 logger.error("[分拨业务]-分拨申请舱单未通过校验:"+FENBO);
47 gatherInfoHandle.sendBw(gatherInfo,false,FENBO,landBusinessTypeList,listinfos); 49 gatherInfoHandle.sendBw(gatherInfo,false,FENBO,landBusinessTypeList,listinfos);
48 return false; 50 return false;
@@ -126,4 +128,29 @@ class BillAllocateCheck extends Script implements ChannelCheckScript { @@ -126,4 +128,29 @@ class BillAllocateCheck extends Script implements ChannelCheckScript {
126 } 128 }
127 return true; 129 return true;
128 } 130 }
  131 +
  132 + boolean checkNMMSAllocateByList(List<LAND_BUSINEESTYPE_LIST_INFO> listinfos){
  133 + //单证类型- 提运单
  134 + String BILL_TYPE_WAYBILL = "B"
  135 + //单证类型-集装器
  136 + String BILL_TYPE_ULD = "C"
  137 + if (listinfos!=null && !listinfos.isEmpty() ){
  138 + for(LAND_BUSINEESTYPE_LIST_INFO item : listinfos){
  139 + if (BILL_TYPE_WAYBILL.equals(item.getExt4())){
  140 + logger.info("分拨申请验放-单证[{}]:提运单",item.getAwba());
  141 + if (!checkNmmsAllocate(item.getAwba())){
  142 + return false;
  143 + }
  144 + }
  145 + if (BILL_TYPE_ULD.equals(item.getExt4())){
  146 + logger.info("分拨申请验放-单证[{}]:集装器",item.getAwba());
  147 + }else {
  148 + logger.info("分拨申请验放-单证[{}]:其他类型[{}]",item.getAwba(),item.getExt4());
  149 + }
  150 + }
  151 + return true;
  152 + }
  153 +
  154 + return false;
  155 + }
129 } 156 }
@@ -10,6 +10,8 @@ import org.slf4j.Logger @@ -10,6 +10,8 @@ import org.slf4j.Logger
10 import org.slf4j.LoggerFactory 10 import org.slf4j.LoggerFactory
11 import org.springframework.context.ApplicationContext 11 import org.springframework.context.ApplicationContext
12 12
  13 +import java.text.DecimalFormat
  14 +
13 /** 15 /**
14 * 重量验放 16 * 重量验放
15 * 分拨调拨流转验放 17 * 分拨调拨流转验放
@@ -32,16 +34,18 @@ class WeightCheckAllocateOrDispatch extends Script implements ChannelCheckScript @@ -32,16 +34,18 @@ class WeightCheckAllocateOrDispatch extends Script implements ChannelCheckScript
32 Double inAisleWT = (Double) executeParams.get("inAisleWT"); 34 Double inAisleWT = (Double) executeParams.get("inAisleWT");
33 List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists"); 35 List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
34 36
  37 + logger.info("[AllocateOrDispatch-Weight-Check]-备案重:{}",selfWt);
  38 + logger.info("[AllocateOrDispatch-Weight-Check]-货重:{}",goodsWt);
  39 + logger.info("[AllocateOrDispatch-Weight-Check]-入场重:{}",inAisleWT);
  40 + logger.info("[AllocateOrDispatch-Weight-Check]-过磅重:{}",gatherInfo.getGrosswt());
  41 +
35 //3.车辆备案验证 42 //3.车辆备案验证
36 // 调用方法 43 // 调用方法
37 ApplicationContext context = getContext(); 44 ApplicationContext context = getContext();
38 // 获取容器中的bean 45 // 获取容器中的bean
39 GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class); 46 GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
40 - //重量校验算法  
41 - WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);  
42 47
43 - logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());  
44 - if (weightCheckHandleService.checkAllocateOrDispatch(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){ 48 + if (checkAllocateOrDispatch(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){
45 return true; 49 return true;
46 }else { 50 }else {
47 gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos); 51 gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos);
@@ -49,7 +53,7 @@ class WeightCheckAllocateOrDispatch extends Script implements ChannelCheckScript @@ -49,7 +53,7 @@ class WeightCheckAllocateOrDispatch extends Script implements ChannelCheckScript
49 } 53 }
50 }catch (Exception e){ 54 }catch (Exception e){
51 e.printStackTrace(); 55 e.printStackTrace();
52 - logger.error("[ExportUnloadWeightCheck-ERROR]:",e); 56 + logger.error("[AllocateOrDispatch-Weight-Check-ERROR]:",e);
53 return false; 57 return false;
54 } 58 }
55 } 59 }
@@ -65,4 +69,57 @@ class WeightCheckAllocateOrDispatch extends Script implements ChannelCheckScript @@ -65,4 +69,57 @@ class WeightCheckAllocateOrDispatch extends Script implements ChannelCheckScript
65 ApplicationContext context = applicationContext; 69 ApplicationContext context = applicationContext;
66 return context; 70 return context;
67 } 71 }
  72 +
  73 + boolean checkAllocateOrDispatch(double grossWt, double wt, double goodsWt,double inWt){
  74 + // 调用方法
  75 + ApplicationContext context = getContext();
  76 +
  77 + //重量校验算法
  78 + WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);
  79 + //todo:调拨分拨中的第二.三...场站的如卡口判断 都应该以带货入场进行判定.离场都应该以空车进行判定.
  80 + DecimalFormat df = new DecimalFormat("0.00");
  81 + boolean flag = false;
  82 + //载货离场判定
  83 + double result= 0.00;
  84 + //空车离场判定
  85 + double result2= 0.00;
  86 +
  87 + //卸货离场判定
  88 + double result3= 0.00;
  89 + double result4= 0.00;
  90 +
  91 + //货重为0 有BUG,0不能作为被除数
  92 + if (goodsWt > 0){
  93 + logger.info("货重正常")
  94 + }else {
  95 + logger.info("货重不正常,被除数改为1")
  96 + goodsWt = 1.0;
  97 + }
  98 +
  99 + if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
  100 + //带货出,入场重量+带货重量 = 离场重量
  101 + result = Double.parseDouble(df.format(Math.abs((grossWt-inWt-goodsWt)) / goodsWt));
  102 + //带货出,用车辆备案重量对碰,车辆备案重量+带货重量 = 离场重量
  103 +// result4 = Double.parseDouble(df.format(Math.abs((wt + goodsWt - grossWt)) / grossWt));
  104 + result4 = Double.parseDouble(df.format(Math.abs((grossWt-wt-goodsWt)) / goodsWt));
  105 + //空车出,过磅重量 = 车辆备案重量
  106 + result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / wt));
  107 + //卸货出,入场重量-卸货重量 = 离场重量
  108 + result3 = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / goodsWt));
  109 +
  110 + System.out.println("进场提货离场差值:"+result);
  111 + System.out.println("空车离场差值:"+result2);
  112 + System.out.println("进场卸货离场差值:"+result3);
  113 + System.out.println("备案重量进场装载货物离场差值:"+result4);
  114 + }
  115 + double range = weightCheckHandleService.valueDob();
  116 + if (result2 <= range
  117 + || result <= range
  118 + || result3 <= range
  119 + || result4 <= range
  120 + ) {
  121 + flag = true;
  122 + }
  123 + return flag;
  124 + }
68 } 125 }
@@ -10,6 +10,8 @@ import org.slf4j.Logger @@ -10,6 +10,8 @@ import org.slf4j.Logger
10 import org.slf4j.LoggerFactory 10 import org.slf4j.LoggerFactory
11 import org.springframework.context.ApplicationContext 11 import org.springframework.context.ApplicationContext
12 12
  13 +import java.text.DecimalFormat
  14 +
13 /** 15 /**
14 * 重量验放 16 * 重量验放
15 * 卸货验放 17 * 卸货验放
@@ -39,11 +41,10 @@ class WeightCheckExportUnload extends Script implements ChannelCheckScript { @@ -39,11 +41,10 @@ class WeightCheckExportUnload extends Script implements ChannelCheckScript {
39 ApplicationContext context = getContext(); 41 ApplicationContext context = getContext();
40 // 获取容器中的bean 42 // 获取容器中的bean
41 GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class); 43 GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
42 - //重量校验算法  
43 - WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class); 44 +
44 45
45 logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype()); 46 logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());
46 - if (weightCheckHandleService.checkExportDownLoading(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){ 47 + if (checkExportDownLoading(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){
47 return true; 48 return true;
48 }else { 49 }else {
49 logger.error("[ExportUnloadWeightCheck]-出场重量未通过校验:"+GROWSSEXCETION); 50 logger.error("[ExportUnloadWeightCheck]-出场重量未通过校验:"+GROWSSEXCETION);
@@ -68,4 +69,50 @@ class WeightCheckExportUnload extends Script implements ChannelCheckScript { @@ -68,4 +69,50 @@ class WeightCheckExportUnload extends Script implements ChannelCheckScript {
68 ApplicationContext context = applicationContext; 69 ApplicationContext context = applicationContext;
69 return context; 70 return context;
70 } 71 }
  72 +
  73 + boolean checkExportDownLoading(double grossWt, double wt, double goodsWt, double inWt){
  74 + // 调用方法
  75 + ApplicationContext context = getContext();
  76 +
  77 + //重量校验算法
  78 + WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);
  79 + /**
  80 + * 异常情况判定
  81 + * 送货业务的入场重量必须大于离场重量
  82 + * 比如申请单申请的时候本来是进口提货 申请成出口送货
  83 + */
  84 + if (inWt<grossWt){
  85 + logger.info("出区重量比入区重量大,信息异常");
  86 + return false;
  87 + }
  88 +
  89 + DecimalFormat df = new DecimalFormat("0.00");
  90 + boolean flag = false;
  91 + //卸货判定
  92 + double result= 0.0;
  93 + //以防万一 空车离场判定
  94 + double result2= 0.0;
  95 + logger.info("进场卸货-入场重量:[{}]",inWt);
  96 + logger.info("进场卸货-离场重量:[{}]",grossWt);
  97 + logger.info("进场卸货-申请货重:[{}]",goodsWt);
  98 + if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
  99 + /**
  100 + * 入场重量 - 离场重量 = (实际卸货重量 - 申请货重)/申请货重
  101 + * 再将卸货重量与申请单的卸货数据比对差值
  102 + */
  103 + result = Double.parseDouble(df.format(Math.abs((inWt - grossWt - goodsWt)) / goodsWt));
  104 +
  105 + result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / wt));
  106 +
  107 + logger.info("[WEIGHT-UNLOADING-CHECK]-进出场比对差值:{},空车出场差值:{},进出场比对重量差:{},空车比对重量差:{}",result,result2,Math.abs(inWt - goodsWt - grossWt),Math.abs(grossWt-wt));
  108 + }
  109 + double range = weightCheckHandleService.valueDob();
  110 +
  111 + //车辆离场重量与车辆备案重量验放,只允许空车离场
  112 + if (result <= range) {
  113 + flag = true;
  114 + }
  115 +
  116 + return flag;
  117 + }
71 } 118 }
@@ -28,7 +28,7 @@ class WeightCheckHandleServiceImplTest { @@ -28,7 +28,7 @@ class WeightCheckHandleServiceImplTest {
28 28
29 @Test 29 @Test
30 void checkAllocateOrDispatch(){ 30 void checkAllocateOrDispatch(){
31 - weightCheckHandleService.checkAllocateOrDispatch(10560,10500,175.6,10310); 31 + weightCheckHandleService.checkAllocateOrDispatch(13220,10500,3125,0);
32 } 32 }
33 33
34 @Test 34 @Test
  1 +# VER 6.0 Date:2023-06-07 周三
  2 +## 大版本更新,更新验放规则为动态验放,采用动态脚本引擎.
  3 + - 可进行通道与验放规则的关联配置进行验放
  4 + - 根据通道号\业务类型\货物类型绑定对应的验放规则
  5 + - 新增一线进口业务
  6 + - 新增一线出口业务
  7 + - 新增规则管理
  8 + - 新增验放管理
  9 + - 新增业务类型管理
  10 + - 操作界面优化
  11 + - 服务名更改为kako-analysisforstation
  12 + - eureka注册打开
  13 +### 更新流程.
  14 +#### 验放端:
  15 + 1. 配置文件增加redis连接池配置部分
  16 + > spring.redis.lettuce.pool.max-active=40
  17 + spring.redis.lettuce.pool.min-idle=20
  18 + spring.redis.lettuce.pool.max-wait=5000
  19 + 2. 配置文件增加groove引擎配置部分
  20 + > # 规则引擎相关配置
  21 + # 脚本检查更新周期(单位:秒),(默认300L)
  22 + enhance.groovy.engine.polling-cycle=10000
  23 + # 开启功能
  24 + enhance.groovy.engine.enable=true
  25 + # 缓存过期时间(默认600L分钟)
  26 + enhance.groovy.engine.cache-expire-after-write=600
  27 + #缓存初始容量(默认100)
  28 + enhance.groovy.engine.cache-initial-capacity=50
  29 + # 缓存最大容量(默认500)
  30 + enhance.groovy.engine.cache-maximum-size=50
  31 + # 开启基于Redis加载groovy脚本
  32 + enhance.groovy.engine.redis-loader.namespace=kako-release-check
  33 + enhance.groovy.engine.redis-loader.enable=true
  34 + 3. 打开IMF定时器
  35 + 4. 打开本地报文读取定时器
  36 + 5. 编译文件
  37 + 6. 上传正式服务器
  38 + 7. 备份正在运行版本
  39 + 8. 更改start.sh脚本中的 执行jar名称.
  40 + 9. 关闭运行的验放端
  41 + 10. 执行start.sh脚本
  42 + 11. 更新完成
  43 +#### 申报端:
  44 + 1. 配置文件同步
  45 + - 无更新
  46 + 2. 数据库表同步
  47 + - rule_config、
  48 + - rule_channel_config、
  49 + - land_business_type_config
  50 + 3. 打开二维码正式环境获取接口,申请接口\取消申请接口\异常处理接口
  51 + 4. 打包编译
  52 + 5. 上传正式服务器
  53 + 7. 备份正在运行版本
  54 + 8. 更改start.sh脚本中的 执行jar名称.
  55 + 9. 关闭运行的验放端
  56 + 10. 执行start.sh脚本
  57 + 11. 通道验放规则同步.
  58 + 12. redis有没有相关配置更改?
  59 +
  60 + 13. 更新完成
  61 +
  62 +#### 前端:
  63 + 1. 备份前端文件 压缩成.zip 带日期
  64 + 2. 上传新版本前端,解压部署前端
  65 + 3. 更改version.json
  66 + 4. 前端更新完毕.
  67 + 5. 通知用户刷新前端
  68 +
  69 +### 业务配置
  70 + 1. 系统权限配置
  71 + - 配置验放管理权限
  72 + - 配置规则管理权限
  73 + - 配置业务类型管理权限
  74 + - 重新配置验放端规则信息到redis
  75 +