作者 朱兆平

验放逻辑及验放规则继续完善

... ... @@ -27,8 +27,8 @@ class BaseFormCacheCheck extends Script implements ChannelCheckScript {
Boolean check(ExecuteParams executeParams) {
try{
// 获取product对象
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
LandBusinessTypeList chanelFormInfo = (LandBusinessTypeList) executeParams.get("chanelFormInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList chanelFormInfo = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
// 调用方法
ApplicationContext context = getContext();
... ...
... ... @@ -29,7 +29,7 @@ class BaseVeCheck extends Script implements ChannelCheckScript {
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandRoadVe ve = (LandRoadVe) executeParams.get("LandRoadVe");
//3.车辆备案验证
... ...
... ... @@ -11,6 +11,7 @@ import org.springframework.context.ApplicationContext
/**
* 基本验放
* 过卡信息验放
* todo:重复过卡验放
*/
class BaseX21GatherInfoCheck extends Script implements ChannelCheckScript {
... ... @@ -22,7 +23,7 @@ class BaseX21GatherInfoCheck extends Script implements ChannelCheckScript {
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
// 获取容器中的bean
// 调用方法
... ...
... ... @@ -31,7 +31,7 @@ class BillAllocateCheck extends Script implements ChannelCheckScript {
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
... ...
... ... @@ -28,7 +28,7 @@ class BillReleaseCheck extends Script implements ChannelCheckScript {
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");
... ...
... ... @@ -32,8 +32,8 @@ class G2Notice extends Script implements ChannelCheckScript {
* 1. 从缓存获取车辆进出场申请信息,有流转信息再进行通道对碰.
* 无流转信息则说明缓存失效或者二维码不对.
*/
GatherInfo info = (GatherInfo) executeParams.get("gatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("chanelFormInfo");
GatherInfo info = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
if (landBusinessTypeList!=null){
rightChnelCheck(landBusinessTypeList.getBusinesstype(),info);
}else {
... ...
... ... @@ -38,7 +38,7 @@ class LockNoticeCheck extends Script implements ChannelCheckScript {
* 离场标识
*/
String OUT_TYPE="E";
GatherInfo info = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo info = (GatherInfo) executeParams.get("GatherInfo");
// 获取容器中的bean
// 调用方法
ApplicationContext context = getContext();
... ...
... ... @@ -25,7 +25,7 @@ class WeightCheckAllocateOrDispatch extends Script implements ChannelCheckScript
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
Double selfWt = (Double) executeParams.get("selfWt");
Double goodsWt = (Double) executeParams.get("goodsWt");
... ...
... ... @@ -27,7 +27,7 @@ class WeightCheckEmpty extends Script implements ChannelCheckScript {
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
Double selfWt = (Double) executeParams.get("selfWt");
Double goodsWt = (Double) executeParams.get("goodsWt");
... ...
... ... @@ -27,7 +27,7 @@ class WeightCheckExportUnload extends Script implements ChannelCheckScript {
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
Double selfWt = (Double) executeParams.get("selfWt");
Double goodsWt = (Double) executeParams.get("goodsWt");
... ...
... ... @@ -27,7 +27,7 @@ class WeightCheckImportDlv extends Script implements ChannelCheckScript {
*/
Boolean check(ExecuteParams executeParams) {
try{
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
Double selfWt = (Double) executeParams.get("selfWt");
Double goodsWt = (Double) executeParams.get("goodsWt");
... ...
... ... @@ -25,11 +25,11 @@ class X21FormReleaseCheck extends Script {
* 传入从redis读取的申请表体实体,验证
* 进行通道比对
*/
void releaseCheck(ExecuteParams executeParams) {
void check(ExecuteParams executeParams) {
try{
// 获取product对象
GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
List<LandBusinessTypeList> formList = (List<LandBusinessTypeList>) executeParams.get("formList");
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
List<LandBusinessTypeList> formList = (List<LandBusinessTypeList>) executeParams.get("FormList");
// 调用方法
ApplicationContext context = getContext();
... ...
package com.sy.groovy
import com.sy.model.GatherInfo
import com.sy.model.LandBusinessTypeList
import com.sy.service.impl.GatherInfoHandle
import org.basis.enhance.groovy.entity.ExecuteParams
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import java.util.stream.Collectors
/**
* 流转申请-核销
* 1. 单进单出即核销判定
* 2. 根据申请单中的通道类型及通道信息判定没有未走完的通道类型,可以核销.比如 申请单证的通道只有进通道,车可以走进一,进二,进二入场,走完进一,即可核销.(一线进)
*/
class X21FormSingileReleaseCheck extends Script {
private final Logger logger = LoggerFactory.getLogger(getClass());
/**x21指令判定
* 传入gatherInfo
*
* 传入从redis读取的申请表体实体,验证
* 进行通道比对
*/
void check(ExecuteParams executeParams) {
try{
// 获取product对象
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
List<LandBusinessTypeList> formList = (List<LandBusinessTypeList>) executeParams.get("FormList");
// 调用方法
ApplicationContext context = getContext();
// 获取容器中的bean
GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
List<LandBusinessTypeList> temp = new ArrayList<>(formList);
//二维码已出区的记录
List<LandBusinessTypeList> havenCrossList = gatherInfoHandle.listService.selectByBarcodeWithE(gatherInfo.getBarcode());
if (formList == null && formList.isEmpty() ){
logger.error("[FORM-RELEASE-CHECK]-车辆进出场对应申请缓存数据为空:{}",gatherInfo.getBarcode());
return;
}
if (havenCrossList.isEmpty()){
logger.error("[FORM-RELEASE-CHECK]{}:车辆无离场数据,不核销",gatherInfo.getVename());
return;
}
logger.info("[FORM-RELEASE-CHECK]:已过卡数量:[{}]",havenCrossList.size())
//申请核销判定,已出区的记录与流转申请数据核碰.如果流转申请列表核碰完,还剩下的需要出区的场站则不核销.
for (LandBusinessTypeList businessTypeList : havenCrossList) {
List<LandBusinessTypeList> r = formList.stream().filter({item ->
//判断还有没有没有出区的场站,还有没有出区的场站就不核销
logger.debug("[releaseFormCheck-Stream-loop]-缓存与已出核碰,缓存元素场站:[{}],已出记录场站:[{}]",item.getEndstation(),businessTypeList.getEndstation());
//解决缓存那里存储有不一样的把人错的的有问题的点,二维码不一致也把缓存删除
if (!item.getBarcode().equals(businessTypeList.getBarcode())){
return true;
}
if(item.getEndstation().equals(businessTypeList.getEndstation())) {
logger.info("[releaseFormCheck-Stream-loop]-缓存元素场站:[{}],已出记录场站:[{}]-核销判定对碰成功",item.getEndstation(),businessTypeList.getEndstation());
return true;
}else {
return false;
}
}).collect(Collectors.toList());
temp.removeAll(r);
}
logger.info("[FORM-RELEASE-CHECK]-核销判定结果:{}",temp.size());
if (temp.isEmpty()){
//todo:流转申请状态核销
logger.info("[进出场申请]-流转申请开始核销:"+gatherInfo.getVename());
//二维码核销
// gatherInfoHandle.releaseBarCode();
logger.info("[进出场申请]-流转申请已核销:"+gatherInfo.getVename());
}
}catch (Exception e){
e.printStackTrace();
logger.error("[FORM-RELEASE-ERROR]:",e);
}
}
@Override
Object run() {
return false;
}
// 获取spring容器
ApplicationContext getContext() {
// 获取spring IOC容器
ApplicationContext context = applicationContext;
return context;
}
}
... ...
package com.sy.mapper;
import com.sy.model.RuleChannelConfig;
import java.util.List;
public interface RuleChannelConfigDao {
int deleteByPrimaryKey(Integer configId);
int insert(RuleChannelConfig record);
int insertSelective(RuleChannelConfig record);
RuleChannelConfig selectByPrimaryKey(Integer configId);
/**
* 根据通道及申报信息查询相关验放规则
* @param record 查询参数包含通道号,业务类型,货物类型
* @return 验放规则列表
*/
List<RuleChannelConfig> selectByChannelAndBusiTypeAndGoodsType(RuleChannelConfig record);
int updateByPrimaryKeySelective(RuleChannelConfig record);
int updateByPrimaryKey(RuleChannelConfig record);
}
... ...
package com.sy.mapper;
import com.sy.model.RuleConfig;
public interface RuleConfigDao {
int deleteByPrimaryKey(Integer ruleId);
int insert(RuleConfig record);
int insertSelective(RuleConfig record);
RuleConfig selectByPrimaryKey(Integer ruleId);
int updateByPrimaryKeySelective(RuleConfig record);
int updateByPrimaryKey(RuleConfig record);
}
\ No newline at end of file
... ...
package com.sy.model;
/**
* 新舱单查询实体类
*/
public class NmmsPrepaidMasterSearch {
/**
* 主单号
* 格式为 804-31118371
*/
public String waybillno;
public int pageIndex;
public int pageSize;
public NmmsPrepaidMasterSearch(String waybillno, int pageIndex, int pageSize) {
this.waybillno = waybillno;
this.pageIndex = pageIndex;
this.pageSize = pageSize;
}
}
... ...
package com.sy.model;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* rule_channel_config
* @author
*/
@Data
public class RuleChannelConfig implements Serializable {
private Integer configId;
/**
* 通道号
*/
private String channelNum;
/**
* 业务类型
*/
private String businessType;
/**
* 货物类型
*/
private String goodsType;
/**
* 验放规则id
*/
private Integer ruleId;
/**
* 验放顺序
*/
private Byte configOrder;
/**
* 数据创建时间
*/
private Date creatTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 关联验放脚本配置类
*/
public RuleConfig ruleConfig;
private static final long serialVersionUID = 1L;
}
... ...
package com.sy.model;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* rule_config
* @author
*/
@Data
public class RuleConfig implements Serializable {
private Integer ruleId;
/**
* 规则名称
*/
private String ruleName;
/**
* 规则key,存redis的键名
*/
private String ruleKey;
/**
* 规则脚本key,存redis中的hash字典中的key名
*/
private String scriptKey;
/**
* 规则脚本内容
*/
private String ruleScriptContent;
/**
* 规则脚本入口方法名
*/
private String scriptMethodName;
/**
* 规则脚本入口方法返回类型
*/
private String scriptMethodReturn;
/**
* 规则描述
*/
private String ruleDes;
/**
* 规则状态,默认1启用,0弃用
*/
private Boolean ruleState;
/**
* 规则验证顺序
*/
private Byte ruleOrder;
/**
* 规则类型
*/
private String ruleType;
/**
* 数据创建时间
*/
private Date creatTime;
/**
* 更新时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
... ...
package com.sy.service;
import com.sy.model.GatherInfo;
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
import com.sy.model.LandBusinessTypeList;
import org.basis.enhance.groovy.entity.ExecuteParams;
import java.util.List;
/**
* 调用groovy 引擎进行验放处理接口
* @author mrz
* @date 2023-05-23
*/
public interface EnginCheckService {
/**
* 根据gatherInfo报文数据获取整体验放数据,并进行脚本验放
* @param gatherInfo 车辆过卡X21报文数据
* @return true 验放成功 可以放行,false 验放失败不可放行
*/
Boolean enginCheckByGatherInfo(GatherInfo gatherInfo,ExecuteParams executeParams);
/**
* 过卡信息参数生成
* @param gatherInfo 过卡信息
* @return 过卡校验相关数据 为map格式
*/
ExecuteParams makeParaByGagherInfo(GatherInfo gatherInfo);
/**
* 发送X22指令
* @param info 过卡信息
* @param check true 抬杆,false 不抬杆
* @param reason 原因
* @param executeParams 所有过卡所需数据
* @return 调试模式 直接返回true,生产模式按业务走
*/
void sendBw(GatherInfo info, boolean check, String reason, ExecuteParams executeParams);
/**
* 直接放行
*/
void pass(GatherInfo info,ExecuteParams executeParams);
/**
* 记录已进出区信息
*/
void record(GatherInfo info,ExecuteParams executeParams);
/**
* 放行日志记录
* @param info 过卡信息
* @param check 是否放行true放行,false不放行
* @param reason 原因
*/
void commandlog(GatherInfo info, boolean check, String reason,ExecuteParams executeParams);
}
... ...
... ... @@ -2,6 +2,7 @@ package com.sy.service;
import com.sy.model.Feign_Allocate_Search;
import com.sy.model.NmmsPrepaidMasterSearch;
import com.sy.service.impl.NmmsServiceHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
... ... @@ -21,5 +22,10 @@ public interface NmmsService {
@PostMapping(value = "/Allocate/querypage_inportallocate")
Map getAllocate(@RequestBody Feign_Allocate_Search feignAllocateSearch);
@ResponseBody
@PostMapping(value = "/Preallocation/QueryPage_Prepared")
Map getPrepaidMaster(@RequestBody NmmsPrepaidMasterSearch prepaidMaster);
}
... ...
package com.sy.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.sy.mapper.RuleChannelConfigDao;
import com.sy.model.*;
import com.sy.service.*;
import com.sy.socket.CommandClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.basis.enhance.groovy.constants.ExecutionStatus;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import static com.sy.service.impl.ResMessageServiceImpl.toStrArry;
/**
* 车辆过卡脚本引擎处理
*/
@Service
@Slf4j
public class EnginCheckServiceImpl implements EnginCheckService {
private static String PERMITTHOUGH = "直接放行";
@Autowired
private EngineExecutor engineExecutor;
@Autowired
private BusnesslistinfoService busnesslistinfoService;
@Autowired
private LandBusListService landBusListService;
/**
* 指令日志表
*/
@Autowired
private CommandLogService commandLogService;
@Autowired
private RedisService redisService;
@Autowired
private LandBusListService listService;
@Autowired
LandRoadVeService veService;
@Resource
RuleChannelConfigDao ruleChannelConfigDao;
@Value("${devdebug}")
private Boolean debug;
@Override
public Boolean enginCheckByGatherInfo(GatherInfo gatherInfo,ExecuteParams executeParams) {
//获取申请信息
LandBusinessTypeList chanelFormInfo = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
if (chanelFormInfo!=null){
//查询验放配置参数生成
RuleChannelConfig ruleChannelConfig = new RuleChannelConfig();
ruleChannelConfig.setBusinessType(chanelFormInfo.getBusinesstype());
ruleChannelConfig.setGoodsType(chanelFormInfo.getCocode());
ruleChannelConfig.setChannelNum(gatherInfo.getChnlno());
List<RuleChannelConfig> ruleChannelConfigs = ruleChannelConfigDao.selectByChannelAndBusiTypeAndGoodsType(ruleChannelConfig);
for (int i = 0; i < ruleChannelConfigs.size(); i++) {
// 执行脚本中指定的方法 changeProduct
EngineExecutorResult executorResult = engineExecutor.execute(
ruleChannelConfigs.get(i).ruleConfig.getScriptMethodName(), new ScriptQuery(ruleChannelConfigs.get(i).ruleConfig.getScriptKey()), executeParams);
log.info("验证脚本名称:{},验证KEY-NAME:{}", ruleChannelConfigs.get(i).ruleConfig.getRuleName(),ruleChannelConfigs.get(i).ruleConfig.getScriptKey());
log.info("使用groovy脚本来验证过卡判定放行结果=========>>>>>>>>>>>执行结果:{}", executorResult);
if (executorResult.getExecutionStatus().equals(ExecutionStatus.SUCCESS)){
if (executorResult.getContext() instanceof Boolean){
Boolean execResult = (Boolean) executorResult.getContext();
if (execResult) {
log.info("验证脚本名称:{},验证KEY-NAME:{}-[验放成功]",ruleChannelConfigs.get(i).ruleConfig.getRuleName(),ruleChannelConfigs.get(i).ruleConfig.getScriptKey());
}else {
log.info("验放失败");
return false;
}
}
//核销判定
if (executorResult.getContext()==null && "void".equals(ruleChannelConfigs.get(i).ruleConfig.getScriptMethodReturn())){
log.info("核销判定");
}
}else {
log.error("验证脚本名称:{},验证KEY-NAME:{}-[验放失败]",ruleChannelConfigs.get(i).ruleConfig.getRuleName(),ruleChannelConfigs.get(i).ruleConfig.getScriptKey());
return false;
}
}
return true;
}
log.error("未找到流转申请信息");
return false;
}
@Override
public ExecuteParams makeParaByGagherInfo(GatherInfo gatherInfo){
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", Double.parseDouble(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;
}
/**
* 发送X22指令
* @param info 过卡信息
* @param check true 抬杆,false 不抬杆
* @param reason 原因
* 调试模式 直接返回true,生产模式按业务走
*/
@Override
public void sendBw(GatherInfo info, boolean check, String reason,ExecuteParams executeParams) {
//调试模式 直接返回true
if (debug){
if (check) {
record(info,executeParams);
//总进出车次计数
redisService.incr("kako-total",1);
}
commandlog(info,check,reason,executeParams);
}
log.info(String.format("开始发送指令:车牌%s,场站%s,通道%s,重量%s",info.getVename(),info.getAreaid(),info.getChnlno(),info.getGrosswt()));
boolean flag = false;
if (check) {
CommandClient.Client(info, PERMITTHOUGH);
log.info("=============>>>>>>>>放行报文发送成功<<<<<<<<<==============");
flag = true;
record(info,executeParams);
//总进出车次计数
redisService.incr("kako-total",1);
} else {
CommandClient.Client(info, reason);
log.info("=============>>>>>>>>重量异常报文发送成功<<<<<<<<<==============");
}
commandlog(info,check,reason,executeParams);
}
/**
* 直接放行
*/
@Override
public void pass(GatherInfo info, ExecuteParams executeParams){
sendBw(info,true,PERMITTHOUGH,executeParams);
}
/**
* 记录进出区信息
*/
@Override
public void record(GatherInfo info, ExecuteParams executeParams){
LandBusinessTypeList landBusinessTypeList = executeParams.getValue("ChanelFormInfo");
Double goodsWt = executeParams.getValue("goodsWt");
Double selfWt = executeParams.getValue("selfWt");
Double diffVal = executeParams.getValue("diffVal");
if ("I".equals(info.getIetype())){
landBusinessTypeList.setAislewt(info.getGrosswt().doubleValue());
landBusinessTypeList.setUpdateDate(new Date());
landBusinessTypeList.setRemark(String.format("%.1f", goodsWt));
//车辆备案重量
landBusinessTypeList.setRemark2(String.valueOf(selfWt));
landBusinessTypeList.setContrastflag("已进站");
}else {
landBusinessTypeList.setAislewt(info.getGrosswt().doubleValue());
landBusinessTypeList.setUpdateDate(new Date());
//装载货物总重量
landBusinessTypeList.setRemark(String.format("%.1f", goodsWt));
//进出差值
landBusinessTypeList.setRemark1(String.format("%.1f", diffVal));
landBusinessTypeList.setRemark2(String.valueOf(selfWt));
landBusinessTypeList.setContrastflag("已出站");
}
//todo:判定放行后,插入数据库,出入区记录
landBusinessTypeList.setId(UUID.randomUUID().toString());
landBusinessTypeList.setIsvalid("1");
//todo:这里SEQN也要入库
listService.saveList(landBusinessTypeList);
}
/**
* 放行日志记录
* @param info
* @param check
* @param reason
*/
@Override
public void commandlog(GatherInfo info, boolean check, String reason,ExecuteParams executeParams){
LandBusinessTypeList land = executeParams.getValue("ChanelFormInfo");
Double selfWt = executeParams.getValue("selfWt");
Double inWt = executeParams.getValue("inWt");
Double goodsWt = executeParams.getValue("goodsWt");
Double diffVal = executeParams.getValue("diffVal");
List<LAND_BUSINEESTYPE_LIST_INFO> listInfos = executeParams.getValue("ChanelFormBillLists");
String flag="",type="";
commandLog command=new commandLog();
command.setId(UUID.randomUUID().toString());
command.setBarcode(info.getBarcode());
if(land!=null){
command.setBarcode(land.getBarcode());
command.setBusnessType(land.getBusinesstype());
}
command.setAreaId(info.getAreaid());
command.setChnlNo(info.getChnlno());
if (check){
flag = "00";
} else{
flag = "11";
}
if("I".equals(info.getIetype())){
type="000000200000000000";
}else{
type="000000100000000000";
}
command.setReasonCode(flag+type);
command.setReasonText(reason);
command.setVeName(info.getVename());
command.setVeWeight(selfWt);
command.setIeType(info.getIetype());
command.setExitGrossWeight(info.getGrosswt().doubleValue());
command.setInGrossWeight(inWt);
command.setGoodsWeight(goodsWt);
command.setActualGoodsWeight(diffVal);
if(listInfos !=null && listInfos.size()>0){
command.setMasterList(Arrays.toString(toStrArry(listInfos)));
}
commandLogService.insert(command);
}
}
... ...
package com.sy.service.impl;
import com.sy.model.Feign_Allocate_Search;
import com.sy.model.NmmsPrepaidMasterSearch;
import com.sy.service.NmmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -18,4 +19,10 @@ public class NmmsServiceHystrix implements NmmsService {
logger.error("feign查询分拨申请数据失败,{}",feignAllocateSearch.waybill);
return new HashMap<>();
}
@Override
public Map<String, Object> getPrepaidMaster(NmmsPrepaidMasterSearch nmmsPrepaidMasterSearch) {
logger.error("feign查询预配数据失败,{}",nmmsPrepaidMasterSearch.waybillno);
return new HashMap<>();
}
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sy.mapper.RuleChannelConfigDao">
<resultMap id="BaseResultMap" type="com.sy.model.RuleChannelConfig">
<id column="config_id" jdbcType="INTEGER" property="configId" />
<result column="channel_num" jdbcType="VARCHAR" property="channelNum" />
<result column="business_type" jdbcType="VARCHAR" property="businessType" />
<result column="goods_type" jdbcType="VARCHAR" property="goodsType" />
<result column="rule_id" jdbcType="INTEGER" property="ruleId" />
<result column="config_order" jdbcType="TINYINT" property="configOrder" />
<result column="creat_time" jdbcType="TIMESTAMP" property="creatTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap id="WithRuleConf" extends="BaseResultMap" type="com.sy.model.RuleChannelConfig">
<association property="ruleConfig" javaType="com.sy.model.RuleConfig">
<result column="script_key" jdbcType="VARCHAR" property="scriptKey" />
<result column="script_method_name" jdbcType="VARCHAR" property="scriptMethodName" />
<result column="script_method_return" jdbcType="VARCHAR" property="scriptMethodReturn" />
<result column="rule_name" jdbcType="VARCHAR" property="ruleName" />
</association>
</resultMap>
<sql id="Base_Column_List">
config_id, channel_num, business_type, goods_type, rule_id, config_order, creat_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from rule_channel_config
where config_id = #{configId,jdbcType=INTEGER}
</select>
<select id="selectByChannelAndBusiTypeAndGoodsType" parameterType="com.sy.model.RuleChannelConfig" resultMap="WithRuleConf">
SELECT
conf.channel_num,
conf.business_type,
conf.goods_type,
conf.config_order,
conf.rule_id,
rule.script_key,
rule.script_method_name,
rule.script_method_return,
rule.rule_name
FROM
(
SELECT
channel_num,
business_type,
goods_type,
config_order,
rule_id
FROM
rule_channel_config
WHERE
channel_num = #{channelNum,jdbcType=VARCHAR}
AND business_type = #{businessType,jdbcType=VARCHAR}
AND goods_type = #{goodsType,jdbcType=VARCHAR}
ORDER BY config_order
) conf
LEFT JOIN
rule_config rule
ON
conf.rule_id = rule.rule_id
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from rule_channel_config
where config_id = #{configId,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="config_id" keyProperty="configId" parameterType="com.sy.model.RuleChannelConfig" useGeneratedKeys="true">
insert into rule_channel_config (channel_num, business_type, goods_type,
rule_id, config_order, creat_time,
update_time)
values (#{channelNum,jdbcType=VARCHAR}, #{businessType,jdbcType=VARCHAR}, #{goodsType,jdbcType=VARCHAR},
#{ruleId,jdbcType=INTEGER}, #{configOrder,jdbcType=TINYINT}, #{creatTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" keyColumn="config_id" keyProperty="configId" parameterType="com.sy.model.RuleChannelConfig" useGeneratedKeys="true">
insert into rule_channel_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="channelNum != null">
channel_num,
</if>
<if test="businessType != null">
business_type,
</if>
<if test="goodsType != null">
goods_type,
</if>
<if test="ruleId != null">
rule_id,
</if>
<if test="configOrder != null">
config_order,
</if>
<if test="creatTime != null">
creat_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="channelNum != null">
#{channelNum,jdbcType=VARCHAR},
</if>
<if test="businessType != null">
#{businessType,jdbcType=VARCHAR},
</if>
<if test="goodsType != null">
#{goodsType,jdbcType=VARCHAR},
</if>
<if test="ruleId != null">
#{ruleId,jdbcType=INTEGER},
</if>
<if test="configOrder != null">
#{configOrder,jdbcType=TINYINT},
</if>
<if test="creatTime != null">
#{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sy.model.RuleChannelConfig">
update rule_channel_config
<set>
<if test="channelNum != null">
channel_num = #{channelNum,jdbcType=VARCHAR},
</if>
<if test="businessType != null">
business_type = #{businessType,jdbcType=VARCHAR},
</if>
<if test="goodsType != null">
goods_type = #{goodsType,jdbcType=VARCHAR},
</if>
<if test="ruleId != null">
rule_id = #{ruleId,jdbcType=INTEGER},
</if>
<if test="configOrder != null">
config_order = #{configOrder,jdbcType=TINYINT},
</if>
<if test="creatTime != null">
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where config_id = #{configId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sy.model.RuleChannelConfig">
update rule_channel_config
set channel_num = #{channelNum,jdbcType=VARCHAR},
business_type = #{businessType,jdbcType=VARCHAR},
goods_type = #{goodsType,jdbcType=VARCHAR},
rule_id = #{ruleId,jdbcType=INTEGER},
config_order = #{configOrder,jdbcType=TINYINT},
creat_time = #{creatTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where config_id = #{configId,jdbcType=INTEGER}
</update>
</mapper>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sy.mapper.RuleConfigDao">
<resultMap id="BaseResultMap" type="com.sy.model.RuleConfig">
<id column="rule_id" jdbcType="INTEGER" property="ruleId" />
<result column="rule_name" jdbcType="VARCHAR" property="ruleName" />
<result column="rule_key" jdbcType="VARCHAR" property="ruleKey" />
<result column="script_key" jdbcType="VARCHAR" property="scriptKey" />
<result column="rule_script_content" jdbcType="VARCHAR" property="ruleScriptContent" />
<result column="script_method_name" jdbcType="VARCHAR" property="scriptMethodName" />
<result column="script_method_return" jdbcType="VARCHAR" property="scriptMethodReturn" />
<result column="rule_des" jdbcType="VARCHAR" property="ruleDes" />
<result column="rule_state" jdbcType="BOOLEAN" property="ruleState" />
<result column="rule_order" jdbcType="TINYINT" property="ruleOrder" />
<result column="rule_type" jdbcType="VARCHAR" property="ruleType" />
<result column="creat_time" jdbcType="TIMESTAMP" property="creatTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
rule_id, rule_name, rule_key, script_key, rule_script_content, script_method_name,
script_method_return, rule_des, rule_state, rule_order, rule_type, creat_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from rule_config
where rule_id = #{ruleId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from rule_config
where rule_id = #{ruleId,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="rule_id" keyProperty="ruleId" parameterType="com.sy.model.RuleConfig" useGeneratedKeys="true">
insert into rule_config (rule_name, rule_key, script_key,
rule_script_content, script_method_name, script_method_return,
rule_des, rule_state, rule_order,
rule_type, creat_time, update_time
)
values (#{ruleName,jdbcType=VARCHAR}, #{ruleKey,jdbcType=VARCHAR}, #{scriptKey,jdbcType=VARCHAR},
#{ruleScriptContent,jdbcType=VARCHAR}, #{scriptMethodName,jdbcType=VARCHAR}, #{scriptMethodReturn,jdbcType=VARCHAR},
#{ruleDes,jdbcType=VARCHAR}, #{ruleState,jdbcType=BOOLEAN}, #{ruleOrder,jdbcType=TINYINT},
#{ruleType,jdbcType=VARCHAR}, #{creatTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" keyColumn="rule_id" keyProperty="ruleId" parameterType="com.sy.model.RuleConfig" useGeneratedKeys="true">
insert into rule_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ruleName != null">
rule_name,
</if>
<if test="ruleKey != null">
rule_key,
</if>
<if test="scriptKey != null">
script_key,
</if>
<if test="ruleScriptContent != null">
rule_script_content,
</if>
<if test="scriptMethodName != null">
script_method_name,
</if>
<if test="scriptMethodReturn != null">
script_method_return,
</if>
<if test="ruleDes != null">
rule_des,
</if>
<if test="ruleState != null">
rule_state,
</if>
<if test="ruleOrder != null">
rule_order,
</if>
<if test="ruleType != null">
rule_type,
</if>
<if test="creatTime != null">
creat_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ruleName != null">
#{ruleName,jdbcType=VARCHAR},
</if>
<if test="ruleKey != null">
#{ruleKey,jdbcType=VARCHAR},
</if>
<if test="scriptKey != null">
#{scriptKey,jdbcType=VARCHAR},
</if>
<if test="ruleScriptContent != null">
#{ruleScriptContent,jdbcType=VARCHAR},
</if>
<if test="scriptMethodName != null">
#{scriptMethodName,jdbcType=VARCHAR},
</if>
<if test="scriptMethodReturn != null">
#{scriptMethodReturn,jdbcType=VARCHAR},
</if>
<if test="ruleDes != null">
#{ruleDes,jdbcType=VARCHAR},
</if>
<if test="ruleState != null">
#{ruleState,jdbcType=BOOLEAN},
</if>
<if test="ruleOrder != null">
#{ruleOrder,jdbcType=TINYINT},
</if>
<if test="ruleType != null">
#{ruleType,jdbcType=VARCHAR},
</if>
<if test="creatTime != null">
#{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sy.model.RuleConfig">
update rule_config
<set>
<if test="ruleName != null">
rule_name = #{ruleName,jdbcType=VARCHAR},
</if>
<if test="ruleKey != null">
rule_key = #{ruleKey,jdbcType=VARCHAR},
</if>
<if test="scriptKey != null">
script_key = #{scriptKey,jdbcType=VARCHAR},
</if>
<if test="ruleScriptContent != null">
rule_script_content = #{ruleScriptContent,jdbcType=VARCHAR},
</if>
<if test="scriptMethodName != null">
script_method_name = #{scriptMethodName,jdbcType=VARCHAR},
</if>
<if test="scriptMethodReturn != null">
script_method_return = #{scriptMethodReturn,jdbcType=VARCHAR},
</if>
<if test="ruleDes != null">
rule_des = #{ruleDes,jdbcType=VARCHAR},
</if>
<if test="ruleState != null">
rule_state = #{ruleState,jdbcType=BOOLEAN},
</if>
<if test="ruleOrder != null">
rule_order = #{ruleOrder,jdbcType=TINYINT},
</if>
<if test="ruleType != null">
rule_type = #{ruleType,jdbcType=VARCHAR},
</if>
<if test="creatTime != null">
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where rule_id = #{ruleId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sy.model.RuleConfig">
update rule_config
set rule_name = #{ruleName,jdbcType=VARCHAR},
rule_key = #{ruleKey,jdbcType=VARCHAR},
script_key = #{scriptKey,jdbcType=VARCHAR},
rule_script_content = #{ruleScriptContent,jdbcType=VARCHAR},
script_method_name = #{scriptMethodName,jdbcType=VARCHAR},
script_method_return = #{scriptMethodReturn,jdbcType=VARCHAR},
rule_des = #{ruleDes,jdbcType=VARCHAR},
rule_state = #{ruleState,jdbcType=BOOLEAN},
rule_order = #{ruleOrder,jdbcType=TINYINT},
rule_type = #{ruleType,jdbcType=VARCHAR},
creat_time = #{creatTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where rule_id = #{ruleId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -5,10 +5,7 @@ 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 com.sy.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.basis.enhance.groovy.entity.EngineExecutorResult;
... ... @@ -53,6 +50,9 @@ public class EnginTest {
@Autowired
LandRoadVeService veService;
@Autowired
EnginCheckService enginCheckService;
/**
... ... @@ -71,7 +71,7 @@ public class EnginTest {
ExecuteParams executeParams = new ExecuteParams();
//初始化
executeParams.put("gatherInfo", gatherInfo);
executeParams.put("formList", null);
executeParams.put("FormList", null);
executeParams.put("ChanelFormInfo", null);
executeParams.put("ChanelFormBillLists", null);
executeParams.put("LandRoadVe", null);
... ... @@ -95,7 +95,7 @@ public class EnginTest {
if (StringUtils.isNotEmpty(landBusinessJson)) {
//这个是申请单表体
List<LandBusinessTypeList> list = JSONArray.parseArray(landBusinessJson, LandBusinessTypeList.class);
executeParams.put("formList", list);
executeParams.put("FormList", list);
//通道对应申请信息
LandBusinessTypeList chanelFormInfo = landBusListService.getLandBusinessTypeListByGather(gatherInfo);
... ... @@ -198,4 +198,24 @@ public class EnginTest {
log.info("共插入{}条规则",i);
}
@Test
public void enginTest(){
GatherInfo gatherInfo = new GatherInfo();
gatherInfo.setAreaid("4604600000");
gatherInfo.setChnlno("4604600010");
gatherInfo.setBarcode("681-43e2-925c-7b1e1054fbef");
gatherInfo.setGrosswt(new BigDecimal("6000"));
gatherInfo.setSeqno("20220630184441000028");
gatherInfo.setIetype("I");
gatherInfo.setVename("豫A61CR7");
ExecuteParams executeParams = enginCheckService.makeParaByGagherInfo(gatherInfo);
Boolean check = enginCheckService.enginCheckByGatherInfo(gatherInfo,executeParams);
if (check){
log.info("脚本验放测试通过");
enginCheckService.pass(gatherInfo,executeParams);
}else {
log.error("脚本验放测试失败");
}
}
}
... ...
package com.sy.nmms;
import com.sy.model.Feign_Allocate_Search;
import com.sy.model.NmmsPrepaidMasterSearch;
import com.sy.service.NmmsService;
import lombok.extern.slf4j.Slf4j;
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 javax.validation.constraints.NotNull;
import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class NmmsTest {
@Autowired
NmmsService nmmsService;
void nmmsAllocate(@NotNull String waybill){
log.info("新舱单查询分拨申请数据开始");
Feign_Allocate_Search feignAllocateSearch = new Feign_Allocate_Search(waybill,0,10);
Map map = nmmsService.getAllocate(feignAllocateSearch);
log.info(""+map);
}
@Test
public void prepaid(){
log.info("新舱单查询预配主单数据开始");
NmmsPrepaidMasterSearch nmmsPrepaidMasterSearch = new NmmsPrepaidMasterSearch("994-67007802",0,100);
Map map = nmmsService.getPrepaidMaster(nmmsPrepaidMasterSearch);
log.info(""+map);
}
}
... ...