正在显示
5 个修改的文件
包含
32 行增加
和
12 行删除
| @@ -90,15 +90,22 @@ public class IMFSender extends TimerTask { | @@ -90,15 +90,22 @@ public class IMFSender extends TimerTask { | ||
| 90 | haiguanXml.setIMFContent(m.getContent()); | 90 | haiguanXml.setIMFContent(m.getContent()); |
| 91 | sendMsg = haiguanXml.finalXmlStr(); | 91 | sendMsg = haiguanXml.finalXmlStr(); |
| 92 | } else { | 92 | } else { |
| 93 | -//_____________________________________解析天信达的报文------------------------------------------------------------------------------------------- | 93 | +//_____________________________________解析天信达的报文,读取配置文件,替换相关参数------------------------------------------------------------------------------------------- |
| 94 | sendMsg= Utils.searchReplace(m.getContent(), header.getSndr(), "SNDR"); | 94 | sendMsg= Utils.searchReplace(m.getContent(), header.getSndr(), "SNDR"); |
| 95 | sendMsg = Utils.searchReplace(sendMsg, header.getType(), "TYPE"); //替换报文主类型 | 95 | sendMsg = Utils.searchReplace(sendMsg, header.getType(), "TYPE"); //替换报文主类型 |
| 96 | 96 | ||
| 97 | String stype = tranlateXML(m.getContent()); | 97 | String stype = tranlateXML(m.getContent()); |
| 98 | sendMsg = Utils.searchReplace(sendMsg, stype, "STYP"); | 98 | sendMsg = Utils.searchReplace(sendMsg, stype, "STYP"); |
| 99 | sendMsg = Utils.searchReplaceSingle(sendMsg, header.getRcvr(), "RCVR"); | 99 | sendMsg = Utils.searchReplaceSingle(sendMsg, header.getRcvr(), "RCVR"); |
| 100 | -//_____________________________________解析天信达的报文------------------------------------------------------------------------------------------- | ||
| 101 | } | 100 | } |
| 101 | +//_____________________________________给多式联运的航空报文,读取配置文件,生成新的META,并把最原始的报文封装到新报文的content里面-------------------------------------------------------------------- | ||
| 102 | +// String sndr = header.getSndr(); | ||
| 103 | +// String type = header.getType(); | ||
| 104 | +// String styp = header.getStype(); | ||
| 105 | +// | ||
| 106 | +// IMFXMLMaker newXml = new IMFXMLMaker(sndr,Integer.toString(m.getFid()),type,styp); | ||
| 107 | +// newXml.setIMFContent(m.getContent()); | ||
| 108 | +// sendMsg = newXml.finalXmlStr(); | ||
| 102 | 109 | ||
| 103 | if (!"".equals(sendMsg)) { | 110 | if (!"".equals(sendMsg)) { |
| 104 | logger.info("开始发送数据 XML:" + sendMsg); | 111 | logger.info("开始发送数据 XML:" + sendMsg); |
| @@ -45,7 +45,7 @@ public class DaoImpl implements Dao { | @@ -45,7 +45,7 @@ public class DaoImpl implements Dao { | ||
| 45 | this.jdbcTemplate.update(new PreparedStatementCreator() { | 45 | this.jdbcTemplate.update(new PreparedStatementCreator() { |
| 46 | public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { | 46 | public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
| 47 | DaoImpl.logger.info("oper=" + oper + " sndr=" + sndr); | 47 | DaoImpl.logger.info("oper=" + oper + " sndr=" + sndr); |
| 48 | - String sql = "insert into MESSAGE_BAK(OPER,SNDR,SNTM,content) values(?,?,sysdate,empty_clob())"; | 48 | + String sql = "insert into T_ETL_MESSAGE(OPER,SNDR,SNTM,content) values(?,?,sysdate,empty_clob())"; |
| 49 | PreparedStatement ps = connection.prepareStatement(sql, new String[]{"FID"}); | 49 | PreparedStatement ps = connection.prepareStatement(sql, new String[]{"FID"}); |
| 50 | ps.setString(1, oper); | 50 | ps.setString(1, oper); |
| 51 | ps.setString(2, sndr); | 51 | ps.setString(2, sndr); |
| @@ -67,7 +67,7 @@ public class DaoImpl implements Dao { | @@ -67,7 +67,7 @@ public class DaoImpl implements Dao { | ||
| 67 | conn = this.jdbcTemplate.getDataSource().getConnection(); | 67 | conn = this.jdbcTemplate.getDataSource().getConnection(); |
| 68 | conn.setAutoCommit(false); | 68 | conn.setAutoCommit(false); |
| 69 | stmt = conn.createStatement(); | 69 | stmt = conn.createStatement(); |
| 70 | - String SQL = "select CONTENT from MESSAGE_BAK where FID=" + fid + " and SNDR='CFPS' for update"; | 70 | + String SQL = "select CONTENT from T_ETL_MESSAGE where FID=" + fid + " and SNDR='FIMS' for update"; |
| 71 | rs = stmt.executeQuery(SQL); | 71 | rs = stmt.executeQuery(SQL); |
| 72 | 72 | ||
| 73 | while(rs.next()) { | 73 | while(rs.next()) { |
| @@ -108,16 +108,20 @@ public class DaoImpl implements Dao { | @@ -108,16 +108,20 @@ public class DaoImpl implements Dao { | ||
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | public void delete(int fid) { | 110 | public void delete(int fid) { |
| 111 | - this.jdbcTemplate.update("delete from MESSAGE_BAK where fid=" + fid); | 111 | + this.jdbcTemplate.update("delete from T_ETL_MESSAGE where fid=" + fid); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | public int getMaxFID() { | 114 | public int getMaxFID() { |
| 115 | - return this.jdbcTemplate.queryForInt("select max(FID) from MESSAGE_BAK where SNDR='CFPS' OR TYPE='CLR' OR TYPE ='RSC' OR TYPE ='ES1' OR TYPE='IS1'"); | 115 | + String sqlmax = "select max(fid) from MESSAGE_BAK WHERE (FID>%s and FID<%s+%s) AND (TYPE='CLR' OR TYPE='ES1' OR TYPE='IS1' OR STYP = 'BSTA' OR STYP = 'FZE_RCF' OR STYP = 'FSU_FOH' OR STYP = 'FSU_DEP' OR STYP = 'COST' OR STYP = 'ABME' OR STYP = 'FZE_DEP' OR STYP = 'FSU_RCF') ORDER BY FID\n"; |
| 116 | + sqlmax = ConfigUtils.SQlMax; | ||
| 117 | + return this.jdbcTemplate.queryForInt(sqlmax); | ||
| 116 | } | 118 | } |
| 117 | 119 | ||
| 118 | public List<MessageBak> getRecordByFID(int fid) { | 120 | public List<MessageBak> getRecordByFID(int fid) { |
| 119 | - String SQL_FMT = "select FID,CONTENT from MESSAGE_BAK where (FID>%s and FID<%s+%s) and (SNDR='CFPS' OR TYPE='CLR' OR TYPE ='RSC' OR TYPE ='ES1' OR TYPE='IS1') order by FID"; | ||
| 120 | - String sql = String.format(SQL_FMT, fid, fid, ConfigUtils.RECORD_COUNT); | 121 | + String SQL_FMT = "select FID,CONTENT from MESSAGE_BAK WHERE (FID>%s and FID<%s+%s) AND (TYPE='CLR' OR TYPE='ES1' OR TYPE='IS1' OR STYP = 'BSTA' OR STYP = 'FZE_RCF' OR STYP = 'FSU_FOH' OR STYP = 'FSU_DEP' OR STYP = 'COST' OR STYP = 'ABME' OR STYP = 'FZE_DEP' OR STYP = 'FSU_RCF') ORDER BY FID "; |
| 122 | + //从配置文件读取sql语句 | ||
| 123 | + String sql_select=ConfigUtils.SQl; | ||
| 124 | + String sql = String.format(sql_select, fid, fid, ConfigUtils.RECORD_COUNT); | ||
| 121 | logger.info(sql); | 125 | logger.info(sql); |
| 122 | final LobHandler lobHandler = new DefaultLobHandler(); | 126 | final LobHandler lobHandler = new DefaultLobHandler(); |
| 123 | final ArrayList xmlList = new ArrayList(); | 127 | final ArrayList xmlList = new ArrayList(); |
| @@ -148,11 +152,11 @@ public class DaoImpl implements Dao { | @@ -148,11 +152,11 @@ public class DaoImpl implements Dao { | ||
| 148 | } | 152 | } |
| 149 | 153 | ||
| 150 | public int getRecordCount() { | 154 | public int getRecordCount() { |
| 151 | - return this.jdbcTemplate.queryForInt("select count(*) from MESSAGE_BAK where SNDR='CFPS' "); | 155 | + return this.jdbcTemplate.queryForInt("select count(*) from T_ETL_MESSAGE where SNDR='FIMS' "); |
| 152 | } | 156 | } |
| 153 | 157 | ||
| 154 | public void update(int fid, int times) { | 158 | public void update(int fid, int times) { |
| 155 | - String sql = String.format("update MESSAGE_BAK set OUTFLAG=%s ,OUTTM=sysdate where FID=%s", times, fid); | 159 | + String sql = String.format("update T_ETL_MESSAGE set OUTFLAG=%s ,OUTTM=sysdate where FID=%s", times, fid); |
| 156 | logger.info("sql=" + sql); | 160 | logger.info("sql=" + sql); |
| 157 | this.jdbcTemplate.update(sql); | 161 | this.jdbcTemplate.update(sql); |
| 158 | } | 162 | } |
| @@ -30,6 +30,8 @@ public class ConfigUtils { | @@ -30,6 +30,8 @@ public class ConfigUtils { | ||
| 30 | public static String RCVR = ""; | 30 | public static String RCVR = ""; |
| 31 | public static String APPID = ""; | 31 | public static String APPID = ""; |
| 32 | public static String SNDR = ""; | 32 | public static String SNDR = ""; |
| 33 | + public static String SQl=""; | ||
| 34 | + public static String SQlMax=""; | ||
| 33 | public static Map<String, String> XTYPE_MAP = new HashMap(); | 35 | public static Map<String, String> XTYPE_MAP = new HashMap(); |
| 34 | 36 | ||
| 35 | public ConfigUtils() { | 37 | public ConfigUtils() { |
| @@ -56,6 +58,8 @@ public class ConfigUtils { | @@ -56,6 +58,8 @@ public class ConfigUtils { | ||
| 56 | ROLE = config.getProperty("role").trim(); | 58 | ROLE = config.getProperty("role").trim(); |
| 57 | IMF_USERNAME = config.getProperty("imf_username").trim(); | 59 | IMF_USERNAME = config.getProperty("imf_username").trim(); |
| 58 | IMF_PASSWORD = config.getProperty("imf_password").trim(); | 60 | IMF_PASSWORD = config.getProperty("imf_password").trim(); |
| 61 | + SQl = config.getProperty("sql"); | ||
| 62 | + SQlMax = config.getProperty("sqlmax"); | ||
| 59 | String interval = config.getProperty("interval").trim(); | 63 | String interval = config.getProperty("interval").trim(); |
| 60 | String record_count = config.getProperty("record_count").trim(); | 64 | String record_count = config.getProperty("record_count").trim(); |
| 61 | logger.info(String.format("role=%s", ROLE)); | 65 | logger.info(String.format("role=%s", ROLE)); |
| @@ -22,7 +22,7 @@ import java.util.regex.Matcher; | @@ -22,7 +22,7 @@ import java.util.regex.Matcher; | ||
| 22 | import java.util.regex.Pattern; | 22 | import java.util.regex.Pattern; |
| 23 | import org.apache.commons.lang.StringUtils; | 23 | import org.apache.commons.lang.StringUtils; |
| 24 | import org.apache.log4j.Logger; | 24 | import org.apache.log4j.Logger; |
| 25 | - | 25 | +//读取写入已发送的FID |
| 26 | public class Utils { | 26 | public class Utils { |
| 27 | private static Logger logger = Logger.getLogger(SystemBean.class); | 27 | private static Logger logger = Logger.getLogger(SystemBean.class); |
| 28 | 28 |
| @@ -20,6 +20,7 @@ public class IMFXMLMaker { | @@ -20,6 +20,7 @@ public class IMFXMLMaker { | ||
| 20 | private Element SEQNElement; | 20 | private Element SEQNElement; |
| 21 | private Element TYPEElement; | 21 | private Element TYPEElement; |
| 22 | private Element STYPElement; | 22 | private Element STYPElement; |
| 23 | + private Element originalELEMENT; | ||
| 23 | 24 | ||
| 24 | private String XmlStr; | 25 | private String XmlStr; |
| 25 | private String SNDR; | 26 | private String SNDR; |
| @@ -111,6 +112,10 @@ public class IMFXMLMaker { | @@ -111,6 +112,10 @@ public class IMFXMLMaker { | ||
| 111 | Element MetaElement = new Element("META"); | 112 | Element MetaElement = new Element("META"); |
| 112 | this.RootElement.addContent(0,MetaElement); | 113 | this.RootElement.addContent(0,MetaElement); |
| 113 | 114 | ||
| 115 | + //原始内容节点,储存最原始报文内容的节点 | ||
| 116 | + this.originalELEMENT = new Element("original"); | ||
| 117 | + this.RootElement.addContent(1,this.originalELEMENT); | ||
| 118 | + | ||
| 114 | //meta下的子节点们 | 119 | //meta下的子节点们 |
| 115 | SndrElement = new Element("SNDR"); | 120 | SndrElement = new Element("SNDR"); |
| 116 | RcvrElement = new Element("RCVR"); | 121 | RcvrElement = new Element("RCVR"); |
| @@ -141,7 +146,7 @@ public class IMFXMLMaker { | @@ -141,7 +146,7 @@ public class IMFXMLMaker { | ||
| 141 | 146 | ||
| 142 | try{ | 147 | try{ |
| 143 | Document contentDocument = string2Doc(this.IMFContent); | 148 | Document contentDocument = string2Doc(this.IMFContent); |
| 144 | - this.RootElement.addContent(1,contentDocument.detachRootElement()); | 149 | + this.originalELEMENT.addContent(0,contentDocument.detachRootElement()); |
| 145 | 150 | ||
| 146 | String backXml = doc2String(this.XmlDocument); | 151 | String backXml = doc2String(this.XmlDocument); |
| 147 | return backXml; | 152 | return backXml; |
-
请 注册 或 登录 后发表评论