作者 朱兆平

合并优化存储报文

@@ -55,10 +55,12 @@ public class IMFReader extends Thread { @@ -55,10 +55,12 @@ public class IMFReader extends Thread {
55 String stype_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/STYP"); 55 String stype_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/STYP");
56 String type_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/TYPE"); 56 String type_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/TYPE");
57 String sender_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/SNDR"); 57 String sender_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/SNDR");
  58 + String sntm_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/DDTM");
  59 + String seqn_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/SEQN");
58 60
59 // fileName = path + stype_value + "_" + Utils.dateToStr(dt, "yyyyMMddhhmmssSSS") + ".xml"; 61 // fileName = path + stype_value + "_" + Utils.dateToStr(dt, "yyyyMMddhhmmssSSS") + ".xml";
60 // Utils.saveFile(fileName, message); 62 // Utils.saveFile(fileName, message);
61 - dao.saveRecord("ALL", sender_value, message,type_value,stype_value); 63 + dao.saveRecord("ALL", sender_value,sntm_value, message,type_value,stype_value,seqn_value);
62 // logger.info("created " + fileName + " ok"); 64 // logger.info("created " + fileName + " ok");
63 } catch (Exception var7) { 65 } catch (Exception var7) {
64 //出错的报文存储到报文目录 66 //出错的报文存储到报文目录
@@ -9,9 +9,9 @@ import com.airport.bean.MessageBak; @@ -9,9 +9,9 @@ import com.airport.bean.MessageBak;
9 import java.util.List; 9 import java.util.List;
10 10
11 public interface Dao { 11 public interface Dao {
12 - int insertRecord(String var1, String var2,String var3,String var4); 12 + int insertRecord(String var1, String var2,String var3,String var4,String var5,String var6);
13 13
14 - void saveRecord(String var1, String var2, String var3,String var4,String var5) throws Exception; 14 + void saveRecord(String var1, String var2, String var3,String var4,String var5,String var6,String var7) throws Exception;
15 15
16 void delete(int var1); 16 void delete(int var1);
17 17
@@ -40,17 +40,19 @@ public class DaoImpl implements Dao { @@ -40,17 +40,19 @@ public class DaoImpl implements Dao {
40 this.jdbcTemplate = jdbcTemplate; 40 this.jdbcTemplate = jdbcTemplate;
41 } 41 }
42 42
43 - public int insertRecord(final String oper, final String sndr,String type,String styp) { 43 + public int insertRecord(final String oper, final String sndr,String sntm,String type,String styp,String seqn) {
44 KeyHolder keyHolder = new GeneratedKeyHolder(); 44 KeyHolder keyHolder = new GeneratedKeyHolder();
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+"type="+type+"styp="+styp); 47 DaoImpl.logger.info("oper=" + oper + " sndr=" + sndr+"type="+type+"styp="+styp);
48 - String sql = "insert into T_ETL_MESSAGE(OPER,SNDR,SNTM,content,TYPE,STYP) values(?,?,sysdate,empty_clob(),?,?)"; 48 + String sql = "insert into T_ETL_MESSAGE(OPER,SNDR,SNTM,content,TYPE,STYP,SEQN) values(?,?,to_date(?,'yyyyMMddhh24miss'),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);
52 - ps.setString(3, type);  
53 - ps.setString(4, styp); 52 + ps.setString(3, sntm);
  53 + ps.setString(4, type);
  54 + ps.setString(5, styp);
  55 + ps.setString(6,seqn);
54 return ps; 56 return ps;
55 } 57 }
56 }, keyHolder); 58 }, keyHolder);
@@ -58,14 +60,14 @@ public class DaoImpl implements Dao { @@ -58,14 +60,14 @@ public class DaoImpl implements Dao {
58 return generatedId; 60 return generatedId;
59 } 61 }
60 62
61 - public void saveRecord(String messaegType, String sndr, String xmlContent,String type,String styp) throws Exception { 63 + public void saveRecord(String messaegType, String sndr,String sntm, String xmlContent,String type,String styp,String seqn) throws Exception {
62 Connection conn = null; 64 Connection conn = null;
63 Statement stmt = null; 65 Statement stmt = null;
64 ResultSet rs = null; 66 ResultSet rs = null;
65 int fid = -100; 67 int fid = -100;
66 68
67 try { 69 try {
68 - fid = this.insertRecord(messaegType, sndr,type,styp); 70 + fid = this.insertRecord(messaegType, sndr,sntm,type,styp,seqn);
69 conn = this.jdbcTemplate.getDataSource().getConnection(); 71 conn = this.jdbcTemplate.getDataSource().getConnection();
70 conn.setAutoCommit(false); 72 conn.setAutoCommit(false);
71 stmt = conn.createStatement(); 73 stmt = conn.createStatement();
@@ -115,6 +117,7 @@ public class DaoImpl implements Dao { @@ -115,6 +117,7 @@ public class DaoImpl implements Dao {
115 117
116 public int getMaxFID(String sqlmax) { 118 public int getMaxFID(String sqlmax) {
117 // 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"; 119 // 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";
  120 + sqlmax = ConfigUtils.SQlMax;
118 return this.jdbcTemplate.queryForInt(sqlmax); 121 return this.jdbcTemplate.queryForInt(sqlmax);
119 } 122 }
120 123