From 17a68ff85228007ffb673687cf38ce606f5ed873 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Tue, 18 Nov 2025 15:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=97=B6=E6=A0=A1=E9=AA=8C=E5=B7=B2=E5=86=B2=E9=94=80=E9=87=91?= =?UTF-8?q?=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/MaterialinCheckBoltamountOp.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinCheckBoltamountOp.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinCheckBoltamountOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinCheckBoltamountOp.java new file mode 100644 index 0000000..96f7232 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinCheckBoltamountOp.java @@ -0,0 +1,79 @@ +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 MaterialinCheckBoltamountOp extends AbstractOperationServicePlugIn { + + private static final Log log = LogFactory.getLog(MaterialinCheckBoltamountOp.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_prepayentry.zcgj_alreadyboltamount");//已冲销金额 + e.getFieldKeys().add("zcgj_prepayentry.zcgj_prepayamount");//预付金额 + 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();//入库单 + String isprepay = dataEntity.getString("zcgj_isprepay"); + if("10".equals(isprepay)){ + DynamicObjectCollection prepayentryCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//冲销预付分录 + 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");//本次冲销金额 + BigDecimal prepayamount = prepay.getBigDecimal("zcgj_prepayamount");//预付金额 + DynamicObject paymentapply = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "ec_paymentapply");//工程资金付款申请单 + if (paymentapply != null) { + DynamicObjectCollection entryentityCollection = paymentapply.getDynamicObjectCollection("entryentity"); + + for (DynamicObject dynamicObject : entryentityCollection) { + long pkValue = (long)dynamicObject.getPkValue(); + if(pkValue==sourceapplyentryid){ + BigDecimal yreversalamount = dynamicObject.getBigDecimal("zcgj_yreversalamount");//付款申请单已冲销金额+入库单本次冲销金额 + yreversalamount = yreversalamount.add(boltamount); + if(prepayamount.subtract(yreversalamount).compareTo(BigDecimal.ZERO) < 0){ + this.addFatalErrorMessage(extendedDataEntity, String.format("冲销预付分录第%d行,累计冲销金额超过预付金额!",seq)); + } + } + } + } + } + } + } + } + } + } +}