作者 朱兆平

合并优化存储报文

... ... @@ -55,10 +55,12 @@ public class IMFReader extends Thread {
String stype_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/STYP");
String type_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/TYPE");
String sender_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/SNDR");
String sntm_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/DDTM");
String seqn_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/SEQN");
// fileName = path + stype_value + "_" + Utils.dateToStr(dt, "yyyyMMddhhmmssSSS") + ".xml";
// Utils.saveFile(fileName, message);
dao.saveRecord("ALL", sender_value, message,type_value,stype_value);
dao.saveRecord("ALL", sender_value,sntm_value, message,type_value,stype_value,seqn_value);
// logger.info("created " + fileName + " ok");
} catch (Exception var7) {
//出错的报文存储到报文目录
... ...
... ... @@ -9,9 +9,9 @@ import com.airport.bean.MessageBak;
import java.util.List;
public interface Dao {
int insertRecord(String var1, String var2,String var3,String var4);
int insertRecord(String var1, String var2,String var3,String var4,String var5,String var6);
void saveRecord(String var1, String var2, String var3,String var4,String var5) throws Exception;
void saveRecord(String var1, String var2, String var3,String var4,String var5,String var6,String var7) throws Exception;
void delete(int var1);
... ...
... ... @@ -40,17 +40,19 @@ public class DaoImpl implements Dao {
this.jdbcTemplate = jdbcTemplate;
}
public int insertRecord(final String oper, final String sndr,String type,String styp) {
public int insertRecord(final String oper, final String sndr,String sntm,String type,String styp,String seqn) {
KeyHolder keyHolder = new GeneratedKeyHolder();
this.jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
DaoImpl.logger.info("oper=" + oper + " sndr=" + sndr+"type="+type+"styp="+styp);
String sql = "insert into T_ETL_MESSAGE(OPER,SNDR,SNTM,content,TYPE,STYP) values(?,?,sysdate,empty_clob(),?,?)";
String sql = "insert into T_ETL_MESSAGE(OPER,SNDR,SNTM,content,TYPE,STYP,SEQN) values(?,?,to_date(?,'yyyyMMddhh24miss'),empty_clob(),?,?,?)";
PreparedStatement ps = connection.prepareStatement(sql, new String[]{"FID"});
ps.setString(1, oper);
ps.setString(2, sndr);
ps.setString(3, type);
ps.setString(4, styp);
ps.setString(3, sntm);
ps.setString(4, type);
ps.setString(5, styp);
ps.setString(6,seqn);
return ps;
}
}, keyHolder);
... ... @@ -58,14 +60,14 @@ public class DaoImpl implements Dao {
return generatedId;
}
public void saveRecord(String messaegType, String sndr, String xmlContent,String type,String styp) throws Exception {
public void saveRecord(String messaegType, String sndr,String sntm, String xmlContent,String type,String styp,String seqn) throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
int fid = -100;
try {
fid = this.insertRecord(messaegType, sndr,type,styp);
fid = this.insertRecord(messaegType, sndr,sntm,type,styp,seqn);
conn = this.jdbcTemplate.getDataSource().getConnection();
conn.setAutoCommit(false);
stmt = conn.createStatement();
... ... @@ -115,6 +117,7 @@ public class DaoImpl implements Dao {
public int getMaxFID(String sqlmax) {
// 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";
sqlmax = ConfigUtils.SQlMax;
return this.jdbcTemplate.queryForInt(sqlmax);
}
... ...