From db5f06c966edbc482deaecafe3d02e6a94984480 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Thu, 19 Dec 2024 16:08:41 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=90=88=E5=90=8C=E7=BB=93=E7=AE=97=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=97=B6,=E5=B0=86=E7=BB=93=E7=AE=97=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=8C=89=E7=85=A7=E5=90=88=E5=90=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E9=87=91=E5=B9=B4=E9=99=90=E8=AE=A1=E7=AE=97=E5=90=88=E5=90=8C?= =?UTF-8?q?=E6=9C=80=E7=BB=88=E4=BB=98=E6=AC=BE=E6=97=A5=E6=9C=9F=E5=8F=8D?= =?UTF-8?q?=E5=86=99=E5=90=88=E5=90=8C(=E5=90=88=E5=90=8C=E8=B4=A8?= =?UTF-8?q?=E9=87=8F=E4=BF=9D=E4=BF=AE=E6=9C=9F=EF=BC=9A1=E6=9C=88?= =?UTF-8?q?=E3=80=812=E6=9C=88=E3=80=813=E6=9C=88=E3=80=814=E6=9C=88?= =?UTF-8?q?=E3=80=815=E6=9C=88=E3=80=81=E5=8D=8A=E5=B9=B4=E3=80=811?= =?UTF-8?q?=E5=B9=B4=E3=80=812=E5=B9=B4=E3=80=813=E5=B9=B4=E3=80=814?= =?UTF-8?q?=E5=B9=B4=E3=80=815=E5=B9=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit S --- .../opplugin/ConsettlebillAuditOPPlugin.java | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java b/main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java index f3de417..d0a6679 100644 --- a/main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java +++ b/main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java @@ -31,34 +31,62 @@ public class ConsettlebillAuditOPPlugin extends AbstractOperationServicePlugIn { DynamicObjectCollection qeug_bondentrys = contractbills.getDynamicObjectCollection("qeug_bondentry"); for (DynamicObject qeugBondentry : qeug_bondentrys) { String qeugYear = qeugBondentry.getString("qeug_year");//年限 - switch (qeugYear){ + //1月、2月、3月、4月、5月、半年、1年、2年、3年、4年、5年 + Date updatedDate = null; // 声明一个变量用于保存更新后的日期 + + switch (qeugYear) { case "A": - //1年 - if (null !=bizdate) { - // 将 Date 转换为 LocalDate - LocalDate localBizDate = bizdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - // 加上一年 - LocalDate newBizDate = localBizDate.plusYears(1); - //转换回 Date 类型 - Date updatedBizDate = Date.from(newBizDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); - qeugBondentry.set("qeug_finalpaymentdate",updatedBizDate);//最终付款日期 - } + updatedDate = updateBizDate(bizdate, 1); // 1个月 break; case "B": - //半年 - if (null !=bizdate) { - LocalDate localBizDate = bizdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - // 加上六个月 - LocalDate newBizDate = localBizDate.plusMonths(6); - Date updatedBizDate = Date.from(newBizDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); - qeugBondentry.set("qeug_finalpaymentdate",updatedBizDate);//最终付款日期 - } + updatedDate = updateBizDate(bizdate, 2); // 2个月 + break; + case "C": + updatedDate = updateBizDate(bizdate, 3); // 3个月 + break; + case "D": + updatedDate = updateBizDate(bizdate, 4); // 4个月 + break; + case "E": + updatedDate = updateBizDate(bizdate, 5); // 5个月 + break; + case "F": + updatedDate = updateBizDate(bizdate, 6); // 6个月 + break; + case "G": + updatedDate = updateBizDate(bizdate, 12); // 一年 + break; + case "H": + updatedDate = updateBizDate(bizdate, 24); // 两年 + break; + case "I": + updatedDate = updateBizDate(bizdate, 36); // 三年 + break; + case "J": + updatedDate = updateBizDate(bizdate, 48); // 四年 + break; + case "K": + updatedDate = updateBizDate(bizdate, 60); // 五年 + break; default: break; } + // 在 switch 语句外设置最终付款日期 + if (updatedDate != null) { + qeugBondentry.set("qeug_finalpaymentdate", updatedDate); // 设置最终付款日期 + } } SaveServiceHelper.save(new DynamicObject[]{contractbills}); } } } + + private Date updateBizDate(Date bizdate, int monthsToAdd) { + if (bizdate != null) { + LocalDate localBizDate = bizdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); // 将 Date 转换为 LocalDate + LocalDate newBizDate = localBizDate.plusMonths(monthsToAdd); // 根据传入的月份数加上月份 + return Date.from(newBizDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); // 返回更新后的 Date 类型 + } + return null; + } }