G2Notice.groovy
6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.sy.groovy
import com.alibaba.fastjson.JSON
import com.sy.mapper.LandRouterConfigDao
import com.sy.model.*
import com.sy.service.CommandLogService
import com.sy.service.RedisService
import com.sy.socket.CommandClient
import org.apache.commons.lang.StringUtils
import org.basis.enhance.groovy.entity.ExecuteParams
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
/**
* 金二验放
* 金二通知验放规则
* todo:需要改造成验放型.返回true false,某些业务类型需要强制走金二验放,海关智能卡口配置端也是根据通道进行配置的
*/
class G2Notice extends Script implements ChannelCheckScript {
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
Object run() {
return null
}
Boolean check(ExecuteParams executeParams) {
try{
/**
* X21通道信息与流转信息比对
* 1. 从缓存获取车辆进出场申请信息,有流转信息再进行通道对碰.
* 无流转信息则说明缓存失效或者二维码不对.
*/
GatherInfo info = (GatherInfo) executeParams.get("GatherInfo");
LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
if (landBusinessTypeList!=null){
rightChnelCheck(landBusinessTypeList.getBusinesstype(),info);
}else {
/**
* 对应进出场申请数据
*/
log.error("[G2]-X21与流转信息核碰失败,未有流转缓存或者二维码对碰不成功");
CommandClient.Client(info,"未找到通道对应申报信息,或二维码信息不一致");
record(info,false,"[FormCheck]-未找到通道对应申报信息",null);
}
}catch (Exception e){
e.printStackTrace();
log.error("[LockNoticeCheck-ERR]:",e);
return false;
}
}
// 获取spring容器
ApplicationContext getContext() {
// 获取spring IOC容器
ApplicationContext context = applicationContext;
return context;
}
void rightChnelCheck(String businessType,GatherInfo info){
LandRouterConfig landRouterConfig = new LandRouterConfig();
landRouterConfig.setBusinessType(businessType);
landRouterConfig.setAreaId(info.getAreaid());
ApplicationContext context = getContext();
LandRouterConfigDao landRouterConfigDao = context.getBean(LandRouterConfigDao.class);
//查询此场站此业务类型有无金二业务配置
List<LandRouterConfig> routerConfigs = landRouterConfigDao.selectByBussType(landRouterConfig);
//有金二与业务类型绑定
if (!routerConfigs.isEmpty()){
/**
* 路由配置的卡口 是进出卡口都有 还是只有进或者出
* 根据X21过的通道类型(进卡口/出卡口)来判定,对应流转申报业务类型 的 进出卡口业务是否有金二通道配置
*/
boolean anyMatch = routerConfigs.stream().anyMatch({router-> router.getChanelType().equals(info.getIetype())});
/**
* 有对应卡口进出类型的配置
* 继续判定
* 1 通道是否走对. 走对 将X21报文给金二,由三宝转成X81
* 2 没走对 返回 走错通道.业务结束.
*/
if (anyMatch){
//是否走对通道的判定
for (LandRouterConfig routerConfig : routerConfigs) {
if (routerConfig.getChanelId().equals(info.getChnlno())){
/**
* 查找到金二与通道的验放配置
*/
log.info("[G2-ROUTER]-车辆[{}]流转为金二业务,转金二处理",info.getVename());
//缓存X21,用来接收海关的x82指令核对.收到X22指令后进行核销此缓存.走金二验放的才缓存
cacheWithSeqno(info);
log.debug("[G2-ROUTER-CACHE]-车辆[{}]流转已缓存[SEQNO]:{}",info.getVename(),info.getSeqno());
//将X21报文发给三宝,让三宝发给金二
sendToSample(info);
record(info,true,"已转金二验放-[SEQN]:"+info.getSeqno(),null);
log.info("[G2]>>为[金二业务],已将[{}]过卡信息发送与金二",info.getVename());
return;
}
}
/**
* 没适配上 为走错通道,走错通道直接给指令,不走本地验放.
* 为提高抬杆效率
*/
//todo:走错通道的回执指令处理
log.info("[rightChnelCheck]-走错通道");
CommandClient.Client(info,"G2-走错通道,未找到通道对应申报信息,或二维码信息不一致");
record(info,false,"走错通道-[SEQN]:"+info.getSeqno(),null);
}
/**
* 有对应卡口进出类型的配置.
* 说明没有金二配置
* 走本地
*/
else{
//没有金二配置,走本地
// X21Local(info);
log.info("[G2Notice-CHECK]-通道[{}]没有G2配置",info.getChnlno())
}
}else {
//没有金二配置,走本地
// X21Local(info);
log.info("[G2Notice-CHECK]-通道[{}]没有G2配置",info.getChnlno())
}
}
void record(GatherInfo info, boolean result, String reason, LandBusinessTypeList landBusinessTypeList){
ApplicationContext context = getContext();
CommandLogService commandLogService = context.getBean(CommandLogService.class);
commandLogService.commandlog(info,result,reason,landBusinessTypeList,null,0.0,0.0,0.0,0.0);
}
void sendToSample(GatherInfo info){
CommandClient.gatherInfoBuildAndSend(info);
}
void cacheWithSeqno(GatherInfo info){
ApplicationContext context = getContext();
RedisService redisService = context.getBean(RedisService.class);
if (info!=null && StringUtils.isNotEmpty(info.getSeqno())) {
redisService.set(info.getSeqno(), JSON.toJSONString(info),60*60*24*3);
}
}
}