package com.tenwa.cgb.util; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.util.SqlObject; import com.amarsoft.awe.util.Transaction; import com.tenwa.comm.util.date.DateAssistant; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @program: apzl_leasing * @author: yjf * @create: 2021-07-20 15:15 **/ public class CGBLogAssistant { public static void insertCGBlog(String flowUnid, String type, String batchNo, String serialNum, String reqMsg) { JBOTransaction tx = null; try { tx = JBOFactory.createJBOTransaction(); Transaction sqlca = Transaction.createTransaction(tx); SqlObject sqlObject = new SqlObject("insert into lb_cgb_log (type,flow_unid,batch_no,serial_num,req_msg,req_time) values (:type,:flowUnid,:batchNo,:serialNum,:reqMsg,:reqTime)") .setParameter("type", type) .setParameter("flowUnid", flowUnid) .setParameter("batchNo", batchNo) .setParameter("serialNum", serialNum) .setParameter("reqMsg", reqMsg) .setParameter("reqTime", DateAssistant.getTodayNow()); sqlca.executeSQL(sqlObject); tx.commit(); } catch (Exception e) { e.printStackTrace(); if (tx != null) try { tx.rollback(); } catch (JBOException e1) { e1.printStackTrace(); } } } public static void updateCGBlog(String batchNo, String serialNum, String retMsg) { JBOTransaction tx = null; try { tx = JBOFactory.createJBOTransaction(); Transaction sqlca = Transaction.createTransaction(tx); SqlObject sqlObject = null; StringBuilder sb = new StringBuilder("update lb_cgb_log set ret_msg=:retMsg,ret_time=:retTime where batch_no =:batchNo and"); if (serialNum == null) { sb.append(" serial_num is null"); sqlObject = new SqlObject(sb.toString()) .setParameter("retMsg", retMsg) .setParameter("retTime", DateAssistant.getTodayNow()) .setParameter("batchNo", batchNo); } else { Pattern pm = Pattern.compile("(?<=)([\\S\\s]+)(?=)"); Matcher mm = pm.matcher(retMsg); String entSeqNo = null; if(mm.find()){ entSeqNo = mm.group(); } sb.append(" serial_num =:serialNum and req_msg regexp :entSeqNo "); sqlObject = new SqlObject(sb.toString()) .setParameter("retMsg", retMsg) .setParameter("retTime", DateAssistant.getTodayNow()) .setParameter("batchNo", batchNo) .setParameter("serialNum", serialNum) .setParameter("entSeqNo", entSeqNo); } sqlca.executeSQL(sqlObject); tx.commit(); } catch (Exception e) { e.printStackTrace(); if (tx != null) try { tx.rollback(); } catch (JBOException e1) { e1.printStackTrace(); } } } }