From 73bab1725175daa793f16307ac0d932a2bb29825 Mon Sep 17 00:00:00 2001 From: zhangbb Date: Thu, 6 Aug 2020 13:30:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8D=A1=E6=89=A3=E4=BF=AE=E6=94=B9=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cache/CollectAuditInfoCache.java | 192 ++++++++++++++++-- 1 file changed, 180 insertions(+), 12 deletions(-) diff --git a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java index c69804c60..c383caa10 100644 --- a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java +++ b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java @@ -10,6 +10,13 @@ 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; @@ -25,7 +32,9 @@ 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.quartz.DateUtil; +import jbo.app.tenwa.calc.LC_COLLECT_MANUAL_INFO; import jbo.app.tenwa.calc.LC_RENT_PLAN; import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; @@ -46,7 +55,27 @@ public class CollectAuditInfoCache { private String clearDate; private String distributor_id; private String penaltys; - + private String collectStyle; + private String collecMoneys; + private String datas; + private String jobName; + + public String getCollecMoneys() { + return collecMoneys; + } + + public void setCollecMoneys(String collecMoneys) { + this.collecMoneys = collecMoneys; + } + + public String getDatas() { + return datas; + } + + public void setDatas(String datas) { + this.datas = datas; + } + /** * 经销商保证金代偿后红冲 * 租金计划表ID,在保证金收取表中为depositcharge_id,在退回表中为RENT_PLAN_ID @@ -801,7 +830,88 @@ public class CollectAuditInfoCache { } return "系统正在处理中,请稍后"; } - + /** + * 手动批量代收-发送请求 + * @param tx + * @return + * @throws Exception + */ + public String batchCollectManageManual(JBOTransaction tx) throws Exception{ + String[] ids = id.split("@"); + String datas_json = datas.replaceAll("@", ","); + JSONObject object = JSON.parseObject(datas_json); + StringBuffer parms = new StringBuffer(); + for (String str : ids) { + if (parms.length()==0) { + parms.append("'"+str+"'"); + }else{ + parms.append(",'"+str+"'"); + } + } + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_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) { + for(BizObject bo:bolist){ + String plan_id = bo.getAttribute("id").toString(); + bo.setAttributeValue("rent", object.get(plan_id)); + } + singleBatchCollectMoeny(tx, bolist); + } + return "系统正在处理中,请稍后"; + } + /** + * 检查定时任务是否正在运行 + * @param jobName + * @return + */ + public String isRunning(){ + try { + Scheduler defaultScheduler = StdSchedulerFactory.getDefaultScheduler(); + List jobContexts = defaultScheduler.getCurrentlyExecutingJobs(); + for (JobExecutionContext context : jobContexts) { + System.out.println(context.getTrigger().getJobKey().getName()); + if (jobName.equals(context.getTrigger().getJobKey().getName())) { + return "using"; + } + } + } catch (SchedulerException e) { + e.printStackTrace(); + return "using"; + } + System.out.println("定时任务未在运行中,可以发起!"); + return "unUse"; + } + /** + * 获取当日扣款数量 + * @param jobName + * @return + */ + public String getCollectCount(){ + String count = ""; + try { + BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME); + String curDate = DateUtil.getSystemTimeByFormat("yyyy/MM/dd"); + String[] ids = id.split("@"); + for(int i=0;i=2){ + count = collectCount+""; + return count; + } + } + + + } catch (JBOException e) { + e.printStackTrace(); + return "error"; + } + + return count; + } /** * 查询批量收款状态 * @return @@ -966,7 +1076,7 @@ public class CollectAuditInfoCache { n = 0; } } - } + } return "success"; @@ -980,6 +1090,8 @@ public class CollectAuditInfoCache { blbo.setAttributeValue("COLLECT_MSG", bo.getAttribute("COLLECT_MSG").getString()); blbo.setAttributeValue("BATCH_STATUS", bo.getAttribute("BATCH_STATUS").getString()); } + DecimalFormat format = new DecimalFormat("0.00"); + rent = format.format(new BigDecimal(rent )); blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_SN, batch_sn); blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_NO, bo.getAttribute("BATCH_NO").getString()); blbo.setAttributeValue(LB_BUCKLE_LOG.RENT_ID, bo.getAttribute("ID").getString()); @@ -1310,11 +1422,12 @@ public class CollectAuditInfoCache { strbuff.append(""); int item = 0; for (BizObject biz : list) { - BigDecimal m = new BigDecimal(biz.getAttribute("rent").toString()); + BigDecimal m = new BigDecimal(biz.getAttribute("rent").toString()); String rent = String.valueOf(m.multiply(new BigDecimal(100)).longValue()); String acc_number = biz.getAttribute("acc_number").toString(); 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; boolean flag = false; @@ -1347,7 +1460,7 @@ public class CollectAuditInfoCache { //追加批量处理状态 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); + BizObject bo = bm.createQuery("O.id=:id").setParameter("id", planId).getSingleResult(false); String itemsn0 = ""; if (bo !=null) { String itemsn = bo.getAttribute("batch_sn").toString(); @@ -1361,14 +1474,34 @@ public class CollectAuditInfoCache { .setParameter("BATCH_STATUS", "")//处理状态-为空 .setParameter("BATCH_NO", req_sn) .setParameter("BATCH_SN", itemsn0) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); + .setParameter("id", planId).executeUpdate(); + //手动的添加到手动表 + if("manual".equals(collectStyle)){ + BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans); + if(k==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(); trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); trans_detail.setACCOUNT_NO(acc_number); trans_detail.setACCOUNT_NAME(account); trans_detail.setACCOUNT_PROP("0"); - trans_detail.setAMOUNT(String.valueOf(singleitem)); + trans_detail.setAMOUNT(String.valueOf(singleitem)); trans_detail.setCURRENCY("CNY"); trans_detail.setRECKON_ACCOUNT(""); strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); @@ -1389,7 +1522,7 @@ public class CollectAuditInfoCache { //追加批量处理状态 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); + BizObject bo = bm.createQuery("O.id=:id").setParameter("id", planId).getSingleResult(false); String itemsn0 = ""; if (bo !=null) { String itemsn = bo.getAttribute("batch_sn").toString(); @@ -1403,7 +1536,15 @@ public class CollectAuditInfoCache { .setParameter("BATCH_STATUS", "")//处理状态-为空 .setParameter("BATCH_NO", req_sn) .setParameter("BATCH_SN", itemsn0) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); + .setParameter("id", planId).executeUpdate(); + //手动的添加到手动表 + if("manual".equals(collectStyle)){ + BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans); + 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(); trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); @@ -1415,6 +1556,7 @@ public class CollectAuditInfoCache { trans_detail.setRECKON_ACCOUNT(""); strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); } + }else{ Trans_Detail trans_detail = new Trans_Detail(); String sn = ""; @@ -1432,7 +1574,18 @@ public class CollectAuditInfoCache { .setParameter("BATCH_STATUS", "")//处理状态-为空 .setParameter("BATCH_NO", req_sn) .setParameter("BATCH_SN", sn) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); + .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("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd")); + bmlcmi.saveObject(bolmci); + } trans.commit(); trans_detail.setSN(sn); trans_detail.setACCOUNT_TYPE(""); @@ -1449,7 +1602,7 @@ public class CollectAuditInfoCache { strbuff.append(""); strbuff.append(""); strbuff.append(""); - + collectStyle=null; return strbuff; } @@ -1783,6 +1936,21 @@ public class CollectAuditInfoCache { public void setPenaltys(String penaltys) { this.penaltys = penaltys; } - + + public String getCollectStyle() { + return collectStyle; + } + + public void setCollectStyle(String collectStyle) { + this.collectStyle = collectStyle; + } + + public String getJobName() { + return jobName; + } + + public void setJobName(String jobName) { + this.jobName = jobName; + } }