业务申请信审复审对审批额度判断

This commit is contained in:
yjf 2023-09-13 16:37:42 +08:00
parent 5dd2284e31
commit e7d9c89a88

View File

@ -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";
}
}
/**
* 条件判断金额获取逻辑
* 主借人或者共借人或担保人出现在其他合同全条线业务中作为主借或者共借人或担保人重复合同取一次计算
* 全部合同的已放款的贷款余额 + 待放款的贷款金额 + 已核准未放款贷款金额 - 保证金金额 + 本单申请的贷款金额 - 保证金金额+ 当前在信审节点中[流程状态不属于0010102010008000]申请的贷款金额 - 保证金金额
*/
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<String> 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<BizObject> 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<BizObject> 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<Map<String, String>> 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);
}
}
}