From e7d9c89a889c9aa89fdbba6125b40d688582c70b Mon Sep 17 00:00:00 2001 From: yjf <2211675158@qq.com> Date: Wed, 13 Sep 2023 16:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E7=94=B3=E8=AF=B7=E4=BF=A1?= =?UTF-8?q?=E5=AE=A1=E5=A4=8D=E5=AE=A1=E5=AF=B9=E5=AE=A1=E6=89=B9=E9=A2=9D?= =?UTF-8?q?=E5=BA=A6=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../businessapply/LBBusinessPrimary.java | 134 ++++++++++++------ 1 file changed, 89 insertions(+), 45 deletions(-) diff --git a/src_tenwa/com/tenwa/lease/flow/project/businessapply/LBBusinessPrimary.java b/src_tenwa/com/tenwa/lease/flow/project/businessapply/LBBusinessPrimary.java index 6cce372c2..0341014df 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/businessapply/LBBusinessPrimary.java +++ b/src_tenwa/com/tenwa/lease/flow/project/businessapply/LBBusinessPrimary.java @@ -1,70 +1,114 @@ package com.tenwa.lease.flow.project.businessapply; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - 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.awe.util.ASResultSet; +import com.amarsoft.awe.util.SqlObject; import com.amarsoft.awe.util.Transaction; -import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.flow.baseBussion.BaseBussiness; -import com.tenwa.reckon.util.Conn; - -import jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP; import jbo.app.tenwa.customer.CUSTOMER_FAMILY_TEMP; -import jbo.app.tenwa.customer.CUSTOMER_INFO; import jbo.app.tenwa.customer.CUSTOMER_INFO_TEMP; import jbo.com.tenwa.lease.comm.LB_GUARANTEE_UNIT_TEMP; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; -public class LBBusinessPrimary extends BaseBussiness { +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class LBBusinessPrimary extends BaseBussiness { @SuppressWarnings("deprecation") @Override public Object run(Transaction Sqlca) throws Exception { this.initBussinessParam(Sqlca); - String flowUnid=this.getAttribute("ObjectNo").toString(); - - BizObjectManager ciManage = JBOFactory.getBizObjectManager(CUSTOMER_INFO.CLASS_NAME, Sqlca); + String flowUnid = this.getAttribute("ObjectNo").toString(); + String custType = this.getAttribute("CustomerType").toString(); + BigDecimal exposureMoney = obtainExposureMoney(Sqlca, flowUnid); + BigDecimal compareMoney = BigDecimal.ZERO; + String routeType = this.getAttribute("routeType").toString(); + if ("40".equals(routeType)) {//个人小于等于60万,法人小于等于100万 + compareMoney = "03".equals(custType) ? BigDecimal.valueOf(600000) : BigDecimal.valueOf(1000000); + } else if ("50".equals(routeType)) {//个人小于等于100万,法人小于等于200万 + compareMoney = "03".equals(custType) ? BigDecimal.valueOf(1000000) : BigDecimal.valueOf(2000000); + } else if ("60".equals(routeType)) {//个人小于等于200万,法人小于等于300万 + compareMoney = "03".equals(custType) ? BigDecimal.valueOf(2000000) : BigDecimal.valueOf(3000000); + } else if ("70".equals(routeType)) {//个人小于等于300万,法人小于等于500万 + compareMoney = "03".equals(custType) ? BigDecimal.valueOf(3000000) : BigDecimal.valueOf(5000000); + } else if ("80".equals(routeType)) {//个人大于300万,法人大于500万 + return "true"; + } + if (exposureMoney.compareTo(compareMoney) > -1) { + return "false"; + } else { + return "true"; + } + } + + + /** + * 条件判断金额获取逻辑 + * 主借人或者共借人或担保人出现在其他合同(全条线业务)中作为主借或者共借人或担保人(重复合同取一次计算) + * 全部合同的(已放款的贷款余额 + 待放款的贷款金额 + 已核准未放款贷款金额 - 保证金金额) + 本单申请的(贷款金额 - 保证金金额)+ 当前在信审节点中[流程状态不属于(0010,1020,1000,8000)]申请的(贷款金额 - 保证金金额) + */ + public static BigDecimal obtainExposureMoney(Transaction Sqlca,String flowUnid) throws Exception{ BizObjectManager citManage = JBOFactory.getBizObjectManager(CUSTOMER_INFO_TEMP.CLASS_NAME, Sqlca); BizObjectManager cftManage = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY_TEMP.CLASS_NAME, Sqlca); BizObjectManager lgutManage = JBOFactory.getBizObjectManager(LB_GUARANTEE_UNIT_TEMP.CLASS_NAME, Sqlca); - - StringBuffer sql = new StringBuffer("select sum(t.bc_money) as bcMoney from (select max(ifnull(CLEAN_LEASE_MONEY,0)) - max(ifnull(CAUTION_MONEY,0)) as bc_money from lb_project_info lpi left join lb_union_lessee lul on lul.PROJECT_ID=lpi.id left join customer_info ci on ci.customerid=lul.CUSTOMER_ID left join lb_contract_info lci on lci.PROJECT_ID=lpi.id left join lc_proj_condition lpc on lpc.PROJECT_ID=lpi.id left join CUSTOMER_FAMILY cf on cf.PROJECT_ID=lpi.id and cf.Partner_='Y' left join LB_GUARANTEE_UNIT lgu on lgu.PROJECT_ID=lpi.ID where ((lpi.PROJECT_STATUS='13' AND lci.id is null) or (lci.id is not null and (lci.CONTRACT_NO='21' or lci.CONTRACT_NO='31') )) "); + //证件号列表 + ArrayList certIdList = new ArrayList<>(); + //承租人 BizObject cit = citManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid",flowUnid ).getSingleResult(false); - String certId = cit.getAttribute("certid").getString(); // 承租人身份证号 - StringBuffer certIdList = new StringBuffer(certId); + if (StringUtils.isNotBlank(cit.getAttribute("certid").getString())) certIdList.add(cit.getAttribute("certid").getString()); + //配偶 BizObject cft = cftManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid",flowUnid ).getSingleResult(false); - if(cft!=null && cft.getAttribute("certid").getString() !=null ) { - certIdList.append("','").append(cft.getAttribute("certid").getString()); + if (cft!=null && StringUtils.isNotBlank(cft.getAttribute("certid").getString())) certIdList.add(cft.getAttribute("certid").getString()); + //担保人 + List lugList = lgutManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid",flowUnid ).getResultList(false); + if (CollectionUtils.isNotEmpty(lugList)) { + lugList.forEach(item -> { + try { + if (StringUtils.isNotBlank(item.getAttribute("certid").getString())) { + certIdList.add(item.getAttribute("CERTID").getString()); + } + } catch (JBOException e) { + e.printStackTrace(); + } + }); } - List lugList = lgutManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid",flowUnid ).getResultList(false); - if(lugList!=null && lugList.size()>0) { - for (BizObject lug : lugList) { - certIdList.append("','").append(lug.getAttribute("CERTID").getString()); - } - + if (certIdList.size() == 0) throw new RuntimeException("信审初审-路由判断证件信息为空!"); + String certIdJoin = certIdList.stream().collect(Collectors.joining("','", "'", "'")); + + //所有合同金额 + StringBuilder allContractSql = new StringBuilder("select sum(bc_money) as bcMoney from (select if(isnull(lri.income_corpus), CLEAN_LEASE_MONEY,CLEAN_LEASE_MONEY-lri.income_corpus) - ifnull(CAUTION_MONEY,0) as bc_money"); + allContractSql.append(" from lb_project_info lpi") + .append(" left join lc_proj_condition lpc on lpc.PROJECT_ID = lpi.id") + .append(" left join lb_contract_info lci on lci.PROJECT_ID = lpi.id") + .append(" left join lb_union_lessee lul on lul.PROJECT_ID = lpi.id") + .append(" left join customer_info ci on ci.customerid = lul.CUSTOMER_ID") + .append(" left join CUSTOMER_FAMILY cf on cf.PROJECT_ID = lpi.id and cf.Partner_ = 'Y'") + .append(" left join LB_GUARANTEE_UNIT lgu on lgu.PROJECT_ID = lpi.ID") + .append(" left join (select sum(CORPUS) as income_corpus, CONTRACT_ID from lc_rent_income group by CONTRACT_ID order by null) lri on lci.id = lri.CONTRACT_ID") + .append(" where lpi.PROJECT_STATUS = '13'") + .append(" and (ci.certid in ("+certIdJoin+") or cf.certid in ("+certIdJoin+") or lgu.CERTID in ("+certIdJoin+"))") + .append(" group by lpi.id) t"); + ASResultSet rsAll = Sqlca.getASResultSet(new SqlObject(allContractSql.toString())); + BigDecimal allContractMoney = BigDecimal.ZERO; + if (rsAll.next()) { + allContractMoney = rsAll.getBigDecimal("bcMoney"); } - sql.append(" and ci.certid in ('").append(certIdList).append("') ");//拼接承租人 - sql.append(" and cf.certid in ('").append(certIdList).append("') ");//拼接共同申请人 - sql.append(" and lgu.CERTID in ('").append(certIdList).append("') ");//拼接担保人 - sql.append(" group by lpi.id) t "); - BigDecimal cMoney =BigDecimal.ZERO; - List> retMoney = DataOperatorUtil.getDataBySql(sql.toString()); - if(retMoney!=null && retMoney.size()>0) { - cMoney.add(new BigDecimal(retMoney.get(0).get("bcMoney"))); + //流程中金额获取 信审初审节点 (包含当前流程) + String InFlowSql = "select sum(_money) as inFlowMoney from ( select lcct.CLEAN_LEASE_MONEY - ifnull(lcct.CAUTION_MONEY, 0) as _money from flow_object fo join lc_calc_condition_temp lcct on fo.objectno = lcct.FLOWUNID left join customer_info_temp cit on cit.flowunid = fo.objectno left join customer_family_temp cft on cft.flowunid = fo.objectno and cft.Partner_ = 'Y' left join lb_guarantee_unit_temp lgut on lgut.FLOWUNID = fo.objectno where flowno = 'BusinessApplyFlow' and phaseno not in ('1000', '8000', '0010', '1020') and isnull(lcct.CLEAN_LEASE_MONEY) = 0" + + " and (cit.certid in ("+certIdJoin+") or cft.certid in ("+certIdJoin+") or lgut.CERTID in ("+certIdJoin+")) group by fo.objectno) t"; + ASResultSet rsIn = Sqlca.getASResultSet(new SqlObject(InFlowSql)); + BigDecimal inFlowMoney = BigDecimal.valueOf(0); + if (rsIn.next()) { + inFlowMoney = rsIn.getBigDecimal("inFlowMoney"); } - - String sMessage =null ; - if(1==1){//走第四个节点 - sMessage="false"; - }else { - sMessage="true"; - } - - - - return sMessage; + return allContractMoney.add(inFlowMoney); } -} \ No newline at end of file + +}