From ae4ee4bac8c64519e03daab1036a1c880ea80680 Mon Sep 17 00:00:00 2001 From: yjf <2211675158@qq.com> Date: Fri, 3 Sep 2021 10:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B6=E8=81=94=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cache/CollectAuditInfoCache.java | 391 ++++++++---------- .../cache/CollectAuditInfoCacheTj.java | 383 ++++++++--------- .../cache/CollectAuditProcess.java | 25 +- .../cache/CollectAuditProcessTj.java | 9 +- 4 files changed, 370 insertions(+), 438 deletions(-) diff --git a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java index bf470c5a0..76a562fb8 100644 --- a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java +++ b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java @@ -1,5 +1,36 @@ package com.tenwa.collectaudit.cache; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.amarsoft.app.awe.config.InitCollectConfig; +import com.amarsoft.app.util.StringUtil; +import com.amarsoft.are.jbo.*; +import com.amarsoft.are.util.StringFunction; +import com.amarsoft.awe.util.ASResultSet; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.gnete.security.crypt.Crypt; +import com.gnete.security.crypt.CryptException; +import com.tenwa.comm.util.date.DateAssistant; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentDo; +import com.tenwa.quartz.DateUtil; +import jbo.app.tenwa.calc.LC_COLLECT_MANUAL_INFO; +import jbo.app.tenwa.calc.LC_RENT_INCOME; +import jbo.app.tenwa.calc.LC_RENT_PLAN; +import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; +import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; +import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO; +import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO; +import jbo.com.tenwa.lease.comm.*; +import jbo.sys.CODE_LIBRARY; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.quartz.JobExecutionContext; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.impl.StdSchedulerFactory; + import java.io.File; import java.math.BigDecimal; import java.sql.SQLException; @@ -10,47 +41,9 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.quartz.JobExecutionContext; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.impl.StdSchedulerFactory; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.amarsoft.app.awe.config.InitCollectConfig; -import com.amarsoft.app.util.StringUtil; -import com.amarsoft.are.jbo.BizObject; -import com.amarsoft.are.jbo.BizObjectManager; -import com.amarsoft.are.jbo.JBOException; -import com.amarsoft.are.jbo.JBOFactory; -import com.amarsoft.are.jbo.JBOTransaction; -import com.amarsoft.are.util.StringFunction; -import com.amarsoft.awe.util.ASResultSet; -import com.amarsoft.awe.util.SqlObject; -import com.amarsoft.awe.util.Transaction; -import com.gnete.security.crypt.Crypt; -import com.gnete.security.crypt.CryptException; -import com.tenwa.comm.util.date.DateAssistant; -import com.tenwa.comm.util.jboutil.DataOperatorUtil; -import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentDo; -import com.tenwa.quartz.DateUtil; - -import jbo.app.tenwa.calc.LC_COLLECT_MANUAL_INFO; -import jbo.app.tenwa.calc.LC_RENT_INCOME; -import jbo.app.tenwa.calc.LC_RENT_PLAN; -import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; -import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; -import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO; -import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO; -import jbo.com.tenwa.lease.comm.LB_BUCKLE_LOG; -import jbo.com.tenwa.lease.comm.LB_CLEAR_FILE_RECORD; -import jbo.com.tenwa.lease.comm.LB_INTFACE_FILE_RECORD; -import jbo.com.tenwa.lease.comm.VI_BOND_COMPENSATORY; -import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN; -import jbo.loan.VI_RENT_COLLECT; -import jbo.sys.CODE_LIBRARY; - public class CollectAuditInfoCache { + + private static Log log = LogFactory.getLog(CollectAuditInfoCache.class); private String id; private String fileSavePath = "d:/tmp/als/InterFace"; @@ -812,13 +805,12 @@ public class CollectAuditInfoCache { } /** - * 批量代收-发送请求 + * 批量代收-发送请求(定时任务--银联卡扣) * @param tx * @return * @throws Exception */ public String batchCollectManage(JBOTransaction tx) throws Exception{ - int i = 0,j = 0; String[] ids = id.split("@"); StringBuffer parms = new StringBuffer(); for (String str : ids) { @@ -829,10 +821,9 @@ public class CollectAuditInfoCache { } } BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); - BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); //这里对天津与深圳的数据进行拆分 - List bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); - if (bolist.size() != 0) { + List bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in (" + parms.toString() + ")").getResultList(false); + if (bolist.size() > 0) { singleBatchCollectMoeny(tx, bolist); } return "系统正在处理中,请稍后"; @@ -1008,7 +999,7 @@ public class CollectAuditInfoCache { } for (int i = 1; i <= snArray.length; i++) { - + log.warn("ShenZhen counteroffer batch_no:"+query_sn+" batch_sn:"+snArray[(i-1)]+" rentid:"+bo.getAttribute("id").toString()); Map map = querySingleBatchCollect(tx, bo, query_sn, snArray[(i-1)]); if(map == null ) { continue; @@ -1337,7 +1328,7 @@ public class CollectAuditInfoCache { return strbuff; } /** - * 批量代收-发送请求 + * 批量代收-发送请求(报文组装,调用银联100001接口,更新租金计划batch_status状态) * @param tx * @param bc * @param bo @@ -1352,37 +1343,46 @@ public class CollectAuditInfoCache { String currentYear = currentDateTime.substring(0,4); String month = currentDateTime.substring(5,7); String day = currentDateTime.substring(8,10); - String merchantNumber = InitCollectConfig.MERCHANTID; - String flag = InitCollectConfig.FLAG; - String version = InitCollectConfig.C_VERSION; + String merchantNumber = InitCollectConfig.MERCHANTID;//银联商户号 + String flag = InitCollectConfig.FLAG;//银联接口--代收标识 + String version = InitCollectConfig.C_VERSION;//接口版本号 String date = currentYear+month+day;//提交日期 - String batch_title = ""; - int i = 0,j = 0; - //创建文件路径 - String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator + //创建卡扣文件路径 + File file = new File( this.fileSavePath+ File.separator + currentYear + File.separator + month + File.separator + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//目录不存在则直接创建 - file.mkdirs(); - } - String req_sn = System.currentTimeMillis()+"";//当日批次号 - batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; + //目录不存在则直接创建 + if(!file.exists()) file.mkdirs(); + + String req_sn = System.currentTimeMillis()+"";//卡扣批次号 REQ_SN + //卡扣文件名称 + String batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; + //卡扣报文 StringBuffer strbuff = collectBatch(req_sn,list); - //响应报文 - String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); - for (BizObject bo : list) { - //生成存盘、回盘文件 - savaFile(tx, strResp,batch_title,bo); + //接口调用,返回响应报文 + String strResp = ""; + try { + strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); + }catch (Exception e){ + JBOTransaction jboTransaction = null; + try { + String rentIds = getRentIds(list); + jboTransaction = JBOFactory.createJBOTransaction(); + Transaction.createTransaction(jboTransaction).executeSQL("update lc_rent_plan set batch_sn=null where id in ('" + rentIds + "')"); + jboTransaction.commit(); + }catch (Exception e1){ + if (jboTransaction != null) jboTransaction.rollback(); + e1.printStackTrace(); + } + throw new RuntimeException("深圳银联接口调用异常:", e); } + //生成存盘、回盘文件(批量卡扣,日志表LB_INTFACE_FILE_RECORD.RELA_ID 存储卡扣批次号) + BizObject bo = new BizObject("jbo.app.tenwa.calc.LC_RENT_PLAN"); + bo.setAttributeValue("id",req_sn); + savaFile(tx, strResp,batch_title,bo); + //解析银联响应报文 Map map = getRetAndCodeByBatch(strResp); if (map.containsKey("RET_CODE")) {//清空批量代收状态 - StringBuilder updateIds = new StringBuilder(); - for (BizObject biz : list) { - updateIds.append(biz.getAttribute("id").toString()).append("','"); - } - String updateIdsStr = updateIds.delete(updateIds.length() - 3, updateIds.length()).toString(); + String updateIdsStr = getRentIds(list); //清空批量处理状态 BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); bm.createQuery("update O set O.BATCH_STATUS=null,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=null where O.id in ('" + updateIdsStr + "')") @@ -1398,31 +1398,37 @@ public class CollectAuditInfoCache { JBOTransaction trans = null; try { trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME, trans); - BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%" + map.get("SN" + k) + "%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(true); - if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS").getString())) { - continue; - } - //响应成功 - if (map.containsKey("REQ_SN") && map.containsKey("RET_CODE" + k) && "0000".equals(map.get("RET_CODE" + k))) { - bo0.setAttributeValue("BATCH_STATUS", "process"); - } else {//响应异常 - bo0.setAttributeValue("BATCH_STATUS", null); - bo0.setAttributeValue("BATCH_NO", null); - bo0.setAttributeValue("BATCH_SN", null); - } - bm.saveObject(bo0); + Transaction sqlCa = Transaction.createTransaction(trans); + SqlObject sqlObject = new SqlObject("update lc_rent_plan lrp join lb_union_middle lum on lrp.id = lum.rent_id set lrp.batch_status = 'process' " + + " where lum.batch_no =:batchNo and lum.batch_sn =:batchSn") + .setParameter("batchNo",map.get("REQ_SN")).setParameter("batchSn", map.get("SN" + k)); + sqlCa.executeSQL(sqlObject); } catch (Exception e) { - e.printStackTrace(); + log.error("ShenZhenBuckle process status update exception ",e); if (trans != null) trans.rollback(); } finally { + log.warn("ShenZhenBuckle process status update -- batch_no:"+map.get("REQ_SN")+" batch_sn:"+map.get("SN" + k)); if (trans != null) trans.commit(); } } } return map; } - + + /** + * 获取租金计划ids + * @param list + * @return + * @throws JBOException + */ + private String getRentIds(List list) throws JBOException { + StringBuilder updateIds = new StringBuilder(); + for (BizObject biz : list) { + updateIds.append(biz.getAttribute("id").toString()).append("','"); + } + return updateIds.delete(updateIds.length() - 3, updateIds.length()).toString(); + } + /** * 批量代收--报文拼接 * @param rent @@ -1434,7 +1440,6 @@ public class CollectAuditInfoCache { */ public StringBuffer collectBatch(String req_sn,List list) throws JBOException{ //拼接XML报文 - //String req = System.currentTimeMillis()+""; StringBuffer strbuff = new StringBuffer(); strbuff.append(""); strbuff.append(""); @@ -1452,32 +1457,32 @@ public class CollectAuditInfoCache { strbuff.append(""); strbuff.append(""); strbuff.append(""); - BigDecimal mutly = new BigDecimal("0"); + BigDecimal mutly = new BigDecimal("0");//卡扣总金额 int i = 0; + //查询银行限额 itemname<银行名称> itemdescribe<限额设置> + List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); + //计算卡扣总金额,卡扣总数量 for (BizObject bo : list) { String single = bo.getAttribute("rent").toString(); BigDecimal m = new BigDecimal(single); mutly = mutly.add(m); String bank_name = bo.getAttribute("BANK_NAME").toString(); - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); - //数据字典中的itemdescribe字段代表银行单笔限 - double itemdescribe = 0; + + BigDecimal itemdescribe = new BigDecimal("0"); boolean flag = false; for (BizObject code : codelist) { String itemnameTmp = code.getAttribute("itemname").toString().trim(); - double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { - itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + itemdescribe = new BigDecimal(itemdescribeTmp1).setScale(2, BigDecimal.ROUND_HALF_UP); flag = true; break; } } - - if (flag == true && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { + if (flag == true && m.compareTo(itemdescribe) == 1) { BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString()); int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); + int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue(); int k = (int) Math.floor(singlerent/singleitem); int l = (int) Math.ceil(singlerent%singleitem); for (int j = 0; j < k; j++) { @@ -1489,8 +1494,8 @@ public class CollectAuditInfoCache { }else{ i++; } - } + String totalSum = String.valueOf(mutly.multiply(new BigDecimal(100)).longValue()); String totalItem = String.valueOf(i); Trans_Sum trans_sum = new Trans_Sum(); @@ -1510,27 +1515,23 @@ public class CollectAuditInfoCache { String account = biz.getAttribute("account").toString(); String bank_name = biz.getAttribute("BANK_NAME").toString(); String planId = biz.getAttribute("id").toString(); - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); - double itemdescribe = 0; + BigDecimal itemdescribe = new BigDecimal("0"); boolean flag = false; for (BizObject code : codelist) { String itemnameTmp = code.getAttribute("itemname").toString().trim(); - double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { - itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + itemdescribe = new BigDecimal(itemdescribeTmp1).setScale(2, BigDecimal.ROUND_HALF_UP); flag = true; break; } } - - if (flag == true && Double.parseDouble(biz.getAttribute("rent").toString()) > itemdescribe) { + if (flag == true && m.compareTo(itemdescribe) == 1) { BigDecimal mi = new BigDecimal(biz.getAttribute("rent").toString()); int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); + int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue(); int k = (int) Math.floor(singlerent/singleitem); int l = (int) Math.ceil(singlerent%singleitem); - for (int k2 = 1; k2 <= k; k2++) { Trans_Detail trans_detail = new Trans_Detail(); String sn = ""; @@ -1541,48 +1542,7 @@ public class CollectAuditInfoCache { }else{ sn = "0000"+ (++item); } - //追加批量处理状态 - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); - BizObject bo = bm.createQuery("O.id=:id").setParameter("id", planId).getSingleResult(false); - String itemsn0 = ""; - if (bo !=null) { - String itemsn = bo.getAttribute("batch_sn").toString(); - if (itemsn.length() == 0) { - itemsn0 += sn; - }else{ - itemsn0 += itemsn+","+sn; - } - } - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//处理状态-为空 - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", itemsn0) - .setParameter("id", planId).executeUpdate(); - //手动的添加到手动表 - if("manual".equals(collectStyle)){ - JBOTransaction transj = JBOFactory.createJBOTransaction(); - BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,transj); - if(k2==1){ - BizObject bolmci = bmlcmi.newObject(); - bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString()); - bolmci.setAttributeValue("plan_id",planId); - bolmci.setAttributeValue("BATCH_NO",req_sn); - bolmci.setAttributeValue("BATCH_SN",itemsn0); - bolmci.setAttributeValue("money",biz.getAttribute("rent").toString()); - bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd")); - bmlcmi.saveObject(bolmci); - transj.commit(); - }else{ - bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO") - .setParameter("BATCH_SN", itemsn0) - .setParameter("BATCH_NO", req_sn) - .setParameter("id", planId).executeUpdate(); - transj.commit(); - } - - } - trans.commit(); + rentPlanHandle(planId,req_sn,sn,biz,k2,String.valueOf(singleitem));//追加批量处理状态 trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); trans_detail.setACCOUNT_NO(acc_number); @@ -1594,8 +1554,7 @@ public class CollectAuditInfoCache { strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); } if (l != 0) { - String surprent = String.format("%.2f", biz.getAttribute("rent").getDouble() - k*itemdescribe); - BigDecimal mj = new BigDecimal(surprent); + BigDecimal mj = mi.subtract(itemdescribe.multiply(new BigDecimal(k))).setScale(2, BigDecimal.ROUND_HALF_UP); String singlerent0 = String.valueOf(mj.multiply(new BigDecimal(100)).longValue()); Trans_Detail trans_detail = new Trans_Detail(); String sn = ""; @@ -1606,35 +1565,7 @@ public class CollectAuditInfoCache { }else{ sn = "0000"+ (++item); } - //追加批量处理状态 - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - BizObject bo = bm.createQuery("O.id=:id").setParameter("id", planId).getSingleResult(false); - String itemsn0 = ""; - if (bo !=null) { - String itemsn = bo.getAttribute("batch_sn").toString(); - if (itemsn.length() == 0) { - itemsn0 += sn; - }else{ - itemsn0 += itemsn+","+sn; - } - } - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//处理状态-为空 - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", itemsn0) - .setParameter("id", planId).executeUpdate(); - //添加到手动表 - if("manual".equals(collectStyle)){ - JBOTransaction transj = JBOFactory.createJBOTransaction(); - bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO") - .setParameter("BATCH_SN", itemsn0) - .setParameter("BATCH_NO", req_sn) - .setParameter("id", planId).executeUpdate(); - transj.commit(); - } - trans.commit(); + rentPlanHandle(planId,req_sn,sn,biz,99,singlerent0);//追加批量处理状态 trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); trans_detail.setACCOUNT_NO(acc_number); @@ -1656,27 +1587,7 @@ public class CollectAuditInfoCache { }else{ sn = "0000"+ (++item); } - //追加批量处理状态 - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//处理状态-为空 - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", sn) - .setParameter("id", planId).executeUpdate(); - //手动的添加到手动表 - if("manual".equals(collectStyle)){ - BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans); - BizObject bolmci = bmlcmi.newObject(); - bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString()); - bolmci.setAttributeValue("plan_id",planId); - bolmci.setAttributeValue("BATCH_NO",req_sn); - bolmci.setAttributeValue("BATCH_SN",sn); - bolmci.setAttributeValue("money",biz.getAttribute("rent").toString()); - bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd")); - bmlcmi.saveObject(bolmci); - } - trans.commit(); + rentPlanHandle(planId,req_sn,sn,biz,1,rent);//追加批量处理状态 trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); trans_detail.setACCOUNT_NO(acc_number); @@ -1693,9 +1604,72 @@ public class CollectAuditInfoCache { strbuff.append(""); strbuff.append(""); collectStyle=null; - return strbuff; } + + + /** + * 更新租金计划表 batch_no batch_sn ,手工卡扣的,添加手工卡扣记录 + * @param planId 租金计划id + * @param req_sn 批次号 + * @param sn 序号 + * @param biz + * @param k2 k2==1 手工卡扣插入新数据,其余更新手工卡扣表数据 + * @throws Exception + */ + private void rentPlanHandle(String planId,String req_sn,String sn,BizObject biz,int k2,String amount) throws JBOException{ + //追加批量处理状态 + JBOTransaction trans = null; + try{ + trans = JBOFactory.createJBOTransaction(); + Transaction transaction = Transaction.createTransaction(trans); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + BizObject bo = bm.createQuery("O.id=:id").setParameter("id", planId).getSingleResult(false); + String itemsn0 = ""; + if (bo !=null) { + String itemsn = bo.getAttribute("batch_sn").toString(); + if (itemsn.length() == 0) { + itemsn0 += sn; + }else{ + itemsn0 += itemsn+","+sn; + } + } + //更新租金批次号 序号 + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") + .setParameter("BATCH_STATUS", "")//处理状态-为空 + .setParameter("BATCH_NO", req_sn) + .setParameter("BATCH_SN", itemsn0) + .setParameter("id", planId).executeUpdate(); + //记录中间表 lb_union_middle + SqlObject sqlObject = new SqlObject("insert into lb_union_middle (id,batch_no,batch_sn,rent_id,amount,input_time) values (replace(uuid(),'-',''),:batchNo,:batchSn,:rentId,:amount,SYSDATE()) ") + .setParameter("batchNo", req_sn).setParameter("batchSn", sn) + .setParameter("rentId", planId).setParameter("amount",amount); + transaction.executeSQL(sqlObject); + //手动卡扣添加到手动表 + if("manual".equals(collectStyle)){ + BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans); + if(k2==1){ + BizObject bolmci = bmlcmi.newObject(); + bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString()); + bolmci.setAttributeValue("plan_id",planId); + bolmci.setAttributeValue("BATCH_NO",req_sn); + bolmci.setAttributeValue("BATCH_SN",itemsn0); + bolmci.setAttributeValue("money",biz.getAttribute("rent").toString()); + bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd")); + bmlcmi.saveObject(bolmci); + }else{ + bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO") + .setParameter("BATCH_SN", itemsn0) + .setParameter("BATCH_NO", req_sn) + .setParameter("id", planId).executeUpdate(); + } + } + trans.commit(); + }catch (Exception e){ + if (trans != null) trans.rollback(); + throw new JBOException(e.getMessage()); + } + } /** * 保存存盘、回盘文件 @@ -1712,13 +1686,9 @@ public class CollectAuditInfoCache { String day = currentDateTime.substring(8,10); //创建文件路径 String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator - + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//目录不存在则直接创建 - file.mkdirs(); - } + File file = new File(rootDir + File.separator + currentYear + File.separator + month + File.separator + day); + //目录不存在则直接创建 + if(!file.exists())file.mkdirs(); //保存存盘文件 BizObjectManager bm = JBOFactory.getFactory().getManager(LB_INTFACE_FILE_RECORD.CLASS_NAME); BizObject send = bm.newObject(); @@ -1731,9 +1701,9 @@ public class CollectAuditInfoCache { send.setAttributeValue("inputorgid", this.inputorgid); send.setAttributeValue("inputtime", currentDateTime); bm.saveObject(send); + //筛选响应信息 Map map = getRetAndCode(strResp); - //getMsgAndCode(strResp); //保存回盘文件 BizObject reply = bm.newObject(); @@ -1795,7 +1765,6 @@ public class CollectAuditInfoCache { public Map getRetAndCodeByBatch(String strXML){ Map map = new HashMap(); Map res = new HashMap(); - System.out.println(1); int iStart = strXML.indexOf(""); if (iStart != -1) { int end = strXML.indexOf(""); diff --git a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java index 16c5e87dc..9811957a5 100644 --- a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java +++ b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java @@ -1,5 +1,34 @@ package com.tenwa.collectaudit.cache; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.amarsoft.app.awe.config.InitCollectConfigTj; +import com.amarsoft.are.jbo.*; +import com.amarsoft.are.util.StringFunction; +import com.amarsoft.awe.util.ASResultSet; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.gnete.security.crypt.CryptException; +import com.tenwa.comm.util.date.DateAssistant; +import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentDo; +import com.tenwa.quartz.DateUtil; +import jbo.app.tenwa.calc.LC_COLLECT_MANUAL_INFO; +import jbo.app.tenwa.calc.LC_RENT_INCOME; +import jbo.app.tenwa.calc.LC_RENT_PLAN; +import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; +import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO; +import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO; +import jbo.com.tenwa.lease.comm.LB_BUCKLE_LOG; +import jbo.com.tenwa.lease.comm.LB_INTFACE_FILE_RECORD; +import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN; +import jbo.sys.CODE_LIBRARY; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.quartz.JobExecutionContext; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.impl.StdSchedulerFactory; + import java.io.File; import java.math.BigDecimal; import java.sql.SQLException; @@ -10,46 +39,10 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.quartz.JobExecutionContext; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.impl.StdSchedulerFactory; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.amarsoft.app.awe.config.InitCollectConfigTj; -import com.amarsoft.app.util.StringUtil; -import com.amarsoft.are.jbo.BizObject; -import com.amarsoft.are.jbo.BizObjectManager; -import com.amarsoft.are.jbo.JBOException; -import com.amarsoft.are.jbo.JBOFactory; -import com.amarsoft.are.jbo.JBOTransaction; -import com.amarsoft.are.util.StringFunction; -import com.amarsoft.awe.util.ASResultSet; -import com.amarsoft.awe.util.SqlObject; -import com.amarsoft.awe.util.Transaction; -import com.gnete.security.crypt.Crypt; -import com.gnete.security.crypt.CryptException; -import com.tenwa.comm.util.date.DateAssistant; -import com.tenwa.comm.util.jboutil.DataOperatorUtil; -import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentDo; -import com.tenwa.quartz.DateUtil; - -import jbo.app.tenwa.calc.LC_COLLECT_MANUAL_INFO; -import jbo.app.tenwa.calc.LC_RENT_INCOME; -import jbo.app.tenwa.calc.LC_RENT_PLAN; -import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; -import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; -import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO; -import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO; -import jbo.com.tenwa.lease.comm.LB_BUCKLE_LOG; -import jbo.com.tenwa.lease.comm.LB_CLEAR_FILE_RECORD; -import jbo.com.tenwa.lease.comm.LB_INTFACE_FILE_RECORD; -import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN; -import jbo.sys.CODE_LIBRARY; - public class CollectAuditInfoCacheTj { - + + private static Log log = LogFactory.getLog(CollectAuditInfoCacheTj.class); + private String id; private String fileSavePath = "d:/tmp/als/InterFace"; private String inputuserid; @@ -1006,7 +999,7 @@ public class CollectAuditInfoCacheTj { } for (int i = 1; i <= snArray.length; i++) { - + log.warn("TianJin counteroffer batch_no:"+query_sn+" batch_sn:"+snArray[(i-1)]+" rentid:"+bo.getAttribute("id").toString()); Map map = querySingleBatchCollect(tx, bo, query_sn, snArray[(i-1)]); if(map == null ) { continue; @@ -1350,39 +1343,45 @@ public class CollectAuditInfoCacheTj { String currentYear = currentDateTime.substring(0,4); String month = currentDateTime.substring(5,7); String day = currentDateTime.substring(8,10); - String merchantNumber = InitCollectConfigTj.MERCHANTID; - String flag = InitCollectConfigTj.FLAG; - String version = InitCollectConfigTj.C_VERSION; + String merchantNumber = InitCollectConfigTj.MERCHANTID;//银联商户号 + String flag = InitCollectConfigTj.FLAG;//银联接口--代收标识 + String version = InitCollectConfigTj.C_VERSION;//接口版本号 String date = currentYear+month+day;//提交日期 - String batch_title = ""; - int i = 0,j = 0; //创建文件路径 - String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator - + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//目录不存在则直接创建 - file.mkdirs(); - } - String req_sn = System.currentTimeMillis()+"";//当日批次号 - batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; - //请求报文(限额处理) + File file = new File(this.fileSavePath + File.separator + currentYear + File.separator + month + File.separator + day); + //目录不存在则直接创建 + if (!file.exists()) file.mkdirs(); + String req_sn = System.currentTimeMillis()+""; //卡扣批次号 REQ_SN + //卡扣文件名称 + String batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; + //卡扣报文 StringBuffer strbuff = collectBatch(req_sn,list); - //响应报文 - String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); - for (BizObject bo : list) { - //生成存盘、回盘文件 - savaFile(tx, strResp,batch_title,bo); + //接口调用,返回响应报文 + String strResp = ""; + try { + strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); + }catch (Exception e){ + JBOTransaction jboTransaction = null; + try { + String rentIds = getRentIds(list); + jboTransaction = JBOFactory.createJBOTransaction(); + Transaction.createTransaction(jboTransaction).executeSQL("update lc_rent_plan set batch_sn=null where id in ('" + rentIds + "')"); + jboTransaction.commit(); + }catch (Exception e1){ + if (jboTransaction != null) jboTransaction.rollback(); + e1.printStackTrace(); + } + throw new RuntimeException("天津银联接口调用异常:", e); } + //生成存盘、回盘文件(批量卡扣,日志表LB_INTFACE_FILE_RECORD.RELA_ID 存储卡扣批次号) + BizObject bo = new BizObject("jbo.app.tenwa.calc.LC_RENT_PLAN"); + bo.setAttributeValue("id",req_sn); + savaFile(tx, strResp,batch_title,bo); + //解析银联响应报文 Map map = getRetAndCodeByBatch(strResp); //包含RET_CODE说明响应没有成功 if (map.containsKey("RET_CODE")) {//清空批量代收状态 - StringBuilder updateIds = new StringBuilder(); - for (BizObject biz : list) { - updateIds.append(biz.getAttribute("id").toString()).append("','"); - } - String updateIdsStr = updateIds.delete(updateIds.length() - 3, updateIds.length()).toString(); + String updateIdsStr = getRentIds(list); //清空批量处理状态 BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); bm.createQuery("update O set O.BATCH_STATUS=null,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=null where O.id in ('" + updateIdsStr + "')") @@ -1395,34 +1394,40 @@ public class CollectAuditInfoCacheTj { m++; } } - for (int k = 1; k <= m; k++) { - JBOTransaction trans = null; - try { - trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME, trans); - BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%" + map.get("SN" + k) + "%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(true); - if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS").getString())) { - continue; - } - //响应成功 - if (map.containsKey("REQ_SN") && map.containsKey("RET_CODE" + k) && "0000".equals(map.get("RET_CODE" + k))) { - bo0.setAttributeValue("BATCH_STATUS", "process"); - } else {//响应异常 - bo0.setAttributeValue("BATCH_STATUS", null); - bo0.setAttributeValue("BATCH_NO", null); - bo0.setAttributeValue("BATCH_SN", null); - } - bm.saveObject(bo0); - } catch (Exception e) { - e.printStackTrace(); - if (trans != null) trans.rollback(); - } finally { - if (trans != null) trans.commit(); - } - } + for (int k = 1; k <= m; k++) { + JBOTransaction trans = null; + try { + trans = JBOFactory.createJBOTransaction(); + Transaction sqlCa = Transaction.createTransaction(trans); + SqlObject sqlObject = new SqlObject("update lc_rent_plan lrp join lb_union_middle lum on lrp.id = lum.rent_id set lrp.batch_status = 'process' " + + " where lum.batch_no =:batchNo and lum.batch_sn =:batchSn") + .setParameter("batchNo", map.get("REQ_SN")).setParameter("batchSn", map.get("SN" + k)); + sqlCa.executeSQL(sqlObject); + } catch (Exception e) { + log.error("TianjinBuckle process status update exception ", e); + if (trans != null) trans.rollback(); + } finally { + log.warn("TianjinBuckle process status update -- batch_no:" + map.get("REQ_SN") + " batch_sn:" + map.get("SN" + k)); + if (trans != null) trans.commit(); + } + } } return map; } + + /** + * 获取租金计划ids + * @param list + * @return + * @throws JBOException + */ + private String getRentIds(List list) throws JBOException { + StringBuilder updateIds = new StringBuilder(); + for (BizObject biz : list) { + updateIds.append(biz.getAttribute("id").toString()).append("','"); + } + return updateIds.delete(updateIds.length() - 3, updateIds.length()).toString(); + } /** * 批量代收--报文拼接 @@ -1435,7 +1440,6 @@ public class CollectAuditInfoCacheTj { */ public StringBuffer collectBatch(String req_sn,List list) throws JBOException{ //拼接XML报文 - //String req = System.currentTimeMillis()+""; StringBuffer strbuff = new StringBuffer(); strbuff.append(""); strbuff.append(""); @@ -1453,17 +1457,17 @@ public class CollectAuditInfoCacheTj { strbuff.append(""); strbuff.append(""); strbuff.append(""); - //总金额 - BigDecimal mutly = new BigDecimal("0"); - //总条数 - int i = 0; + BigDecimal mutly = new BigDecimal("0");//卡扣总金额 + int i = 0;//总条数 + //查询银行限额 itemname<银行名称> itemdescribe<限额设置> + List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false); + //计算卡扣总金额,卡扣总数量 for (BizObject bo : list) { String single_s = bo.getAttribute("rent").toString(); BigDecimal m_s = new BigDecimal(single_s); mutly = mutly.add(m_s); String bank_name = bo.getAttribute("BANK_NAME").toString(); - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false); - //数据字典中的itemdescribe字段代表银行单笔限 + //数据字典中的itemdescribe字段代表银行单笔限 BigDecimal itemdescribe = new BigDecimal("0"); boolean flag = false; for (BizObject code : codelist) { @@ -1475,9 +1479,8 @@ public class CollectAuditInfoCacheTj { break; } } - if (flag == true && m_s.compareTo(itemdescribe)==1) { - BigDecimal mi_s = m_s; - int singlerent = mi_s.multiply(new BigDecimal(100)).intValue(); + if (flag == true && m_s.compareTo(itemdescribe) == 1) { + int singlerent = m_s.multiply(new BigDecimal(100)).intValue(); int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue(); int k = singlerent/singleitem; int l = singlerent%singleitem; @@ -1490,7 +1493,6 @@ public class CollectAuditInfoCacheTj { }else{ i++; } - } String totalSum = String.valueOf(mutly.multiply(new BigDecimal(100)).longValue()); String totalItem = String.valueOf(i); @@ -1511,7 +1513,6 @@ public class CollectAuditInfoCacheTj { String account = biz.getAttribute("account").toString(); String bank_name = biz.getAttribute("BANK_NAME").toString(); String planId = biz.getAttribute("id").toString(); - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false); BigDecimal itemdescribe = new BigDecimal("0"); boolean flag = false; for (BizObject code : codelist) { @@ -1524,8 +1525,7 @@ public class CollectAuditInfoCacheTj { } } if (flag == true && m.compareTo(itemdescribe)==1) { - BigDecimal mi = m; - int singlerent = mi.multiply(new BigDecimal(100)).intValue(); + int singlerent = m.multiply(new BigDecimal(100)).intValue(); int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue(); int k = singlerent/singleitem; int l = singlerent%singleitem; @@ -1543,48 +1543,7 @@ public class CollectAuditInfoCacheTj { }else{ sn = "" + (++item); } - //追加批量处理状态 - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false); - String itemsn0 = ""; - if (bo !=null) { - String itemsn = bo.getAttribute("batch_sn").toString(); - if (itemsn.length() == 0) { - itemsn0 += sn; - }else{ - itemsn0 += itemsn+","+sn; - } - } - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//处理状态-为空 - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", itemsn0) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); - //手动的添加到手动表 - if("manual".equals(collectStyle)){ - JBOTransaction transj = JBOFactory.createJBOTransaction(); - BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,transj); - if(k2==1){ - BizObject bolmci = bmlcmi.newObject(); - bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString()); - bolmci.setAttributeValue("plan_id",planId); - bolmci.setAttributeValue("BATCH_NO",req_sn); - bolmci.setAttributeValue("BATCH_SN",itemsn0); - bolmci.setAttributeValue("money",biz.getAttribute("rent").toString()); - bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd")); - bmlcmi.saveObject(bolmci); - transj.commit(); - }else{ - bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO") - .setParameter("BATCH_SN", itemsn0) - .setParameter("BATCH_NO", req_sn) - .setParameter("id", planId).executeUpdate(); - transj.commit(); - } - - } - trans.commit(); + rentPlanHandle(planId,req_sn,sn,biz,k2,String.valueOf(singleitem));//追加批量处理状态 trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); trans_detail.setACCOUNT_NO(acc_number); @@ -1596,7 +1555,7 @@ public class CollectAuditInfoCacheTj { strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); } if (l != 0) { - BigDecimal mj = mi.subtract(itemdescribe.multiply(new BigDecimal(k))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal mj = m.subtract(itemdescribe.multiply(new BigDecimal(k))).setScale(2, BigDecimal.ROUND_HALF_UP); String singlerent0 = String.valueOf(mj.multiply(new BigDecimal(100)).longValue()); Trans_Detail trans_detail = new Trans_Detail(); String sn = ""; @@ -1611,35 +1570,7 @@ public class CollectAuditInfoCacheTj { }else{ sn = "" + (++item); } - //追加批量处理状态 - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false); - String itemsn0 = ""; - if (bo !=null) { - String itemsn = bo.getAttribute("batch_sn").toString(); - if (itemsn.length() == 0) { - itemsn0 += sn; - }else{ - itemsn0 += itemsn+","+sn; - } - } - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//处理状态-为空 - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", itemsn0) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); - //手动的添加到手动表 - if("manual".equals(collectStyle)){ - JBOTransaction transj = JBOFactory.createJBOTransaction(); - BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,transj); - bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO") - .setParameter("BATCH_SN", itemsn0) - .setParameter("BATCH_NO", req_sn) - .setParameter("id", planId).executeUpdate(); - transj.commit(); - } - trans.commit(); + rentPlanHandle(planId,req_sn,sn,biz,99,singlerent0);//追加批量处理状态 trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); trans_detail.setACCOUNT_NO(acc_number); @@ -1664,27 +1595,7 @@ public class CollectAuditInfoCacheTj { }else{ sn = "" + (++item); } - //追加批量处理状态 - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//处理状态-为空 - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", sn) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); - //手动的添加到手动表 - if("manual".equals(collectStyle)){ - BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans); - BizObject bolmci = bmlcmi.newObject(); - bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString()); - bolmci.setAttributeValue("plan_id",planId); - bolmci.setAttributeValue("BATCH_NO",req_sn); - bolmci.setAttributeValue("BATCH_SN",sn); - bolmci.setAttributeValue("money",biz.getAttribute("rent").toString()); - bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd")); - bmlcmi.saveObject(bolmci); - } - trans.commit(); + rentPlanHandle(planId,req_sn,sn,biz,1,rent);//追加批量处理状态 trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); trans_detail.setACCOUNT_NO(acc_number); @@ -1704,7 +1615,70 @@ public class CollectAuditInfoCacheTj { return strbuff; } - + + /** + * 更新租金计划表 batch_no batch_sn ,手工卡扣的,添加手工卡扣记录 + * @param planId 租金计划id + * @param req_sn 批次号 + * @param sn 序号 + * @param biz + * @param k2 k2==1 手工卡扣插入新数据,其余更新手工卡扣表数据 + * @throws Exception + */ + private void rentPlanHandle(String planId,String req_sn,String sn,BizObject biz,int k2,String amount) throws JBOException{ + //追加批量处理状态 + JBOTransaction trans = null; + try{ + trans = JBOFactory.createJBOTransaction(); + Transaction transaction = Transaction.createTransaction(trans); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + BizObject bo = bm.createQuery("O.id=:id").setParameter("id", planId).getSingleResult(false); + String itemsn0 = ""; + if (bo !=null) { + String itemsn = bo.getAttribute("batch_sn").toString(); + if (itemsn.length() == 0) { + itemsn0 += sn; + }else{ + itemsn0 += itemsn+","+sn; + } + } + //更新租金批次号 序号 + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") + .setParameter("BATCH_STATUS", "")//处理状态-为空 + .setParameter("BATCH_NO", req_sn) + .setParameter("BATCH_SN", itemsn0) + .setParameter("id", planId).executeUpdate(); + //记录中间表 lb_union_middle + SqlObject sqlObject = new SqlObject("insert into lb_union_middle (id,batch_no,batch_sn,rent_id,amount,input_time) values (replace(uuid(),'-',''),:batchNo,:batchSn,:rentId,:amount,SYSDATE()) ") + .setParameter("batchNo", req_sn).setParameter("batchSn", sn) + .setParameter("rentId", planId).setParameter("amount",amount); + transaction.executeSQL(sqlObject); + //手动卡扣添加到手动表 + if("manual".equals(collectStyle)){ + BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans); + if(k2==1){ + BizObject bolmci = bmlcmi.newObject(); + bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString()); + bolmci.setAttributeValue("plan_id",planId); + bolmci.setAttributeValue("BATCH_NO",req_sn); + bolmci.setAttributeValue("BATCH_SN",itemsn0); + bolmci.setAttributeValue("money",biz.getAttribute("rent").toString()); + bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd")); + bmlcmi.saveObject(bolmci); + }else{ + bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO") + .setParameter("BATCH_SN", itemsn0) + .setParameter("BATCH_NO", req_sn) + .setParameter("id", planId).executeUpdate(); + } + } + trans.commit(); + }catch (Exception e){ + if (trans != null) trans.rollback(); + throw new JBOException(e.getMessage()); + } + } + /** * 保存存盘、回盘文件 * @param tx @@ -1720,13 +1694,10 @@ public class CollectAuditInfoCacheTj { String day = currentDateTime.substring(8,10); //创建文件路径 String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator + File file = new File(rootDir + File.separator + currentYear + File.separator + month + File.separator + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//目录不存在则直接创建 - file.mkdirs(); - } + if (!file.exists()) file.mkdirs();//目录不存在则直接创建 + //保存存盘文件 BizObjectManager bm = JBOFactory.getFactory().getManager(LB_INTFACE_FILE_RECORD.CLASS_NAME); BizObject send = bm.newObject(); @@ -1741,7 +1712,6 @@ public class CollectAuditInfoCacheTj { bm.saveObject(send); //筛选响应信息 Map map = getRetAndCode(strResp); - //getMsgAndCode(strResp); //保存回盘文件 BizObject reply = bm.newObject(); @@ -1803,7 +1773,6 @@ public class CollectAuditInfoCacheTj { public Map getRetAndCodeByBatch(String strXML){ Map map = new HashMap(); Map res = new HashMap(); - System.out.println(1); int iStart = strXML.indexOf(""); if (iStart != -1) { int end = strXML.indexOf(""); diff --git a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcess.java b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcess.java index 250c133ad..1e179d798 100644 --- a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcess.java +++ b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcess.java @@ -1,18 +1,19 @@ package com.tenwa.collectaudit.cache; -import java.io.IOException; +import com.amarsoft.app.awe.config.InitCollectConfig; +import com.gnete.security.crypt.Crypt; +import com.gnete.security.crypt.CryptException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.params.HttpMethodParams; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; -import com.amarsoft.app.awe.config.InitCollectConfig; -import com.gnete.security.crypt.Crypt; -import com.gnete.security.crypt.CryptException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.IOException; /** @@ -94,8 +95,7 @@ public class CollectAuditProcess { protected String CollectAuditPayReq(StringBuffer sendXml,String fileSavePath,String fileName) throws CryptException { String strSendData = sendXml.toString(); HttpClient httpClient = new HttpClient( ); - PostMethod postMethod = - new PostMethod(InitCollectConfig.C_SERVERURL); + PostMethod postMethod = new PostMethod(InitCollectConfig.C_SERVERURL); //设置编码 httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"GBK"); @@ -105,19 +105,17 @@ public class CollectAuditProcess { Protocol.registerProtocol("https", new Protocol("https", fcty, 443)); strSendData = this.signMsg(strSendData); - log.info(strSendData); - System.out.println("发送报文:"+strSendData); + log.info("发送报文:"+strSendData); InterFaceFileCreate.sendDiscFileCreate(strSendData, fileSavePath, fileName); postMethod.setRequestBody(strSendData); try { long start = System.currentTimeMillis(); //执行getMethod int statusCode = httpClient.executeMethod(postMethod); - System.out.println("cost:"+(System.currentTimeMillis()-start)); + System.out.println("ShenZhen interface ["+fileName+"] call cost time:" + (System.currentTimeMillis() - start)); //失败 if (statusCode != HttpStatus.SC_OK) { - log.error( - "Method failed: " + postMethod.getStatusLine()); + log.error("Method failed: " + postMethod.getStatusLine()); //读取内容 byte[] responseBody = postMethod.getResponseBody(); //处理内容 @@ -131,7 +129,6 @@ public class CollectAuditProcess { String strResp = new String(responseBody, "GBK"); log.info("服务器返回:" + strResp); InterFaceFileCreate.replyDiscFileCreate(strResp, fileSavePath, fileName); - System.out.println("服务器返回:" + strResp); //验签 if (this.verifySign(strResp)) { log.info("验签正确,处理服务器返回的报文"); diff --git a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcessTj.java b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcessTj.java index 2f0d80f72..dd8a31dd1 100644 --- a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcessTj.java +++ b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditProcessTj.java @@ -106,19 +106,17 @@ public class CollectAuditProcessTj { Protocol.registerProtocol("https", new Protocol("https", fcty, 443)); strSendData = this.signMsg(strSendData); - log.info(strSendData); - System.out.println("发送报文:"+strSendData); + log.info("发送报文:"+strSendData); InterFaceFileCreate.sendDiscFileCreate(strSendData, fileSavePath, fileName); postMethod.setRequestBody(strSendData); try { long start = System.currentTimeMillis(); //执行getMethod int statusCode = httpClient.executeMethod(postMethod); - System.out.println("cost:"+(System.currentTimeMillis()-start)); + System.out.println("TianJin interface ["+fileName+"] call cost time:" + (System.currentTimeMillis() - start)); //失败 if (statusCode != HttpStatus.SC_OK) { - log.error( - "Method failed: " + postMethod.getStatusLine()); + log.error("Method failed: " + postMethod.getStatusLine()); //读取内容 byte[] responseBody = postMethod.getResponseBody(); //处理内容 @@ -132,7 +130,6 @@ public class CollectAuditProcessTj { String strResp = new String(responseBody, "GBK"); log.info("服务器返回:" + strResp); InterFaceFileCreate.replyDiscFileCreate(strResp, fileSavePath, fileName); - System.out.println("服务器返回:" + strResp); //验签 if (this.verifySign(strResp)) { log.info("验签正确,处理服务器返回的报文");