From e62988389f224b1fbba4cc01f14f5dc952bc78a9 Mon Sep 17 00:00:00 2001 From: yjf <2211675158@qq.com> Date: Thu, 14 Sep 2023 09:11:59 +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 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 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 0341014df..67577cfb5 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/businessapply/LBBusinessPrimary.java +++ b/src_tenwa/com/tenwa/lease/flow/project/businessapply/LBBusinessPrimary.java @@ -83,7 +83,7 @@ public class LBBusinessPrimary extends BaseBussiness { 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"); + StringBuilder allContractSql = new StringBuilder("select ifnull(sum(bc_money),0) as bcMoney,group_concat(proj_id separator '\\',\\'') as proj_ids from (select lpi.id as proj_id,CLEAN_LEASE_MONEY-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") @@ -91,24 +91,34 @@ public class LBBusinessPrimary extends BaseBussiness { .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; + String projIds = null; if (rsAll.next()) { allContractMoney = rsAll.getBigDecimal("bcMoney"); + projIds = rsAll.getString("proj_ids"); + } + //项目下实收金额 + BigDecimal incomeMoney = BigDecimal.ZERO; + if (StringUtils.isNotBlank(projIds)) { + String incomeMoneySql = "select ifnull(sum(corpus),0) as all_income from lc_rent_income where PROJECT_ID in ('" + projIds + "')"; + ASResultSet incomeMoneyRs = Sqlca.getASResultSet(new SqlObject(incomeMoneySql)); + if (incomeMoneyRs.next()) { + incomeMoney = incomeMoneyRs.getBigDecimal("all_income"); + } } //流程中金额获取 信审初审节点 (包含当前流程) - 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" + String InFlowSql = "select ifnull(sum(_money),0) 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"); } - return allContractMoney.add(inFlowMoney); + return allContractMoney.subtract(incomeMoney).add(inFlowMoney); } }