diff --git a/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java b/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java index c00d400..32fc9b9 100644 --- a/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java +++ b/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java @@ -72,13 +72,13 @@ public class ContractOPPlugin extends AbstractOperationServicePlugIn { if (qeug_amounts.setScale(2, RoundingMode.HALF_UP).compareTo(amount) > 0) { this.addErrorMessage(extendedDataEntity, "合同清单(定额)的金额之和不能大于合同金额"); } - DynamicObjectCollection qeug_orderformentry1 = dataEntity.getDynamicObjectCollection("qeug_orderformentry"); - int qeug_orderformentry = qeug_orderformentry1==null?0:qeug_orderformentry1.size(); - DynamicObjectCollection qeug_invoiceentryinfo1 = dataEntity.getDynamicObjectCollection("qeug_invoiceentryinfo"); - int qeug_invoiceentryinfo = qeug_invoiceentryinfo1==null?0:qeug_invoiceentryinfo1.size(); - if(qeug_orderformentry+qeug_invoiceentryinfo<1){ - this.addErrorMessage(extendedDataEntity, "合同清单不允许为空!"); - } +// DynamicObjectCollection qeug_orderformentry1 = dataEntity.getDynamicObjectCollection("qeug_orderformentry"); +// int qeug_orderformentry = qeug_orderformentry1==null?0:qeug_orderformentry1.size(); +// DynamicObjectCollection qeug_invoiceentryinfo1 = dataEntity.getDynamicObjectCollection("qeug_invoiceentryinfo"); +// int qeug_invoiceentryinfo = qeug_invoiceentryinfo1==null?0:qeug_invoiceentryinfo1.size(); +// if(qeug_orderformentry+qeug_invoiceentryinfo<1){ +// this.addErrorMessage(extendedDataEntity, "合同清单不允许为空!"); +// } QFilter qFilter = new QFilter("billno", QCP.equals, dataEntity.getString("billno")); DynamicObject[] load = BusinessDataServiceHelper.load("recon_conpayplan", "contractbill", qFilter.toArray()); if (load.length!=0) { diff --git a/main/java/shkd/repc/repe/formplugin/OrderFormEditNewPlugin.java b/main/java/shkd/repc/repe/formplugin/OrderFormEditNewPlugin.java new file mode 100644 index 0000000..ea91f1a --- /dev/null +++ b/main/java/shkd/repc/repe/formplugin/OrderFormEditNewPlugin.java @@ -0,0 +1,125 @@ +package shkd.repc.repe.formplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.resource.ResManager; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.repc.repe.formplugin.order.OrderFormEdit; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +//继承OrderFormEdit,去除自动计算材料单价功能 +public class OrderFormEditNewPlugin extends OrderFormEdit { + + + @Override + protected void calculatePrice(int rowIndex, String fieldKey, PropertyChangedArgs e) { + DynamicObject orderForm = this.getModel().getDataEntity(true); + DynamicObjectCollection orderformEntryColl = orderForm.getDynamicObjectCollection("orderformentry"); + DynamicObject orderFormEntry = (DynamicObject)orderformEntryColl.get(rowIndex); + DynamicObject material = orderFormEntry.getDynamicObject("material"); + if (material != null) { + BigDecimal orderCount = orderFormEntry.getBigDecimal("ordercount"); + BigDecimal unitPrice; + BigDecimal transportPrice; + BigDecimal installPrice; + if (fieldKey.equals("ordercount") && this.getNpFlag(orderForm)) { + unitPrice = this.getContractOrderCount(orderForm, material.getPkValue()); + transportPrice = ((DynamicObject)orderForm.getDynamicObjectCollection("orderformentry").get(rowIndex)).getBigDecimal("contractnum"); + installPrice = transportPrice.subtract(unitPrice); + if (orderCount.compareTo(installPrice) > 0) { + this.getView().showTipNotification(ResManager.loadKDString("本次订货数量只可填≤合同剩余数量的值", "OrderFormEdit_25", "repc-repe-formplugin", new Object[0])); + orderFormEntry.set("ordercount", 0); + } + + orderFormEntry.set("contractremainnum", installPrice.subtract(orderCount)); + this.getView().setEnable(Boolean.FALSE, rowIndex, new String[]{"brand", "model", "contractnum", "unitprice", "transportprice", "installprice", "taxprice", "taxrate", "description"}); + } + + unitPrice = orderFormEntry.getBigDecimal("unitprice").setScale(4, 1); + transportPrice = orderFormEntry.getBigDecimal("transportprice").setScale(4, 1); + installPrice = orderFormEntry.getBigDecimal("installprice").setScale(4, 1); + DynamicObject taxRate = orderFormEntry.getDynamicObject("taxrate"); + BigDecimal totalPrice; + BigDecimal noTaxTotalPrice; + if (fieldKey.equals("taxprice")) { + totalPrice = orderFormEntry.getBigDecimal("taxprice"); + if (null != taxRate) { + noTaxTotalPrice = taxRate.getBigDecimal("taxrate"); + totalPrice = totalPrice.divide(BigDecimal.ONE.add(noTaxTotalPrice.divide(new BigDecimal("100"))), 4, 4).setScale(4, 4); + } + + unitPrice = totalPrice.subtract(transportPrice).subtract(installPrice); +// orderFormEntry.set("unitprice", unitPrice); + } + + totalPrice = transportPrice.add(unitPrice).add(installPrice); + noTaxTotalPrice = orderCount.multiply(totalPrice).setScale(4, 4); + BigDecimal taxPrice = totalPrice; + BigDecimal taxTotalPrice = noTaxTotalPrice; + BigDecimal taxAmount = BigDecimal.ZERO; + if (taxRate != null) { + BigDecimal rate = taxRate.getBigDecimal("taxrate"); + taxPrice = totalPrice.multiply(BigDecimal.ONE.add(rate.divide(new BigDecimal("100")))).setScale(4, 4); + taxTotalPrice = noTaxTotalPrice.multiply(BigDecimal.ONE.add(rate.divide(new BigDecimal("100")))).setScale(4, 4); + taxAmount = noTaxTotalPrice.multiply(rate.divide(new BigDecimal(100))).setScale(4, 4); + } + + orderFormEntry.set("totalprice", totalPrice); + orderFormEntry.set("notaxtotalprice", noTaxTotalPrice); + orderFormEntry.set("taxprice", taxPrice); + orderFormEntry.set("taxamount", taxAmount); + orderFormEntry.set("taxtotalprice", taxTotalPrice); + this.getView().updateView("orderformentry"); + this.setTotalAmoTaxAndNotTax(orderformEntryColl); + } + } + + + private BigDecimal getContractOrderCount(DynamicObject orderForm, Object pkValue) { + DynamicObject insideNprContract = orderForm.getDynamicObject("insidenprcontract"); + String entityName = orderForm.getDynamicObjectType().getName(); + List qFilters = new ArrayList(); + qFilters.add(new QFilter("insidenprcontract", "=", insideNprContract.getPkValue())); + qFilters.add(new QFilter("isfrom", "=", true)); + qFilters.add(new QFilter("id", "!=", orderForm.getPkValue())); + if ("repe_orderform_change".equals(entityName)) { + DynamicObject relatedorderform = orderForm.getDynamicObject("relatedorderform"); + if (relatedorderform != null) { + qFilters.add(new QFilter("id", "!=", relatedorderform.getPkValue())); + } + } + + DynamicObject[] orderForms = BusinessDataServiceHelper.load("repe_orderform", "material,ordercount", (QFilter[])qFilters.toArray(new QFilter[0])); + BigDecimal totalCount = new BigDecimal(0); + if (orderForms != null && orderForms.length > 0) { + DynamicObject[] var8 = orderForms; + int var9 = orderForms.length; + + for(int var10 = 0; var10 < var9; ++var10) { + DynamicObject order = var8[var10]; + DynamicObjectCollection entrys = order.getDynamicObjectCollection("orderformentry"); + Map map = (Map)entrys.stream().collect(Collectors.toMap((item) -> { + return item.getDynamicObject("material").getPkValue(); + }, (item) -> { + return item; + }, (v1, v2) -> { + return v1; + })); + if (map.containsKey(pkValue)) { + BigDecimal ordercount = ((DynamicObject)map.get(pkValue)).getBigDecimal("ordercount"); + totalCount = totalCount.add(ordercount); + } + } + } + + return totalCount; + } + +} diff --git a/main/java/shkd/repc/repe/formplugin/RepeOrderFormPlugin.java b/main/java/shkd/repc/repe/formplugin/RepeOrderFormPlugin.java index 6120b44..edfef65 100644 --- a/main/java/shkd/repc/repe/formplugin/RepeOrderFormPlugin.java +++ b/main/java/shkd/repc/repe/formplugin/RepeOrderFormPlugin.java @@ -134,7 +134,24 @@ public class RepeOrderFormPlugin extends AbstractFormPlugin { return ordercount; } -// @Override + @Override + public void afterBindData(EventObject e) { + super.afterBindData(e); + DynamicObject dataEntity = this.getModel().getDataEntity(); + DynamicObject purchaseorg = dataEntity.getDynamicObject("purchaseorg"); + DynamicObject projectname = dataEntity.getDynamicObject("projectname"); + if(projectname==null){ + QFilter qFilter = new QFilter("org.id",QCP.equals,purchaseorg.getPkValue()); + DynamicObject[] load = BusinessDataServiceHelper.load("rebm_purproject", "id", qFilter.toArray()); + if(load!=null&&load.length>0){ + dataEntity.set("projectname",load[0]); + this.getView().updateView("projectname"); + System.out.println("projectname"); + } + } + } + + // @Override // public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { // super.afterDoOperation(afterDoOperationEventArgs); // //采购订单,选择合同,填写明细审核后反写到对应合同 diff --git a/main/java/shkd/wfs/wf/plugin/form/ApprovalPagePluginNewDemo.java b/main/java/shkd/wfs/wf/plugin/form/ApprovalPagePluginNewDemo.java index 47067be..cb5b672 100644 --- a/main/java/shkd/wfs/wf/plugin/form/ApprovalPagePluginNewDemo.java +++ b/main/java/shkd/wfs/wf/plugin/form/ApprovalPagePluginNewDemo.java @@ -1,7 +1,9 @@ package shkd.wfs.wf.plugin.form; +import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.serialization.SerializationUtils; import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.workflow.component.ApprovalRecord; import kd.bos.workflow.component.approvalrecord.IApprovalRecordGroup; import kd.bos.workflow.engine.TaskService; @@ -20,13 +22,24 @@ public class ApprovalPagePluginNewDemo extends AbstractFormPlugin implements Plu @Override public void afterCreateNewData(EventObject evt) { // Boolean onlyView = (Boolean)this.getView().getFormShowParameter().getCustomParams().get("onlyView"); - String type = (String)this.getView().getFormShowParameter().getCustomParams().get("type"); +// String type = (String)this.getView().getFormShowParameter().getCustomParams().get("type"); + Object id = this.getView().getFormShowParameter().getCustomParams().get("tId"); //查看态,需要显示 审批记录页签 - if(type==null||"tohandle".equals(type)){ - this.getView().setVisible(false,"tabpageap_approvalrecord"); - this.showApprovalRecord(true, Boolean.FALSE, false, Boolean.FALSE,"approvalrecordap"); - }else if("handled".equals(type)){ + if(id==null){ this.showApprovalRecord(true, Boolean.FALSE, false, Boolean.FALSE,"qeug_approvalrecordap"); + }else{ + try { + System.out.println(1); + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(id, "wf_task"); + if(dynamicObject==null){ + this.showApprovalRecord(true, Boolean.FALSE, false, Boolean.FALSE,"qeug_approvalrecordap"); + }else{ + this.getView().setVisible(false,"tabpageap_approvalrecord"); + this.showApprovalRecord(true, Boolean.FALSE, false, Boolean.FALSE,"approvalrecordap"); + } + }catch (Exception e){ + this.showApprovalRecord(true, Boolean.FALSE, false, Boolean.FALSE,"qeug_approvalrecordap"); + } } }