From 5571bfd3bb6efdf8dec2b7c0b2e9cc46ae6c7405 Mon Sep 17 00:00:00 2001 From: chenshaoxin <1981897232@qq.com> Date: Wed, 4 Jun 2025 11:38:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BA=BA=EF=BC=9A=E9=99=88?= =?UTF-8?q?=E7=BB=8D=E9=91=AB=20=E6=97=A5=E6=9C=9F=EF=BC=9A2025/6/4=2012?= =?UTF-8?q?=EF=BC=9A30=20=E5=86=85=E5=AE=B9:=E6=8B=85=E4=BF=9D=E5=90=88?= =?UTF-8?q?=E5=90=8C=E5=88=97=E8=A1=A8=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/list/guaranteecontListPlugin.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/guaranteecontListPlugin.java diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/guaranteecontListPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/guaranteecontListPlugin.java new file mode 100644 index 0000000..3446da7 --- /dev/null +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/guaranteecontListPlugin.java @@ -0,0 +1,65 @@ +package shkd.sys.sys.plugin.list; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.events.PackageDataEvent; +import kd.bos.entity.list.column.AmountColumnDesc; +import kd.bos.entity.list.column.DynamicTextColumnDesc; +import kd.bos.list.plugin.AbstractListPlugin; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.tmc.fbp.common.constant.Constants; +import kd.tmc.fbp.common.helper.GuaranteeUseHelper; +import kd.tmc.fbp.common.helper.TmcBusinessBaseHelper; +import kd.tmc.fbp.common.helper.TmcDataServiceHelper; +import kd.tmc.fbp.common.util.EmptyUtil; +import kd.tmc.gm.common.helper.GuaranteeContractHelper; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +public class guaranteecontListPlugin extends AbstractListPlugin { + private static final String[] gcProps = new String[]{"gcomment", "gcparty", "gsrcbillid", "gsrcbillno", "gsrcbilltype", "gdebtorg", "gdebtorgtext", "gdebtcurrency", "gdebtamount", "gdebtbalance", "gratio", "gexchrate", "gdebtstartdate", "gdebtenddate", "gcontract", "gsrcbillbizamount", "gcreditortype", "gcreditor", "gcreditortext"}; + + @Override + public void packageData(PackageDataEvent e) { + super.packageData(e); + if (e.getSource() instanceof DynamicTextColumnDesc) { + DynamicTextColumnDesc column = (DynamicTextColumnDesc) e.getSource(); + if ("shkd_dynamictextlistcolum".equals(column.getFieldKey())) { + Long id = (Long) e.getRowData().get("id"); + DynamicObject gContractCcy = e.getRowData().getDynamicObject("currency"); + Long gContractCcyId = (Long)gContractCcy.getPkValue(); + QFilter gQF = new QFilter("gcontract.id", "=", id); + DynamicObjectCollection gcUseBills = QueryServiceHelper.query("gm_guaranteeuse", String.join(",", gcProps), gQF.toArray()); + Map letterCreditMap = GuaranteeContractHelper.getLetterCreditMap(gcUseBills); + Map loanBillMap = GuaranteeContractHelper.getLoanBillMap(gcUseBills); + BigDecimal sumOfBal = BigDecimal.ZERO; + if (!EmptyUtil.isEmpty(gcUseBills)) { + for (DynamicObject gcBIll : gcUseBills) { + if ("cfm_creditlimit".equals(TmcBusinessBaseHelper.getBillFormId(gcBIll.getString("gsrcbilltype")))) { + } else { + BigDecimal debtBalance = gcBIll.getBigDecimal("gdebtbalance"); + if ("lc_lettercredit".equals(gcBIll.get("gsrcbilltype")) && EmptyUtil.isNoEmpty((BigDecimal)letterCreditMap.get(gcBIll.getLong("gsrcbillid")))) { + debtBalance = ((BigDecimal)letterCreditMap.get(gcBIll.getLong("gsrcbillid"))).multiply(gcBIll.getBigDecimal("gratio")).divide(Constants.ONE_HUNDRED, 4, RoundingMode.HALF_UP); + } else if (Arrays.asList("cfm_loanbill_b_l", "cfm_loanbill_e_l", "cfm_loanbill", "cim_invest_loanbill").contains(gcBIll.get("gsrcbilltype")) && EmptyUtil.isNoEmpty((BigDecimal)loanBillMap.get(gcBIll.getLong("gsrcbillid")))) { + debtBalance = ((BigDecimal)loanBillMap.get(gcBIll.getLong("gsrcbillid"))).multiply(gcBIll.getBigDecimal("gratio")).divide(Constants.ONE_HUNDRED, 4, RoundingMode.HALF_UP); + } + Long debtBillCcy = gcBIll.getLong("gdebtcurrency"); + if (EmptyUtil.isNoEmpty(debtBillCcy) && !gContractCcyId.equals(debtBillCcy) && debtBalance.compareTo(BigDecimal.ZERO) != 0) { + BigDecimal gExchangeRate = gcBIll.getBigDecimal("gexchrate"); + debtBalance = debtBalance.multiply(gExchangeRate); + } + sumOfBal = sumOfBal.add(debtBalance); + } + } + } + e.setFormatValue(sumOfBal); + } + } + } +}