CustomsLockServiceImpl.java
6.3 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
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;
}
}