From b242e37fa2cdd533db0e0596f534342065d0cf3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=B4=B5=E5=BC=BA?= Date: Wed, 9 Jul 2025 16:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=90=86=E8=B4=A2=E6=89=B9=E9=87=8F=E9=A2=84?= =?UTF-8?q?=E6=8F=90=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/CimIntBillBatchFormPlugin.java | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/CimIntBillBatchFormPlugin.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/CimIntBillBatchFormPlugin.java index 8986af8..eb77453 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/CimIntBillBatchFormPlugin.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/CimIntBillBatchFormPlugin.java @@ -11,8 +11,10 @@ import shjh.jhzj7.fi.fi.plugin.report.FinancialFormReport; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.ArrayList; import java.util.Date; import java.util.EventObject; +import java.util.List; /** * 理财批量预提表单插件 @@ -45,10 +47,7 @@ public class CimIntBillBatchFormPlugin extends AbstractFormPlugin implements Plu DynamicObjectCollection valuationentry = finsubscribe.getDynamicObjectCollection("valuationentry"); if (valuationentry != null && valuationentry.size() != 0) { - BigDecimal redProductAmount = this.getRedProductAmount(valuationentry, preintdate); - - DynamicObject targetValuation = null; // 1. 如果只有一条估值数据,直接使用 @@ -59,6 +58,7 @@ public class CimIntBillBatchFormPlugin extends AbstractFormPlugin implements Plu else { // 初始化最近日期和最小时间差 long minDiff = Long.MAX_VALUE; + List candidates = new ArrayList<>(); for (int j = 0; j < valuationentry.size(); j++) { DynamicObject valuation = valuationentry.get(j); @@ -68,13 +68,54 @@ public class CimIntBillBatchFormPlugin extends AbstractFormPlugin implements Plu // 计算时间差(绝对值) long diff = Math.abs(valuationDate.getTime() - preintdate.getTime()); - // 如果找到更接近的日期,更新目标数据 if (diff < minDiff) { minDiff = diff; - targetValuation = valuation; + candidates.clear(); + candidates.add(valuation); + } else if (diff == minDiff) { + candidates.add(valuation); } } } + + // 如果有多个候选记录,按照规则选择 + if (candidates.size() > 1) { + candidates.sort((o1, o2) -> { + // 1. 比较赎回日期 + Date redDate1 = o1.getDate("shjh_shrq"); + Date redDate2 = o2.getDate("shjh_shrq"); + + if (redDate1 != null && redDate2 != null) { + int compareRedDate = redDate2.compareTo(redDate1); // 赎回日期降序 + if (compareRedDate != 0) { + return compareRedDate; + } + } else if (redDate1 != null) { + return -1; + } else if (redDate2 != null) { + return 1; + } + + // 2. 赎回日期都为null时,比较seq(假设有seq字段) + Integer seq1 = o1.getInt("seq"); + Integer seq2 = o2.getInt("seq"); + + if (seq1 != null && seq2 != null) { + return seq2.compareTo(seq1); // seq降序 + } else if (seq1 != null) { + return -1; + } else if (seq2 != null) { + return 1; + } + + return 0; + }); + } + + // 选择排序后的第一个候选记录 + if (!candidates.isEmpty()) { + targetValuation = candidates.get(0); + } } // 3. 计算本次预算预提收益