AnalysisRoute.java
9.5 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
package com.sy.bwAnalysis;
import com.sy.bwAssist.Message;
import com.sy.logic.LiftBar;
import com.sy.logic.LogicOperation;
import com.sy.model.*;
import com.sy.service.*;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.List;
@Component
public class AnalysisRoute implements Runnable{
@Autowired
private aironeExStockService exStockService;
@Autowired
private aironeImStockService imStockService;
@Autowired
private GATService gatService;
@Autowired
private CLRService clrService;
@Autowired
@Qualifier("GatherInfoServiceImpl")
private GatherInfoService infoService;
@Autowired
private CommandInfoService commandService;
@Autowired
private LandBusListService listService;
@Autowired
private ResMessageService resMessageService;
@Autowired
private RepertoryService repertoryService;
protected static final Logger logger = Logger.getLogger(AnalysisRoute.class);
private static AnalysisRoute route;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
private String message;
@PostConstruct
public void init(){
route = this;
route.clrService = this.clrService;
route.exStockService = this.exStockService;
route.imStockService = this.imStockService;
route.gatService = this.gatService;
route.infoService = this.infoService;
route.commandService = this.commandService;
route.listService = this.listService;
route.resMessageService = this.resMessageService;
route.repertoryService = this.repertoryService;
}
/**
* 解析从IMF接收过来的报文
* @param string 报文内容
*/
public void analysis(String string) {
MessageAnalysis analysis = new MessageAnalysis();
CLRAnalysis clrAnalysis = new CLRAnalysis();
ExStockAnalysis exStockAnalysis = new ExStockAnalysis();
ImStockAnalysis imStockAnalysis = new ImStockAnalysis();
GATAnaluysis gatAnaluysis = new GATAnaluysis();
GatherInfoAnalysis gatherInfoAnalysis = new GatherInfoAnalysis();
CommandInfoAnalysis commandInfoAnalysis = new CommandInfoAnalysis();
ResMessageAnalysis resMessageAnalysis = new ResMessageAnalysis();
PropertyConfigurator.configure("config/log4j.properties");
string = string.replace("Msg","MSG");
Message message = analysis.readTicketsXml(string);
String stype = message.getMeta().getSmType();
if (stype.equals("CARM")) {
if(message.getComInfo() !=null){
CommandInfoX22 info = commandInfoAnalysis.toJavaBean(message);
route.commandService.save(info);
}else{
//处理车辆过磅数据,结合申请数据,判定是否抬杆
GatherInfo info = gatherInfoAnalysis.toJavaBean(message);
if(info.getBarcode().length()>0){
//LogicOperation.operation(info)
try {
LiftBar lift = new LiftBar();
if(lift.liftBar(info)){
String type = null;
if("I".equals(info.getIetype())){
type="进入";
}else{
type="离开";
}
logger.info("进出站业务申请成功");
logger.info("------->>>>>>>"+info.getVename()+"已"+type+info.getAreaid()+"场站<<<<<<<-----");
}
} catch (InterruptedException e) {
logger.error(e);
e.printStackTrace();
}
}else{
if("4604000000".equals(info.getAreaid())){
if("I".equals(info.getIetype())){
LogicOperation.sendData("HK05",info.getVename(),false);
}else{
LogicOperation.sendData("HK06",info.getVename(),false);
}
}
//todo:这里场站看下
}
route.infoService.save(info);
}
} else if (stype.equals("ES1")) {
airone_ex_stock exStock = exStockAnalysis.toExStock(message);
T_AIR_REPERTORY repertory = route.repertoryService.selectByPermaryKey(exStock.getMawbNo());
if(repertory!=null){
if(repertory.getCnt()>exStock.getCnt().longValue() && repertory.getWt().longValue()>exStock.getWt().longValue()){
repertory.setCnt(repertory.getCnt()-exStock.getCnt().longValue());
repertory.setWt(repertory.getWt().subtract(exStock.getWt()));
repertory.setUpdateTime(new Date());
route.repertoryService.updateEntry(repertory);
}
}else{
T_AIR_REPERTORY airRepertoryrepertory = new T_AIR_REPERTORY();
airRepertoryrepertory.setAreaCode(exStock.getAreaCode());
airRepertoryrepertory.setSupCode(exStock.getSupCode());
airRepertoryrepertory.setSupName(exStock.getSupName());
airRepertoryrepertory.setVoyageNo(exStock.getVoyageNo());
airRepertoryrepertory.setIeDate(exStock.getIeDate());
airRepertoryrepertory.setMawbNo(exStock.getMawbNo());
airRepertoryrepertory.setIeFlag(exStock.getIeFlag());
airRepertoryrepertory.setCnt(exStock.getCnt().longValue());
airRepertoryrepertory.setWt(exStock.getWt());
airRepertoryrepertory.setGoodName(exStock.getgName());
airRepertoryrepertory.setCopCode(exStock.getCopCode());
airRepertoryrepertory.setCopName(exStock.getCopName());
airRepertoryrepertory.setOpCode(exStock.getInputCode());
airRepertoryrepertory.setCreateDate(new Date());
route.repertoryService.insertEntry(airRepertoryrepertory);
}
route.exStockService.save(exStock);
} else if (stype.equals("CLR")) {
v_express_billno billno = clrAnalysis.toBill(message);
route.clrService.save(billno);
} else if (stype.equals("IS1")) {
airone_im_stock imStock = ImStockAnalysis.toImStock(message);
T_AIR_REPERTORY repertory = route.repertoryService.selectByPermaryKey(imStock.getMawbNo());
if(repertory!=null){
repertory.setCnt(repertory.getCnt()+imStock.getCnt());
repertory.setWt(repertory.getWt().add(imStock.getWt()));
repertory.setUpdateTime(new Date());
route.repertoryService.updateEntry(repertory);
}else{
T_AIR_REPERTORY airRepertoryrepertory = new T_AIR_REPERTORY();
airRepertoryrepertory.setAreaCode(imStock.getAreaCode());
airRepertoryrepertory.setSupCode(imStock.getSupCode());
airRepertoryrepertory.setSupName(imStock.getSupName());
airRepertoryrepertory.setVoyageNo(imStock.getVoyageNo());
airRepertoryrepertory.setIeDate(imStock.getIeDate());
airRepertoryrepertory.setMawbNo(imStock.getMawbNo());
airRepertoryrepertory.setCnt(imStock.getCnt());
airRepertoryrepertory.setWt(imStock.getWt());
airRepertoryrepertory.setIeFlag(imStock.getIeFlag());
airRepertoryrepertory.setGoodName(imStock.getgName());
airRepertoryrepertory.setCopCode(imStock.getCopCode());
airRepertoryrepertory.setCopName(imStock.getCopName());
airRepertoryrepertory.setOpCode(imStock.getInputCode());
airRepertoryrepertory.setCreateDate(new Date());
route.repertoryService.insertEntry(airRepertoryrepertory);
}
route.imStockService.save(imStock);
} else if (stype.equals("GAT")) {
port_manifest_head portHead = gatAnaluysis.toPortHead(message);
route.gatService.savePortHead(portHead);
List<port_manifest_body> portBody = gatAnaluysis.toPortBody(message);
for (int a = 0; a<portBody.size();a++){
route. gatService.savePortBody(portBody.get(a));
}
port_manifest_head_stat portStat = gatAnaluysis.toPortStat(message);
route.gatService.savePortStat(portStat);
} else if(stype.equals("CDHZ")){
if("MT9999".equals(message.getManifest().getHead().getMessageType())){
RESMESSAGE resmessage = resMessageAnalysis.saveEntry(message.getManifest());
RESMESSAGE msg =route.resMessageService.selectByManifest(resmessage.getManifest());
//放行回执中 有航班号的放行回执才入库
if(msg==null && StringUtils.isNotEmpty(resmessage.getJourneyid())){
route.resMessageService.saveEnter(resmessage);
}
}
}
}
@Override
public void run() {
analysis(message);
}
}