GatherInfoHandle.java
2.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
package com.sy.bwAnalysis;
import com.sy.bwAssist.Message;
import com.sy.model.GatherInfo;
import com.sy.model.commandInfo;
import org.apache.commons.lang.NullArgumentException;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
/**
* 车辆过卡报文处理器
* @author mrz
*/
@Component
public class GatherInfoHandle implements Runnable{
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
/**
* 1). 非空验证
*/
if (StringUtils.isNotEmpty(message)){
this.message = message;
}else {
throw new NullArgumentException("报文内容为空");
}
}
@Override
public void run() {
/**
* 一. 报文处理
*/
stypConfirmAndRoute();
}
/**
* 1). 通过将xml转实体类进行验证,
* 同时验证报文的合法性,
* 转换失败会throw 异常出来
*/
private Message xmlTransToBean(){
message = message.replace("Msg","MSG");
MessageAnalysis analysis = new MessageAnalysis();
return analysis.readTicketsXml(message);
}
/**
* XML报文类型判断
* 通过META节点的STYP节点判定
*/
private void stypConfirmAndRoute(){
Message messageBean = xmlTransToBean();
String stype = messageBean.getMeta().getSmType();
if ("CARM".equals(stype)) {
if(messageBean.getComInfo() !=null){
CommandInfoAnalysis commandInfoAnalysis = new CommandInfoAnalysis();
commandInfo info = commandInfoAnalysis.toJavaBean(messageBean);
/**
* x22 commandInfo抬杆指令报文的处理
*/
}else{
/**
* x21 gatherInfo通道采集报文的处理
*/
GatherInfoAnalysis gatherInfoAnalysis = new GatherInfoAnalysis();
GatherInfo info = gatherInfoAnalysis.toJavaBean(messageBean);
}
}
}
}