作者 朱兆平

关锁业务处理:

1. 新增配置文件增加关锁通知接口地址配置
2. 新增关锁施解封逻辑判定
3. 新增关锁回调接口
4. 更新X21插入关锁通知判定逻辑
5. 更新gatherinfoHandle插入关锁判定
6. 流转申请实体类增加关锁字段
... ... @@ -84,5 +84,7 @@ nmms.interface.host=http://10.50.3.82:8081/
nmms.site.host=http://nmms1.15miaoo.com:17999
custom.receptDirectory= bw/read/
# 卡口指令通知接口
interface.lock.url=http://127.0.0.1:8848
devdebug=true
g2.onoff=false
... ...
package com.sy.controller;
import com.alibaba.fastjson.JSON;
import com.sy.model.GatherInfo;
import com.sy.model.LockFeedBack;
import com.sy.model.LockFeignResponse;
import com.sy.model.NoticeLock;
import com.sy.response.ResultJson;
import com.sy.service.CommandLogService;
import com.sy.service.CustomsLockService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/lock")
@Slf4j
public class CustomsLockController {
@Autowired
CustomsLockService customsLockService;
@Autowired
CommandLogService commandLogService;
@PostMapping("response")
public ResultJson lockResponse(@RequestBody LockFeedBack feedBack){
if (StringUtils.isEmpty(feedBack.barcode)){
return new ResultJson("400","缺少二维码信息","缺少二维码信息");
}
log.info("收到关锁通知");
StringBuilder sb = new StringBuilder();
sb.append("施解封时间:").append(feedBack.locktime).append("\n")
.append("关锁秘钥:").append(feedBack.secret).append("\n")
.append("施解封内容:").append(feedBack.feedbackconten).append("\n")
.append("施解封状态:").append(feedBack.feedbackcode).append("\n");
String LOCK_TYPE_UNLOCK = "2";
/**
* 关锁施解封类型
* 1 施封
* 2 解封
*/
String LOCK_TYPE_LOCK = "1";
if (LOCK_TYPE_LOCK.equals(feedBack.type)){
sb.append("施解封类型:").append("施封").append("\n");
}else if (LOCK_TYPE_UNLOCK.equals(feedBack.type)){
sb.append("施解封类型:").append("解封").append("\n");
}else {
sb.append("施解封类型:").append("未知").append("\n");
sb.append("施解封类型:").append(feedBack.type).append("\n");
}
//判定关锁返回结果,结果正常,继续走抬杆指令,结果异常 不走抬杆指令,转人工抬杆
/**
* 关锁通知施解封状态
* 01 成功
* 02 失败
*/
String LOCK_SUCCESS = "01";
if(LOCK_SUCCESS.equals(feedBack.feedbackcode)){
//读取缓存
GatherInfo gatherInfo = customsLockService.cacheRead(feedBack.barcode);
sb.append("成功");
if (gatherInfo!=null){
commandLogService.commandlog(gatherInfo,true,sb.toString(),null,null,0.0,0.0,0.0,0.0);
customsLockService.localGatherInfoHandle(gatherInfo);
}else {
sb.append("关锁缓存信息读取失败");
gatherInfo = new GatherInfo();
gatherInfo.setBarcode(feedBack.barcode);
commandLogService.commandlog(gatherInfo,false,sb.toString(),null,null,0.0,0.0,0.0,0.0);
log.info("[LOCK-RSP]-关锁缓存信息读取失败");
}
}else {
sb.append("关锁缓存信息读取失败");
GatherInfo gatherInfo = new GatherInfo();
gatherInfo.setBarcode(feedBack.barcode);
commandLogService.commandlog(gatherInfo,false,sb.toString(),null,null,0.0,0.0,0.0,0.0);
log.info("[LOCK-RSP]-关锁施解封失败");
}
return new ResultJson("200","success");
}
}
... ...
package com.sy.controller;
import com.alibaba.fastjson.JSON;
import com.sy.model.GatherInfo;
import com.sy.model.LockFeedBack;
import com.sy.model.LockFeignResponse;
import com.sy.model.NoticeLock;
import com.sy.response.ResultJson;
import com.sy.service.CommandLogService;
import com.sy.service.CustomsLockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
public class CustomsLockTestController {
@PostMapping("/bizApi/noticeLock")
public LockFeignResponse lockTest(@RequestBody NoticeLock noticeLock){
log.info("测试接口接收到关锁通知施解封:{}", JSON.toJSONString(noticeLock));
LockFeignResponse lockFeignResponse = new LockFeignResponse();
lockFeignResponse.success=true;
lockFeignResponse.code=0;
lockFeignResponse.message="关锁通知测试接收成功";
return lockFeignResponse;
}
}
... ...
... ... @@ -59,4 +59,22 @@ public interface LandBusinessTypeListMapper {
//查询出场申请为最后一个
int selectlaststation(@Param("trailerFrameNo") String trailerFrameNo, @Param("barcode") String barcode);
/**
* 首次离场查询
* @param barcode 二维码
* @param trailerFrameNo 车牌
* @param turnoverflag 进出标识
* @return 0 代表首次离场,大于0代表非首次离场已经产生过离场记录
*/
int selectFirstLeave(@Param("trailerFrameNo") String trailerFrameNo, @Param("barcode") String barcode,
@Param("turnoverflag") String turnoverflag);
/**
* 查询二维码车辆进出场记录信息
* @param trailerFrameNo
* @param barcode
* @return
*/
List<LandBusinessTypeList> selectHistory (@Param("trailerFrameNo") String trailerFrameNo, @Param("barcode") String barcode);
}
... ...
... ... @@ -11,6 +11,13 @@ public interface LandListDao {
LandList selectByPrimaryKey(String id);
/**
* 根据二维码找申请单的关锁信息
* @param barcode 二维码, 二维码要做数据库的唯一索引
* @return 申请单信息
*/
LandList selectLockInfoByBarcode(String barcode);
int updateByPrimaryKeySelective(LandList record);
int updateByPrimaryKey(LandList record);
... ...
... ... @@ -13,6 +13,8 @@ public class LAND_BUSINEESTYPE_LIST_INFO {
private String applicationformid;
private String endcarlogo;
private String ext1;
private String ext2;
... ... @@ -21,6 +23,11 @@ public class LAND_BUSINEESTYPE_LIST_INFO {
private String ext4;
private String flightno;
private String piece;
public String getId() {
return id;
}
... ... @@ -100,4 +107,29 @@ public class LAND_BUSINEESTYPE_LIST_INFO {
public void setExt4(String ext4) {
this.ext4 = ext4 == null ? null : ext4.trim();
}
public String getEndcarlogo() {
return endcarlogo;
}
public void setEndcarlogo(String endcarlogo) {
this.endcarlogo = endcarlogo;
}
public String getFlightno() {
return flightno;
}
public void setFlightno(String flightno) {
this.flightno = flightno;
}
public String getPiece() {
return piece;
}
public void setPiece(String piece) {
this.piece = piece;
}
}
... ...
package com.sy.model;
import java.util.Date;
import java.util.List;
public class LandBusinessTypeList {
private String id;
... ... @@ -69,6 +70,10 @@ public class LandBusinessTypeList {
private String veProperty;
private List<String> endstationList;
private List<LAND_BUSINEESTYPE_LIST_INFO> landBusineestypeListInfoList;
public String getIsthree() {
return isthree;
}
... ... @@ -342,4 +347,21 @@ public class LandBusinessTypeList {
public void setVeProperty(String veProperty) {
this.veProperty = veProperty;
}
public List<String> getEndstationList() {
return endstationList;
}
public void setEndstationList(List<String> endstationList) {
this.endstationList = endstationList;
}
public List<LAND_BUSINEESTYPE_LIST_INFO> getLandBusineestypeListInfoList() {
return landBusineestypeListInfoList;
}
public void setLandBusineestypeListInfoList(List<LAND_BUSINEESTYPE_LIST_INFO> landBusineestypeListInfoList) {
this.landBusineestypeListInfoList = landBusineestypeListInfoList;
}
}
... ...
... ... @@ -205,5 +205,11 @@ public class LandList implements Serializable {
*/
private String modeTransportation;
/**
* 关锁号
*/
private String lockNum;
private static final long serialVersionUID = 1L;
}
... ...
package com.sy.model;
/**
* 关锁回调接口实体
* @author mrz
*/
public class LockFeedBack {
/**
* 二维码
*/
public String barcode;
/**
* 施解封状态
*/
public String feedbackcode;
/**
* 施解封描述
*/
public String feedbackconten;
/**
* 关锁秘钥
*/
public String secret;
/**
* 施解封时间
*/
public String locktime;
/**
* 施解封类型 ,1 施封 2 解封
*/
public String type;
}
... ...
package com.sy.model;
/**
* 关锁通知响应实体
*/
public class LockFeignResponse {
//接口成功失败标识
public boolean success;
//返回码 0 成功,-1失败
public Integer code;
//返回对象实体
public Object data;
//返回信息描述
public String message;
public LockFeignResponse(boolean success, Integer code) {
this.success = success;
this.code = code;
}
public LockFeignResponse() {
}
}
... ...
package com.sy.model;
/**
* 关锁通知实体
*/
public class NoticeLock {
//二维码
public String barcode;
//车牌号
public String vehicleNo;
//关锁号
public String lockNo;
//场站编号
public String areaId;
//通道编号
public String chnlNo;
//1 施封,2解封,施解封类型
public String type;
}
... ...
package com.sy.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author 子诚
* Description:返回结果封装类
* 时间:2020/7/01 10:06
*/
@Data
public class ResultJson<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 响应业务状态,默认为200
*/
private String code;
/**
* 响应消息
*/
private String msg;
/**
* 错误消息内容
*/
private String error;
/**
* 数据总条数
*/
private Integer total;
/**
* 响应数据
*/
private T data;
/**
* JWT令牌
*/
private String jwtToken;
/**
* 无参,构造方法
*/
public ResultJson()
{
}
/**
* 定义有参构造器
*
* @param code 响应状态
* @param msg 响应消息
*/
public ResultJson(String code, String msg)
{
this.code = code;
this.msg = msg;
}
/**
* 定义有参构造器
*
* @param code 响应状态
* @param msg 响应消息
* @param data 响应数据
*/
public ResultJson(String code, String msg, T data)
{
this.code = code;
this.msg = msg;
this.data = data;
}
public ResultJson(String code, String msg, String error)
{
this.code = code;
this.msg = msg;
this.error = error;
}
public ResultJson(String code, String msg, T data, Integer total)
{
this.code = code;
this.msg = msg;
this.data = data;
this.total = total;
}
/**
* 定义静态、成功方法(重载)
*
* @return 成功(没有响应数据)
*/
public static ResultJson success()
{
return new ResultJson<>("200", "success");
}
public static ResultJson success(String msg)
{
return new ResultJson<>("200", msg);
}
/**
* 定义静态、成功方法(重载)
*
* @return 成功(响应数据)
*/
public static ResultJson success(Object data)
{
return new ResultJson<>("200", "success", data);
}
/**
* 定义静态、成功方法(重载)
*
* @return 成功(响应数据)
*/
public static ResultJson success(String message, Object data)
{
return new ResultJson<>("200", message, data);
}
}
... ...
package com.sy.service;
import com.sy.model.GatherInfo;
/**
* 关锁业务接口
* @author mrz
*/
public interface CustomsLockService {
/**
* 上关锁通知
*/
void lockNotice();
/**
* 解关锁通知
*/
void unLockNotice();
/**
* 关锁通知消息缓存
* key为二维码
* value 为GatherInfo
*/
void cacheWrite(GatherInfo info);
/**
* 读取关锁消息缓存
* 关锁回调处理
*/
GatherInfo cacheRead(String barcode);
/**
* 回调读取缓存,继续处理抬杆业务
*/
void localGatherInfoHandle(GatherInfo info);
/**
* 判断是否需要通知
* 判定要素
* 1. 流转申请携带关锁号-这个判定取消
* 2. 业务类型为分拨业务或者调拨业务
* 3. 场站含综保区不涉及关锁
* 4. 流转申请中的货物有单证又是多场站,多场站又不包含综保区必须为关锁业务
* 5. 顺丰上锁通知的问题
* @param info 车辆过卡信息
* @return true 需要通知,走关锁业务
*/
boolean lockNoticeCheck(GatherInfo info);
/**
* 是否上锁通知判定
* @return
*/
boolean lockCheck(GatherInfo info);
/**
* 是否解锁通知判定
* @param info
* @return
*/
boolean unLockCheck(GatherInfo info);
}
... ...
... ... @@ -45,4 +45,15 @@ public interface LandBusListService {
*/
LandBusinessTypeList getLandBusinessTypeListByGather(GatherInfo info);
List<LandBusinessTypeList> getLandBusinessTypeListsByGather(GatherInfo info);
/**
* 首次离场查询
* @param barcode 二维码
* @param trailerFrameNo 车牌
* @param turnoverflag 进出标识
* @return 0 代表首次离场,大于0代表非首次离场已经产生过离场记录
*/
int selectFirstLeave(String trailerFrameNo, String barcode, String turnoverflag);
}
... ...
package com.sy.service.feigin;
import com.sy.model.LockFeignResponse;
import com.sy.model.NoticeLock;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author mrz
*/
@Component
@Slf4j
public class LockFeignFallBackFactory implements FallbackFactory<LockFeignService> {
@Override
public LockFeignService create(Throwable throwable) {
log.error("调用关锁通知接口异常",throwable);
return new LockFeignService() {
@Override
public LockFeignResponse noticeLock(NoticeLock noticeLock) {
return new LockFeignResponse(false,-1);
}
};
}
}
... ...
package com.sy.service.feigin;
import com.sy.model.LockFeignResponse;
import com.sy.model.NoticeLock;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
/**
* 关锁通知接口
* @author mrz
*/
@FeignClient(name = "LOCK-SERVER",url = "${interface.lock.url}",fallbackFactory = LockFeignFallBackFactory.class)
public interface LockFeignService {
@PostMapping("/bizApi/noticeLock")
LockFeignResponse noticeLock(@RequestBody NoticeLock noticeLock);
}
... ...
... ... @@ -28,4 +28,8 @@ public class GatherInfoServiceImpl implements GatherInfoService {
}
@Override
public boolean haveLockNum(String barcode) {
return false;
}
}
... ...
... ... @@ -10,6 +10,7 @@ import com.sy.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -137,7 +138,7 @@ public class LandBusListServiceImpl implements LandBusListService {
/**
* 通道对碰有了.二维码不一致怎么办?
*/
if (item.getAisle().equals(gatherInfo.getChnlno())){
if (item.getBarcode().equals(gatherInfo.getBarcode()) && item.getAisle().equals(gatherInfo.getChnlno())){
if (item.getBarcode().equals(gatherInfo.getBarcode())){
log.info("车辆-{}的申请缓存信息核碰成功,通道:{}",gatherInfo.getVename(),gatherInfo.getChnlno());
return item;
... ... @@ -160,4 +161,35 @@ public class LandBusListServiceImpl implements LandBusListService {
return null;
}
@Override
public List<LandBusinessTypeList> getLandBusinessTypeListsByGather(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()) {
log.error(gatherInfo.getVename()+"无相对应进出场申请");
return null;
}
return list;
}else {
log.error("未找到车辆-{}的申请缓存信息",gatherInfo.getVename());
log.info("未找到车辆-{}的申请缓存信息,或者流转已超期失效",gatherInfo.getVename());
return null;
}
}catch (Exception e){
log.error("{}获取流转缓存异常",gatherInfo.getVename(),e);
return null;
}
}
@Override
public int selectFirstLeave(String trailerFrameNo, String barcode, String turnoverflag){
return listMapper.selectFirstLeave(trailerFrameNo, barcode, turnoverflag);
}
}
... ...
package com.sy.service.lock;
import com.alibaba.fastjson.JSONObject;
import com.sy.mapper.LandBusinessTypeListMapper;
import com.sy.mapper.LandListDao;
import com.sy.model.GatherInfo;
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
import com.sy.model.LandBusinessTypeList;
import com.sy.model.LandList;
import com.sy.service.CustomsLockService;
import com.sy.service.LandBusListService;
import com.sy.service.RedisService;
import com.sy.service.impl.GatherInfoHandle;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* 关锁业务处理
* @author mrz
*/
@Slf4j
@Service
public class CustomsLockServiceImpl implements CustomsLockService {
@Resource
private LandListDao landListDao;
@Autowired
private RedisService redisService;
@Autowired
private LandBusListService landBusListService;
@Resource
private LandBusinessTypeListMapper landBusinessTypeListMapper;
/**
* 缓存关锁相关前缀
*/
private static String LOCK_PRE="LOCK-";
@Override
public void lockNotice() {
}
@Override
public void unLockNotice() {
}
@Override
public void cacheWrite(GatherInfo info) {
redisService.set(LOCK_PRE+info.getBarcode(),
JSONObject.toJSONString(info),
60*60*6);
}
@Override
public GatherInfo cacheRead(String barcode) {
String jsonStr = redisService.get(LOCK_PRE+barcode);
if (StringUtils.isNotEmpty(jsonStr)){
GatherInfo gatherInfo = JSONObject.parseObject(jsonStr, GatherInfo.class);
return gatherInfo;
}
return null;
}
@Override
public void localGatherInfoHandle(GatherInfo gatherInfo) {
GatherInfoHandle gatherInfoHandle = new GatherInfoHandle();
gatherInfoHandle.handel(gatherInfo);
}
@Override
public boolean lockNoticeCheck(GatherInfo info) {
if (info!=null && StringUtils.isNotEmpty(info.getBarcode())) {
/**
* 申请业务类型检查
* 调拨业务及分拨业务装载货物为单证的,必须有关锁号
* 就算申请信息里面没关锁号也要通知
*/
LandBusinessTypeList landBusinessTypeList = landBusListService.getLandBusinessTypeListByGather(info);
if (landBusinessTypeList!=null){
if ("调拨业务".equals(landBusinessTypeList.getBusinesstype()) || "分拨业务".equals(landBusinessTypeList.getBusinesstype())) {
//综保区场站及内三不通知
if ("4600329012".equals(landBusinessTypeList.getEndstation()) || "4612199001".equals(landBusinessTypeList.getEndstation())) {
log.info("[LOCK-CHECK]-综保区及内三场站不处理关锁业务,当前场站:{}",landBusinessTypeList.getEndstation());
return false;
//场站检查,todo:快邮场站特殊判定
}else {
return true;
/**
* 单证验证-取消
*/
// List<LAND_BUSINEESTYPE_LIST_INFO> land_busineestype_list_infos = landBusinessTypeList.getLandBusineestypeListInfoList();
// if (!land_busineestype_list_infos.isEmpty()){
// LAND_BUSINEESTYPE_LIST_INFO list_info = land_busineestype_list_infos.stream().parallel()
// .filter(item -> "B".equals(item.getExt4()))
// .findAny().orElse(null);
//
// //包含单证
// if (list_info!=null){
// log.info("[LOCK-CHECK]-包含单证,开始关锁通知");
// return true;
// }
// }
}
}
}else {
log.info("[LOCK-CHECK]-无对应进出场申请");
return false;
}
}
return false;
}
@Override
public boolean lockCheck(GatherInfo info) {
int e = landBusListService.selectFirstLeave(info.getVename(), info.getBarcode(), "E");
if (e==0){
//首次离场,通知关锁接口 上锁
log.info("[UNLOCK-NOTICE]-上锁通知");
return true;
}
return false;
}
@Override
public boolean unLockCheck(GatherInfo info){
//从缓存获取通道流转列表信息
List<LandBusinessTypeList> landBusinessTypeListsByGather = landBusListService.getLandBusinessTypeListsByGather(info);
List<LandBusinessTypeList> temp = landBusinessTypeListsByGather;
//已经过场的记录
List<LandBusinessTypeList> landBusinessTypeLists = landBusinessTypeListMapper.selectHistory(info.getVename(), info.getBarcode());
for (LandBusinessTypeList formItem : landBusinessTypeLists) {
List<LandBusinessTypeList> r = landBusinessTypeListsByGather.stream().filter(item -> {
if (item.getEndstation().equals(formItem.getEndstation())) {
log.info("[Lock-Stream-loop]-缓存元素场站:[{}],已出入记录场站:[{}]-核销判定对碰成功", item.getEndstation(), formItem.getEndstation());
return true;
} else {
return false;
}
}).collect(Collectors.toList());
temp.removeAll(r);
}
//筛选出未入场的申请
List<String> stationList = temp.stream().map(LandBusinessTypeList::getEndstation).distinct().collect(Collectors.toList());
log.info("[unLockCheck]-未走的流转申请:{}",temp.size());
//判定是否还剩最后一个场站未入场
if (stationList.size() == 1){
//场站信息 与 当前GatherInfo信息又对的上
if (stationList.get(0).equals(info.getAreaid())) {
//通知解锁
log.info("[UNLOCK-NOTICE]-解锁通知");
return true;
}
}
return false;
}
}
... ...
... ... @@ -3,14 +3,14 @@ package com.sy.service.router;
import com.alibaba.fastjson.JSON;
import com.sy.bwAnalysis.GatherInfoAnalysis;
import com.sy.bwAssist.Message;
import com.sy.mapper.LandListDao;
import com.sy.mapper.LandRouterConfigDao;
import com.sy.model.G2Bean;
import com.sy.model.GatherInfo;
import com.sy.model.LandBusinessTypeList;
import com.sy.model.LandRouterConfig;
import com.sy.model.*;
import com.sy.service.CommandLogService;
import com.sy.service.CustomsLockService;
import com.sy.service.LandBusListService;
import com.sy.service.RedisService;
import com.sy.service.feigin.LockFeignService;
import com.sy.service.impl.GatherInfoHandle;
import com.sy.socket.CommandClient;
import lombok.extern.slf4j.Slf4j;
... ... @@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.net.ConnectException;
import java.util.List;
/**
... ... @@ -49,6 +50,24 @@ public class MessageRouterX21 implements MessageRouter {
@Autowired
private CommandLogService commandLogService;
@Autowired
private CustomsLockService customsLockService;
@Autowired
private LockFeignService lockFeignService;
@Resource
private LandListDao landListDao;
/**
* 入场标识
*/
private static String IN_TYPE="I";
/**
* 离场标识
*/
private static String OUT_TYPE="E";
@Override
public void route(Message message) {
log.info("处理X21:gatherInfo,[switch]-G2开关状态:[{}]",g2Bean.getOnoff());
... ... @@ -202,14 +221,73 @@ public class MessageRouterX21 implements MessageRouter {
* 本地处理
*/
private void X21Local(GatherInfo info){
//先判定关锁业务
if (lockHandle(info)) {
log.info("[{}]-关锁通知,等待回调",info.getBarcode());
}else {
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);
}
//关锁施解封通知判定
private boolean lockHandle(GatherInfo info){
//需要关锁业务通知
if (customsLockService.lockNoticeCheck(info)){
/**
* 关锁号申请检查
* 根据二维码查申请是否有关锁信息,没有查到实体返回null
*/
LandList landList = landListDao.selectLockInfoByBarcode(info.getBarcode());
if (landList!=null && StringUtils.isNotEmpty(landList.getLockNum())) {
log.info("[LOCK-CHECK]-流转申请携带关锁,二维码:{}",info.getBarcode());
NoticeLock noticeLock = new NoticeLock();
noticeLock.barcode = info.getBarcode();
noticeLock.areaId = info.getAreaid();
noticeLock.chnlNo = info.getChnlno();
noticeLock.vehicleNo = info.getVename();
//1. 判定是上锁通知还是解锁通知
if (OUT_TYPE.equals(info.getIetype()) && customsLockService.lockCheck(info)) {
//写入缓存
customsLockService.cacheWrite(info);
//接口通知
noticeLock.lockNo =landList.getLockNum();
noticeLock.type = "1";
LockFeignResponse lockFeignResponse = lockFeignService.noticeLock(noticeLock);
log.info("[LOCK-API-RSP]-关锁通知接口返回,code:{},message:{},success:{}",lockFeignResponse.code,lockFeignResponse.message,lockFeignResponse.success);
record(info,false,"关锁施封通知中,等待下一步指令",null);
return true;
}else {
if (IN_TYPE.equals(info.getIetype()) && customsLockService.unLockCheck(info)) {
customsLockService.cacheWrite(info);
//接口通知
noticeLock.lockNo =landList.getLockNum();
noticeLock.type = "2";
LockFeignResponse lockFeignResponse = lockFeignService.noticeLock(noticeLock);
log.info("[LOCK-API-RSP]-关锁通知接口返回,code:{},message:{},success:{}",lockFeignResponse.code,lockFeignResponse.message,lockFeignResponse.success);
record(info,false,"关锁解封通知中,等待下一步指令",null);
return true;
}
}
}else {
CommandClient.Client(info,"流转业务-未申请关锁号");
record(info,false,"业务异常:流转业务-未申请关锁号",null);
//这里需要返回true,是关锁业务,但是中断,不抬杆不放行,给予关锁业务异常通知
return true;
}
}
return false;
}
}
... ...
... ... @@ -84,6 +84,25 @@
and TURNOVERFLAG = #{turnoverflag,jdbcType=VARCHAR}
AND AISLEWT IS NOT NULL AND REMARK IS NOT NULL
</select>
<select id="selectFirstLeave" parameterType="java.lang.String" resultType="java.lang.Integer">
select
count(BARCODE)
from land_businesstype_list
where
BARCODE = #{barcode,jdbcType=VARCHAR}
and TRAILER_FRAME_NO = #{trailerFrameNo,jdbcType=VARCHAR}
and TURNOVERFLAG = 'E'
and ISVALID = '1'
</select>
<select id="selectHistory" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from land_businesstype_list
where
BARCODE = #{barcode,jdbcType=VARCHAR}
and TRAILER_FRAME_NO = #{trailerFrameNo,jdbcType=VARCHAR}
and ISVALID = '1'
</select>
<update id="updateisvalid" parameterType="java.lang.String">
update land_businesstype_list set ISVALID = '1' where
TRAILER_FRAME_NO = #{trailerFrameNo,jdbcType=VARCHAR}
... ...
... ... @@ -44,6 +44,7 @@
<result column="ORGANIZATION_CODE" jdbcType="VARCHAR" property="organizationCode" />
<result column="DECLARE_PERSONNEL_NUMBERS" jdbcType="VARCHAR" property="declarePersonnelNumbers" />
<result column="MODE_TRANSPORTATION" jdbcType="VARCHAR" property="modeTransportation" />
<result column="LOCK_NUM" jdbcType="VARCHAR" property="lockNum" />
</resultMap>
<sql id="Base_Column_List">
id, MASSAGE_ID, TRAILER_FRAME_NO, TRAILER_LICENSE_NO, MASTER_LIST, PRODECT_TIME,
... ... @@ -60,6 +61,13 @@
from land_list
where id = #{id,jdbcType=VARCHAR}
</select>
<select id="selectLockInfoByBarcode" parameterType="java.lang.String" resultMap="BaseResultMap">
select
LOCK_NUM
from land_list
where BARCODE = #{barcode,jdbcType=VARCHAR}
and ISVALID = '0'
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from land_list
where id = #{id,jdbcType=VARCHAR}
... ...