From 5385dc37d4a5d043081f64c072e46de7a1d297a3 Mon Sep 17 00:00:00 2001 From: xiaoshi <2272816786@qq.com> Date: Fri, 6 Dec 2024 15:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E5=85=A5=E4=B8=8E=E6=94=AF=E5=87=BA?= =?UTF-8?q?=E5=90=88=E5=90=8C=E8=AE=A1=E9=87=8F=E6=B8=85=E5=8D=95=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InContractMeasurementBillEditPlugin.java | 102 ++++++++++++++---- .../operate/OutContractSettlementOp.java | 10 ++ 2 files changed, 93 insertions(+), 19 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractMeasurementBillEditPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractMeasurementBillEditPlugin.java index c0cd5eb..6f93925 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractMeasurementBillEditPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractMeasurementBillEditPlugin.java @@ -3,6 +3,7 @@ package zcgj.zcdev.zcdev.pr.plugin.form; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.CloseCallBack; import kd.bos.form.ShowFormHelper; import kd.bos.list.ListShowParameter; @@ -20,25 +21,20 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd @Override protected void onThisQtyChanged(ChangeData changeData) { - BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal)changeData.getNewValue()); + BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal) changeData.getNewValue()); int rowIndex = changeData.getRowIndex(); int parentRowIndex = changeData.getParentRowIndex(); - BigDecimal totalqty = (BigDecimal)this.getModel().getValue("totalqty", rowIndex, parentRowIndex); - BigDecimal preQty = (BigDecimal)this.getModel().getValue("preqty", rowIndex, parentRowIndex); + BigDecimal totalqty = (BigDecimal) this.getModel().getValue("totalqty", rowIndex, parentRowIndex); + BigDecimal preQty = (BigDecimal) this.getModel().getValue("preqty", rowIndex, parentRowIndex); BigDecimal balanceQty = totalqty.subtract(preQty); - if (qty.compareTo(balanceQty) > 0) { -// this.getView().showMessage(String.format(ResManager.loadKDString("本期计量数量不能超过%s(总数量-期初累计计量数量)。", "ContractMeasureBillEditPlugin_4", "ec-contract-formplugin", new Object[0]), balanceQty.intValue())); -// this.getModel().setValue("thisqty", BigDecimal.ZERO, rowIndex, parentRowIndex); - } else { - this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex); - BigDecimal taxPrice = (BigDecimal)this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex); - BigDecimal amount = taxPrice.multiply(qty); - this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex); - if (this.isInContract()) { - this.countPercent(rowIndex, parentRowIndex); - } - + this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex); + BigDecimal taxPrice = (BigDecimal) this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex); + BigDecimal amount = taxPrice.multiply(qty); + this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex); + if (this.isInContract()) { + this.countPercent(rowIndex, parentRowIndex); } + } @Override @@ -52,8 +48,8 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd List listingIds = new ArrayList(); int rowIndex; - for(rowIndex = 0; rowIndex < rowCount; ++rowIndex) { - DynamicObject listing = (DynamicObject)this.getModel().getValue("listing", rowIndex); + for (rowIndex = 0; rowIndex < rowCount; ++rowIndex) { + DynamicObject listing = (DynamicObject) this.getModel().getValue("listing", rowIndex); if (listing != null) { // listingIds.add(listing.getPkValue()); } @@ -61,9 +57,9 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd qFilters.add(new QFilter("id", "not in", listingIds)); rowIndex = this.getModel().getEntryCurrentRowIndex("listmodelentry"); - String listModelId = (String)this.getModel().getValue("listmodelid", rowIndex); + String listModelId = (String) this.getModel().getValue("listmodelid", rowIndex); qFilters.add(new QFilter("listingmodel", "=", StringUtils.isNotBlank(listModelId) ? Long.parseLong(listModelId) : 0L)); - DynamicObject contract = (DynamicObject)this.getModel().getValue("contract"); + DynamicObject contract = (DynamicObject) this.getModel().getValue("contract"); if (contract != null) { qFilters.add(new QFilter("contractid", "=", contract.getLong("id"))); } @@ -101,6 +97,7 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd this.getView().showForm(param); } } + private List getUnitprojectIds(DynamicObject project) { List result = null; DynamicObject orgObj = this.getModel().getDataEntity().getDynamicObject("org"); @@ -118,4 +115,71 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd }).collect(Collectors.toList()); return result; } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + ChangeData changeData = e.getChangeSet()[0]; + int rowIndex = changeData.getRowIndex(); + int parentRowIndex = changeData.getParentRowIndex(); + BigDecimal curtaxprice = BigDecimal.ZERO;//当前含税单价 + BigDecimal currentprice = BigDecimal.ZERO;//当前单价 + BigDecimal qty = BigDecimal.ZERO;//数量 + BigDecimal entrytaxrate = BigDecimal.ZERO;//税率 + BigDecimal taxrate = entrytaxrate.divide(new BigDecimal(100)); + if (parentRowIndex+rowIndex>=0){ + Object curtaxpriceobj = this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex); + if (curtaxpriceobj != null) { + curtaxprice = (BigDecimal) curtaxpriceobj; + } + Object currentpriceobj = this.getModel().getValue("currentprice", rowIndex, parentRowIndex); + if (currentpriceobj != null) { + currentprice = (BigDecimal) currentpriceobj; + ; + } + Object totalqtyibj = this.getModel().getValue("totalqty", rowIndex, parentRowIndex); + if (totalqtyibj != null) { + qty = (BigDecimal) totalqtyibj; + } + Object entrytaxrateobj = this.getModel().getValue("entrytaxrate", rowIndex, parentRowIndex); + if (entrytaxrateobj != null) { + entrytaxrate = (BigDecimal) entrytaxrateobj; + } + if (name.equals("curtaxprice") && curtaxprice.compareTo(new BigDecimal(0))>0) { + BigDecimal divide = currentprice.divide(taxrate.add(new BigDecimal(1)));//当前单价 + BigDecimal multiply = divide.multiply(qty);//当前金额 + BigDecimal multiply1 = curtaxprice.multiply(qty);//当前价税合计 + BigDecimal subtract = multiply1.subtract(multiply);//当前税额 + this.getModel().setValue("currentprice",divide, rowIndex, parentRowIndex);//当前单价 + this.getModel().setValue("currentamt", multiply,rowIndex, parentRowIndex);//当前金额 + this.getModel().setValue("currenttaxamt", subtract,rowIndex, parentRowIndex);//当前税额 + this.getModel().setValue("currentoftax", multiply1,rowIndex, parentRowIndex);//当前价税合计 + } else if (name.equals("currentprice")&¤tprice.compareTo(new BigDecimal(0))>0) { + BigDecimal divide = curtaxprice.multiply(taxrate.add(new BigDecimal(1)));//当前含税单价 + BigDecimal multiply = curtaxprice.multiply(qty);//当前金额 + BigDecimal multiply1 = divide.multiply(qty);//当前价税合计 + BigDecimal subtract = multiply1.subtract(multiply);//当前税额 + this.getModel().setValue("curtaxprice",divide, rowIndex, parentRowIndex);//当前含税单价 + this.getModel().setValue("currentamt", multiply,rowIndex, parentRowIndex);//当前金额 + this.getModel().setValue("currenttaxamt",multiply1, rowIndex, parentRowIndex);//当前税额 + this.getModel().setValue("currentoftax",subtract, rowIndex, parentRowIndex);//当前价税合计 + } + } + } + + protected void updateAmount(ChangeData changeData) { +// int rowIndex = changeData.getRowIndex(); +// int parentRowIndex = changeData.getParentRowIndex(); +// BigDecimal curtaxrate = (BigDecimal)this.getModel().getValue("curtaxprice", rowIndex,parentRowIndex);//当前含税单价 +// BigDecimal curtaxprice = (BigDecimal)this.getModel().getValue("currentprice", rowIndex,parentRowIndex);//当前单价 +// BigDecimal qty = (BigDecimal)this.getModel().getValue("totalqty", rowIndex,parentRowIndex);//数量 +// +// this.getModel().setValue("curtaxprice", rowIndex,parentRowIndex);//当前金额 +// this.getModel().setValue("currentprice", rowIndex,parentRowIndex);//当前税额 +// this.getModel().setValue("currentamt", rowIndex,parentRowIndex);//当前金额 +// this.getModel().setValue("currenttaxamt", rowIndex,parentRowIndex);//当前税额 +// this.getModel().setValue("currentoftax", rowIndex,parentRowIndex);//当前价税合计 + + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java index 633da93..8e44301 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java @@ -1,12 +1,22 @@ package zcgj.zcdev.zcdev.pr.plugin.operate; import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.entity.validate.AbstractValidator; import kd.ec.contract.opplugin.OutContractSettleOp; +import kd.ec.contract.opplugin.validator.OutContractSettleValidator; + +import java.util.List; public class OutContractSettlementOp extends OutContractSettleOp { @Override public void onAddValidators(AddValidatorsEventArgs e) { super.onAddValidators(e); + List validators = e.getValidators(); + // 删除标品校验器 + validators.removeIf(validator -> validator instanceof OutContractSettleValidator); + + // 添加定制二开的校验器(位置放第一位,优先执行) + validators.add(0, new OutContractSettlementValidator()); } }