From 4ed0a524faf46dc8bb1ea2afc0d768f40e97b270 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Thu, 19 Dec 2024 14:56:38 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit S --- .../opplugin/ConsettlebillAuditOPPlugin.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java diff --git a/main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java b/main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java new file mode 100644 index 0000000..f3de417 --- /dev/null +++ b/main/java/shkd/repc/recon/opplugin/ConsettlebillAuditOPPlugin.java @@ -0,0 +1,64 @@ +package shkd.repc.recon.opplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.args.AfterOperationArgs; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; + +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Date; + +/** + * 合同结算审核 + */ +public class ConsettlebillAuditOPPlugin extends AbstractOperationServicePlugIn { + + @Override + public void afterExecuteOperationTransaction(AfterOperationArgs e) { + super.afterExecuteOperationTransaction(e); + //合同结算审核时,将结算日期按照合同保证金年限计算合同最终付款日期反写合同 + DynamicObject[] dataEntities = e.getDataEntities(); + DynamicObject dataEntity = dataEntities[0];//合同结算 + Date bizdate = dataEntity.getDate("bizdate");//结算日期 + DynamicObject contractbill = dataEntity.getDynamicObject("contractbill");//合同f7 + if (null != contractbill) { + DynamicObject contractbills = BusinessDataServiceHelper.loadSingle(contractbill.getPkValue(), "recon_contractbill"); + if (null != contractbills) { + //保证金明细 + DynamicObjectCollection qeug_bondentrys = contractbills.getDynamicObjectCollection("qeug_bondentry"); + for (DynamicObject qeugBondentry : qeug_bondentrys) { + String qeugYear = qeugBondentry.getString("qeug_year");//年限 + 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);//最终付款日期 + } + 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);//最终付款日期 + } + default: + break; + } + } + SaveServiceHelper.save(new DynamicObject[]{contractbills}); + } + } + } +}