X21FormSingileReleaseCheck.groovy
4.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
package com.sy.groovy
import com.sy.model.GatherInfo
import com.sy.model.LandBusinessTypeList
import com.sy.service.impl.GatherInfoHandle
import org.basis.enhance.groovy.entity.ExecuteParams
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import java.util.stream.Collectors
/**
* 流转申请-核销
* 1. 单进单出即核销判定
* 2. 根据申请单中的通道类型及通道信息判定没有未走完的通道类型,可以核销.比如 申请单证的通道只有进通道,车可以走进一,进二,进二入场,走完进一,即可核销.(一线进)
*/
class X21FormSingileReleaseCheck extends Script {
private final Logger logger = LoggerFactory.getLogger(getClass());
/**x21指令判定
* 传入gatherInfo
*
* 传入从redis读取的申请表体实体,验证
* 进行通道比对
*/
void check(ExecuteParams executeParams) {
try{
// 获取product对象
GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
List<LandBusinessTypeList> formList = (List<LandBusinessTypeList>) executeParams.get("FormList");
// 调用方法
ApplicationContext context = getContext();
// 获取容器中的bean
GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
List<LandBusinessTypeList> temp = new ArrayList<>(formList);
//二维码已出区的记录
List<LandBusinessTypeList> havenCrossList = gatherInfoHandle.listService.selectByBarcodeWithE(gatherInfo.getBarcode());
if (formList == null && formList.isEmpty() ){
logger.error("[FORM-RELEASE-CHECK]-车辆进出场对应申请缓存数据为空:{}",gatherInfo.getBarcode());
return;
}
if (havenCrossList.isEmpty()){
logger.error("[FORM-RELEASE-CHECK]{}:车辆无离场数据,不核销",gatherInfo.getVename());
return;
}
logger.info("[FORM-RELEASE-CHECK]:已过卡数量:[{}]",havenCrossList.size())
//申请核销判定,已出区的记录与流转申请数据核碰.如果流转申请列表核碰完,还剩下的需要出区的场站则不核销.
for (LandBusinessTypeList businessTypeList : havenCrossList) {
List<LandBusinessTypeList> r = formList.stream().filter({item ->
//判断还有没有没有出区的场站,还有没有出区的场站就不核销
logger.debug("[releaseFormCheck-Stream-loop]-缓存与已出核碰,缓存元素场站:[{}],已出记录场站:[{}]",item.getEndstation(),businessTypeList.getEndstation());
//解决缓存那里存储有不一样的把人错的的有问题的点,二维码不一致也把缓存删除
if (!item.getBarcode().equals(businessTypeList.getBarcode())){
return true;
}
if(item.getEndstation().equals(businessTypeList.getEndstation())) {
logger.info("[releaseFormCheck-Stream-loop]-缓存元素场站:[{}],已出记录场站:[{}]-核销判定对碰成功",item.getEndstation(),businessTypeList.getEndstation());
return true;
}else {
return false;
}
}).collect(Collectors.toList());
temp.removeAll(r);
}
logger.info("[FORM-RELEASE-CHECK]-核销判定结果:{}",temp.size());
if (temp.isEmpty()){
//todo:流转申请状态核销
logger.info("[进出场申请]-流转申请开始核销:"+gatherInfo.getVename());
//二维码核销
// gatherInfoHandle.releaseBarCode();
logger.info("[进出场申请]-流转申请已核销:"+gatherInfo.getVename());
}
}catch (Exception e){
e.printStackTrace();
logger.error("[FORM-RELEASE-ERROR]:",e);
}
}
@Override
Object run() {
return false;
}
// 获取spring容器
ApplicationContext getContext() {
// 获取spring IOC容器
ApplicationContext context = applicationContext;
return context;
}
}