CDHZSender.java
2.4 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
package com.airport.core;
import com.airport.bean.MessageBak;
import com.airport.bean.XMLHeader;
import com.airport.dao.Dao;
import com.airport.dao.impl.DaoImpl;
import com.airport.util.ConfigUtils;
import com.airport.util.SystemBean;
import com.airport.util.Utils;
import com.airport.util.parse.IMFXMLMaker;
import com.airport.util.parse.XMPParse;
import com.caac.imf.api.IMFClient;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class CDHZSender extends Thread {
private static final Logger logger = Logger.getLogger(IMFNoDelaySender.class);
private Dao dao = (DaoImpl) SystemBean.getBean("dao");
private IMFClient client;
private String indexFileName; //记录发送数据的节点
private String sql;
private String sqlMax;
public CDHZSender(IMFClient client, String fileName,String sql,String sqlMax) {
this.indexFileName = fileName;
this.client = client;
this.sql=sql;
this.sqlMax=sqlMax;
}
public void run() {
try {
if (this.client == null) {
logger.info("IMFClient has been closed");
return;
}
String msg = "<MSG><META><SNDR>KAKO</SNDR><RCVR/><SEQN>Z-001</SEQN><DDTM>20181008112408256</DDTM><TYPE>KAKO</TYPE><STYP>CARM</STYP></META><BODY>TEST</BODY></MSG>";
sendXml(msg);
}catch (Exception var14) {
var14.printStackTrace();
logger.info(var14.getMessage());
}
}
public synchronized void sendXml(String msg){
logger.info("线程:::"+Thread.currentThread().getName()+"开始发送数据 XML:" + msg);
String is_send_ok = this.client.sendMSG(msg);
logger.info("发送回执=" + is_send_ok);
}
private static String tranlateXML(String xml) throws Exception {
String stype = XMPParse.getNodeValueFromXmlString(xml, "/MSG/META/STYP");
if (!StringUtils.isBlank(stype)) {
if (ConfigUtils.XTYPE_MAP.containsKey(stype)) {
stype = (String)ConfigUtils.XTYPE_MAP.get(stype);
} else {
logger.info("stype=" + stype + " 在对应关系里找不到这个KEY");
}
} else {
logger.info(" 在XML找不到STYPE这个节点");
stype = "";
}
return stype;
}
}