diff --git a/src/main/java/com/yem/wm/es/shippingdetails/form/ShippingDetailsFormPlugin.java b/src/main/java/com/yem/wm/es/shippingdetails/form/ShippingDetailsFormPlugin.java index 5e6bd26b..eec34b3a 100644 --- a/src/main/java/com/yem/wm/es/shippingdetails/form/ShippingDetailsFormPlugin.java +++ b/src/main/java/com/yem/wm/es/shippingdetails/form/ShippingDetailsFormPlugin.java @@ -434,10 +434,6 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef } } } - if ("yem_es_materialinfo".equals(name)) { - extracted1(); - } - } @Override @@ -477,6 +473,8 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef this.getView().showMessage("删除单已存在下游单,不允许删除!!!"); e.setCancel(true); } + qtys(rowIndexs); + } if ("yem_es_salesorder_p".equals(name)) { Boolean aseqty = aseqty(rowIndexs); @@ -486,6 +484,40 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef } } + private void qtys(int[] rowIndexs) { + Map map = new HashMap<>(); + for (int rowIndex : rowIndexs) { + DynamicObject yemProductmodel = (DynamicObject) this.getModel().getValue("yem_productmodel", rowIndex); + BigDecimal yemQty = (BigDecimal) this.getModel().getValue("yem_qty"); + if (yemProductmodel != null) { + long aLong = yemProductmodel.getLong("id"); + map.merge(aLong, yemQty, (a, b) -> b.add(a)); + } + } + DynamicObjectCollection yemEsSalesorderP = this.getModel().getEntryEntity("yem_es_salesorder_p"); + if (!yemEsSalesorderP.isEmpty()) { + List ints = new ArrayList<>(); + for (int i = 0; i < yemEsSalesorderP.size(); i++) { + DynamicObject yemAccessorytype = yemEsSalesorderP.get(i).getDynamicObject("yem_accessorytype"); + if (yemAccessorytype != null) { + long aLong = yemAccessorytype.getLong("id"); + BigDecimal yemPcstype = yemAccessorytype.getBigDecimal("yem_pcstype"); + if (map.get(aLong) != null) { + if (yemPcstype.compareTo(map.get(aLong)) == 0) { + ints.add(i); + } else { + this.getModel().setValue("yem_pcstype", yemPcstype.subtract(map.get(aLong)), i); + } + } + } + } + int[] intArray = ints.stream().mapToInt(Integer::intValue).toArray(); + if (intArray.length > 0) { + this.getModel().deleteEntryRows("yem_es_salesorder_p", intArray); + } + } + } + @Override public void click(EventObject evt) { Control source = (Control) evt.getSource(); @@ -686,7 +718,7 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef // } else { // ies.add(i1); // } - }else { + } else { ies.add(i1); } } @@ -739,13 +771,13 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef public void clientCallBack(ClientCallBackEvent e) { super.clientCallBack(e); String name = e.getName(); - if("offeramountchanged".equals(name)){ + if ("offeramountchanged".equals(name)) { DynamicObject dataEntity = this.getModel().getDataEntity(true); BigDecimal offeramount = dataEntity.getBigDecimal("yem_offeramount"); DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_es_salescontrac_s"); for (int i = 0; i < collection.size(); i++) { BigDecimal raprate = collection.get(i).getBigDecimal("yem_raprate"); - this.getModel().setValue("yem_rapamt", PaymentControlUtil.getAdvancePayment(offeramount, raprate),i); + this.getModel().setValue("yem_rapamt", PaymentControlUtil.getAdvancePayment(offeramount, raprate), i); } // this.getView().invokeOperation("save"); }