From a61824e72faa5b81190362718a553db15d40b1b9 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:19:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E5=87=BA=E8=B4=A2=E5=8A=A1=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E5=8D=95=E6=8F=90=E4=BA=A4=E6=97=B6=E5=86=B2=E9=94=80?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E6=A0=A1=E9=AA=8C=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialinbillReversalamountCkOp.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java new file mode 100644 index 0000000..10adbfa --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java @@ -0,0 +1,81 @@ +package zcgj.zcdev.zcdev.pr.plugin.operate; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.ExtendedDataEntity; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.entity.plugin.PreparePropertysEventArgs; +import kd.bos.entity.validate.AbstractValidator; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.servicehelper.BusinessDataServiceHelper; + +import java.math.BigDecimal; + +/** + * 支出财务确认单提交时冲销金额校验插件 + */ +public class MaterialinbillReversalamountCkOp extends AbstractOperationServicePlugIn { + + private static final Log log = LogFactory.getLog(MaterialinbillReversalamountCkOp.class); + + public void onPreparePropertys(PreparePropertysEventArgs e) { + e.getFieldKeys().add("zcgj_prepayentry"); + e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplybillid"); + e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplyentryid"); + e.getFieldKeys().add("zcgj_prepayentry.zcgj_boltamount"); + e.getFieldKeys().add("zcgj_isprepay"); + } + + @Override + public void onAddValidators(AddValidatorsEventArgs e) { + super.onAddValidators(e); + e.getValidators().add(new ValidatorExt()); + } + + class ValidatorExt extends AbstractValidator { + @Override + public void validate() { + ExtendedDataEntity[] extendedDataEntities = this.getDataEntities(); + for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) { + DynamicObject dataEntity = extendedDataEntity.getDataEntity();//支出财务确认单 + DynamicObjectCollection entryEntityCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//付款信息分录 + for (int i = 0; i < entryEntityCollection.size(); i++) { + DynamicObject entryEntity = entryEntityCollection.get(i); + DynamicObjectCollection prepayentryCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//冲销预付分录 + String isprepay = dataEntity.getString("zcgj_isprepay"); + if("10".equals(isprepay)){ + if(prepayentryCollection == null || prepayentryCollection.isEmpty()){ + this.addFatalErrorMessage(extendedDataEntity, String.format("请录入冲销预付明细数据!")); + }else{ + int seq = 0; + for (DynamicObject prepay : prepayentryCollection) { + seq++; + long sourceapplybillid = prepay.getLong("zcgj_sourceapplybillid"); + long sourceapplyentryid = prepay.getLong("zcgj_sourceapplyentryid"); + BigDecimal boltamount = prepay.getBigDecimal("zcgj_boltamount");//入库单冲销金额 + DynamicObject paymentapply = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "ec_paymentapply");//工程资金付款申请单 + if (paymentapply != null) { + DynamicObjectCollection entryentityCollection = paymentapply.getDynamicObjectCollection("entryentity"); + + for (DynamicObject dynamicObject : entryentityCollection) { + BigDecimal thisrealpayamt = dynamicObject.getBigDecimal("thisrealpayamt");//付款申请单本次实付金额 + long pkValue = (long)dynamicObject.getPkValue(); + if(pkValue==sourceapplyentryid){ + BigDecimal zcgjYreversalamount = dynamicObject.getBigDecimal("zcgj_yreversalamount"); + zcgjYreversalamount = zcgjYreversalamount.add(boltamount); + if(thisrealpayamt.subtract(zcgjYreversalamount).compareTo(BigDecimal.ZERO) < 0){ + this.addFatalErrorMessage(extendedDataEntity, String.format("冲销预付分录第%d行,冲销金额超限!",seq)); + } + } + } + } + } + } + } + } + } + } + } +}