作者 朱兆平

1 配置文件增加金二配置节点

2 pom增加配置文件热更新模块
3 X21过卡信息金二判定,策略模式
4 X22放行信息金二判定
5 优化本地验放抬杆指令
正在显示 32 个修改的文件 包含 1359 行增加243 行删除
... ... @@ -68,6 +68,11 @@ feign.httpclient.enabled=true
feign.hystrix.enabled=true
# 请求连接超时时间(毫秒)
feign.httpclient.connection-timeout=3000
# 这个是刷新接口
#curl -X POST http://localhost:8080/actuator/refresh
management.endpoints.web.exposure.include=refresh
#码头接口通知地址,注意尾部带/符号
wharf.interface.host=http://10.50.3.66:1983/
#新舱单运单查询数据接口,注意尾部带/符号
... ... @@ -75,3 +80,6 @@ nmms.interface.host=http://10.50.3.82:8081/
#新舱单网站内网接口,注意尾部带/符号
nmms.site.host=http://10.50.3.61:90
custom.receptDirectory= bw/read/
devdebug=true
g2.switch=true
... ...
... ... @@ -5,11 +5,11 @@
<groupId>com.sy</groupId>
<artifactId>analysis_imf</artifactId>
<version>2.12-BH-SNAPSHOT</version>
<version>3.0-BH-SNAPSHOT</version>
<packaging>jar</packaging>
<name>analysis_imf</name>
<description>Demo project for Spring Boot</description>
<description>北货集成金二抬杆指令判定</description>
<parent>
<groupId>org.springframework.boot</groupId>
... ... @@ -27,6 +27,17 @@
<dependencies>
<!-- 配置文件热加载-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
... ...
... ... @@ -5,11 +5,11 @@ import com.sy.logic.LiftBar;
import com.sy.logic.LogicOperation;
import com.sy.model.*;
import com.sy.service.*;
import com.sy.service.impl.GatherInfoServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
... ... @@ -31,8 +31,9 @@ public class AnalysisRoute implements Runnable{
@Autowired
private CLRService clrService;
@Qualifier("GatherInfoService")
@Autowired
private GatherInfoServiceImpl infoService;
private GatherInfoService infoService;
@Autowired
private CommandInfoService commandService;
... ... @@ -94,7 +95,7 @@ public class AnalysisRoute implements Runnable{
String stype = message.getMeta().getSmType();
if (stype.equals("CARM")) {
if(message.getComInfo() !=null){
commandInfo info = commandInfoAnalysis.toJavaBean(message);
CommandInfoX22 info = commandInfoAnalysis.toJavaBean(message);
route.commandService.save(info);
}else{
//处理车辆过磅数据,结合申请数据,判定是否抬杆
... ...
... ... @@ -3,13 +3,13 @@ package com.sy.bwAnalysis;
import com.sy.bwAssist.commandInfo.CommandInfo;
import com.sy.bwAssist.Message;
import com.sy.bwAssist.Meta;
import com.sy.model.commandInfo;
import com.sy.model.CommandInfoX22;
public class CommandInfoAnalysis {
public commandInfo toJavaBean(Message msg) {
commandInfo bean = new commandInfo();
public CommandInfoX22 toJavaBean(Message msg) {
CommandInfoX22 bean = new CommandInfoX22();
CommandInfo info = msg.getComInfo();
Meta meta = msg.getMeta();
bean.setSender(meta.getSender());
... ...
package com.sy.bwAnalysis;
import com.sy.bwAssist.Message;
import com.sy.model.GatherInfo;
import com.sy.model.commandInfo;
import org.apache.commons.lang.NullArgumentException;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
/**
* 车辆过卡报文处理器
* @author mrz
*/
@Component
public class GatherInfoHandle implements Runnable{
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
/**
* 1). 非空验证
*/
if (StringUtils.isNotEmpty(message)){
this.message = message;
}else {
throw new NullArgumentException("报文内容为空");
}
}
@Override
public void run() {
/**
* 一. 报文处理
*/
stypConfirmAndRoute();
}
/**
* 1). 通过将xml转实体类进行验证,
* 同时验证报文的合法性,
* 转换失败会throw 异常出来
*/
private Message xmlTransToBean(){
message = message.replace("Msg","MSG");
MessageAnalysis analysis = new MessageAnalysis();
return analysis.readTicketsXml(message);
}
/**
* XML报文类型判断
* 通过META节点的STYP节点判定
*/
private void stypConfirmAndRoute(){
Message messageBean = xmlTransToBean();
String stype = messageBean.getMeta().getSmType();
if ("CARM".equals(stype)) {
if(messageBean.getComInfo() !=null){
CommandInfoAnalysis commandInfoAnalysis = new CommandInfoAnalysis();
commandInfo info = commandInfoAnalysis.toJavaBean(messageBean);
/**
* x22 commandInfo抬杆指令报文的处理
*/
}else{
/**
* x21 gatherInfo通道采集报文的处理
*/
GatherInfoAnalysis gatherInfoAnalysis = new GatherInfoAnalysis();
GatherInfo info = gatherInfoAnalysis.toJavaBean(messageBean);
}
}
}
}
... ... @@ -147,6 +147,7 @@ public class LiftBar {
return result;
}
if("Y".equals(ve.getVeState())){
logger.info(BLACKLIST+vaName);
sendBw(info,false,BLACKLIST + vaName,new LandBusinessTypeList(),listinfos);
return result;
}
... ... @@ -381,7 +382,11 @@ public class LiftBar {
logic.listService.updateById(list);
//进出场申请业务表对应场站的卡口失效
logic.listService.updateisvalid(list.getTrailerFrameNo(),list.getBarcode(),list.getEndstation(),list.getTurnoverflag());
if("I".equals(info.getIetype())){
logic.listService.updateisvalid(list.getTrailerFrameNo(),list.getBarcode(),list.getEndstation(),list.getTurnoverflag());
}else{
logic.listService.updateisvalid(list.getTrailerFrameNo(),list.getBarcode(),list.getEndstation(),null);
}
//判断是否为最后一个场站,若是最后个场站申请为出,二维码失效
int count=logic.listService.selectlaststation(list.getTrailerFrameNo(),list.getBarcode());
... ... @@ -461,7 +466,7 @@ public class LiftBar {
flag = true;
} else {
CommandClient.Client(info, reason);
logger.info("=============>>>>>>>>重量异常报文发送成功<<<<<<<<<==============");
logger.info("=============>>>>>>>>"+reason+"<<<<<<<<<==============");
}
commandlog(info,check,reason,land,list_infos);
return flag;
... ... @@ -497,7 +502,7 @@ public class LiftBar {
command.setInGrossWeight(inWt);
command.setGoodsWeight(goodsWt);
command.setActualGoodsWeight(diffVal);
if(list_infos.size()>0){
if(list_infos !=null && list_infos.size()>0){
command.setMasterList(Arrays.toString(toStrArry(list_infos)));
}
logic.commandLogService.insert(command);
... ...
package com.sy.mapper;
import com.sy.model.LandRouterConfig;
import java.util.List;
public interface LandRouterConfigDao {
int deleteByPrimaryKey(Integer id);
int insert(LandRouterConfig record);
int insertSelective(LandRouterConfig record);
LandRouterConfig selectByPrimaryKey(Integer id);
List<LandRouterConfig> selectByGatherInfo(LandRouterConfig record);
List<LandRouterConfig> selectByBussType(String businessType);
int updateByPrimaryKeySelective(LandRouterConfig record);
int updateByPrimaryKey(LandRouterConfig record);
}
... ...
package com.sy.mapper;
import com.sy.model.commandInfo;
import com.sy.model.CommandInfoX22;
import org.springframework.stereotype.Component;
@Component
public interface commandInfoMapper {
int deleteByPrimaryKey(String seqNo);
int insert(commandInfo record);
int insert(CommandInfoX22 record);
int insertSelective(commandInfo record);
int insertSelective(CommandInfoX22 record);
commandInfo selectByPrimaryKey(String seqNo);
CommandInfoX22 selectByPrimaryKey(String seqNo);
int updateByPrimaryKeySelective(commandInfo record);
int updateByPrimaryKeySelective(CommandInfoX22 record);
int updateByPrimaryKey(commandInfo record);
}
\ No newline at end of file
int updateByPrimaryKey(CommandInfoX22 record);
}
... ...
... ... @@ -2,7 +2,7 @@ package com.sy.model;
import java.util.Date;
public class commandInfo {
public class CommandInfoX22 {
private String seqNo;
private String sender;
... ... @@ -192,4 +192,4 @@ public class commandInfo {
public void setOpHint(String opHint) {
this.opHint = opHint == null ? null : opHint.trim();
}
}
\ No newline at end of file
}
... ...
package com.sy.model;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* land_router_config
* @author
*/
@Data
public class LandRouterConfig implements Serializable {
private Integer id;
/**
* 场站编号
*/
private String areaId;
/**
* 场站名称
*/
private String areaName;
/**
* 通道编号
*/
private String chanelId;
/**
* 通道名称
*/
private String chanelName;
/**
* 进出口类型
*/
private String chanelType;
/**
* 流转申请表头业务类型
*/
private String businessType;
/**
* 对应金二业务类型码
*/
private String g2BusinessType;
/**
* 车辆信息识别方式;IC;VN;VE;BC;BC>VN>VE>IC
*/
private String identifyType;
/**
* 路由目的处理方;金二还是本地;G2;LOC;
*/
private String gatherReceiver;
private Date createTime;
/**
* 默认Y生效,N失效
*/
private String status;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
... ...
package com.sy.service;
import com.sy.model.commandInfo;
import com.sy.model.CommandInfoX22;
public interface CommandInfoService {
int save(commandInfo info);
int save(CommandInfoX22 info);
void handel(CommandInfoX22 info);
}
... ...
package com.sy.service;
import com.sy.model.GatherInfo;
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
import com.sy.model.LandBusinessTypeList;
import com.sy.model.commandLog;
import java.util.List;
public interface CommandLogService {
int insert(commandLog command);
/**
* 根据进出场信息写入日志
* @param info 过卡信息
* @param check 过卡状态
* @param reason 抬杆指令内容
* @param land 流转申请信息
* @param listInfos 流转单列表
* @param selfWt 车辆备案重量
* @param inWt 车辆入场重量
* @param goodsWt 车辆装载货物重量
* @param diffVal 进出场差值
*/
void commandlog(GatherInfo info, boolean check, String reason, LandBusinessTypeList land, List<LAND_BUSINEESTYPE_LIST_INFO> listInfos,
Double selfWt,Double inWt,Double goodsWt,Double diffVal
);
}
... ...
package com.sy.service;
import com.sy.model.GatherInfo;
import com.sy.model.LandBusinessTypeList;
public interface GatherInfoService {
... ... @@ -10,4 +11,6 @@ public interface GatherInfoService {
* 根据过卡进行抬杆指令处理
*/
void handel(GatherInfo info);
}
... ...
package com.sy.service;
import com.sy.model.GatherInfo;
import com.sy.model.LandBusinessTypeList;
import java.util.List;
... ... @@ -38,4 +39,10 @@ public interface LandBusListService {
//查询出场申请为最后一个
int selectlaststation(String frameNo, String barcode);
/**
* 根据gatherInfo获取对应的流转申请
* @return 对应通道的流转申请信息
*/
LandBusinessTypeList getLandBusinessTypeListByGather(GatherInfo info);
}
... ...
... ... @@ -19,5 +19,12 @@ public interface RedisService {
boolean set(String key,String value);
/**
*
* @param key key
* @param value 值
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
* @return
*/
boolean set(String key,String value,long time);
}
... ...
... ... @@ -6,12 +6,15 @@ import com.sy.service.BusnesslistinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class BusnesslistinfoImpl implements BusnesslistinfoService {
@Autowired
@Resource
LAND_BUSINEESTYPE_LIST_INFOMapper list_infoMapper;
@Override
public List<LAND_BUSINEESTYPE_LIST_INFO> selectarrvie(String applicationformid) {
return list_infoMapper.selectarrive(applicationformid);
... ...
... ... @@ -2,7 +2,7 @@ package com.sy.service.impl;
import com.sy.mapper.commandInfoMapper;
import com.sy.model.commandInfo;
import com.sy.model.CommandInfoX22;
import com.sy.service.CommandInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -14,7 +14,7 @@ public class CommandInfoImpl implements CommandInfoService {
private commandInfoMapper infoMapper;
@Override
public int save(commandInfo info) {
public int save(CommandInfoX22 info) {
int row = 0;
try {
row =infoMapper.insert(info);
... ... @@ -23,4 +23,9 @@ public class CommandInfoImpl implements CommandInfoService {
}
return row;
}
@Override
public void handel(CommandInfoX22 info) {
}
}
... ...
package com.sy.service.impl;
import com.sy.mapper.commandLogMapper;
import com.sy.model.GatherInfo;
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
import com.sy.model.LandBusinessTypeList;
import com.sy.model.commandLog;
import com.sy.service.CommandLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import static com.sy.service.impl.ResMessageServiceImpl.toStrArry;
@Service
public class CommandLogImpl implements CommandLogService {
@Autowired
@Resource
commandLogMapper mapper;
@Override
public int insert(commandLog command) {
return mapper.insertSelective(command);
}
@Override
public void commandlog(GatherInfo info, boolean check, String reason, LandBusinessTypeList land, List<LAND_BUSINEESTYPE_LIST_INFO> list_infos,
Double selfWt,Double inWt,Double goodsWt,Double diffVal
){
String flag="",type="";
commandLog command=new commandLog();
command.setId(UUID.randomUUID().toString());
command.setBarcode(info.getBarcode());
if(land!=null){
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(list_infos.size()>0){
command.setMasterList(Arrays.toString(toStrArry(list_infos)));
}
insert(command);
}
}
... ...
... ... @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sy.crossDomain.buildBarCode;
import com.sy.logic.LiftBar;
import com.sy.model.*;
import com.sy.service.*;
import com.sy.socket.CommandClient;
... ... @@ -13,8 +12,10 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.*;
... ... @@ -22,10 +23,11 @@ import java.util.stream.Collectors;
import static com.sy.service.impl.ResMessageServiceImpl.toStrArry;
@Service("GatherInfoHandle")
public class GatherInfoHandleImpl implements GatherInfoService {
@Component("GatherInfoHandle")
public class GatherInfoHandle implements GatherInfoService {
private static final Logger logger = LoggerFactory.getLogger(LiftBar.class);
private static final Logger logger = LoggerFactory.getLogger(GatherInfoHandle.class);
private static GatherInfoHandle gatherInfoHandle;
//逻辑判断后的返回信息定义
private static String PERMITTHOUGH = "直接放行";
... ... @@ -42,44 +44,48 @@ public class GatherInfoHandleImpl implements GatherInfoService {
private static String NOGrossWt = "过磅重量异常";
private static String BLACKLIST= "此车辆已被拉进黑名单,不允许出区";
@Autowired
FeignService feignService;
@Autowired
NmmsService nmmsService;
private NmmsService nmmsService;
/**
* 车辆信息备案表
*/
@Autowired
LandRoadVeService veService;
private LandRoadVeService veService;
@Autowired
RedisService redisService;
private RedisService redisService;
@Autowired
BusnesslistinfoService busnesslistinfoService;
@Value("${devdebug}")
private Boolean debug;
/**
* 进出场申请表
*/
@Autowired
LandBusListService listService;
private LandBusListService listService;
/**
* 重量校验算法
*/
@Autowired
WeightCheckHandleService weightCheckHandleService;
private WeightCheckHandleService weightCheckHandleService;
/**
* 查询运单放行表
*/
@Autowired
ResMessageService resMessageService;
private ResMessageService resMessageService;
/**
* 指令日志表
*/
@Autowired
CommandLogService commandLogService;
private CommandLogService commandLogService;
/**
* 车辆过卡信息
... ... @@ -129,6 +135,10 @@ public class GatherInfoHandleImpl implements GatherInfoService {
private double diffVal=0.0;
@PostConstruct
public void init() {
gatherInfoHandle = this;
}
@Override
public int save(GatherInfo info) {
... ... @@ -137,12 +147,54 @@ public class GatherInfoHandleImpl implements GatherInfoService {
@Override
public void handel(GatherInfo gatherInfo) {
this.info = gatherInfo;
//获取过磅重量
growssWt = info.getGrosswt().doubleValue();
try {
this.info = gatherInfo;
//获取过磅重量
growssWt = info.getGrosswt().doubleValue();
//取车牌号,判定卡口是否取到车牌号
vaName = info.getVename();
//车牌校验
if (veNameCheck(vaName)
&& veRecordCheck() //车辆备案
&& LandBusinessFormCheck() //流转申请校验
&& weightCheck(info) //过磅重量校验
){
// 场站白名单放行验证
if (areaWhiteListCheck()){
pass();
return;
}
//入区核放
if(chanelInCheck()){
pass();
}else{
inStationInfo(); //入场信息获取
setListinfos(); //流转申请表体获取
if (goodsWhiteListCheck()){ //货物类型白名单
pass();
return;
}
if(checkRelease()){ //出区核放
sendBw(info, true,PERMITTHOUGH,landBusinessTypeList,listinfos);
releaseFormCheck(); //流转申请单核销
}
}
}
logger.info("[X21-ERROR]:车辆过磅验放失败");
}catch (Exception e){
logger.error("放行判定异常",e);
CommandClient.Client(gatherInfo, "放行判定异常");
}
//取车牌号,判定卡口是否取到车牌号
vaName = info.getVename();
}
... ... @@ -166,7 +218,7 @@ public class GatherInfoHandleImpl implements GatherInfoService {
//1. 若无车牌号,返回未识别错误
if (StringUtils.isEmpty(vaName)) {
logger.error(NO_CHEPAI+vaName);
sendBw(info,false,NO_CHEPAI + vaName,new LandBusinessTypeList(),listinfos);
sendBw(info,false,NO_CHEPAI + vaName,null,listinfos);
//CommandClient.Client(info, NO_CHEPAI + vaName);
return false;
}
... ... @@ -178,11 +230,11 @@ public class GatherInfoHandleImpl implements GatherInfoService {
*/
private boolean veRecordCheck(){
//2. 校验车辆是否备案
LandRoadVe ve = veService.selectByFrameNo(vaName);
LandRoadVe ve = gatherInfoHandle.veService.selectByFrameNo(vaName);
//若无备案信息或者黑名单,返回车辆未备案或者识别错误,
if (ve == null && !veBlackListCheck(ve)) {
logger.error(NORECORD+vaName);
sendBw(info,false,NORECORD + vaName,new LandBusinessTypeList(),listinfos);
sendBw(info,false,NORECORD + vaName,null,listinfos);
//CommandClient.Client(info, NORECORD + vaName);
return false;
}
... ... @@ -198,7 +250,8 @@ public class GatherInfoHandleImpl implements GatherInfoService {
*/
private boolean veBlackListCheck(LandRoadVe ve){
if("Y".equals(ve.getVeState())){
sendBw(info,false,BLACKLIST + vaName,new LandBusinessTypeList(),listinfos);
logger.info(BLACKLIST+vaName);
sendBw(info,false,BLACKLIST + vaName,null,listinfos);
return false;
}
return true;
... ... @@ -211,12 +264,19 @@ public class GatherInfoHandleImpl implements GatherInfoService {
*/
private boolean LandBusinessFormCheck(){
try {
logger.info("车辆-{}核碰缓存",info.getVename());
landBusinessTypeListList = new ArrayList<>();
//通过车牌号,二维码,场站,通道号,进出类型查询进出场站申请列表
String landBusinessJson = redisService.get(info.getVename());
if (info==null){
logger.error("info 实体为NULL");
return false;
}
String landBusinessJson = gatherInfoHandle.redisService.get(info.getVename());
List<LandBusinessTypeList> list = new ArrayList<>();
if (StringUtils.isNotEmpty(landBusinessJson)){
list = (List<LandBusinessTypeList>) JSON.parseObject(landBusinessJson,List.class);
list = JSONArray.parseArray(landBusinessJson,LandBusinessTypeList.class);
landBusinessTypeListList = list;
//4. 若查询结果为null,返回无相对应进出场申请
... ... @@ -226,33 +286,53 @@ public class GatherInfoHandleImpl implements GatherInfoService {
return false;
}
list.stream()
.filter( item->{
if (item.getAisle().equals(info.getChnlno()) && item.getBarcode().equals(info.getBarcode())){
landBusinessTypeList = item;
for (LandBusinessTypeList item : list) {
//离场装载货物重量
goodsWt = Double.parseDouble(landBusinessTypeList.getRemark());
if (item.getAisle().equals(info.getChnlno()) && item.getBarcode().equals(info.getBarcode())){
landBusinessTypeList = item;
//离场装载货物重量
goodsWt = Double.parseDouble(landBusinessTypeList.getRemark());
logger.info("车辆-{}的申请缓存信息核碰成功,通道:{}",info.getVename(),info.getChnlno());
return true;
}
}
return true;
}else {
return false;
}
});
//核碰流转申请失败
logger.info("[CACHE]:车辆-{}的流转申请校验失败,无对应流转申请信息",info.getVename());
}else {
logger.error("未找到车辆-{}的申请缓存信息",info.getVename());
logger.info("未找到车辆-{}的申请缓存信息,或者流转已超期失效",info.getVename());
logger.error("[CACHE-ERROR]:未找到车辆-{}的申请缓存信息",info.getVename());
logger.info("[CACHE-ERROR]:未找到车辆-{}的申请缓存信息,或者流转已超期失效",info.getVename());
return false;
}
}catch (Exception e){
e.printStackTrace();
logger.error("[CACHE-PARSE-ERROR]:",e);
return false;
}
return false;
}
/**
* 5. 车辆过磅重量校验
* @return true 通过 false 不通过
*/
private boolean weightCheck(GatherInfo info){
if(info.getGrosswt().compareTo(BigDecimal.ZERO) > 0){
logger.info("过磅重量校验通过,过磅重量大于0");
}else{
sendBw(info,false,NOGrossWt + growssWt,new LandBusinessTypeList(),listinfos);
return false;
}
return true;
}
/**
* 流转申请-货物类型白名单,白名单的货物类型目前直接放行
* @return
* @return true 白名单货物直接放行 false 非白名单 需要验放
*/
private boolean goodsWhiteListCheck(){
if(!"普通货物".equals(landBusinessTypeList.getCocode())
... ... @@ -265,30 +345,29 @@ public class GatherInfoHandleImpl implements GatherInfoService {
//todo:换单货物校验逻辑待定
//todo:未来取消货物类型判定.
logger.info("车辆装载货物为:" + landBusinessTypeList.getCocode());
return true;
return true;
}
return false;
}
/**
* 5. 车辆过磅重量校验
* @return true 通过 false 不通过
* todo:通道及金二路由判定,是金二通道的话,等金二X22
* 目前宽进严出策略,本地判定
*
*/
private boolean weightCheck(GatherInfo info){
if(info.getGrosswt().compareTo(BigDecimal.ZERO) > 0){
logger.info("过磅重量校验通过,过磅重量大于0");
}else{
sendBw(info,false,NOGrossWt + growssWt,new LandBusinessTypeList(),listinfos);
private boolean chanelInCheck(){
if ("I".equals(info.getIetype())){
return true;
}else {
return false;
}
return true;
}
/**
* 离场时需要获取的车辆进场信息,入场重量,进出场差值
*/
private void inStationInfo(){
List<LandBusinessTypeList> stationInChanleInfo= listService.selectwt(info.getVename(),info.getBarcode(),info.getAreaid(),"I");
List<LandBusinessTypeList> stationInChanleInfo= gatherInfoHandle.listService.selectwt(info.getVename(),info.getBarcode(),info.getAreaid(),"I");
if (stationInChanleInfo.isEmpty()){
logger.info("未查询到车辆:{}的入场信息",info.getVename());
}else {
... ... @@ -313,36 +392,26 @@ public class GatherInfoHandleImpl implements GatherInfoService {
}
/**
* todo:通道及金二路由判定,是金二通道的话,等金二X22
* 目前宽进严出策略,本地判定
*
*/
private boolean chanelInCheck(){
if ("I".equals(info.getIetype())){
return true;
}else {
return false;
}
}
/**
* 设置表体全局变量
*/
private void setListinfos(){
//查询运单列表
listinfos=busnesslistinfoService.selectmanilist(info.getBarcode());
listinfos=gatherInfoHandle.busnesslistinfoService.selectmanilist(info.getBarcode());
}
/**
* todo:与金二指令一起核碰
* 出区抬杆放行判定
* @return
* @return true 抬杆放行
*/
private boolean checkRelease(){
logger.info("[进出场申请]-业务类型为:"+landBusinessTypeList.getCocode()+landBusinessTypeList.getBusinesstype());
switch (landBusinessTypeList.getBusinesstype()){
case "空车业务":
if(weightCheckHandleService.checkEmpty(growssWt,selfWt)){
if(gatherInfoHandle.weightCheckHandleService.checkEmpty(growssWt,selfWt)){
return true;
}else{
logger.error("[空车业务]-出场重量未通过校验:"+GROWSSEXCETION);
... ... @@ -351,7 +420,7 @@ public class GatherInfoHandleImpl implements GatherInfoService {
}
case "出口转关":
case "出口送货":
if (weightCheckHandleService.checkExportDownLoading(growssWt, selfWt, goodsWt,inWt)){
if (gatherInfoHandle.weightCheckHandleService.checkExportDownLoading(growssWt, selfWt, goodsWt,inWt)){
return true;
}else{
logger.error("[出口送货]-出场重量未通过校验:"+GROWSSEXCETION);
... ... @@ -360,7 +429,7 @@ public class GatherInfoHandleImpl implements GatherInfoService {
}
case "进口转关":
case "进口提货":
if (weightCheckHandleService.checkImportDlv(growssWt, selfWt, goodsWt,inWt)){
if (gatherInfoHandle.weightCheckHandleService.checkImportDlv(growssWt, selfWt, goodsWt,inWt)){
if ("退库货物".equals(landBusinessTypeList.getCocode())){
/**
* 退库货物不校验运单放行.
... ... @@ -368,7 +437,7 @@ public class GatherInfoHandleImpl implements GatherInfoService {
logger.info("[退库业务]-重量核验通过.");
}else{
//检查运单放行
if (resMessageService.checkManifestRelease(info,listinfos)){
if (gatherInfoHandle.resMessageService.checkManifestRelease(info,listinfos)){
return true;
}else {
//有运单未放行
... ... @@ -385,7 +454,7 @@ public class GatherInfoHandleImpl implements GatherInfoService {
}
break;
case "分拨业务":
if (weightCheckHandleService.checkAllocateOrDispatch(growssWt, selfWt, goodsWt,inWt)){
if (gatherInfoHandle.weightCheckHandleService.checkAllocateOrDispatch(growssWt, selfWt, goodsWt,inWt)){
//todo:检查分拨申请
boolean allocatCheck = checkNmmsAllocate(landBusinessTypeList.getMasterList());
if(!allocatCheck){
... ... @@ -401,9 +470,9 @@ public class GatherInfoHandleImpl implements GatherInfoService {
return false;
}
case "调拨业务":
if (weightCheckHandleService.checkAllocateOrDispatch(growssWt, selfWt, goodsWt,inWt)){
if (gatherInfoHandle.weightCheckHandleService.checkAllocateOrDispatch(growssWt, selfWt, goodsWt,inWt)){
//检查运单放行
if (resMessageService.checkManifestRelease(info,listinfos)){
if (gatherInfoHandle.resMessageService.checkManifestRelease(info,listinfos)){
return true;
}else {
//有运单未放行
... ... @@ -451,30 +520,39 @@ public class GatherInfoHandleImpl implements GatherInfoService {
landBusinessTypeList.setId(UUID.randomUUID().toString());
landBusinessTypeList.setIsvalid("1");
//todo:这里SEQN也要入库
listService.saveList(landBusinessTypeList);
gatherInfoHandle.listService.saveList(landBusinessTypeList);
}
/**
* 流转申请是否核销判定
* 流转申请是否进行核销判定
*/
private void releaseFormCheck(){
List<LandBusinessTypeList> temp = landBusinessTypeListList;
//二维码已出区的记录
List<LandBusinessTypeList> havenCrossList = listService.selectByBarcodeWithE(info.getBarcode());
//申请核销判定
List<LandBusinessTypeList> havenCrossList = gatherInfoHandle.listService.selectByBarcodeWithE(info.getBarcode());
if (landBusinessTypeListList.isEmpty() && havenCrossList.isEmpty()){
return;
}
//申请核销判定,已出区的记录与流转申请数据核碰.如果流转申请列表核碰完,还剩下的需要出区的场站则不核销.
for (LandBusinessTypeList businessTypeList : havenCrossList) {
List<LandBusinessTypeList> r = landBusinessTypeListList.stream().filter(item ->{
//判断还有没有没有出区的场站,还有没有出区的场站就不核销
if(item.getEndstation().equals(businessTypeList.getEndstation())) {
landBusinessTypeListList.remove(item);
return true;
}else {
return false;
}
})
.collect(Collectors.toList());
temp.removeAll(r);
}
if (landBusinessTypeListList.isEmpty()){
if (temp.isEmpty()){
//todo:流转申请状态核销
logger.info("[进出场申请]-流转申请已核销:"+vaName);
//二维码核销
releaseBarCode();
}
... ... @@ -486,12 +564,15 @@ public class GatherInfoHandleImpl implements GatherInfoService {
*/
private void releaseBarCode(){
//二维码判定
int count=listService.selectlaststation(info.getVename(),info.getBarcode());
int count=gatherInfoHandle.listService.selectlaststation(info.getVename(),info.getBarcode());
//二维码失效通知,已进入场站的与缓存比较.
if(count==0){
//todo:测试注释掉,二维码释放
logger.info("[进出场申请]-二维码释放:"+vaName);
buildBarCode.cancleBarCode(vaName);
if (!gatherInfoHandle.debug){
buildBarCode.cancleBarCode(vaName);
}
gatherInfoHandle.redisService.del(info.getVename());
}
}
... ... @@ -501,20 +582,30 @@ public class GatherInfoHandleImpl implements GatherInfoService {
/**
* 发送X22指令
* @param info
* @param check
* @param reason
* @param land
* @param list_infos
* @return
*/
public boolean sendBw(GatherInfo info, boolean check, String reason, LandBusinessTypeList land, List<LAND_BUSINEESTYPE_LIST_INFO> list_infos) {
* @param info 过卡信息
* @param check true 抬杆,false 不抬杆
* @param reason 原因
* @param land 流转申请表头信息
* @param list_infos 流转申请表体信息
* @return 调试模式 直接返回true,生产模式按业务走
*/
private boolean sendBw(GatherInfo info, boolean check, String reason, LandBusinessTypeList land, List<LAND_BUSINEESTYPE_LIST_INFO> list_infos) {
//调试模式 直接返回true
if (gatherInfoHandle.debug){
if (check) {
record();
}
commandlog(info,check,reason,land,list_infos);
return check;
}
logger.info(String.format("开始发送指令:车牌%s,场站%s,通道%s,重量%s",info.getVename(),info.getAreaid(),info.getChnlno(),info.getGrosswt()));
boolean flag = false;
if (check) {
CommandClient.Client(info, PERMITTHOUGH);
logger.info("=============>>>>>>>>放行报文发送成功<<<<<<<<<==============");
flag = true;
record();
} else {
CommandClient.Client(info, reason);
logger.info("=============>>>>>>>>重量异常报文发送成功<<<<<<<<<==============");
... ... @@ -524,6 +615,13 @@ public class GatherInfoHandleImpl implements GatherInfoService {
}
/**
* 直接放行
*/
private void pass(){
sendBw(info,true,PERMITTHOUGH,landBusinessTypeList,listinfos);
}
/**
* 放行日志记录
* @param info
* @param check
... ... @@ -531,7 +629,7 @@ public class GatherInfoHandleImpl implements GatherInfoService {
* @param land
* @param list_infos
*/
public void commandlog(GatherInfo info,boolean check,String reason,LandBusinessTypeList land,List<LAND_BUSINEESTYPE_LIST_INFO> list_infos){
private void commandlog(GatherInfo info,boolean check,String reason,LandBusinessTypeList land,List<LAND_BUSINEESTYPE_LIST_INFO> list_infos){
String flag="",type="";
commandLog command=new commandLog();
command.setId(UUID.randomUUID().toString());
... ... @@ -562,10 +660,10 @@ public class GatherInfoHandleImpl implements GatherInfoService {
command.setInGrossWeight(inWt);
command.setGoodsWeight(goodsWt);
command.setActualGoodsWeight(diffVal);
if(list_infos.size()>0){
if(list_infos !=null && list_infos.size()>0){
command.setMasterList(Arrays.toString(toStrArry(list_infos)));
}
commandLogService.insert(command);
gatherInfoHandle.commandLogService.insert(command);
}
/**
... ... @@ -576,7 +674,7 @@ public class GatherInfoHandleImpl implements GatherInfoService {
private Map nmmsAllocate(@NotNull String waybill){
logger.info("新舱单查询分拨申请数据开始");
Feign_Allocate_Search feignAllocateSearch = new Feign_Allocate_Search(waybill,0,10);
Map map = nmmsService.getAllocate(feignAllocateSearch);
Map map = gatherInfoHandle.nmmsService.getAllocate(feignAllocateSearch);
logger.info(""+map);
return map;
}
... ...
... ... @@ -6,7 +6,7 @@ import com.sy.service.GatherInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Service("GatherInfoService")
public class GatherInfoServiceImpl implements GatherInfoService {
@Autowired
... ...
package com.sy.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.sy.mapper.LandBusinessTypeListMapper;
import com.sy.model.GatherInfo;
import com.sy.model.LandBusinessTypeList;
import com.sy.service.LandBusListService;
import com.sy.service.RedisService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class LandBusListServiceImpl implements LandBusListService {
private static final Logger logger = LoggerFactory.getLogger(LandBusListServiceImpl.class);
@Autowired
private LandBusinessTypeListMapper listMapper;
@Autowired
private RedisService redisService;
@Override
public List<LandBusinessTypeList> selectByFrameNoAndType(String frameNo, String flag) {
List<LandBusinessTypeList> lists = null;
... ... @@ -101,4 +113,43 @@ public class LandBusListServiceImpl implements LandBusListService {
public int selectlaststation(String frameNo, String barcode) {
return listMapper.selectlaststation(frameNo,barcode);
}
/**
* 根据gatherInfo获取对应的流转申请
* @return 流转申请信息
*/
@Override
public LandBusinessTypeList getLandBusinessTypeListByGather(GatherInfo gatherInfo){
try {
//通过车牌号,二维码,场站,通道号,进出类型查询进出场站申请列表
String landBusinessJson = redisService.get(gatherInfo.getVename());
List<LandBusinessTypeList> list = new ArrayList<>();
if (StringUtils.isNotEmpty(landBusinessJson)){
list = JSONArray.parseArray(landBusinessJson,LandBusinessTypeList.class);
//4. 若查询结果为null,返回无相对应进出场申请
if (list == null || list.isEmpty()) {
logger.error(gatherInfo.getVename()+"无相对应进出场申请");
return null;
}
for (LandBusinessTypeList item : list) {
if (item.getAisle().equals(gatherInfo.getChnlno()) && item.getBarcode().equals(gatherInfo.getBarcode())){
logger.info("车辆-{}的申请缓存信息核碰成功,通道:{}",gatherInfo.getVename(),gatherInfo.getChnlno());
return item;
}
}
}else {
logger.error("未找到车辆-{}的申请缓存信息",gatherInfo.getVename());
logger.info("未找到车辆-{}的申请缓存信息,或者流转已超期失效",gatherInfo.getVename());
return null;
}
}catch (Exception e){
e.printStackTrace();
return null;
}
return null;
}
}
... ...
... ... @@ -4,6 +4,7 @@ import com.sy.mapper.RESMESSAGEMapper;
import com.sy.model.GatherInfo;
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
import com.sy.model.RESMESSAGE;
import com.sy.service.CommandLogService;
import com.sy.service.ResMessageService;
import com.sy.socket.CommandClient;
import org.apache.log4j.Logger;
... ... @@ -14,6 +15,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import java.util.stream.Collectors;
/**
* @author
... ... @@ -27,6 +29,9 @@ public class ResMessageServiceImpl implements ResMessageService {
@Autowired
private RESMESSAGEMapper mapper;
@Autowired
CommandLogService commandLogService;
@Override
public int saveEnter(RESMESSAGE resmessage){
... ... @@ -51,30 +56,49 @@ public class ResMessageServiceImpl implements ResMessageService {
return false;
}
//只拉板箱的话,这里list_infos会为null
list_infos = list_infos.stream().filter(listInfo ->{
if("B".equals(listInfo.getExt4())){
return true;
}else {
return false;
}
}).collect(Collectors.toList());
logger.info("运单列表:" + toStrArry(list_infos));
boolean flag = false;
List<RESMESSAGE> list = selectByManifestList(toStrArry(list_infos));
/**
* 这里如果list_infos为NULL,会报错NULL Exception.什么指令都不给了.
* 如果申请单据只有ULD板箱类型的时候.
*/
if (!list_infos.isEmpty()){
List<RESMESSAGE> list = selectByManifestList(toStrArry(list_infos));
if (list.size() == toStrArry(list_infos).length) {
flag = true;
}else{
//返回未放行的运单列表
if (toStrArry(list_infos).length>0){
for (String awb : toStrArry(list_infos)) {
boolean anyMatch = list.stream().anyMatch(resmessage -> {
return resmessage.getManifest().equals(awb);
});
if (!anyMatch){
noRelease.add(awb);
if (list.size() == toStrArry(list_infos).length) {
flag = true;
}else{
//返回未放行的运单列表
if (toStrArry(list_infos).length>0){
for (String awb : toStrArry(list_infos)) {
boolean anyMatch = list.stream().anyMatch(resmessage -> {
return resmessage.getManifest().equals(awb);
});
if (!anyMatch){
noRelease.add(awb);
}
}
if (!noRelease.isEmpty()) {
logger.info(Arrays.toString(noRelease.toArray())+FANGXING);
commandLogService.commandlog(info,false,Arrays.toString(noRelease.toArray())+FANGXING,null,list_infos,
new Double("0.0"),new Double("0.0"),new Double("0.0"),new Double("0.0"));
CommandClient.Client(info, Arrays.toString(noRelease.toArray())+FANGXING);
}
}
if (!noRelease.isEmpty()) {
logger.info(Arrays.toString(noRelease.toArray())+FANGXING);
CommandClient.Client(info, Arrays.toString(noRelease.toArray())+FANGXING);
}
}
}
return flag;
}
public static String[] toStrArry(List<LAND_BUSINEESTYPE_LIST_INFO> list_infos){
... ...
... ... @@ -164,17 +164,24 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
//卸货离场判定
double result3= 0.00;
double result4= 0.00;
if(Double.doubleToLongBits(grossWt)>Double.doubleToLongBits(0)){
//带货出,入场重量+带货重量 = 离场重量
result = Double.parseDouble(df.format(Math.abs((inWt + goodsWt - grossWt)) / grossWt));
//带货出,用车辆备案重量对碰,车辆备案重量+带货重量 = 离场重量
result4 = Double.parseDouble(df.format(Math.abs((wt + goodsWt - grossWt)) / grossWt));
//空车出,过磅重量 = 车辆备案重量
result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / grossWt));
//卸货出,入场重量-卸货重量 = 离场重量
result3 = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / grossWt));
System.out.println("进场提货离场差值:"+result);
System.out.println("空车离场差值:"+result2);
System.out.println("进场卸货离场差值:"+result3);
System.out.println("备案重量进场装载货物离场差值:"+result4);
}
double range = valueDob();
if (result <= range || result2 <= range || result3 <= range ) {
if (result <= range || result2 <= range || result3 <= range || result4 <= range) {
flag = true;
}
return flag;
... ...
package com.sy.service.router;
import com.sy.bwAssist.Message;
/**
* 卡口业务报文处理路由
* 处理接收的卡口报文X22与X21,
* 并根据路由表,决定X21报文是否发送给金二,由金二验放处理,并本地记录.还是不发金二本地验放处理
* 集中核销流转申请.
* @author mrz
*/
public interface MessageRouter {
/**
* CARM报文实体路由处理
*/
void route(Message message);
}
... ...
package com.sy.service.router;
import com.alibaba.fastjson.JSON;
import com.sy.bwAnalysis.GatherInfoAnalysis;
import com.sy.bwAssist.Message;
import com.sy.mapper.LandRouterConfigDao;
import com.sy.model.GatherInfo;
import com.sy.model.LandBusinessTypeList;
import com.sy.model.LandRouterConfig;
import com.sy.service.CommandLogService;
import com.sy.service.LandBusListService;
import com.sy.service.RedisService;
import com.sy.service.impl.GatherInfoHandle;
import com.sy.socket.CommandClient;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.List;
@Service("X21")
public class MessageRouterX21 implements MessageRouter {
private static final Logger logger = LoggerFactory.getLogger(MessageRouterX21.class);
/**
* 金二与本地认证兼容性开关
* Y 是金二业务必须走金二
* N 车辆扫二维码或本地和金二都可进出区验放
*/
@Value("${g2.switch}")
private boolean g2Switch;
@Resource
private LandRouterConfigDao landRouterConfigDao;
@Autowired
private LandBusListService landBusListService;
@Autowired
private RedisService redisService;
@Autowired
private CommandLogService commandLogService;
@Override
public void route(Message message) {
logger.info("处理X21:gatherInfo");
GatherInfoAnalysis gatherInfoAnalysis = new GatherInfoAnalysis();
GatherInfo info = gatherInfoAnalysis.toJavaBean(message);
if (g2Switch){
//金二判断,业务类型,通道,路由目的地
routerCheckG2(info);
}else {
X21Local(info);
}
}
/**
* 判断X21报文是否给金二
* @param info 过卡信息
*
* @return true 给金二 false 不给金二
*/
private void routerCheckG2(GatherInfo info){
/**
* 通过业务类型进行核对
* 1. 获取进出场申请信息,主要获取业务类型
*/
LandBusinessTypeList landBusinessTypeList = landBusListService.getLandBusinessTypeListByGather(info);
if (landBusinessTypeList!=null){
rightChnelCheck(landBusinessTypeList.getBusinesstype(),info);
}else {
}
/**
* 通过X21的通道进行核对.暂时不用这个
*/
// LandRouterConfig config = new LandRouterConfig();
// config.setChanelId(info.getChnlno());
// config.setBusinessType(landBusinessTypeList.getBusinesstype());
// config.setChanelType(info.getIetype());
// config.setGatherReceiver("G2");
// config.setStatus("Y");
//
// List<LandRouterConfig> routerConfigs = landRouterConfigDao.selectByGatherInfo(config);
// return !routerConfigs.isEmpty();
}
/**
* 有金二通道配置 ,但是车辆没走金二通道进行验放,用这个方法验证
* G2_SWITCH 开关为Y的时候.进行此校验.
* G2_SWITCH 开关为N时此校验永远返回true
* 金二业务的正确性校验
* 比如进口提货业务,走金二的应该是出一通道验放金二.但是车辆从出二扫二维码出区了,也是不允许的.
* 要返回走错通道G2.
* 逻辑:查询路由表 流转业务类型 目的核放处理方是G2 反向查找得到 通道列表,车辆没走此列表中的通道 视为走错通道.
* @param businessType 业务类型
* @param info 过卡信息
* @return true 走对通道 false 走错通道
*/
private void rightChnelCheck(String businessType,GatherInfo info){
List<LandRouterConfig> routerConfigs = landRouterConfigDao.selectByBussType(businessType);
//有金二与业务类型绑定
if (!routerConfigs.isEmpty()){
//是否走对通道的判定
for (LandRouterConfig routerConfig : routerConfigs) {
if (routerConfig.getChanelId().equals(info.getChnlno())){
/**
* 查找到金二与通道的验放配置
*/
//缓存X21,用来接收海关的x82指令核对.收到X22指令后进行核销此缓存.走金二验放的才缓存
cacheWithSeqno(info);
//将X21报文发给三宝,让三宝发给金二
sendToSample(info);
record(info,true,"已转金二验放-[SEQN]:"+info.getSeqno(),null);
logger.info("[G2]>>为[金二业务],已将[{}]过卡信息发送与金二",info.getVename());
return;
}
}
/**
* 没适配上 为走错通道,走错通道直接给指令,不走本地验放.
* 为提高抬杆效率
*/
//todo:走错通道的回执指令处理
record(info,false,"走错通道-[SEQN]:"+info.getSeqno(),null);
logger.info("走错通道");
}else {
//没有金二配置,走本地
X21Local(info);
}
}
/**
* 如果是金二将报文发送给三宝接口
*/
private void sendToSample(GatherInfo info){
CommandClient.gatherInfoBuildAndSend(info);
}
/**
* 缓存X21信息,如果走金二,KEY 为SEQN_NO
*/
private void cacheWithSeqno(GatherInfo info){
if (info!=null && StringUtils.isNotEmpty(info.getSeqno())) {
redisService.set(info.getSeqno(), JSON.toJSONString(info),60*60*24);
}
}
/**
* 本地处理
*/
private void X21Local(GatherInfo info){
GatherInfoHandle gatherInfoHandle = new GatherInfoHandle();
gatherInfoHandle.handel(info);
}
/**
* 车辆过卡指令日志记录
*/
private void record(GatherInfo info,boolean result,String reason,LandBusinessTypeList landBusinessTypeList){
commandLogService.commandlog(info,result,reason,landBusinessTypeList,null,0.0,0.0,0.0,0.0);
}
}
... ...
package com.sy.service.router;
import com.alibaba.fastjson.JSON;
import com.sy.bwAnalysis.CommandInfoAnalysis;
import com.sy.bwAssist.Message;
import com.sy.mapper.LandRouterConfigDao;
import com.sy.model.GatherInfo;
import com.sy.model.LandBusinessTypeList;
import com.sy.model.LandRouterConfig;
import com.sy.model.CommandInfoX22;
import com.sy.service.CommandLogService;
import com.sy.service.LandBusListService;
import com.sy.service.RedisService;
import com.sy.service.impl.GatherInfoHandle;
import com.sy.socket.CommandClient;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.List;
@Service("X22")
public class MessageRouterX22 implements MessageRouter {
private static final Logger logger = LoggerFactory.getLogger(MessageRouterX22.class);
@Value("${g2.switch}")
private boolean g2Switch;
@Autowired
private RedisService redisService;
@Autowired
private CommandLogService commandLogService;
/**
* 放行的code标识
*/
private static String CODE_RELEASE = "00000000200000000000";
/**
* 金二抬杆指令处理
* 1. 金二通道正常可以接收抬杆指令时,与本地联合验放
* 2. ERROR 或者 金二 TIME_OUT,金二通道异常 接收不到放行指令,使用金二开关,进行本地验放.
* @param message
*/
@Override
public void route(Message message) {
try {
logger.info("处理X22:CommandInfo");
CommandInfoAnalysis commandInfoAnalysis = new CommandInfoAnalysis();
CommandInfoX22 commandInfoX22 = commandInfoAnalysis.toJavaBean(message);
if (commandInfoX22!=null){
/**
* 根据SEQNO 读取缓存 确定是否金二指令
*/
GatherInfo gatherInfo = readCacheWithSeqno(commandInfoX22);
//是金二指令
if (gatherInfo!=null){
/**
* 1. 判断指令是否放行
*/
if (commandInfoX22.getCheckResult().equals(CODE_RELEASE)) {
/**
* todo:第一种.收到G2指令直接放行.并记录过卡与流转申请的核销
*/
/**
* 第二种,结合本地指令进行放行.
*/
GatherInfoHandle gatherInfoHandle = new GatherInfoHandle();
gatherInfoHandle.handel(gatherInfo);
}else {
/**
* 是金二指令,但是是未放行指令
* 记录未放行原因.
* 通知卡口
*/
CommandClient.Client(gatherInfo,commandInfoX22.getOpHint());
record(gatherInfo,false,gatherInfo.getSeqno()+"金二验放失败:"+commandInfoX22.getOpHint(),null);
}
}
}
}catch (Exception e){
logger.error("[X22-ERROR]:",e);
}
}
/**
* 读取X21信息,如果走金二,KEY 为SEQN_NO
* @param info X22实体
* @return X21实体.
*/
private GatherInfo readCacheWithSeqno(CommandInfoX22 info){
if (info!=null && StringUtils.isNotEmpty(info.getSeqNo())) {
String X21_GatherInfo = redisService.get(info.getSeqNo());
if (StringUtils.isNotEmpty(X21_GatherInfo)){
GatherInfo gatherInfo = JSON.parseObject(X21_GatherInfo, GatherInfo.class);
return gatherInfo;
}
}
return null;
}
/**
* 车辆过卡指令日志记录
*/
private void record(GatherInfo info,boolean result,String reason,LandBusinessTypeList landBusinessTypeList){
commandLogService.commandlog(info,result,reason,landBusinessTypeList,null,0.0,0.0,0.0,0.0);
}
}
... ...
package com.sy.service.router;
import com.sy.bwAssist.Message;
public class RouterContext {
private MessageRouter messageRouter;
public RouterContext(MessageRouter messageRouter){
this.messageRouter = messageRouter;
}
public void executeStrategy(Message message){
messageRouter.route(message);
}
}
... ...
package com.sy.socket;
import com.sy.model.CommandInfoX22;
import com.sy.model.GatherInfo;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
... ... @@ -14,12 +15,69 @@ public class CommandClient {
private static final Logger logger = Logger.getLogger(CommandClient.class);
private static final String GATHER_TEMPLATE = "<GATHER_INFO AREA_ID=\"${AREA_ID}\" CHNL_NO=\"${CHNL_NO}\" I_E_TYPE=\"${I_E_TYPE}\" SEQ_NO=\"${SEQ_NO}\">\n" +
"\t<IC>\n" +
"\t\t<DR_IC_NO/>\n" +
"\t\t<IC_DR_CUSTOMS_NO/>\n" +
"\t\t<IC_CO_CUSTOMS_NO/>\n" +
"\t\t<IC_BILL_NO/>\n" +
"\t\t<IC_FORM_TYPE/>\n" +
"\t\t<IC_GROSS_WT/>\n" +
"\t\t<IC_VE_CUSTOMS_NO/>\n" +
"\t\t<IC_VE_NAME/>\n" +
"\t\t<IC_CONTA_ID/>\n" +
"\t\t<IC_ESEAL_ID/>\n" +
"\t\t<IC_REG_DATETIME/>\n" +
"\t\t<IC_PER_DAY_DUE/>\n" +
"\t</IC>\n" +
"\t<WEIGHT>\n" +
"\t\t<GROSS_WT>${GROSS_WT}</GROSS_WT>\n" +
"\t</WEIGHT>\n" +
"\t<CAR>\n" +
"\t\t<VE_NAME>${VE_NAME}</VE_NAME>\n" +
"\t\t<CAR_EC_NO/>\n" +
"\t\t<CAR_EC_NO2/>\n" +
"\t\t<VE_CUSTOMS_NO/>\n" +
"\t\t<VE_WT/>\n" +
"\t</CAR>\n" +
"\t<CONTA>\n" +
"\t\t<CONTA_NUM/>\n" +
"\t\t<CONTA_RECO>${CONTA_RECO}</CONTA_RECO>\n" +
"\t\t<CONTA_ID_F/>\n" +
"\t\t<CONTA_ID_B/>\n" +
"\t\t<CONTA_MODEL_F/>\n" +
"\t\t<CONTA_MODEL_B/>\n" +
"\t</CONTA>\n" +
"\t<ORDER_NUM/>\n" +
"\t<BAR_CODE>${BAR_CODE}</BAR_CODE>\n" +
"\t<SEAL>\n" +
"\t\t<ESEAL_ID/>\n" +
"\t\t<SEAL_KEY/>\n" +
"\t</SEAL>\n" +
"</GATHER_INFO>";
private static final String COMMAND_INFO_TEMPLATE = "<COMMAND_INFO AREA_ID=\"${AREA_ID}\" CHNL_NO=\"${CHNL_NO}\" I_E_TYPE=\"${I_E_TYPE}\" SEQ_NO=\"${SEQ_NO}\">\n" +
"\t<CHECK_RESULT>${CHECK_RESULT}</CHECK_RESULT>\n" +
"\t<OP_HINT>${OP_HINT}</OP_HINT>\n" +
"\t<SEAL>\n" +
"\t\t<ESEAL_ID/>\n" +
"\t\t<SEAL_KEY>${SEAL_KEY}</SEAL_KEY>\n" +
"\t\t<OPEN_TIMES/>\n" +
"\t\t<ESEAL_IC_NO/>\n" +
"\t</SEAL>\n" +
"\t<SZ_MSG/>\n" +
"</COMMAND_INFO>";
/**
* @Param GatherInfo 卡口采集信息
* @Param flag 是否放行信息
* */
public static void Client(GatherInfo info,String flag) {
String xmlBody = getXmlInfo(info,flag);
sendWithSocket(info,xmlBody);
}
private static void sendWithSocket(GatherInfo info,String xmlBody){
Socket socket =null;
OutputStream op = null;
try {
... ... @@ -73,8 +131,6 @@ public class CommandClient {
e.printStackTrace();
logger.info("文件发送失败"+e.getMessage());
}
}
/**
* @Param info 卡口采集信息
... ... @@ -114,6 +170,27 @@ public class CommandClient {
return buffer.toString();
}
/**
* 生成GATHERINFO 报文内容
* @param info 过卡信息
* @return X21报文
*/
public static void gatherInfoBuildAndSend(GatherInfo info){
String gatherXML = "";
gatherXML = GATHER_TEMPLATE.replace("${AREA_ID}",info.getAreaid())
.replace("${CHNL_NO}",info.getChnlno())
.replace("${I_E_TYPE}",info.getIetype())
.replace("${SEQ_NO}",info.getSeqno())
.replace("${GROSS_WT}", info.getGrosswt().toString())
.replace("${VE_NAME}",info.getVename())
.replace("${CONTA_RECO}",info.getContareco())
//给三宝的去掉BARCODE,todo:不去掉做个测试
.replace("${BAR_CODE}",info.getBarcode());
sendWithSocket(info,gatherXML);
}
//int转byte
private static byte[] intToByte4(int i) {
byte[] targets = new byte[4];
... ...
<?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.LandRouterConfigDao">
<resultMap id="BaseResultMap" type="com.sy.model.LandRouterConfig">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="area_id" jdbcType="VARCHAR" property="areaId" />
<result column="area_name" jdbcType="VARCHAR" property="areaName" />
<result column="chanel_id" jdbcType="VARCHAR" property="chanelId" />
<result column="chanel_name" jdbcType="VARCHAR" property="chanelName" />
<result column="chanel_type" jdbcType="VARCHAR" property="chanelType" />
<result column="business_type" jdbcType="VARCHAR" property="businessType" />
<result column="g2_business_type" jdbcType="VARCHAR" property="g2BusinessType" />
<result column="identify_type" jdbcType="VARCHAR" property="identifyType" />
<result column="gather_receiver" jdbcType="VARCHAR" property="gatherReceiver" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="status" jdbcType="VARCHAR" property="status" />
</resultMap>
<sql id="Base_Column_List">
id, area_id, area_name, chanel_id, chanel_name, chanel_type, business_type, g2_business_type,
identify_type, gather_receiver, create_time, `status`
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from land_router_config
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByGatherInfo" parameterType="com.sy.model.LandRouterConfig" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from land_router_config
where chanel_id = #{chanelId,jdbcType=VARCHAR}
and `status` = #{status,jdbcType=VARCHAR}
and gather_receiver = #{gatherReceiver,jdbcType=VARCHAR}
and business_type = #{businessType,jdbcType=VARCHAR}
</select>
<select id="selectByBussType" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from land_router_config
where
business_type = #{businessType,jdbcType=VARCHAR}
and gather_receiver = 'G2'
and `status` = 'Y'
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from land_router_config
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.sy.model.LandRouterConfig" useGeneratedKeys="true">
insert into land_router_config (area_id, area_name, chanel_id,
chanel_name, chanel_type, business_type,
g2_business_type, identify_type, gather_receiver,
create_time, `status`)
values (#{areaId,jdbcType=VARCHAR}, #{areaName,jdbcType=VARCHAR}, #{chanelId,jdbcType=VARCHAR},
#{chanelName,jdbcType=VARCHAR}, #{chanelType,jdbcType=VARCHAR}, #{businessType,jdbcType=VARCHAR},
#{g2BusinessType,jdbcType=VARCHAR}, #{identifyType,jdbcType=VARCHAR}, #{gatherReceiver,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.sy.model.LandRouterConfig" useGeneratedKeys="true">
insert into land_router_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaId != null">
area_id,
</if>
<if test="areaName != null">
area_name,
</if>
<if test="chanelId != null">
chanel_id,
</if>
<if test="chanelName != null">
chanel_name,
</if>
<if test="chanelType != null">
chanel_type,
</if>
<if test="businessType != null">
business_type,
</if>
<if test="g2BusinessType != null">
g2_business_type,
</if>
<if test="identifyType != null">
identify_type,
</if>
<if test="gatherReceiver != null">
gather_receiver,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="status != null">
`status`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="areaId != null">
#{areaId,jdbcType=VARCHAR},
</if>
<if test="areaName != null">
#{areaName,jdbcType=VARCHAR},
</if>
<if test="chanelId != null">
#{chanelId,jdbcType=VARCHAR},
</if>
<if test="chanelName != null">
#{chanelName,jdbcType=VARCHAR},
</if>
<if test="chanelType != null">
#{chanelType,jdbcType=VARCHAR},
</if>
<if test="businessType != null">
#{businessType,jdbcType=VARCHAR},
</if>
<if test="g2BusinessType != null">
#{g2BusinessType,jdbcType=VARCHAR},
</if>
<if test="identifyType != null">
#{identifyType,jdbcType=VARCHAR},
</if>
<if test="gatherReceiver != null">
#{gatherReceiver,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sy.model.LandRouterConfig">
update land_router_config
<set>
<if test="areaId != null">
area_id = #{areaId,jdbcType=VARCHAR},
</if>
<if test="areaName != null">
area_name = #{areaName,jdbcType=VARCHAR},
</if>
<if test="chanelId != null">
chanel_id = #{chanelId,jdbcType=VARCHAR},
</if>
<if test="chanelName != null">
chanel_name = #{chanelName,jdbcType=VARCHAR},
</if>
<if test="chanelType != null">
chanel_type = #{chanelType,jdbcType=VARCHAR},
</if>
<if test="businessType != null">
business_type = #{businessType,jdbcType=VARCHAR},
</if>
<if test="g2BusinessType != null">
g2_business_type = #{g2BusinessType,jdbcType=VARCHAR},
</if>
<if test="identifyType != null">
identify_type = #{identifyType,jdbcType=VARCHAR},
</if>
<if test="gatherReceiver != null">
gather_receiver = #{gatherReceiver,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sy.model.LandRouterConfig">
update land_router_config
set area_id = #{areaId,jdbcType=VARCHAR},
area_name = #{areaName,jdbcType=VARCHAR},
chanel_id = #{chanelId,jdbcType=VARCHAR},
chanel_name = #{chanelName,jdbcType=VARCHAR},
chanel_type = #{chanelType,jdbcType=VARCHAR},
business_type = #{businessType,jdbcType=VARCHAR},
g2_business_type = #{g2BusinessType,jdbcType=VARCHAR},
identify_type = #{identifyType,jdbcType=VARCHAR},
gather_receiver = #{gatherReceiver,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
`status` = #{status,jdbcType=VARCHAR}
where id = #{id,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.commandInfoMapper">
<resultMap id="BaseResultMap" type="com.sy.model.commandInfo">
<resultMap id="BaseResultMap" type="com.sy.model.CommandInfoX22">
<id column="SEQ_NO" jdbcType="VARCHAR" property="seqNo" />
<result column="sender" jdbcType="VARCHAR" property="sender" />
<result column="receiver" jdbcType="VARCHAR" property="receiver" />
... ... @@ -23,12 +23,12 @@
<result column="OP_HINT" jdbcType="VARCHAR" property="opHint" />
</resultMap>
<sql id="Base_Column_List">
SEQ_NO, sender, receiver, seqn, sendtime, btype, stype, AREA_ID, CHNL_NO, I_E_TYPE,
CHECK_RESULT, VE_NAME, GPS_ID, ORIGIN_CUSTOMS, DEST_CUSTOMS, ESEAL_ID, SEAL_KEY,
SEQ_NO, sender, receiver, seqn, sendtime, btype, stype, AREA_ID, CHNL_NO, I_E_TYPE,
CHECK_RESULT, VE_NAME, GPS_ID, ORIGIN_CUSTOMS, DEST_CUSTOMS, ESEAL_ID, SEAL_KEY,
FORM_ID, OP_HINT
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from commandinfo
where SEQ_NO = #{seqNo,jdbcType=VARCHAR}
... ... @@ -37,23 +37,23 @@
delete from commandinfo
where SEQ_NO = #{seqNo,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sy.model.commandInfo">
insert into commandinfo (SEQ_NO, sender, receiver,
seqn, sendtime, btype,
stype, AREA_ID, CHNL_NO,
I_E_TYPE, CHECK_RESULT, VE_NAME,
GPS_ID, ORIGIN_CUSTOMS, DEST_CUSTOMS,
ESEAL_ID, SEAL_KEY, FORM_ID,
<insert id="insert" parameterType="com.sy.model.CommandInfoX22">
insert into commandinfo (SEQ_NO, sender, receiver,
seqn, sendtime, btype,
stype, AREA_ID, CHNL_NO,
I_E_TYPE, CHECK_RESULT, VE_NAME,
GPS_ID, ORIGIN_CUSTOMS, DEST_CUSTOMS,
ESEAL_ID, SEAL_KEY, FORM_ID,
OP_HINT)
values (#{seqNo,jdbcType=VARCHAR}, #{sender,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR},
#{seqn,jdbcType=VARCHAR}, #{sendtime,jdbcType=TIMESTAMP}, #{btype,jdbcType=VARCHAR},
#{stype,jdbcType=VARCHAR}, #{areaId,jdbcType=VARCHAR}, #{chnlNo,jdbcType=VARCHAR},
#{iEType,jdbcType=VARCHAR}, #{checkResult,jdbcType=VARCHAR}, #{veName,jdbcType=VARCHAR},
#{gpsId,jdbcType=VARCHAR}, #{originCustoms,jdbcType=VARCHAR}, #{destCustoms,jdbcType=VARCHAR},
#{esealId,jdbcType=VARCHAR}, #{sealKey,jdbcType=VARCHAR}, #{formId,jdbcType=VARCHAR},
values (#{seqNo,jdbcType=VARCHAR}, #{sender,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR},
#{seqn,jdbcType=VARCHAR}, #{sendtime,jdbcType=TIMESTAMP}, #{btype,jdbcType=VARCHAR},
#{stype,jdbcType=VARCHAR}, #{areaId,jdbcType=VARCHAR}, #{chnlNo,jdbcType=VARCHAR},
#{iEType,jdbcType=VARCHAR}, #{checkResult,jdbcType=VARCHAR}, #{veName,jdbcType=VARCHAR},
#{gpsId,jdbcType=VARCHAR}, #{originCustoms,jdbcType=VARCHAR}, #{destCustoms,jdbcType=VARCHAR},
#{esealId,jdbcType=VARCHAR}, #{sealKey,jdbcType=VARCHAR}, #{formId,jdbcType=VARCHAR},
#{opHint,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sy.model.commandInfo">
<insert id="insertSelective" parameterType="com.sy.model.CommandInfoX22">
insert into commandinfo
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="seqNo != null">
... ... @@ -174,7 +174,7 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sy.model.commandInfo">
<update id="updateByPrimaryKeySelective" parameterType="com.sy.model.CommandInfoX22">
update commandinfo
<set>
<if test="sender != null">
... ... @@ -234,7 +234,7 @@
</set>
where SEQ_NO = #{seqNo,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sy.model.commandInfo">
<update id="updateByPrimaryKey" parameterType="com.sy.model.CommandInfoX22">
update commandinfo
set sender = #{sender,jdbcType=VARCHAR},
receiver = #{receiver,jdbcType=VARCHAR},
... ... @@ -256,4 +256,4 @@
OP_HINT = #{opHint,jdbcType=VARCHAR}
where SEQ_NO = #{seqNo,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
</mapper>
... ...
... ... @@ -57,5 +57,6 @@ class RedisServiceTest {
@Test
void testSet() {
redisService.set("豫A61CR7","[{\"agentname\":\"ceshi\",\"agentno\":\"ceshi\",\"aisle\":\"4604601010\",\"barcode\":\"74b-4bef-b248-80a95358683f\",\"businesstype\":\"进口提货\",\"cocode\":\"普通货物\",\"createBy\":\"1\",\"createDate\":1661237499690,\"declarePersonnelNumbers\":\"8930000085548\",\"endport\":\"4604\",\"endstation\":\"4604600000\",\"endstationList\":[\"4604600000\"],\"enterpriseCreditCode\":\"9141010070678920XJ\",\"id\":\"402eff8d-ca6b-4192-99ff-ccc6c22b4749\",\"inAllocatingBusiness\":0,\"isDelete\":\"0\",\"isfull\":\"0\",\"isthree\":\"0\",\"isvalid\":\"0\",\"landBusineestypeListInfoList\":[{\"applicationformid\":\"74b-4bef-b248-80a95358683f\",\"arrivedaheadtime\":\"0\",\"awba\":\"999-11111111\",\"ext1\":\"123\",\"ext2\":\"123\",\"ext3\":\"进口提货\",\"ext4\":\"B\",\"flightno\":\"CV2212\",\"id\":\"0f9fd8a3-3485-43a3-bf5d-e53908999075\",\"intelligentLockOne\":\"123321\",\"intelligentLockTwo\":\"123321\",\"licenseplatenumber\":\"豫A61CR7\",\"partialidentity\":\"0\"}],\"massageId\":\"202208231451390761\",\"masterList\":\"999-11111111\",\"mediumtype\":\"2\",\"modeTransportation\":\"5\",\"organizationCode\":\"70678920X\",\"prodectTime\":1661237499690,\"remark\":\"123.00\",\"remark3\":\"\",\"trailerFrameNo\":\"豫A61CR7\",\"trailerLicenseNo\":\"超级管理员\",\"trainsconfirmationNumber\":\"\",\"turnoverflag\":\"I\",\"veProperty\":\"超级管理员\"},{\"agentname\":\"ceshi\",\"agentno\":\"ceshi\",\"aisle\":\"4604601011\",\"barcode\":\"74b-4bef-b248-80a95358683f\",\"businesstype\":\"进口提货\",\"cocode\":\"普通货物\",\"createBy\":\"1\",\"createDate\":1661237499690,\"declarePersonnelNumbers\":\"8930000085548\",\"endport\":\"4604\",\"endstation\":\"4604600000\",\"endstationList\":[\"4604600000\"],\"enterpriseCreditCode\":\"9141010070678920XJ\",\"id\":\"5fb6b71f-59f4-4fbc-aa18-a73758cac8e6\",\"inAllocatingBusiness\":0,\"isDelete\":\"0\",\"isfull\":\"0\",\"isthree\":\"0\",\"isvalid\":\"0\",\"landBusineestypeListInfoList\":[{\"applicationformid\":\"74b-4bef-b248-80a95358683f\",\"arrivedaheadtime\":\"0\",\"awba\":\"999-11111111\",\"ext1\":\"123\",\"ext2\":\"123\",\"ext3\":\"进口提货\",\"ext4\":\"B\",\"flightno\":\"CV2212\",\"id\":\"0f9fd8a3-3485-43a3-bf5d-e53908999075\",\"intelligentLockOne\":\"123321\",\"intelligentLockTwo\":\"123321\",\"licenseplatenumber\":\"豫A61CR7\",\"partialidentity\":\"0\"}],\"massageId\":\"202208231451390761\",\"masterList\":\"999-11111111\",\"mediumtype\":\"2\",\"modeTransportation\":\"5\",\"organizationCode\":\"70678920X\",\"prodectTime\":1661237499690,\"remark\":\"123.00\",\"remark3\":\"\",\"trailerFrameNo\":\"豫A61CR7\",\"trailerLicenseNo\":\"超级管理员\",\"trainsconfirmationNumber\":\"\",\"turnoverflag\":\"I\",\"veProperty\":\"超级管理员\"},{\"agentname\":\"ceshi\",\"agentno\":\"ceshi\",\"aisle\":\"4604601012\",\"barcode\":\"74b-4bef-b248-80a95358683f\",\"businesstype\":\"进口提货\",\"cocode\":\"普通货物\",\"createBy\":\"1\",\"createDate\":1661237499690,\"declarePersonnelNumbers\":\"8930000085548\",\"endport\":\"4604\",\"endstation\":\"4604600000\",\"endstationList\":[\"4604600000\"],\"enterpriseCreditCode\":\"9141010070678920XJ\",\"id\":\"a1bd7e91-4a7f-4e36-b525-93f6b21a933a\",\"inAllocatingBusiness\":0,\"isDelete\":\"0\",\"isfull\":\"0\",\"isthree\":\"0\",\"isvalid\":\"0\",\"landBusineestypeListInfoList\":[{\"applicationformid\":\"74b-4bef-b248-80a95358683f\",\"arrivedaheadtime\":\"0\",\"awba\":\"999-11111111\",\"ext1\":\"123\",\"ext2\":\"123\",\"ext3\":\"进口提货\",\"ext4\":\"B\",\"flightno\":\"CV2212\",\"id\":\"0f9fd8a3-3485-43a3-bf5d-e53908999075\",\"intelligentLockOne\":\"123321\",\"intelligentLockTwo\":\"123321\",\"licenseplatenumber\":\"豫A61CR7\",\"partialidentity\":\"0\"}],\"massageId\":\"202208231451390761\",\"masterList\":\"999-11111111\",\"mediumtype\":\"2\",\"modeTransportation\":\"5\",\"organizationCode\":\"70678920X\",\"prodectTime\":1661237499690,\"remark\":\"123.00\",\"remark3\":\"\",\"trailerFrameNo\":\"豫A61CR7\",\"trailerLicenseNo\":\"超级管理员\",\"trainsconfirmationNumber\":\"\",\"turnoverflag\":\"I\",\"veProperty\":\"超级管理员\"},{\"agentname\":\"ceshi\",\"agentno\":\"ceshi\",\"aisle\":\"4604600010\",\"barcode\":\"74b-4bef-b248-80a95358683f\",\"businesstype\":\"进口提货\",\"cocode\":\"普通货物\",\"createBy\":\"1\",\"createDate\":1661237499690,\"declarePersonnelNumbers\":\"8930000085548\",\"endport\":\"4604\",\"endstation\":\"4604600000\",\"endstationList\":[\"4604600000\"],\"enterpriseCreditCode\":\"9141010070678920XJ\",\"id\":\"0fd720f2-31d1-4304-a513-7e1c85713394\",\"inAllocatingBusiness\":0,\"isDelete\":\"0\",\"isfull\":\"0\",\"isthree\":\"0\",\"isvalid\":\"0\",\"landBusineestypeListInfoList\":[{\"applicationformid\":\"74b-4bef-b248-80a95358683f\",\"arrivedaheadtime\":\"0\",\"awba\":\"999-11111111\",\"ext1\":\"123\",\"ext2\":\"123\",\"ext3\":\"进口提货\",\"ext4\":\"B\",\"flightno\":\"CV2212\",\"id\":\"0f9fd8a3-3485-43a3-bf5d-e53908999075\",\"intelligentLockOne\":\"123321\",\"intelligentLockTwo\":\"123321\",\"licenseplatenumber\":\"豫A61CR7\",\"partialidentity\":\"0\"}],\"massageId\":\"202208231451390761\",\"masterList\":\"999-11111111\",\"mediumtype\":\"2\",\"modeTransportation\":\"5\",\"organizationCode\":\"70678920X\",\"prodectTime\":1661237499690,\"remark\":\"123.00\",\"remark3\":\"\",\"trailerFrameNo\":\"豫A61CR7\",\"trailerLicenseNo\":\"超级管理员\",\"trainsconfirmationNumber\":\"\",\"turnoverflag\":\"E\",\"veProperty\":\"超级管理员\"},{\"agentname\":\"ceshi\",\"agentno\":\"ceshi\",\"aisle\":\"4604600011\",\"barcode\":\"74b-4bef-b248-80a95358683f\",\"businesstype\":\"进口提货\",\"cocode\":\"普通货物\",\"createBy\":\"1\",\"createDate\":1661237499690,\"declarePersonnelNumbers\":\"8930000085548\",\"endport\":\"4604\",\"endstation\":\"4604600000\",\"endstationList\":[\"4604600000\"],\"enterpriseCreditCode\":\"9141010070678920XJ\",\"id\":\"5eee7cdd-4851-43bd-a5ff-914a3c618f9a\",\"inAllocatingBusiness\":0,\"isDelete\":\"0\",\"isfull\":\"0\",\"isthree\":\"0\",\"isvalid\":\"0\",\"landBusineestypeListInfoList\":[{\"applicationformid\":\"74b-4bef-b248-80a95358683f\",\"arrivedaheadtime\":\"0\",\"awba\":\"999-11111111\",\"ext1\":\"123\",\"ext2\":\"123\",\"ext3\":\"进口提货\",\"ext4\":\"B\",\"flightno\":\"CV2212\",\"id\":\"0f9fd8a3-3485-43a3-bf5d-e53908999075\",\"intelligentLockOne\":\"123321\",\"intelligentLockTwo\":\"123321\",\"licenseplatenumber\":\"豫A61CR7\",\"partialidentity\":\"0\"}],\"massageId\":\"202208231451390761\",\"masterList\":\"999-11111111\",\"mediumtype\":\"2\",\"modeTransportation\":\"5\",\"organizationCode\":\"70678920X\",\"prodectTime\":1661237499690,\"remark\":\"123.00\",\"remark3\":\"\",\"trailerFrameNo\":\"豫A61CR7\",\"trailerLicenseNo\":\"超级管理员\",\"trainsconfirmationNumber\":\"\",\"turnoverflag\":\"E\",\"veProperty\":\"超级管理员\"},{\"agentname\":\"ceshi\",\"agentno\":\"ceshi\",\"aisle\":\"4604600012\",\"barcode\":\"74b-4bef-b248-80a95358683f\",\"businesstype\":\"进口提货\",\"cocode\":\"普通货物\",\"createBy\":\"1\",\"createDate\":1661237499690,\"declarePersonnelNumbers\":\"8930000085548\",\"endport\":\"4604\",\"endstation\":\"4604600000\",\"endstationList\":[\"4604600000\"],\"enterpriseCreditCode\":\"9141010070678920XJ\",\"id\":\"44bcde85-20ae-4467-a44e-4406396dd0c0\",\"inAllocatingBusiness\":0,\"isDelete\":\"0\",\"isfull\":\"0\",\"isthree\":\"0\",\"isvalid\":\"0\",\"landBusineestypeListInfoList\":[{\"applicationformid\":\"74b-4bef-b248-80a95358683f\",\"arrivedaheadtime\":\"0\",\"awba\":\"999-11111111\",\"ext1\":\"123\",\"ext2\":\"123\",\"ext3\":\"进口提货\",\"ext4\":\"B\",\"flightno\":\"CV2212\",\"id\":\"0f9fd8a3-3485-43a3-bf5d-e53908999075\",\"intelligentLockOne\":\"123321\",\"intelligentLockTwo\":\"123321\",\"licenseplatenumber\":\"豫A61CR7\",\"partialidentity\":\"0\"}],\"massageId\":\"202208231451390761\",\"masterList\":\"999-11111111\",\"mediumtype\":\"2\",\"modeTransportation\":\"5\",\"organizationCode\":\"70678920X\",\"prodectTime\":1661237499690,\"remark\":\"123.00\",\"remark3\":\"\",\"trailerFrameNo\":\"豫A61CR7\",\"trailerLicenseNo\":\"超级管理员\",\"trainsconfirmationNumber\":\"\",\"turnoverflag\":\"E\",\"veProperty\":\"超级管理员\"}]");
}
}
... ...
package com.sy.service.impl;
import com.sy.bwAnalysis.AnalysisRoute;
import com.sy.bwAnalysis.GatherInfoAnalysis;
import com.sy.bwAnalysis.MessageAnalysis;
import com.sy.bwAssist.Message;
import com.sy.model.GatherInfo;
import com.sy.service.RedisService;
import com.sy.service.router.MessageRouter;
import com.sy.service.router.RouterContext;
import org.apache.log4j.PropertyConfigurator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class GatherInfoHandleImplTest {
private static final Logger logger = LoggerFactory.getLogger(GatherInfoHandleImplTest.class);
private AnalysisRoute analysisRoute=new AnalysisRoute();
private static String AREA_BEIHUO= "4604600000";
private static String CHANEL_BEIHUO_I1 = "4604601010";
private static String CHANEL_BEIHUO_E1 = "4604600010";
private static String CHANEL_BEIHUO_E2 = "4604600011";
@Autowired
RedisService redisService;
@Qualifier("X21")
@Autowired
MessageRouter messageRouterX21;
@Qualifier("X22")
@Autowired
MessageRouter messageRouterX22;
//车牌号
private String voNo = "豫A61CR7";
//备案重量
private String vo_weight = "2000";
//过卡重量
private String cross_weight= "2324";
//场站编号
private String areaID = "4604600000";
//通道编号
private String chnlNo = "4604601010";
//进出场类型I/E
private String ie = "I";
//二维码
private String barcode = "613f5c";
//进通道报文
private static String IMPORT_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<MSG>\n" +
"\t<META>\n" +
"\t\t<SNDR>KAO</SNDR>\n" +
"\t\t<RCVR/>\n" +
"\t\t<SEQN>20220624063157</SEQN>\n" +
"\t\t<DDTM>20220624063157</DDTM>\n" +
"\t\t<TYPE>KAKO</TYPE>\n" +
"\t\t<STYP>CARM</STYP>\n" +
"\t</META>\n" +
"\t<GATHER_INFO AREA_ID=\"${areaID}\" CHNL_NO=\"${chnlNo}\" I_E_TYPE=\"${IETYPE}\" SEQ_NO=\"20220624063118000004\">\n" +
"\t\t<IC>\n" +
"\t\t\t<DR_IC_NO/>\n" +
"\t\t\t<IC_DR_CUSTOMS_NO/>\n" +
"\t\t\t<IC_CO_CUSTOMS_NO/>\n" +
"\t\t\t<IC_BILL_NO/>\n" +
"\t\t\t<IC_FORM_TYPE/>\n" +
"\t\t\t<IC_GROSS_WT/>\n" +
"\t\t\t<IC_VE_CUSTOMS_NO/>\n" +
"\t\t\t<IC_VE_NAME/>\n" +
"\t\t\t<IC_CONTA_ID/>\n" +
"\t\t\t<IC_ESEAL_ID/>\n" +
"\t\t\t<IC_REG_DATETIME/>\n" +
"\t\t\t<IC_PER_DAY_DUE/>\n" +
"\t\t\t<GPS_ID/>\n" +
"\t\t</IC>\n" +
"\t\t<WEIGHT>\n" +
"\t\t\t<GROSS_WT>${cross_weight}</GROSS_WT>\n" +
"\t\t</WEIGHT>\n" +
"\t\t<CAR>\n" +
"\t\t\t<VE_NAME>${car}</VE_NAME>\n" +
"\t\t\t<CAR_EC_NO/>\n" +
"\t\t\t<CAR_EC_NO2/>\n" +
"\t\t\t<VE_CUSTOMS_NO/>\n" +
"\t\t\t<VE_WT/>\n" +
"\t\t</CAR>\n" +
"\t\t<CONTA>\n" +
"\t\t\t<CONTA_NUM/>\n" +
"\t\t\t<CONTA_RECO>1</CONTA_RECO>\n" +
"\t\t\t<CONTA_ID_F/>\n" +
"\t\t\t<CONTA_ID_B/>\n" +
"\t\t\t<CONTA_MODEL_F/>\n" +
"\t\t\t<CONTA_MODEL_B/>\n" +
"\t\t</CONTA>\n" +
"\t\t<ORDER_NUM/>\n" +
"\t\t<BAR_CODE>${barcode}</BAR_CODE>\n" +
"\t\t<SEAL>\n" +
"\t\t\t<ESEAL_ID/>\n" +
"\t\t\t<SEAL_KEY/>\n" +
"\t\t</SEAL>\n" +
"\t</GATHER_INFO>\n" +
"</MSG>";
/**
* 进场测试
*/
@Test
public void exportDownload_I() {
//车牌号
String voNo = "豫A61CR7";
//过卡重量
String cross_weight= "1660";
//场站编号
String areaID = AREA_BEIHUO;
//通道编号
String chnlNo = CHANEL_BEIHUO_I1;
//进出场类型I/E
String ie = "I";
//二维码
String barcode = "74b-4bef-b248-80a95358683f";
logger.error("开始进场测试");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
String string = IMPORT_XML.replace("Msg","MSG");
MessageAnalysis analysis = new MessageAnalysis();
Message message = analysis.readTicketsXml(string);
GatherInfoAnalysis gatherInfoAnalysis = new GatherInfoAnalysis();
GatherInfo info = gatherInfoAnalysis.toJavaBean(message);
}
/**
* 出场测试
*/
@Test
public void exportDownload_E(){
PropertyConfigurator.configure("config/log4j.properties");
//车牌号
String voNo = "豫A61CR7";
//过卡重量
String cross_weight= String.valueOf(2000+123);
//场站编号
String areaID = AREA_BEIHUO;
//通道编号
String chnlNo = CHANEL_BEIHUO_E2;
//进出场类型I/E
String ie = "E";
//二维码
String barcode = "22a-47a0-a296-1fe53e37a217";
logger.error("开始出口送货离场测试");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
String string = IMPORT_XML.replace("Msg","MSG");
MessageAnalysis analysis = new MessageAnalysis();
Message message = analysis.readTicketsXml(string);
if ("CARM".equals(message.getMeta().getSmType())) {
//策略判断
if(message.getComInfo() !=null){
RouterContext routerContext = new RouterContext(messageRouterX22);
routerContext.executeStrategy(message);
}else{
RouterContext routerContext = new RouterContext(messageRouterX21);
routerContext.executeStrategy(message);
}
}
}
}
... ...