From a8af3c532ac9645d71fc29496fe39e1e7f93336c Mon Sep 17 00:00:00 2001 From: hello Date: Fri, 10 Oct 2025 15:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=AF=E5=87=BA=E5=90=88?= =?UTF-8?q?=E5=90=8C=E7=BB=93=E7=AE=97=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContractSettleCommonEditPluginExt.java | 565 +++++++++++------- 1 file changed, 353 insertions(+), 212 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleCommonEditPluginExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleCommonEditPluginExt.java index 711ea5a..145096b 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleCommonEditPluginExt.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleCommonEditPluginExt.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; + import kd.bos.bill.OperationStatus; import kd.bos.dataentity.entity.DataEntityBase; import kd.bos.dataentity.entity.DynamicObject; @@ -53,6 +54,7 @@ import kd.bos.form.field.events.BeforeF7SelectEvent; import kd.bos.form.field.events.BeforeF7SelectListener; import kd.bos.form.operate.FormOperate; import kd.bos.list.ListShowParameter; +import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.ec.basedata.business.model.cont.ContractSettleTplConstant; @@ -67,6 +69,7 @@ import kd.ec.contract.common.utils.ContractHelper; import kd.ec.contract.formplugin.AbstractContBillPlugin; import kd.ec.contract.utils.SettleUpdateAmtUtils; import org.jetbrains.annotations.NotNull; +import zcgj.zcdev.zcdev.pr.plugin.utils.PluginUtils; /** * 支出合同结算修改系统插件 @@ -91,8 +94,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im Iterator var4 = payItemDetailEntries.iterator(); DynamicObject payItem; - while(var4.hasNext()) { - DynamicObject entry = (DynamicObject)var4.next(); + while (var4.hasNext()) { + DynamicObject entry = (DynamicObject) var4.next(); payItem = entry.getDynamicObject("detailpayitem"); if (payItem != null) { detailItemIds.add(payItem.getPkValue()); @@ -101,8 +104,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im int rowCount = this.getModel().getEntryRowCount("itementry"); - for(int i = 0; i < rowCount; ++i) { - payItem = (DynamicObject)this.getModel().getValue("payitem", i); + for (int i = 0; i < rowCount; ++i) { + payItem = (DynamicObject) this.getModel().getValue("payitem", i); if (payItem != null && detailItemIds.contains(payItem.getPkValue())) { this.getModel().setValue("hasdetail", true, i); if (!isDataChange) { @@ -143,7 +146,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im public void registerListener(EventObject e) { super.registerListener(e); - BasedataEdit contract = (BasedataEdit)this.getControl("contract"); + BasedataEdit contract = (BasedataEdit) this.getControl("contract"); if (contract != null) { contract.addBeforeF7SelectListener(this); contract.addBeforeF7ViewDetailListener((beforeF7ViewDetailEvent) -> { @@ -152,7 +155,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im }); } - BasedataEdit project = (BasedataEdit)this.getView().getControl("project"); + BasedataEdit project = (BasedataEdit) this.getView().getControl("project"); if (project != null) { project.addBeforeF7ViewDetailListener((beforeF7ViewDetailEvent) -> { beforeF7ViewDetailEvent.setCancel(true); @@ -160,13 +163,13 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im }); } - EntryGrid payItemDetailEntry = (EntryGrid)this.getControl("payitemdetailentry"); + EntryGrid payItemDetailEntry = (EntryGrid) this.getControl("payitemdetailentry"); payItemDetailEntry.addHyperClickListener(this); } public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) { String propName = beforeF7SelectEvent.getProperty().getName(); - ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter(); + ListShowParameter showParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter(); if (StringUtils.equals(propName, "contract")) { this.beforeContractSelect(showParameter); } @@ -179,7 +182,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im public void beforeDoOperation(BeforeDoOperationEventArgs args) { super.beforeDoOperation(args); - FormOperate operate = (FormOperate)args.getSource(); + FormOperate operate = (FormOperate) args.getSource(); String operateKey = operate.getOperateKey(); if (StringUtils.equals(operateKey, "addentry")) { this.addItemEntry(args); @@ -194,16 +197,16 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected void beforeDeleteDetail(BeforeDoOperationEventArgs args) { - EntryGrid payItemDetailEntryGrid = (EntryGrid)this.getControl("payitemdetailentry"); + EntryGrid payItemDetailEntryGrid = (EntryGrid) this.getControl("payitemdetailentry"); int[] selectRows = payItemDetailEntryGrid.getSelectRows(); boolean flag = false; Set deleteReferBillIds = new HashSet(); List list = new ArrayList(); String referBillType; - for(int i = 0; i < selectRows.length; ++i) { - Long referBillNumber = (Long)this.getModel().getValue("referbillid", selectRows[i]); - referBillType = (String)this.getModel().getValue("referbilltype", selectRows[i]); + for (int i = 0; i < selectRows.length; ++i) { + Long referBillNumber = (Long) this.getModel().getValue("referbillid", selectRows[i]); + referBillType = (String) this.getModel().getValue("referbilltype", selectRows[i]); if (StringUtils.equals("perform", referBillType)) { deleteReferBillIds.add(referBillNumber); flag = true; @@ -215,10 +218,10 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im if (!deleteReferBillIds.isEmpty()) { DynamicObjectCollection payItemEntry = this.getModel().getEntryEntity("payitemdetailentry"); - for(int i = 0; i < payItemEntry.size(); ++i) { - referBillType = ((DynamicObject)payItemEntry.get(i)).getString("referbilltype"); + for (int i = 0; i < payItemEntry.size(); ++i) { + referBillType = ((DynamicObject) payItemEntry.get(i)).getString("referbilltype"); if (StringUtils.equals("perform", referBillType)) { - long referBillNumber = ((DynamicObject)payItemEntry.get(i)).getLong("referbillid"); + long referBillNumber = ((DynamicObject) payItemEntry.get(i)).getLong("referbillid"); if (deleteReferBillIds.contains(referBillNumber)) { list.add(i); } @@ -256,11 +259,11 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im private void deletePerform() { String selectPayItem = this.getPageCache().get("selectPayItem"); - List selectPerform = (List)SerializationUtils.fromJsonString(selectPayItem, List.class); + List selectPerform = (List) SerializationUtils.fromJsonString(selectPayItem, List.class); int[] selectRows = new int[selectPerform.size()]; - for(int i = 0; i < selectPerform.size(); ++i) { - selectRows[i] = (Integer)selectPerform.get(i); + for (int i = 0; i < selectPerform.size(); ++i) { + selectRows[i] = (Integer) selectPerform.get(i); } if (this.getPayDirection().equals(PayDirectionEnum.OUT.getValue())) { @@ -286,22 +289,22 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im BigDecimal itemOfTaxAmt; BigDecimal ofTax; BigDecimal amount; - for(int var7 = 0; var7 < var6; ++var7) { + for (int var7 = 0; var7 < var6; ++var7) { int rowIndex = var5[var7]; itemPayItem = this.getModel().getEntryRowEntity("payitemdetailentry", rowIndex); DynamicObject detailpayitem = itemPayItem.getDynamicObject("detailpayitem"); if (detailpayitem != null) { // 修复:正确获取detailunitproject并生成mapKey - DynamicObject detailunitproject1 = (DynamicObject)itemPayItem.get("detailunitproject"); + DynamicObject detailunitproject1 = (DynamicObject) itemPayItem.get("detailunitproject"); String mapKey = detailpayitem.getString("id") + "," + (detailunitproject1 != null ? detailunitproject1.getString("id") : ""); - itemOfTaxAmt = (BigDecimal)ofTaxMap.getOrDefault(mapKey, BigDecimal.ZERO); + itemOfTaxAmt = (BigDecimal) ofTaxMap.getOrDefault(mapKey, BigDecimal.ZERO); itemOfTaxAmt = itemOfTaxAmt.add(itemPayItem.getBigDecimal("detailoftaxamt") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("detailoftaxamt")); ofTaxMap.put(mapKey, itemOfTaxAmt); - ofTax = (BigDecimal)amountMap.getOrDefault(mapKey, BigDecimal.ZERO); + ofTax = (BigDecimal) amountMap.getOrDefault(mapKey, BigDecimal.ZERO); ofTax = ofTax.add(itemPayItem.getBigDecimal("detailamt") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("detailamt")); amountMap.put(mapKey, ofTax); - amount = (BigDecimal)taxMap.getOrDefault(mapKey, BigDecimal.ZERO); + amount = (BigDecimal) taxMap.getOrDefault(mapKey, BigDecimal.ZERO); amount = amount.add(itemPayItem.getBigDecimal("detailtaxamt") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("detailtaxamt")); taxMap.put(mapKey, amount); } @@ -311,8 +314,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObjectCollection itemEntryCol = this.getModel().getEntryEntity("itementry"); Iterator iterator = itemEntryCol.iterator(); - while(true) { - while(true) { + while (true) { + while (true) { DynamicObject itemEntry; String uniquekey; do { @@ -322,26 +325,26 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im return; } - itemEntry = (DynamicObject)iterator.next(); + itemEntry = (DynamicObject) iterator.next(); /* itemPayItem = itemEntry.getDynamicObject("payitem"); detailunitproject = (DynamicObject)itemEntry.get("itemunitproject"); uniquekey = itemPayItem.getString("id") + "," + (detailunitproject != null ? detailunitproject.getString("id") : "");*///系统源码 itemPayItem = itemEntry.getDynamicObject("payitem");//合同支付项-名称 - DynamicObject itemunitproject = (DynamicObject)itemEntry.get("itemunitproject");//合同支付项-单位工程 + DynamicObject itemunitproject = (DynamicObject) itemEntry.get("itemunitproject");//合同支付项-单位工程 // 修复:正确生成uniquekey以匹配mapKey uniquekey = itemPayItem.getString("id") + "," + (itemunitproject != null ? itemunitproject.getString("id") : "");//二开修改 - } while(!ofTaxMap.containsKey(uniquekey)); + } while (!ofTaxMap.containsKey(uniquekey)); - BigDecimal itemDetailOfTaxAmt = (BigDecimal)ofTaxMap.getOrDefault(uniquekey, BigDecimal.ZERO); + BigDecimal itemDetailOfTaxAmt = (BigDecimal) ofTaxMap.getOrDefault(uniquekey, BigDecimal.ZERO); itemOfTaxAmt = itemEntry.getBigDecimal("oftaxamount"); if (itemDetailOfTaxAmt.compareTo(itemOfTaxAmt) == 0 && !StringUtils.equals(itemPayItem.getString("paymentitemtype"), PayItemTypeEnum.FIXED.getValue())) { iterator.remove(); } else { ofTax = itemEntry.getBigDecimal("oftaxamount").subtract(itemDetailOfTaxAmt); itemEntry.set("oftaxamount", ofTax); - amount = itemEntry.getBigDecimal("amount").subtract((BigDecimal)amountMap.getOrDefault(uniquekey, BigDecimal.ZERO)); + amount = itemEntry.getBigDecimal("amount").subtract((BigDecimal) amountMap.getOrDefault(uniquekey, BigDecimal.ZERO)); itemEntry.set("amount", amount); - BigDecimal tax = itemEntry.getBigDecimal("taxamt").subtract((BigDecimal)taxMap.getOrDefault(uniquekey, BigDecimal.ZERO)); + BigDecimal tax = itemEntry.getBigDecimal("taxamt").subtract((BigDecimal) taxMap.getOrDefault(uniquekey, BigDecimal.ZERO)); itemEntry.set("taxamt", tax); if (amount != null && amount.compareTo(BigDecimal.ZERO) != 0 && tax != null && multiRate) { itemEntry.set("rate", tax.multiply(new BigDecimal(100)).divide(amount, 2).setScale(0, RoundingMode.HALF_UP)); @@ -367,25 +370,25 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im BigDecimal ofTax; BigDecimal amount; BigDecimal tax; - for(int var7 = 0; var7 < var6; ++var7) { + for (int var7 = 0; var7 < var6; ++var7) { int rowIndex = var5[var7]; itemPayItem = this.getModel().getEntryRowEntity("payitemdetailentry", rowIndex); DynamicObject payItem = itemPayItem.getDynamicObject("detailpayitem"); if (payItem != null) { - itemOfTaxAmt = (BigDecimal)ofTaxMap.getOrDefault(payItem.getPkValue(), BigDecimal.ZERO); + itemOfTaxAmt = (BigDecimal) ofTaxMap.getOrDefault(payItem.getPkValue(), BigDecimal.ZERO); itemOfTaxAmt = itemOfTaxAmt.add(itemPayItem.getBigDecimal("detailoftaxamt") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("detailoftaxamt")); ofTaxMap.put(payItem.getPkValue(), itemOfTaxAmt); - ofTax = (BigDecimal)amountMap.getOrDefault(payItem.getPkValue(), BigDecimal.ZERO); + ofTax = (BigDecimal) amountMap.getOrDefault(payItem.getPkValue(), BigDecimal.ZERO); ofTax = ofTax.add(itemPayItem.getBigDecimal("detailamt") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("detailamt")); amountMap.put(payItem.getPkValue(), ofTax); - amount = (BigDecimal)taxMap.getOrDefault(payItem.getPkValue(), BigDecimal.ZERO); + amount = (BigDecimal) taxMap.getOrDefault(payItem.getPkValue(), BigDecimal.ZERO); amount = amount.add(itemPayItem.getBigDecimal("detailtaxamt") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("detailtaxamt")); taxMap.put(payItem.getPkValue(), amount); if (StringUtils.equals(PayDirectionEnum.OUT.getValue(), this.getPayDirection()) && itemPayItem.getBoolean("ismeasurebymatin")) { - tax = (BigDecimal)ofTaxMap.getOrDefault("760004250343646208", BigDecimal.ZERO); + tax = (BigDecimal) ofTaxMap.getOrDefault("760004250343646208", BigDecimal.ZERO); tax = tax.add(itemPayItem.getBigDecimal("measuretransoftax") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("measuretransoftax")); ofTaxMap.put(Long.valueOf("760004250343646208"), tax); - BigDecimal transAmount = (BigDecimal)amountMap.getOrDefault("760004250343646208", BigDecimal.ZERO); + BigDecimal transAmount = (BigDecimal) amountMap.getOrDefault("760004250343646208", BigDecimal.ZERO); transAmount = transAmount.add(itemPayItem.getBigDecimal("measuretransamt") == null ? BigDecimal.ZERO : itemPayItem.getBigDecimal("measuretransamt")); amountMap.put(Long.valueOf("760004250343646208"), transAmount); BigDecimal transTax = tax.subtract(transAmount); @@ -398,8 +401,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObjectCollection itemEntryCol = this.getModel().getEntryEntity("itementry"); Iterator iterator = itemEntryCol.iterator(); - while(true) { - while(true) { + while (true) { + while (true) { DynamicObject itemEntry; do { if (!iterator.hasNext()) { @@ -408,20 +411,20 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im return; } - itemEntry = (DynamicObject)iterator.next(); + itemEntry = (DynamicObject) iterator.next(); itemPayItem = itemEntry.getDynamicObject("payitem"); - } while(!ofTaxMap.containsKey(itemPayItem.getPkValue())); + } while (!ofTaxMap.containsKey(itemPayItem.getPkValue())); - BigDecimal itemDetailOfTaxAmt = (BigDecimal)ofTaxMap.getOrDefault(itemPayItem.getPkValue(), BigDecimal.ZERO); + BigDecimal itemDetailOfTaxAmt = (BigDecimal) ofTaxMap.getOrDefault(itemPayItem.getPkValue(), BigDecimal.ZERO); itemOfTaxAmt = itemEntry.getBigDecimal("oftaxamount"); if (itemDetailOfTaxAmt.compareTo(itemOfTaxAmt) == 0 && !StringUtils.equals(itemPayItem.getString("paymentitemtype"), PayItemTypeEnum.FIXED.getValue())) { iterator.remove(); } else { ofTax = itemEntry.getBigDecimal("oftaxamount").subtract(itemDetailOfTaxAmt); itemEntry.set("oftaxamount", ofTax); - amount = itemEntry.getBigDecimal("amount").subtract((BigDecimal)amountMap.getOrDefault(itemPayItem.getPkValue(), BigDecimal.ZERO)); + amount = itemEntry.getBigDecimal("amount").subtract((BigDecimal) amountMap.getOrDefault(itemPayItem.getPkValue(), BigDecimal.ZERO)); itemEntry.set("amount", amount); - tax = itemEntry.getBigDecimal("taxamt").subtract((BigDecimal)taxMap.getOrDefault(itemPayItem.getPkValue(), BigDecimal.ZERO)); + tax = itemEntry.getBigDecimal("taxamt").subtract((BigDecimal) taxMap.getOrDefault(itemPayItem.getPkValue(), BigDecimal.ZERO)); itemEntry.set("taxamt", tax); if (amount != null && amount.compareTo(BigDecimal.ZERO) != 0 && tax != null && multiRate) { itemEntry.set("rate", tax.multiply(new BigDecimal(100)).divide(amount, 2).setScale(0, RoundingMode.HALF_UP)); @@ -446,7 +449,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected void beforeDeleteItemEntry(BeforeDoOperationEventArgs args) { - EntryGrid control = (EntryGrid)this.getView().getControl("itementry"); + EntryGrid control = (EntryGrid) this.getView().getControl("itementry"); int[] selectRows = control.getSelectRows(); if (!this.deleteItemEntryValidate(args, selectRows)) { DynamicObjectCollection payItemDetailEntryCol = this.getModel().getEntryEntity("payitemdetailentry"); @@ -454,7 +457,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im int[] var6 = selectRows; int i = selectRows.length; - for(int var8 = 0; var8 < i; ++var8) { + for (int var8 = 0; var8 < i; ++var8) { int rowIndex = var6[var8]; DynamicObject itemEntryObj = this.getModel().getEntryRowEntity("itementry", rowIndex); DynamicObject payItem = itemEntryObj.getDynamicObject("payitem"); @@ -465,8 +468,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im List deleteList = new ArrayList(payItemDetailEntryCol.size()); - for(i = 0; i < payItemDetailEntryCol.size(); ++i) { - DynamicObject payItemDetailEntryObj = (DynamicObject)payItemDetailEntryCol.get(i); + for (i = 0; i < payItemDetailEntryCol.size(); ++i) { + DynamicObject payItemDetailEntryObj = (DynamicObject) payItemDetailEntryCol.get(i); DynamicObject detailPatItem = payItemDetailEntryObj.getDynamicObject("detailpayitem"); if (detailPatItem != null && deletePayItemSet.contains(detailPatItem.getPkValue())) { deleteList.add(i); @@ -486,7 +489,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im int[] var5 = selectRows; int var6 = selectRows.length; - for(int var7 = 0; var7 < var6; ++var7) { + for (int var7 = 0; var7 < var6; ++var7) { int rowIndex = var5[var7]; deleteRows.add(itemEntry.get(rowIndex)); } @@ -496,10 +499,10 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im boolean isTrans = false; Iterator var14 = deleteRows.iterator(); - while(true) { - while(var14.hasNext()) { - DynamicObject row = (DynamicObject)var14.next(); - DynamicObject payItem = (DynamicObject)row.get("payitem"); + while (true) { + while (var14.hasNext()) { + DynamicObject row = (DynamicObject) var14.next(); + DynamicObject payItem = (DynamicObject) row.get("payitem"); if (payItem != null && payItem.getString("paymentitemtype").equals(PayItemTypeEnum.FIXED.value)) { message.append("“").append(payItem.getString("number")).append("”"); isCancel = true; @@ -523,7 +526,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected void addItemEntry(BeforeDoOperationEventArgs args) { - DynamicObject contract = (DynamicObject)this.getModel().getValue("contract"); + DynamicObject contract = (DynamicObject) this.getModel().getValue("contract"); if (contract == null) { this.getView().showTipNotification(ResManager.loadKDString("请先选择合同。", "ContractSettleCommonEditPlugin_8", "ec-contract-formplugin", new Object[0])); args.setCancel(true); @@ -534,14 +537,14 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im int rowCount = this.getModel().getEntryRowCount("itementry"); List originValue = new ArrayList(); - for(int index = 0; index < rowCount; ++index) { - DynamicObject payItem = (DynamicObject)this.getModel().getValue("payitem", index); + for (int index = 0; index < rowCount; ++index) { + DynamicObject payItem = (DynamicObject) this.getModel().getValue("payitem", index); if (payItem.getString("paymentitemtype").equals(PayItemTypeEnum.CHANGED.value)) { originValue.add(payItem.getPkValue()); } } - Long contAttrPk = (Long)BusinessDataServiceHelper.loadSingle(contract.getPkValue(), this.getContractFormId()).getDynamicObject("contracttype").getDynamicObject("contattr").getPkValue(); + Long contAttrPk = (Long) BusinessDataServiceHelper.loadSingle(contract.getPkValue(), this.getContractFormId()).getDynamicObject("contracttype").getDynamicObject("contattr").getPkValue(); QFilter notPreFilter = new QFilter("contattr", "=", 0L); notPreFilter.and(new QFilter("ispreitem", "=", "0")); notPreFilter.and(new QFilter("status", "=", BillStatusEnum.AUDIT.getValue())); @@ -564,7 +567,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im if (StringUtils.equals(this.getPayDirection(), PayDirectionEnum.IN.getValue())) { return false; } else { - DynamicObject contractAttr = (DynamicObject)this.getModel().getValue("contattr"); + DynamicObject contractAttr = (DynamicObject) this.getModel().getValue("contattr"); if (contractAttr != null) { String basicType = contractAttr.getString("basictype"); return StringUtils.equals("03", basicType); @@ -595,9 +598,9 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im Object returnData = closedCallBackEvent.getReturnData(); String actionId = closedCallBackEvent.getActionId(); if (actionId.equals("ec_payitem") && returnData != null) { - this.payItemCallBack((ListSelectedRowCollection)returnData); + this.payItemCallBack((ListSelectedRowCollection) returnData); } else if (StringUtils.equals("adddetail", actionId) && returnData != null) { - this.itemDetailCallBack((DynamicObjectCollection)returnData); + this.itemDetailCallBack((DynamicObjectCollection) returnData); } } @@ -607,18 +610,18 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObjectCollection addItemDetailCol = new DynamicObjectCollection(); DynamicObjectType payItemDetailType = payItemDetailCol.getDynamicObjectType(); boolean isOut = StringUtils.equals(PayDirectionEnum.OUT.getValue(), this.getPayDirection()); - boolean isMultiRate = (Boolean)this.getModel().getValue("ismultirate"); + boolean isMultiRate = (Boolean) this.getModel().getValue("ismultirate"); BigDecimal taxRate = BigDecimal.ZERO; if (!isMultiRate) { - DynamicObject rate = (DynamicObject)this.getModel().getValue("taxrate"); + DynamicObject rate = (DynamicObject) this.getModel().getValue("taxrate"); taxRate = rate == null ? taxRate : rate.getBigDecimal("taxrate").divide(new BigDecimal(100), 10, 4); } if (returnData.size() > 0) { Iterator var14 = returnData.iterator(); - while(var14.hasNext()) { - DynamicObject dynamicObject = (DynamicObject)var14.next(); + while (var14.hasNext()) { + DynamicObject dynamicObject = (DynamicObject) var14.next(); DynamicObject payItemDetail = new DynamicObject(payItemDetailType); BigDecimal amount = dynamicObject.getBigDecimal("detailamt"); BigDecimal ofTax = amount.multiply(BigDecimal.ONE.add(taxRate)); @@ -665,13 +668,13 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im Map> itemAmtMap = new HashMap(); boolean isOut = StringUtils.equals(PayDirectionEnum.OUT.getValue(), this.getPayDirection()); boolean isIn = StringUtils.equals(PayDirectionEnum.IN.getValue(), this.getPayDirection()); - DynamicObject contact = (DynamicObject)this.getModel().getValue("contract"); + DynamicObject contact = (DynamicObject) this.getModel().getValue("contract"); contact = BusinessDataServiceHelper.loadSingle(contact.getPkValue(), "ec_out_contract"); DynamicObject taxRate = contact.getDynamicObject("taxrate"); String mapkey = ""; Iterator var10 = payItemDetailEntryCol.iterator(); - while(true) { + while (true) { DynamicObject payItemDetail; DynamicObject item; DynamicObject unitproject; @@ -689,14 +692,14 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im var22 = itemAmtMap.entrySet().iterator(); label157: - while(var22.hasNext()) { - mapEntry = (Map.Entry)var22.next(); - key = (String)mapEntry.getKey(); - Map amtMap = (Map)mapEntry.getValue(); + while (var22.hasNext()) { + mapEntry = (Map.Entry) var22.next(); + key = (String) mapEntry.getKey(); + Map amtMap = (Map) mapEntry.getValue(); boolean isExist = false; Iterator var32 = itemEntryCol.iterator(); - while(true) { + while (true) { do { if (!var32.hasNext()) { if (!isExist) { @@ -706,8 +709,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im newItemEntry.set("oftaxamount", amtMap.get("oftaxamt")); newItemEntry.set("amount", amtMap.get("amt")); newItemEntry.set("taxamt", amtMap.get("tax")); - if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal)amtMap.get("amt")) != 0) { - newItemEntry.set("rate", ((BigDecimal)amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal)amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); + if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal) amtMap.get("amt")) != 0) { + newItemEntry.set("rate", ((BigDecimal) amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal) amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); } newItemEntry.set("hasdetail", true); @@ -720,16 +723,16 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im continue label157; } - newItemEntry = (DynamicObject)var32.next(); + newItemEntry = (DynamicObject) var32.next(); payitem = newItemEntry.getDynamicObject("payitem"); - } while(payitem != null && !StringUtils.equals(payitem.getString("id"), String.valueOf(key))); + } while (payitem != null && !StringUtils.equals(payitem.getString("id"), String.valueOf(key))); isExist = true; - newItemEntry.set("oftaxamount", newItemEntry.getBigDecimal("oftaxamount").add((BigDecimal)amtMap.get("oftaxamt"))); - newItemEntry.set("amount", newItemEntry.getBigDecimal("amount").add((BigDecimal)amtMap.get("amt"))); - newItemEntry.set("taxamt", newItemEntry.getBigDecimal("taxamt").add((BigDecimal)amtMap.get("tax"))); - if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal)amtMap.get("amt")) != 0 && (multiRate || StringUtils.equals("760004250343646208", (CharSequence)mapEntry.getKey()))) { - newItemEntry.set("rate", ((BigDecimal)amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal)amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); + newItemEntry.set("oftaxamount", newItemEntry.getBigDecimal("oftaxamount").add((BigDecimal) amtMap.get("oftaxamt"))); + newItemEntry.set("amount", newItemEntry.getBigDecimal("amount").add((BigDecimal) amtMap.get("amt"))); + newItemEntry.set("taxamt", newItemEntry.getBigDecimal("taxamt").add((BigDecimal) amtMap.get("tax"))); + if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal) amtMap.get("amt")) != 0 && (multiRate || StringUtils.equals("760004250343646208", (CharSequence) mapEntry.getKey()))) { + newItemEntry.set("rate", ((BigDecimal) amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal) amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); } newItemEntry.set("hasdetail", true); @@ -739,21 +742,21 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im var22 = itemAmtMap.entrySet().iterator(); label131: - while(true) { - while(true) { + while (true) { + while (true) { if (!var22.hasNext()) { break label131; } - mapEntry = (Map.Entry)var22.next(); - key = (String)mapEntry.getKey(); + mapEntry = (Map.Entry) var22.next(); + key = (String) mapEntry.getKey(); String itemId = key.split(",")[0]; String unitprojctId = ""; if (key.split(",").length > 1) { unitprojctId = key.split(",")[1]; } - Map amtMap = (Map)mapEntry.getValue(); + Map amtMap = (Map) mapEntry.getValue(); if (itemId.equals("506427748873442304")) { newItemEntry = new DynamicObject(itemEntryType); payitem = BusinessDataServiceHelper.loadSingle(Long.valueOf(itemId), "ec_payitem"); @@ -770,8 +773,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } newItemEntry.set("remark", payitem.getString("description")); - if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal)amtMap.get("amt")) != 0 && (multiRate || StringUtils.equals("760004250343646208", (CharSequence)mapEntry.getKey()))) { - newItemEntry.set("rate", ((BigDecimal)amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal)amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); + if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal) amtMap.get("amt")) != 0 && (multiRate || StringUtils.equals("760004250343646208", (CharSequence) mapEntry.getKey()))) { + newItemEntry.set("rate", ((BigDecimal) amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal) amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); } newItemEntry.set("hasdetail", true); @@ -785,8 +788,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im newItemEntry.set("oftaxamount", amtMap.get("oftaxamt")); newItemEntry.set("amount", amtMap.get("amt")); newItemEntry.set("taxamt", amtMap.get("tax")); - if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal)amtMap.get("amt")) != 0) { - newItemEntry.set("rate", ((BigDecimal)amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal)amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); + if (amtMap.get("amt") != null && BigDecimal.ZERO.compareTo((BigDecimal) amtMap.get("amt")) != 0) { + newItemEntry.set("rate", ((BigDecimal) amtMap.get("tax")).multiply(new BigDecimal(100)).divide((BigDecimal) amtMap.get("amt"), 2).setScale(0, RoundingMode.HALF_UP)); } newItemEntry.set("hasdetail", true); @@ -819,9 +822,9 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im return; } - payItemDetail = (DynamicObject)var10.next(); + payItemDetail = (DynamicObject) var10.next(); item = payItemDetail.getDynamicObject("detailpayitem"); - } while(item == null); + } while (item == null); mapkey = item.getString("id"); if (!this.getPayDirection().equals(PayDirectionEnum.IN.getValue())) { @@ -830,9 +833,9 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject detailunitproject = payItemDetail.getDynamicObject("detailunitproject"); mapkey = item.getString("id") + "," + (detailunitproject == null ? "" : detailunitproject.getString("id")); - unitproject = (DynamicObject)this.getModel().getValue("unitproject"); + unitproject = (DynamicObject) this.getModel().getValue("unitproject"); detailupId = detailunitproject != null ? detailunitproject.getLong("id") : 0L; - } while(unitproject != null && detailupId != unitproject.getLong("id")); + } while (unitproject != null && detailupId != unitproject.getLong("id")); BigDecimal tax; Map amtAmp; @@ -845,10 +848,10 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im amtMap.put("amt", payItemDetail.getBigDecimal("detailamt")); itemAmtMap.put(mapkey, amtMap); } else { - amtAmp = (Map)itemAmtMap.get(mapkey); - ofTax = ((BigDecimal)amtAmp.get("oftaxamt")).add(payItemDetail.getBigDecimal("detailoftaxamt")); - amount = ((BigDecimal)amtAmp.get("tax")).add(payItemDetail.getBigDecimal("detailtaxamt")); - tax = ((BigDecimal)amtAmp.get("amt")).add(payItemDetail.getBigDecimal("detailamt")); + amtAmp = (Map) itemAmtMap.get(mapkey); + ofTax = ((BigDecimal) amtAmp.get("oftaxamt")).add(payItemDetail.getBigDecimal("detailoftaxamt")); + amount = ((BigDecimal) amtAmp.get("tax")).add(payItemDetail.getBigDecimal("detailtaxamt")); + tax = ((BigDecimal) amtAmp.get("amt")).add(payItemDetail.getBigDecimal("detailamt")); amtAmp.put("oftaxamt", ofTax); amtAmp.put("tax", amount); amtAmp.put("amt", tax); @@ -856,9 +859,9 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } if (StringUtils.equals(item.getString("id"), "506427748873442304") && isOut && payItemDetail.getBoolean("ismeasurebymatin")) { - amtAmp = (Map)itemAmtMap.getOrDefault("760004250343646208", new HashMap(3)); - ofTax = (BigDecimal)amtAmp.getOrDefault("oftaxamt", BigDecimal.ZERO); - amount = (BigDecimal)amtAmp.getOrDefault("amt", BigDecimal.ZERO); + amtAmp = (Map) itemAmtMap.getOrDefault("760004250343646208", new HashMap(3)); + ofTax = (BigDecimal) amtAmp.getOrDefault("oftaxamt", BigDecimal.ZERO); + amount = (BigDecimal) amtAmp.getOrDefault("amt", BigDecimal.ZERO); ofTax = ofTax.add(payItemDetail.getBigDecimal("measuretransoftax")); amount = amount.add(payItemDetail.getBigDecimal("measuretransamt")); tax = ofTax.subtract(amount); @@ -878,8 +881,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im List originalIds = new ArrayList(); Iterator var4 = returnData.iterator(); - while(var4.hasNext()) { - ListSelectedRow row = (ListSelectedRow)var4.next(); + while (var4.hasNext()) { + ListSelectedRow row = (ListSelectedRow) var4.next(); selectedIds.add(row.getPrimaryKeyValue()); } @@ -887,8 +890,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im Iterator var13 = entries.iterator(); DynamicObject taxRateObject; - while(var13.hasNext()) { - taxRateObject = (DynamicObject)var13.next(); + while (var13.hasNext()) { + taxRateObject = (DynamicObject) var13.next(); DynamicObject payItem = taxRateObject.getDynamicObject("payitem"); if (payItem.getString("paymentitemtype").equals(PayItemTypeEnum.CHANGED.value)) { originalIds.add(payItem.getPkValue()); @@ -896,16 +899,16 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } selectedIds.removeAll(originalIds); - boolean isMultiRate = (Boolean)this.getModel().getValue("ismultirate"); - taxRateObject = (DynamicObject)this.getModel().getValue("taxrate"); + boolean isMultiRate = (Boolean) this.getModel().getValue("ismultirate"); + taxRateObject = (DynamicObject) this.getModel().getValue("taxrate"); if (!selectedIds.isEmpty()) { int[] indexArray = this.getModel().batchCreateNewEntryRow("itementry", selectedIds.size()); - for(int i = 0; i < selectedIds.size(); ++i) { + for (int i = 0; i < selectedIds.size(); ++i) { Object pk = selectedIds.get(i); int row = indexArray[i]; this.getModel().setValue("payitem", pk, row); - DynamicObject payItem = (DynamicObject)this.getModel().getValue("payitem", row); + DynamicObject payItem = (DynamicObject) this.getModel().getValue("payitem", row); this.getModel().setValue("remark", payItem.getString("description"), row); if (!isMultiRate) { this.getModel().setValue("rate", taxRateObject.getBigDecimal("taxrate"), row); @@ -924,7 +927,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected void reComputePayItem(int rowIndex, int rowCount) { - DynamicObject payItem = (DynamicObject)this.getModel().getValue("payitem", rowIndex); + DynamicObject payItem = (DynamicObject) this.getModel().getValue("payitem", rowIndex); BigDecimal amount = BigDecimal.ZERO; BigDecimal ofTaxAmount = BigDecimal.ZERO; BigDecimal taxAmt = BigDecimal.ZERO; @@ -932,7 +935,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im if (formulas != null && !formulas.isEmpty()) { Iterator var8 = formulas.iterator(); - while(true) { + while (true) { DynamicObject formula; DynamicObject item; do { @@ -943,20 +946,20 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im return; } - formula = (DynamicObject)var8.next(); + formula = (DynamicObject) var8.next(); item = formula.getDynamicObject("item"); - } while(item == null); + } while (item == null); Object formulaItemPk = item.getPkValue(); BigDecimal formulaPercent = formula.getBigDecimal("percent"); String operation = formula.getString("operation"); - for(int index = 0; index < rowCount; ++index) { - Object sourcePk = ((DynamicObject)this.getModel().getValue("payitem", index)).getPkValue(); + for (int index = 0; index < rowCount; ++index) { + Object sourcePk = ((DynamicObject) this.getModel().getValue("payitem", index)).getPkValue(); if (formulaItemPk.equals(sourcePk)) { - BigDecimal sourceAmount = (BigDecimal)this.getModel().getValue("amount", index); - BigDecimal sourceOfTaxAmount = (BigDecimal)this.getModel().getValue("oftaxamount", index); - BigDecimal sourceTaxAmt = (BigDecimal)this.getModel().getValue("taxamt", index); + BigDecimal sourceAmount = (BigDecimal) this.getModel().getValue("amount", index); + BigDecimal sourceOfTaxAmount = (BigDecimal) this.getModel().getValue("oftaxamount", index); + BigDecimal sourceTaxAmt = (BigDecimal) this.getModel().getValue("taxamt", index); if (operation.equals("01")) { amount = amount.add(sourceAmount.multiply(formulaPercent)); ofTaxAmount = ofTaxAmount.add(sourceOfTaxAmount.multiply(formulaPercent)); @@ -974,7 +977,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im protected void fillItemEntryCbs(int row) { DynamicObject cbs = this.getNeedFillCbs(); - if (cbs != null && !(Boolean)this.getModel().getValue("isonlist")) { + if (cbs != null && !(Boolean) this.getModel().getValue("isonlist")) { this.getModel().setValue("itemcbs", cbs.getPkValue(), row); } @@ -1002,14 +1005,32 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im public void propertyChanged(PropertyChangedArgs e) { String name = e.getProperty().getName(); ChangeData changeData = e.getChangeSet()[0]; - DynamicObject contract; if (StringUtils.equals(name, "contract")) { - contract = (DynamicObject)changeData.getNewValue(); +/* contract = (DynamicObject) changeData.getNewValue(); this.clearUnitproject(); - this.contractChanged(contract); + this.contractChanged(contract);*///已被二开替代 + Object objcontract = this.getModel().getValue("contract"); + if (objcontract!=null){ + DynamicObject contract = (DynamicObject) objcontract; + DynamicObject contractInfo = BusinessDataServiceHelper.loadSingle("ec_in_contract", "id,billno,billname,zcgj_renewal,zcgj_isrenewal,zcgj_enddate", new QFilter[]{new QFilter("id", QCP.equals, contract.getLong("id"))}); + Date zcgjEnddate = contractInfo.getDate("zcgj_enddate"); + if (zcgjEnddate!=null){ + Date nowdate = new Date(); + int timeDays = PluginUtils.getTimeDays(zcgjEnddate, nowdate); + int endDays = Integer.parseInt(System.getProperty("contract.enddays")); +// int endDays = 100; + if (timeDays-endDays<=0){ + this.getView().showTipNotification("当前选择合同距离到期不足"+endDays+"天!"); + } + } + } + DynamicObject contract = (DynamicObject)changeData.getNewValue(); + this.clearUnitproject(); + this.contractChanged(contract);//二开替代代码 +// this.clearOrNewProcessAlloc();//清除或者新增工序分摊分录 } else if (StringUtils.equals(name, "period")) { this.periodChanged(changeData); - } else if (!StringUtils.equals(name, "begindate") && !StringUtils.equals(name, "enddate")) { + } else if (!StringUtils.equals(name, "begindate") && !StringUtils.equals(name, "enddate")) /*{ if (StringUtils.equals(name, "issettlebymatin")) { this.isSettleByMaterialInChanged(changeData); } else if (StringUtils.equals(name, "issettlebyreconc")) { @@ -1021,45 +1042,151 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } else if (StringUtils.equals(name, "rate")) { this.rateChanged(changeData); } else if (StringUtils.equals("unitproject", name)) { - contract = (DynamicObject)this.getModel().getValue("contract"); + DynamicObject contract = (DynamicObject) this.getModel().getValue("contract"); this.contractChanged(contract); } + }*/ + { + if (StringUtils.equals(name, "issettlebymatin")) { + this.isSettleByMaterialInChanged(changeData); + } else if (StringUtils.equals(name, "issettlebyreconc")) { + this.isSettleByReconciliationChanged(changeData); + } else if (StringUtils.equals(name, "oftaxamount")) { + this.ofTaxAmountChanged(changeData); + } else if (StringUtils.equals(name, "amount")) { + boolean checkbox= this.getModel().getDataEntity().getBoolean("zcgj_adjustmounttax");//获取微调金额 + if(checkbox){//微调打开,调用子类值改变方法 + this.amountChanged(changeData); + }else{//没打开,调用父类的 + this.amountChanged1(changeData); + } + } else if (StringUtils.equals(name, "taxamt")) { + boolean checkbox= this.getModel().getDataEntity().getBoolean("zcgj_adjustmounttax");//获取微调金额 + if(checkbox){//微调打开,调用子类值改变方法 + this.taxamtChanged(changeData); + } + } else if (StringUtils.equals(name, "rate")) { + this.rateChanged(changeData); + } else if (StringUtils.equals("unitproject", name)) { + DynamicObject contract = (DynamicObject)this.getModel().getValue("contract"); + this.contractChanged(contract); + }else if (StringUtils.equals(name, "zcgj_adjustmounttax")) { + //this.adjustAmountTax(changeData); + } }/* else { this.setDateEditMinAndMaxDate(); }*/ } + /* protected void rateChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + boolean isMultiRate = (Boolean)this.getModel().getValue("ismultirate"); + BigDecimal ofTaxAmount = (BigDecimal)this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal amount = (BigDecimal)this.getModel().getValue("amount", rowIndex); + BigDecimal taxRate = (BigDecimal)changeData.getNewValue(); + String ignoreRateChanged = this.getPageCache().get("ignoreRateChanged"); + if (ignoreRateChanged != null) { + this.getPageCache().remove("ignoreRateChanged"); + } else { + if (isMultiRate) { + BigDecimal rate = BigDecimal.ONE.add(taxRate.divide(BigDecimal.valueOf(100L), 10, RoundingMode.HALF_UP)); + BigDecimal taxAmount; + if (ofTaxAmount.compareTo(BigDecimal.ZERO) != 0) { + amount = ofTaxAmount.divide(rate, 6, 4); + taxAmount = ofTaxAmount.subtract(amount); + this.getModel().setValue("taxamt", taxAmount, rowIndex); + this.getModel().setValue("amount", amount, rowIndex); + } else { + ofTaxAmount = amount.multiply(rate); + taxAmount = ofTaxAmount.subtract(amount); + this.getModel().setValue("taxamt", taxAmount, rowIndex); + this.getModel().setValue("oftaxamount", ofTaxAmount, rowIndex); + } + } + + } + }*///已被二开替代 protected void rateChanged(ChangeData changeData) { int rowIndex = changeData.getRowIndex(); - boolean isMultiRate = (Boolean)this.getModel().getValue("ismultirate"); - BigDecimal ofTaxAmount = (BigDecimal)this.getModel().getValue("oftaxamount", rowIndex); - BigDecimal amount = (BigDecimal)this.getModel().getValue("amount", rowIndex); - BigDecimal taxRate = (BigDecimal)changeData.getNewValue(); + boolean isMultiRate = (Boolean) this.getModel().getValue("ismultirate"); + BigDecimal ofTaxAmount = (BigDecimal) this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal amount = (BigDecimal) this.getModel().getValue("amount", rowIndex); + BigDecimal taxRate = (BigDecimal) changeData.getNewValue(); String ignoreRateChanged = this.getPageCache().get("ignoreRateChanged"); if (ignoreRateChanged != null) { this.getPageCache().remove("ignoreRateChanged"); } else { if (isMultiRate) { BigDecimal rate = BigDecimal.ONE.add(taxRate.divide(BigDecimal.valueOf(100L), 10, RoundingMode.HALF_UP)); - BigDecimal taxAmount; if (ofTaxAmount.compareTo(BigDecimal.ZERO) != 0) { amount = ofTaxAmount.divide(rate, 6, 4); - taxAmount = ofTaxAmount.subtract(amount); + BigDecimal taxAmount = ofTaxAmount.subtract(amount); this.getModel().setValue("taxamt", taxAmount, rowIndex); this.getModel().setValue("amount", amount, rowIndex); } else { ofTaxAmount = amount.multiply(rate); - taxAmount = ofTaxAmount.subtract(amount); + BigDecimal taxAmount = ofTaxAmount.subtract(amount); this.getModel().setValue("taxamt", taxAmount, rowIndex); this.getModel().setValue("oftaxamount", ofTaxAmount, rowIndex); } } } - } + }//二开替代代码 + /* protected void amountChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + if (this.isNotNonDirection(rowIndex)) { + boolean isMultiRate = (Boolean) this.getModel().getValue("ismultirate"); + BigDecimal ofTaxAmount = (BigDecimal) this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal amount = (BigDecimal) this.getModel().getValue("amount", rowIndex); + if (isMultiRate && (BigDecimal.ZERO.compareTo(ofTaxAmount) == 0 || BigDecimal.ZERO.compareTo(amount) == 0)) { + this.getModel().setValue("rate", 0, rowIndex); + this.getModel().setValue("taxamt", BigDecimal.ZERO, rowIndex); + this.getModel().setValue("oftaxamount", amount, rowIndex); + return; + } + + BigDecimal taxAmt = ofTaxAmount.subtract(amount); + if (BigDecimal.ZERO.compareTo(amount) != 0 && isMultiRate) { + BigDecimal taxRate = taxAmt.multiply(BigDecimal.valueOf(100L)).divide(amount, 4, 4); + this.getModel().setValue("rate", taxRate, rowIndex); + } + + this.getModel().setValue("taxamt", taxAmt, rowIndex); + this.checkNeedReComputeItem(rowIndex); + SettleUpdateAmtUtils.setItemEntrySumAmt(this.getView()); + SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); + } + + //已被二开替代 + /* protected void ofTaxAmountChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + if (this.isNotNonDirection(rowIndex)) { + BigDecimal ofTaxAmount = (BigDecimal) this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal rate = (BigDecimal) this.getModel().getValue("rate", rowIndex); + BigDecimal amount = ofTaxAmount.divide(BigDecimal.ONE.add(rate.divide(BigDecimal.valueOf(100L), 10, RoundingMode.HALF_UP)), 10, 4); + BigDecimal taxAmount = ofTaxAmount.subtract(amount); + this.getModel().setValue("taxamt", taxAmount, rowIndex); + this.getModel().setValue("amount", amount, rowIndex); + this.checkNeedReComputeItem(rowIndex); + SettleUpdateAmtUtils.setItemEntrySumAmt(this.getView()); + SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); + } + + }*///已被二开替代 protected void amountChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + BigDecimal amount = (BigDecimal) changeData.getNewValue(); + BigDecimal oftaxamount = (BigDecimal) this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal taxamt = oftaxamount.subtract(amount); + this.getModel().setValue("taxamt", taxamt, rowIndex); + SettleUpdateAmtUtils.setItemEntrySumAmt(this.getView()); + SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); + + }//二开替代代码 + protected void amountChanged1(ChangeData changeData) { int rowIndex = changeData.getRowIndex(); if (this.isNotNonDirection(rowIndex)) { boolean isMultiRate = (Boolean)this.getModel().getValue("ismultirate"); @@ -1084,13 +1211,13 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); } - } + }//二开添加 protected void ofTaxAmountChanged(ChangeData changeData) { int rowIndex = changeData.getRowIndex(); if (this.isNotNonDirection(rowIndex)) { - BigDecimal ofTaxAmount = (BigDecimal)this.getModel().getValue("oftaxamount", rowIndex); - BigDecimal rate = (BigDecimal)this.getModel().getValue("rate", rowIndex); + BigDecimal ofTaxAmount = (BigDecimal) this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal rate = (BigDecimal) this.getModel().getValue("rate", rowIndex); BigDecimal amount = ofTaxAmount.divide(BigDecimal.ONE.add(rate.divide(BigDecimal.valueOf(100L), 10, RoundingMode.HALF_UP)), 10, 4); BigDecimal taxAmount = ofTaxAmount.subtract(amount); this.getModel().setValue("taxamt", taxAmount, rowIndex); @@ -1100,20 +1227,28 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); } - } + }//二开替代代码 + + private void taxamtChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + BigDecimal taxamt = (BigDecimal) changeData.getNewValue(); + BigDecimal oftaxamount = (BigDecimal) this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal amount = oftaxamount.subtract(taxamt); + this.getModel().setValue("amount", amount, rowIndex); + }//二开添加代码 public void checkNeedReComputeItem(int rowIndex) { - Object changedPayItemPk = ((DynamicObject)this.getModel().getValue("payitem", rowIndex)).getPkValue(); + Object changedPayItemPk = ((DynamicObject) this.getModel().getValue("payitem", rowIndex)).getPkValue(); int rowCount = this.getModel().getEntryRowCount("itementry"); - for(int index = 0; index < rowCount; ++index) { - DynamicObject payItem = (DynamicObject)this.getModel().getValue("payitem", index); + for (int index = 0; index < rowCount; ++index) { + DynamicObject payItem = (DynamicObject) this.getModel().getValue("payitem", index); if (payItem != null && payItem.getBoolean("iscompute")) { DynamicObjectCollection formulas = BusinessDataServiceHelper.loadSingle(payItem.getPkValue(), "ec_payitem").getDynamicObjectCollection("entryentity"); Iterator var7 = formulas.iterator(); - while(var7.hasNext()) { - DynamicObject formula = (DynamicObject)var7.next(); + while (var7.hasNext()) { + DynamicObject formula = (DynamicObject) var7.next(); Object pk = formula.getDynamicObject("item").getPkValue(); if (changedPayItemPk.equals(pk)) { this.reComputePayItem(index, rowCount); @@ -1141,7 +1276,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected void isSettleByMaterialInChanged(ChangeData changeData) { - if ((Boolean)changeData.getNewValue()) { + if ((Boolean) changeData.getNewValue()) { this.deleteDetailsByReferBillType(false, ReferBillTypeEnum.MEASURE.getValue()); } else { this.reloadMeasureDetails(); @@ -1151,7 +1286,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im protected void isSettleByReconciliationChanged(ChangeData changeData) { int entryRowCount = this.getModel().getEntryRowCount("itementry"); - DynamicObject rate = (DynamicObject)this.getModel().getValue("taxrate"); + DynamicObject rate = (DynamicObject) this.getModel().getValue("taxrate"); if (entryRowCount > 0) { this.getModel().setValue("amount", 0, 0); this.getModel().setValue("oftaxamount", 0, 0); @@ -1161,7 +1296,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } } - if ((Boolean)changeData.getNewValue()) { + if ((Boolean) changeData.getNewValue()) { this.deleteDetailsByReferBillType(false, ReferBillTypeEnum.MEASURE.getValue()); } else { this.reloadMeasureDetails(); @@ -1196,7 +1331,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected void periodChanged(ChangeData changeData) { - DynamicObject period = (DynamicObject)changeData.getNewValue(); + DynamicObject period = (DynamicObject) changeData.getNewValue(); this.getModel().setValue("begindate", period == null ? null : period.getDate("begindate")); this.getModel().setValue("enddate", period == null ? null : period.getDate("enddate")); this.reloadMeasureDetails(); @@ -1228,12 +1363,18 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im this.initPayItemDetailEntry(); } + /* private void clearUnitproject() { + if (this.getPayDirection().equals(PayDirectionEnum.IN.getValue())) { + this.getModel().setValue("unitproject", (Object) null); + } + + }*///已被二开替代 private void clearUnitproject() { if (this.getPayDirection().equals(PayDirectionEnum.IN.getValue())) { - this.getModel().setValue("unitproject", (Object)null); + this.getModel().setValue("unitproject", (Object) null); } - } + }//二开替代代码 protected void initPayItemDetailEntry() { this.updateItemDetailEntry(); @@ -1276,17 +1417,17 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObjectType entryType = entryCollection.getDynamicObjectType(); DynamicObjectCollection addEntry = new DynamicObjectCollection(); DynamicObject materialOutItem = BusinessDataServiceHelper.loadSingle(1204312316120741888L, "ec_payitem"); - boolean isMultiRate = (Boolean)this.getModel().getValue("ismultirate"); + boolean isMultiRate = (Boolean) this.getModel().getValue("ismultirate"); BigDecimal taxRate = BigDecimal.ZERO; if (!isMultiRate) { - DynamicObject rate = (DynamicObject)this.getModel().getValue("taxrate"); + DynamicObject rate = (DynamicObject) this.getModel().getValue("taxrate"); taxRate = rate == null ? taxRate : rate.getBigDecimal("taxrate").divide(new BigDecimal(100), 10, 4); } DynamicObject[] var15 = materialOutBills; int var9 = materialOutBills.length; - for(int var10 = 0; var10 < var9; ++var10) { + for (int var10 = 0; var10 < var9; ++var10) { DynamicObject materialOutBill = var15[var10]; DynamicObject entryObj = new DynamicObject(entryType); BigDecimal amount = materialOutBill.getBigDecimal("settleamt"); @@ -1317,7 +1458,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im List deleteRows = new ArrayList(); int rowCount = this.getModel().getEntryRowCount("payitemdetailentry"); - for(int i = 0; i < rowCount; ++i) { + for (int i = 0; i < rowCount; ++i) { DynamicObject entry = this.getModel().getEntryRowEntity("payitemdetailentry", i); if (StringUtils.equals(referBillType, entry.getString("referbilltype"))) { deleteRows.add(i); @@ -1344,14 +1485,14 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] var6 = settleBills; int var7 = settleBills.length; - for(int var8 = 0; var8 < var7; ++var8) { + for (int var8 = 0; var8 < var7; ++var8) { DynamicObject settleBill = var6[var8]; settleBill = BusinessDataServiceHelper.loadSingle(settleBill.getPkValue(), "ec_out_contract_settle"); DynamicObjectCollection entries = settleBill.getDynamicObjectCollection("payitemdetailentry"); Iterator var11 = entries.iterator(); - while(var11.hasNext()) { - DynamicObject entry = (DynamicObject)var11.next(); + while (var11.hasNext()) { + DynamicObject entry = (DynamicObject) var11.next(); if (StringUtils.equals(entry.getString("referbilltype"), ReferBillTypeEnum.MATERIAL_OUT.getValue())) { materialOutBillIds.add(entry.getLong("referbillid")); } @@ -1368,7 +1509,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im protected void fixedNeedReComputeItem() { DynamicObjectCollection itementry = this.getModel().getEntryEntity("itementry"); - for(int i = 0; i < itementry.size(); ++i) { + for (int i = 0; i < itementry.size(); ++i) { if (this.isNotNonDirection(i)) { this.checkNeedReComputeItem(i); } @@ -1390,7 +1531,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im QFilter periodFilter = new QFilter("period.enddate", "<=", period.getDate("enddate")); QFilter isNotSettleFilter = new QFilter("issettled", "=", "0"); QFilter notUseFilter = this.getNotUseFilter(contract, ReferBillTypeEnum.MEASURE.getValue()); - String paydirection = (String)this.getModel().getValue("paydirection"); + String paydirection = (String) this.getModel().getValue("paydirection"); String formId = "ec_outcontractmeasure"; String others = ""; if (PayDirectionEnum.IN.getValue().equals(paydirection)) { @@ -1415,14 +1556,14 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im int var9 = settleBills.length; label67: - for(int var10 = 0; var10 < var9; ++var10) { + for (int var10 = 0; var10 < var9; ++var10) { DynamicObject settleBill = var8[var10]; settleBill = BusinessDataServiceHelper.loadSingle(settleBill.getPkValue(), formId); DynamicObjectCollection entries = settleBill.getDynamicObjectCollection("payitemdetailentry"); Iterator var13 = entries.iterator(); - while(true) { - while(true) { + while (true) { + while (true) { DynamicObject entry; do { do { @@ -1430,8 +1571,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im continue label67; } - entry = (DynamicObject)var13.next(); - } while(!StringUtils.equals(entry.getString("referbilltype"), billType)); + entry = (DynamicObject) var13.next(); + } while (!StringUtils.equals(entry.getString("referbilltype"), billType)); if (!StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), billType) && !StringUtils.equals(ReferBillTypeEnum.PERFORM.getValue(), billType)) { measureBillSet.add(entry.getLong("referbillid")); @@ -1440,12 +1581,12 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im if (StringUtils.equals(ReferBillTypeEnum.PERFORM.getValue(), billType)) { measureBillSet.add(entry.getLong("referentryid")); } - } while(!StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), billType)); + } while (!StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), billType)); if (this.getPayDirection().equals(PayDirectionEnum.IN.getValue())) { Long measureId = entry.getLong("referbillid"); Long eUnitId = entry.getLong("detailunitproject_id"); - Set orDefault = (Set)ret.getOrDefault(measureId, new HashSet()); + Set orDefault = (Set) ret.getOrDefault(measureId, new HashSet()); orDefault.add(eUnitId); ret.put(measureId, orDefault); DynamicObject measureBill = BusinessDataServiceHelper.loadSingle(measureId, "ec_incontractmeasure"); @@ -1453,16 +1594,16 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im Set curUnitProIds = new HashSet(); Iterator var21 = listmodelentry.iterator(); - while(var21.hasNext()) { - DynamicObject model = (DynamicObject)var21.next(); + while (var21.hasNext()) { + DynamicObject model = (DynamicObject) var21.next(); DynamicObjectCollection listentry = model.getDynamicObjectCollection("listentry"); - List ids = (List)listentry.stream().map((o) -> { + List ids = (List) listentry.stream().map((o) -> { return o.getLong("entryunitproject_id"); }).collect(Collectors.toList()); curUnitProIds.addAll(ids); } - if (((Set)ret.get(measureId)).containsAll(curUnitProIds)) { + if (((Set) ret.get(measureId)).containsAll(curUnitProIds)) { measureBillSet.add(entry.getLong("referbillid")); } } else { @@ -1483,7 +1624,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im protected Map> getUsedMeasureEntryMap() { String formId = this.getSettleFormId(); - DynamicObject contract = (DynamicObject)this.getModel().getValue("contract"); + DynamicObject contract = (DynamicObject) this.getModel().getValue("contract"); QFilter qFilter = new QFilter("contract", "=", contract.getPkValue()); qFilter.and(new QFilter(ContractSettleTplConstant.ID_ENTITY_PK, "!=", this.getModel().getDataEntity().getPkValue())); Map> ret = new HashMap(); @@ -1491,18 +1632,18 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] var6 = settleBills; int var7 = settleBills.length; - for(int var8 = 0; var8 < var7; ++var8) { + for (int var8 = 0; var8 < var7; ++var8) { DynamicObject settleBill = var6[var8]; settleBill = BusinessDataServiceHelper.loadSingle(settleBill.getPkValue(), formId); DynamicObjectCollection entries = settleBill.getDynamicObjectCollection("payitemdetailentry"); Iterator var11 = entries.iterator(); - while(var11.hasNext()) { - DynamicObject entry = (DynamicObject)var11.next(); + while (var11.hasNext()) { + DynamicObject entry = (DynamicObject) var11.next(); if (entry.getString("referbilltype").equals(ReferBillTypeEnum.MEASURE.getValue()) && this.getPayDirection().equals(PayDirectionEnum.IN.getValue())) { long referbillid = entry.getLong("referbillid"); Long eUnitId = entry.getLong("detailunitproject_id"); - Set orDefault = (Set)ret.getOrDefault(referbillid, new HashSet()); + Set orDefault = (Set) ret.getOrDefault(referbillid, new HashSet()); orDefault.add(eUnitId); ret.put(referbillid, orDefault); } @@ -1524,7 +1665,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] var7 = measureBills; int var8 = measureBills.length; - for(int var9 = 0; var9 < var8; ++var9) { + for (int var9 = 0; var9 < var8; ++var9) { DynamicObject measureBill = var7[var9]; DynamicObject entryObj = new DynamicObject(entryType); entryObj.set("detailitem", measureBill.getString("billname")); @@ -1544,8 +1685,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im BigDecimal ofTax = BigDecimal.ZERO; Iterator var15 = materialInEntries.iterator(); - while(var15.hasNext()) { - DynamicObject materialInEntry = (DynamicObject)var15.next(); + while (var15.hasNext()) { + DynamicObject materialInEntry = (DynamicObject) var15.next(); if (materialInEntry.getBoolean("istranssettle")) { amount = amount.add(materialInEntry.getBigDecimal("transnotaxamount")); ofTax = ofTax.add(materialInEntry.getBigDecimal("transtaxamount")); @@ -1566,25 +1707,25 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im Map taxOfAmountMap = new HashMap(); Map entryIdsMap = new HashMap(); Map> usedMeasureEntryMap = this.getUsedMeasureEntryMap(); - Map measurebillMap = (Map)Arrays.stream(measureBills).collect(Collectors.toMap(DataEntityBase::getPkValue, Function.identity())); - DynamicObject project = (DynamicObject)this.getModel().getValue("project"); + Map measurebillMap = (Map) Arrays.stream(measureBills).collect(Collectors.toMap(DataEntityBase::getPkValue, Function.identity())); + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); DynamicObject[] var43 = measureBills; int var45 = measureBills.length; DynamicObject entryObj; - for(int var47 = 0; var47 < var45; ++var47) { + for (int var47 = 0; var47 < var45; ++var47) { DynamicObject measureBill = var43[var47]; Long measurebillId = measureBill.getLong("id"); DynamicObjectCollection listmodelentry = measureBill.getDynamicObjectCollection("listmodelentry"); Iterator var20 = listmodelentry.iterator(); label115: - while(var20.hasNext()) { - entryObj = (DynamicObject)var20.next(); + while (var20.hasNext()) { + entryObj = (DynamicObject) var20.next(); DynamicObjectCollection listentry = entryObj.getDynamicObjectCollection("listentry"); Iterator var23 = listentry.iterator(); - while(true) { + while (true) { DynamicObject measureEntry; DynamicObject unitproject; long entryUnitId; @@ -1599,11 +1740,11 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im continue label115; } - measureEntry = (DynamicObject)var23.next(); + measureEntry = (DynamicObject) var23.next(); unitproject = measureEntry.getDynamicObject("entryunitproject"); - headunitproject = (DynamicObject)this.getModel().getValue("unitproject"); + headunitproject = (DynamicObject) this.getModel().getValue("unitproject"); unitProjectId = unitproject == null ? 0L : unitproject.getLong("id"); - } while(null != headunitproject && unitProjectId != headunitproject.getLong("id")); + } while (null != headunitproject && unitProjectId != headunitproject.getLong("id")); if (null != headunitproject || unitproject == null || project == null) { break; @@ -1612,19 +1753,19 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im proOrg = project.getDynamicObject("projectorg"); DynamicObject orgObj = this.getModel().getDataEntity().getDynamicObject("org"); orgId = orgObj == null ? 0L : orgObj.getLong("id"); - } while(proOrg != null && orgId != proOrg.getLong("id") && unitproject.getLong("responsibleorg.id") != orgId); + } while (proOrg != null && orgId != proOrg.getLong("id") && unitproject.getLong("responsibleorg.id") != orgId); entryUnitId = measureEntry.getLong("entryunitproject_id"); - } while(usedMeasureEntryMap.containsKey(measurebillId) && ((Set)usedMeasureEntryMap.get(measurebillId)).contains(entryUnitId)); + } while (usedMeasureEntryMap.containsKey(measurebillId) && ((Set) usedMeasureEntryMap.get(measurebillId)).contains(entryUnitId)); String key = unitproject == null ? "0," + measurebillId : unitproject.getString("id") + "," + measurebillId; BigDecimal thisamount = measureEntry.getBigDecimal("thisamount"); BigDecimal thistax = measureEntry.getBigDecimal("thistax"); BigDecimal thisoftaxmount = measureEntry.getBigDecimal("thisoftaxmount"); - amountMap.put(key, ((BigDecimal)amountMap.getOrDefault(key, BigDecimal.ZERO)).add(thisamount)); - taxMap.put(key, ((BigDecimal)taxMap.getOrDefault(key, BigDecimal.ZERO)).add(thistax)); - taxOfAmountMap.put(key, ((BigDecimal)taxOfAmountMap.getOrDefault(key, BigDecimal.ZERO)).add(thisoftaxmount)); - String str = entryIdsMap.get(key) == null ? measureEntry.getString("id") : ((String)entryIdsMap.get(key)).concat(",").concat(measureEntry.getString("id")); + amountMap.put(key, ((BigDecimal) amountMap.getOrDefault(key, BigDecimal.ZERO)).add(thisamount)); + taxMap.put(key, ((BigDecimal) taxMap.getOrDefault(key, BigDecimal.ZERO)).add(thistax)); + taxOfAmountMap.put(key, ((BigDecimal) taxOfAmountMap.getOrDefault(key, BigDecimal.ZERO)).add(thisoftaxmount)); + String str = entryIdsMap.get(key) == null ? measureEntry.getString("id") : ((String) entryIdsMap.get(key)).concat(",").concat(measureEntry.getString("id")); entryIdsMap.put(key, str); } } @@ -1632,8 +1773,8 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im Iterator iterator = amountMap.keySet().iterator(); - while(iterator.hasNext()) { - String key = (String)iterator.next(); + while (iterator.hasNext()) { + String key = (String) iterator.next(); String[] split = key.split(","); String unitprojectId = split[0]; DynamicObject up = null; @@ -1642,7 +1783,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } String billId = split[1]; - DynamicObject measureBill = (DynamicObject)measurebillMap.get(Long.valueOf(billId)); + DynamicObject measureBill = (DynamicObject) measurebillMap.get(Long.valueOf(billId)); entryObj = new DynamicObject(entryType); entryObj.set("detailitem", measureBill.getString("billname")); entryObj.set("detailpayitem", measureItem); @@ -1678,16 +1819,16 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im QFilter payDirectionFilter = new QFilter("paydirection", "=", this.getPayDirection()); QFilter isNeedSettleFilter = new QFilter("isneedsettle", "=", "1"); QFilter isNotSettleFilter = new QFilter("issettle", "=", "0"); - String paydirection = (String)this.getModel().getValue("paydirection"); + String paydirection = (String) this.getModel().getValue("paydirection"); if (PayDirectionEnum.IN.getValue().equals(paydirection)) { - DynamicObject unitproject = (DynamicObject)this.getModel().getValue("unitproject"); + DynamicObject unitproject = (DynamicObject) this.getModel().getValue("unitproject"); if (null != unitproject) { contractFilter.and(new QFilter("unitproject", "=", unitproject.getPkValue())); } else { DynamicObject project = this.getModel().getDataEntity().getDynamicObject("project"); if (project != null) { DynamicObject proOrg = project.getDynamicObject("projectorg"); - DynamicObject orgObj = (DynamicObject)this.getModel().getValue("org"); + DynamicObject orgObj = (DynamicObject) this.getModel().getValue("org"); long orgId = orgObj == null ? 0L : orgObj.getLong("id"); if (proOrg != null && orgId != proOrg.getLong("id")) { contractFilter.and(new QFilter("unitproject.responsibleorg.id", "=", orgId)); @@ -1743,7 +1884,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] var4 = visaBillArr; int var5 = visaBillArr.length; - for(int var6 = 0; var6 < var5; ++var6) { + for (int var6 = 0; var6 < var5; ++var6) { DynamicObject visaBill = var4[var6]; DynamicObject entryObj = new DynamicObject(entryType); entryObj.set("detailitem", visaBill.getString("billname")); @@ -1771,13 +1912,13 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] var4 = performRecordArr; int var5 = performRecordArr.length; - for(int var6 = 0; var6 < var5; ++var6) { + for (int var6 = 0; var6 < var5; ++var6) { DynamicObject performRecord = var4[var6]; DynamicObjectCollection performRecordEntryCol = performRecord.getDynamicObjectCollection("entryentity"); Iterator var9 = performRecordEntryCol.iterator(); - while(var9.hasNext()) { - DynamicObject performRecordEntry = (DynamicObject)var9.next(); + while (var9.hasNext()) { + DynamicObject performRecordEntry = (DynamicObject) var9.next(); boolean isSettle = performRecordEntry.getBoolean("issettle"); boolean isNeedSettle = performRecordEntry.getBoolean("isneedsettle"); if (isNeedSettle && !isSettle) { @@ -1815,7 +1956,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] var4 = claimArr; int var5 = claimArr.length; - for(int var6 = 0; var6 < var5; ++var6) { + for (int var6 = 0; var6 < var5; ++var6) { DynamicObject claim = var4[var6]; DynamicObject entryObj = new DynamicObject(entryType); entryObj.set("detailitem", claim.getString("billname")); @@ -1850,7 +1991,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] payItems = BusinessDataServiceHelper.load("ec_payitem", "id,isupdateamount,computesource,ispreitem,iscompute,description", new QFilter[]{preFilter.or(attrFilter).or(noAttrFilter)}, "ispreitem desc,number asc"); int initEntrylen = payItems.length; if (this.getPayDirection().equals(PayDirectionEnum.IN.getValue()) && contract.getBoolean("isonlist")) { - initEntrylen = (int)Arrays.stream(payItems).filter((obj) -> { + initEntrylen = (int) Arrays.stream(payItems).filter((obj) -> { return !obj.getString("id").equals("506427748873442304"); }).count(); } @@ -1861,7 +2002,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im DynamicObject[] var13 = payItems; int var14 = payItems.length; - for(int var15 = 0; var15 < var14; ++var15) { + for (int var15 = 0; var15 < var14; ++var15) { DynamicObject payItem = var13[var15]; if (!this.getPayDirection().equals(PayDirectionEnum.IN.getValue()) || !payItem.getString("id").equals("506427748873442304") || !contract.getBoolean("isonlist")) { int row = indexArray[index]; @@ -1885,16 +2026,16 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected void initBasicInfoByContract(DynamicObject contract) { - this.getModel().setValue("settleoftaxamount", (Object)null); - this.getModel().setValue("taxamount", (Object)null); - this.getModel().setValue("settleamount", (Object)null); + this.getModel().setValue("settleoftaxamount", (Object) null); + this.getModel().setValue("taxamount", (Object) null); + this.getModel().setValue("settleamount", (Object) null); if (contract == null) { - this.getModel().setValue("project", (Object)null); - this.getModel().setValue("taxrate", (Object)null); + this.getModel().setValue("project", (Object) null); + this.getModel().setValue("taxrate", (Object) null); this.getModel().setValue("ismultirate", false); this.getModel().setValue("ismulticurrency", false); this.getModel().setValue("isonlist", false); - this.getModel().setValue("contattr", (Object)null); + this.getModel().setValue("contattr", (Object) null); this.clearAllAmtWhenDelContract(); } else { this.getModel().setValue("conttotaloftaxamount", contract.getBigDecimal("totaloftaxamount")); @@ -1907,7 +2048,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im if (project != null) { this.getModel().setValue("project", project.getPkValue()); } else { - this.getModel().setValue("project", (Object)null); + this.getModel().setValue("project", (Object) null); } DynamicObject taxRate = contract.getDynamicObject("taxrate"); @@ -2009,7 +2150,7 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected String getPayDirection() { - return (String)this.getModel().getValue("paydirection"); + return (String) this.getModel().getValue("paydirection"); } protected String getCurrentFormBillId() { @@ -2017,6 +2158,6 @@ public class ContractSettleCommonEditPluginExt extends AbstractContBillPlugin im } protected boolean isMultiRate() { - return (Boolean)this.getModel().getValue("ismultirate"); + return (Boolean) this.getModel().getValue("ismultirate"); } }