public boolean insertOrderLog(OrderLogPojo orderLogPojo) {
String logIdSql = "SELECT ''||sys_guid() AS LOG_ID FROM DUAL";
String logId = "";
List logIdList = jdbcTemplate.queryForList(logIdSql);
if(logIdList != null && logIdList.size()> 0){
Map startSet = (Map) logIdList.get(0);
logId = startSet.get("LOG_ID").toString();
}
String insertOrderLogSql = "insert into ORDER_SERVICE_EXCUTE_LOG(LOG_ID,INTERFACE_NAME,METHOD_NAME,EXCUTETIME,"+
"COMPLETETIME,RETFLAG,PROD_ORDER_ID,APP_NO,INMSG,OUTMSG,ERRMSG,TIME_LONG,RECALL_FLAG) values" +
"(?,?,?,SYSDATE,SYSDATE," +
"?,?,?,empty_clob(),empty_clob(),empty_clob(),0,?)";
jdbcTemplate.update(insertOrderLogSql,
new Object[]{
logId,
orderLogPojo.getInterfaceName(),
orderLogPojo.getMethodName(),
orderLogPojo.getRetFlag(),
orderLogPojo.getProdOrderId(),
orderLogPojo.getAppNo(),
"0"});
updateClobColumn(orderLogPojo, logId);
return true;
}
private void updateClobColumn(OrderLogPojo orderLogPojo, String logId) {
String inmsg = orderLogPojo.getInmsg();
if(inmsg != null){
String updateInmsgSql = "UPDATE ORDER_SERVICE_EXCUTE_LOG set INMSG = INMSG||? WHERE LOG_ID = ? ";
while (inmsg.length() > 500) {
String temp = inmsg.substring(0, 500);
this.jdbcTemplate.update(updateInmsgSql, new Object[] { temp , logId });
inmsg = inmsg.substring(500);
}
this.jdbcTemplate.update(updateInmsgSql, new Object[] { inmsg , logId });
}
String outmsg = orderLogPojo.getOutmsg();
if(outmsg != null){
String updateOutmsgSql = "UPDATE ORDER_SERVICE_EXCUTE_LOG set OUTMSG = OUTMSG||? WHERE LOG_ID = ? ";
while (outmsg.length() > 500) {
String temp = outmsg.substring(0, 500);
this.jdbcTemplate.update(updateOutmsgSql, new Object[] { temp , logId });
outmsg = outmsg.substring(500);
}
this.jdbcTemplate.update(updateOutmsgSql, new Object[] { outmsg , logId });
}
String errmsg = orderLogPojo.getErrmsg();
if(errmsg != null){
String updateErrmsgSql = "UPDATE ORDER_SERVICE_EXCUTE_LOG set ERRMSG = ERRMSG||? WHERE LOG_ID = ? ";
while (errmsg.length() > 1000) {
String temp = errmsg.substring(0, 1000);
this.jdbcTemplate.update(updateErrmsgSql, new Object[] { temp , logId });
errmsg = errmsg.substring(1000);
}
this.jdbcTemplate.update(updateErrmsgSql, new Object[] { errmsg , logId });
}
}