CustomsLockServiceImpl.java
9.1 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
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 com.sy.utils.FileTool;
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())) {
//todo:这里后期判定可以复用场站白名单验证
// FileTool.readProperties("station").contains(info.getAreaid());
/**
* 申请业务类型检查
* 调拨业务及分拨业务装载货物为单证的,必须有关锁号
* 就算申请信息里面没关锁号也要通知
*/
LandBusinessTypeList landBusinessTypeList = landBusListService.getLandBusinessTypeListByGather(info);
if (landBusinessTypeList!=null){
if ("调拨业务".equals(landBusinessTypeList.getBusinesstype()) || "分拨业务".equals(landBusinessTypeList.getBusinesstype())) {
String sfAreaid = "4600541001";
String zbqAreaid = "4600329012";
String zbqN3Areaid = "4612199001";
String carEndstationList = redisService.get(info.getVename() + "_endstationList");
if (StringUtils.isNotEmpty(info.getVename()) && StringUtils.isNotEmpty(carEndstationList)){
//涉及综保区场站的申请不核验关锁业务.
if (carEndstationList.contains(zbqAreaid)) {
log.info("[LOCK-CHECK]-申报场站列表包含综保区,不处理关锁业务,当前场站:{}",landBusinessTypeList.getEndstation());
return false;
}
//综保区场站及内三不通知,顺丰场站不通知
if (zbqAreaid.equals(landBusinessTypeList.getEndstation())
|| zbqN3Areaid.equals(landBusinessTypeList.getEndstation())
|| sfAreaid.equals(landBusinessTypeList.getEndstation())
) {
log.info("[LOCK-CHECK]-综保区及内三场站,顺丰场站,不处理关锁业务,当前场站:{}",landBusinessTypeList.getEndstation());
return false;
}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 {
return false;
}
}
}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]-非顺丰场站业务上锁通知");
/**
* 涉及顺丰的场站业务涉及三个场站
* 顺丰的通道没有读解锁设备
* 需要在快邮卡口进行解读锁
*/
//顺丰出通道,首次出不上锁
String sfExportChanel = "4600010001";
if (sfExportChanel.equals(info.getChnlno())) {
log.warn("[UNLOCK-NOTICE]-顺丰货站,不进行上锁通知,{}",info.getBarcode());
return false;
}
return true;
}else {
/**
* 顺丰上锁通知判定,是在第二个离场通道进行施封
* 当前场站是快邮货站出
* 有一个离场信息,那么就上锁通知
*/
//快邮出通道,上锁通知,二次出上锁
String sfExportChanel = "4604110112";
if (sfExportChanel.equals(info.getChnlno()) && e==1){
log.warn("[UNLOCK-NOTICE]-快邮货站,进行上锁通知,{}",info.getBarcode());
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){
//顺丰进通道,解锁通知,末次进不解锁
String sfImportChanel = "4600011001";
if (sfImportChanel.equals(info.getChnlno())) {
log.warn("[UNLOCK-NOTICE]-顺丰货站,不进行解锁通知,{}",info.getBarcode());
return false;
}
//场站信息 与 当前GatherInfo信息又对的上
if (stationList.get(0).equals(info.getAreaid())) {
//通知解锁
log.info("[UNLOCK-NOTICE]-解锁通知");
return true;
}
}
/**
* 顺丰快邮特殊判定
*/
//快邮进通道,解锁通知,二次进锁
String kyImportChanel = "4604111111";
if (kyImportChanel.equals(info.getChnlno()) && stationList.size() == 2 ){
log.info("[UNLOCK-NOTICE]-快邮货站,解锁通知,{}",info.getBarcode());
return true;
}
return false;
}
}