From d0f4cc31d2fe111c25c977ec3598644e2a219ad4 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Tue, 17 Dec 2024 12:39:25 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=87=87=E8=B4=AD=E5=85=A8=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=90=BA=E5=B8=A6(=E4=BE=9B=E6=96=B9=E5=85=A5=E5=9B=B4,?= =?UTF-8?q?=E6=A0=87=E4=B9=A6=E7=BC=96=E5=88=B6,=E6=A0=87=E5=BA=95?= =?UTF-8?q?=E7=BC=96=E5=88=B6,=E6=8B=9B=E6=A0=87=E4=BA=A4=E5=BA=95,?= =?UTF-8?q?=E5=8F=91=E6=A0=87=E5=BC=80=E6=A0=87,=E7=AD=94=E7=96=91?= =?UTF-8?q?=E8=AE=B0=E5=BD=95,=E8=AF=84=E6=A0=87=E8=B0=88=E5=88=A4,?= =?UTF-8?q?=E5=AE=9A=E6=A0=87)=202.=E7=AB=8B=E9=A1=B9=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=97=B6=E6=8E=A7=E5=88=B6,=E7=AB=8B=E9=A1=B9=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E9=87=91=E9=A2=9D=E4=B8=8D=E8=83=BD=E5=A4=A7=E4=BA=8E?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E7=9A=84=E6=BA=90=E5=8D=95?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E9=87=91=E9=A2=9D+=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=8D=95=E6=98=8E=E7=BB=86=E5=90=88=E5=B9=B6=E5=90=8E=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E9=87=91=E9=A2=9D+=E5=90=88=E7=BA=A6=E8=A7=84?= =?UTF-8?q?=E5=88=92=E4=B8=AD=E8=A7=84=E5=88=92=E9=87=91=E9=A2=9D=203.?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E9=9C=80=E6=B1=82=E4=BB=A3=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E7=BC=96=E7=A0=81=E8=A7=84=E5=88=99=204.=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=9C=80=E6=B1=82,=E8=AE=A1=E5=88=92,=E7=AB=8B?= =?UTF-8?q?=E9=A1=B9,=E6=A0=B9=E6=8D=AE=E7=BB=84=E7=BB=87=E6=90=BA?= =?UTF-8?q?=E5=B8=A6=E9=A1=B9=E7=9B=AE=E7=9A=84=E9=80=BB=E8=BE=91(?= =?UTF-8?q?=E7=BC=BA=E7=9C=81=E5=80=BC:=E8=99=9A=E6=8B=9F=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit S --- .../ImportPurchaseApplyBillPlugin.java | 11 +- .../rebm/formplugin/PurDemandFormPlugin.java | 47 ++++++- .../rebm/formplugin/PurPlanFormPlugin.java | 11 +- .../formplugin/SupplierinvitaFormPlugin.java | 32 ++--- .../opplugin/PurProjectSubmitOPPlugin.java | 128 ++++++++---------- 5 files changed, 136 insertions(+), 93 deletions(-) diff --git a/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java b/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java index 588db1e..748af95 100644 --- a/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java +++ b/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java @@ -72,11 +72,16 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements //采购项目 DynamicObject[] projectbills = BusinessDataServiceHelper.load("rebm_purproject", "id", new QFilter[]{new QFilter("org.id", QCP.equals, org.getPkValue())}); + DynamicObject projectbill = null; if (projectbills.length > 0) { - DynamicObject projectbill = projectbills[0]; - this.getModel().setValue("qeug_renovation_proj", projectbill); - this.getView().updateView("qeug_renovation_proj"); + projectbill = projectbills[0]; + }else { + DynamicObject[] projectbillss = BusinessDataServiceHelper.load("rebm_purproject", "id", + new QFilter[]{new QFilter("number", QCP.equals, "XM-202412-008")}); + projectbill = projectbillss[0]; } + this.getModel().setValue("qeug_renovation_proj", projectbill); + this.getView().updateView("qeug_renovation_proj"); } diff --git a/main/java/shkd/repc/rebm/formplugin/PurDemandFormPlugin.java b/main/java/shkd/repc/rebm/formplugin/PurDemandFormPlugin.java index bfc6353..33d6372 100644 --- a/main/java/shkd/repc/rebm/formplugin/PurDemandFormPlugin.java +++ b/main/java/shkd/repc/rebm/formplugin/PurDemandFormPlugin.java @@ -1,11 +1,17 @@ package shkd.repc.rebm.formplugin; +import kd.bos.coderule.api.CodeRuleInfo; +import kd.bos.coderule.service.cache.CodeRuleCache; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.bos.servicehelper.coderule.CodeRuleServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.bos.util.StringUtils; import java.util.EventObject; @@ -20,6 +26,36 @@ public class PurDemandFormPlugin extends AbstractFormPlugin { super.afterBindData(e); //根据组织携带项目 updateRenovationProject(); + DynamicObject dataEntity = this.getModel().getDataEntity(true); + + if (StringUtils.isEmpty(dataEntity.getString("billno"))) { + QFilter q1 = new QFilter("number","=","CGXQ"); + DynamicObject coderule = BusinessDataServiceHelper.loadSingle("bos_coderule", "id", new QFilter[]{q1}); + if (null != coderule) { + CodeRuleInfo codeRule = CodeRuleCache.reloadCodeRuleById(coderule.getString("id")); + String number = CodeRuleServiceHelper.getNumber(codeRule, dataEntity); + String purissue = codeRuleNumberIsExits(number, codeRule, dataEntity); + this.getModel().setValue("billno", purissue); + } + } + } + + /** + * 递归,若生成的采购单号已存在,则重新生成 + * @param purissue + * @param codeRule + * @param purapplybill + * @return + */ + public static String codeRuleNumberIsExits(String purissue,CodeRuleInfo codeRule,DynamicObject purapplybill){ + QFilter filter = new QFilter("billno", QCP.equals,purissue); + boolean exists = QueryServiceHelper.exists("recon_settleplanbill", new QFilter[]{filter}); + if(exists){ + purissue = CodeRuleServiceHelper.getNumber(codeRule, purapplybill); + return codeRuleNumberIsExits(purissue,codeRule,purapplybill); + }else{ + return purissue; + } } @Override @@ -55,11 +91,16 @@ public class PurDemandFormPlugin extends AbstractFormPlugin { //采购项目 DynamicObject[] projectbills = BusinessDataServiceHelper.load("rebm_purproject", "id", new QFilter[]{new QFilter("org.id", QCP.equals, org.getPkValue())}); + DynamicObject projectbill = null; if (projectbills.length > 0) { - DynamicObject projectbill = projectbills[0]; - this.getModel().setValue("qeug_renovation_proj", projectbill); - this.getView().updateView("qeug_renovation_proj"); + projectbill = projectbills[0]; + }else { + DynamicObject[] projectbillss = BusinessDataServiceHelper.load("rebm_purproject", "id", + new QFilter[]{new QFilter("number", QCP.equals, "XM-202412-008")}); + projectbill = projectbillss[0]; } + this.getModel().setValue("qeug_renovation_proj", projectbill); + this.getView().updateView("qeug_renovation_proj"); } } diff --git a/main/java/shkd/repc/rebm/formplugin/PurPlanFormPlugin.java b/main/java/shkd/repc/rebm/formplugin/PurPlanFormPlugin.java index 229cb62..b1d806c 100644 --- a/main/java/shkd/repc/rebm/formplugin/PurPlanFormPlugin.java +++ b/main/java/shkd/repc/rebm/formplugin/PurPlanFormPlugin.java @@ -96,10 +96,15 @@ public class PurPlanFormPlugin extends AbstractBillPlugIn implements HyperLinkCl //采购项目 DynamicObject[] projectbills = BusinessDataServiceHelper.load("rebm_purproject", "id", new QFilter[]{new QFilter("org.id", QCP.equals, org.getPkValue())}); + DynamicObject projectbill = null; if (projectbills.length > 0) { - DynamicObject projectbill = projectbills[0]; - this.getModel().setValue("purproject", projectbill); - this.getView().updateView("purproject"); + projectbill = projectbills[0]; + }else { + DynamicObject[] projectbillss = BusinessDataServiceHelper.load("rebm_purproject", "id", + new QFilter[]{new QFilter("number", QCP.equals, "XM-202412-008")}); + projectbill = projectbillss[0]; } + this.getModel().setValue("qeug_renovation_proj", projectbill); + this.getView().updateView("qeug_renovation_proj"); } } diff --git a/main/java/shkd/repc/rebm/formplugin/SupplierinvitaFormPlugin.java b/main/java/shkd/repc/rebm/formplugin/SupplierinvitaFormPlugin.java index 753987a..d0eb0d1 100644 --- a/main/java/shkd/repc/rebm/formplugin/SupplierinvitaFormPlugin.java +++ b/main/java/shkd/repc/rebm/formplugin/SupplierinvitaFormPlugin.java @@ -16,22 +16,22 @@ public class SupplierinvitaFormPlugin extends AbstractFormPlugin { public void afterBindData(EventObject e) { super.afterBindData(e); - /** - * 供方入围 qeug_rebm_supplierinv_ext - * 标书编制 qeug_rebm_biddocument_ext - * 标底编制 qeug_rebm_bottom_make_ext - * 招标交底 qeug_rebm_clarificait_ext - * 技术标开标 - * 技术标评标 - * 商务标开标 - * 商务标评标 - * 发标 qeug_rebm_bidpublish_ext - * 开标 qeug_rebm_bidopen_ext - * 答疑记录 qeug_rebm_answerques_ext1 - * 在线评标 - * 评标 qeug_rebm_bidevaluati_ext - * 商务谈判 qeug_rebm_bustalk_ext - * 定标 qeug_rebm_decision_ext + /* + 供方入围 qeug_rebm_supplierinv_ext + 标书编制 qeug_rebm_biddocument_ext + 标底编制 qeug_rebm_bottom_make_ext + 招标交底 qeug_rebm_clarificait_ext + 技术标开标 + 技术标评标 + 商务标开标 + 商务标评标 + 发标 qeug_rebm_bidpublish_ext + 开标 qeug_rebm_bidopen_ext + 答疑记录 qeug_rebm_answerques_ext1 + 在线评标 + 评标 qeug_rebm_bidevaluati_ext + 商务谈判 qeug_rebm_bustalk_ext + 定标 qeug_rebm_decision_ext */ //业务类型携带 String qeugCombofield = (String)this.getModel().getValue("qeug_combofield"); diff --git a/main/java/shkd/repc/rebm/opplugin/PurProjectSubmitOPPlugin.java b/main/java/shkd/repc/rebm/opplugin/PurProjectSubmitOPPlugin.java index 4d96ce7..e01dea5 100644 --- a/main/java/shkd/repc/rebm/opplugin/PurProjectSubmitOPPlugin.java +++ b/main/java/shkd/repc/rebm/opplugin/PurProjectSubmitOPPlugin.java @@ -6,17 +6,11 @@ import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.AddValidatorsEventArgs; import kd.bos.entity.validate.AbstractValidator; -import kd.bos.logging.Log; -import kd.bos.logging.LogFactory; -import kd.bos.orm.query.QCP; -import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.util.StringUtils; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -25,73 +19,75 @@ import java.util.Map; */ public class PurProjectSubmitOPPlugin extends AbstractOperationServicePlugIn { - private static final Log logger = LogFactory.getLog(PurProjectSubmitOPPlugin.class); - @Override public void onAddValidators(AddValidatorsEventArgs e) { super.onAddValidators(e); + /* + 校验金额逻辑 + 1)引用合约规划:遍历子单据体,取计划,需求均为空并且合约规划名称不为空的行,累加规划金额 + 2)引用采购计划:遍历子单据体,取计划不为空的行,穿透到计划中累加对应明细的控制金额 + 3)引用采购需求:合并相同的采购需求单,累加需求金额 + */ + e.addValidator(new AbstractValidator() { @Override public void validate() { String operateKey = this.getOperateKey(); ExtendedDataEntity[] dataEntities1 = this.getDataEntities(); - switch (operateKey) { - case "submit": - for (ExtendedDataEntity extendedDataEntity : dataEntities1) { - // 控制金额校验 - DynamicObject dataEntity = extendedDataEntity.getDataEntity(); - List ids = new ArrayList<>(); - Map XqMap = new HashMap<>(); - DynamicObjectCollection bidSections = dataEntity.getDynamicObjectCollection("bidsection"); // 标段 - BigDecimal totalAmount = BigDecimal.ZERO; // 遍历明细, 需求单去重后累加申请金额, 非需求单累加规划金额 + if ("submit".equals(operateKey)) { + for (ExtendedDataEntity extendedDataEntity : dataEntities1) { + // 控制金额校验 + DynamicObject dataEntity = extendedDataEntity.getDataEntity(); + Map XqMap = new HashMap<>(); + DynamicObjectCollection bidSections = dataEntity.getDynamicObjectCollection("bidsection"); // 标段 + BigDecimal totalAmount = BigDecimal.ZERO; // 遍历明细, 需求单去重后累加申请金额, 非需求单累加规划金额 - if (bidSections != null) { - for (DynamicObject bidSection : bidSections) { - DynamicObjectCollection projectEntries = bidSection.getDynamicObjectCollection("projectentry"); // 采购明细 + if (bidSections != null) { + for (DynamicObject bidSection : bidSections) { + DynamicObjectCollection projectEntries = bidSection.getDynamicObjectCollection("projectentry"); // 采购明细 - if (projectEntries != null) { - for (DynamicObject projectEntry : projectEntries) { - long id = projectEntry.getLong("qeug_purentry_id"); + if (projectEntries != null) { + for (DynamicObject projectEntry : projectEntries) { + long id = projectEntry.getLong("qeug_purentry_id"); - // 需求_对应金额, 若id相同, 覆盖 - if (id != 0) { - DynamicObject qeugCgxq = projectEntry.getDynamicObject("qeug_cgxq"); + // 需求_对应金额, 若id相同, 覆盖 + if (id != 0) { + DynamicObject qeugCgxq = projectEntry.getDynamicObject("qeug_cgxq"); + if (qeugCgxq != null) { + qeugCgxq = BusinessDataServiceHelper.loadSingle(qeugCgxq.getPkValue(), "recon_settleplanbill"); if (qeugCgxq != null) { - qeugCgxq = BusinessDataServiceHelper.loadSingle(qeugCgxq.getPkValue(), "recon_settleplanbill"); - if (qeugCgxq != null) { - XqMap.put(qeugCgxq.getLong("id"), qeugCgxq.getBigDecimal("qeug_applyamount")); - } + XqMap.put(qeugCgxq.getLong("id"), qeugCgxq.getBigDecimal("qeug_applyamount")); } } - // 非采购需求 - else { - String purplanname = projectEntry.getString("purplanname"); // 采购计划名称 - DynamicObject programcontract = projectEntry.getDynamicObject("programcontract"); // 合约规划 - DynamicObject cqprogcon = projectEntry.getDynamicObject("cqprogcon"); // 合约规划树形 + } + // 非采购需求 + else { + String purplanname = projectEntry.getString("purplanname"); // 采购计划名称 + DynamicObject programcontract = projectEntry.getDynamicObject("programcontract"); // 合约规划 + DynamicObject cqprogcon = projectEntry.getDynamicObject("cqprogcon"); // 合约规划树形 - // 合约规划 - if (StringUtils.isEmpty(purplanname) && projectEntry.getDynamicObject("qeug_cgxq") == null) { - if (programcontract != null || cqprogcon != null) { - totalAmount = totalAmount.add(projectEntry.getBigDecimal("planamount")); - } + // 合约规划 + if (StringUtils.isEmpty(purplanname) && projectEntry.getDynamicObject("qeug_cgxq") == null) { + if (programcontract != null || cqprogcon != null) { + totalAmount = totalAmount.add(projectEntry.getBigDecimal("planamount")); } + } - // 采购计划 - if (!StringUtils.isEmpty(purplanname)) { - DynamicObject purplanentry = projectEntry.getDynamicObject("purplanentry"); // 采购计划分录 - if (purplanentry != null) { - purplanentry = BusinessDataServiceHelper.loadSingle(purplanentry.getPkValue(), "rebm_purplanentry_f7"); - DynamicObject purplan = purplanentry.getDynamicObject("purplan"); - if (purplan != null) { - DynamicObject rebm_purplan = BusinessDataServiceHelper.loadSingle(purplan.getPkValue(), "rebm_purplan"); - DynamicObjectCollection collection = rebm_purplan.getDynamicObjectCollection("entryentity"); + // 采购计划 + if (!StringUtils.isEmpty(purplanname)) { + DynamicObject purplanentry = projectEntry.getDynamicObject("purplanentry"); // 采购计划分录 + if (purplanentry != null) { + purplanentry = BusinessDataServiceHelper.loadSingle(purplanentry.getPkValue(), "rebm_purplanentry_f7"); + DynamicObject purplan = purplanentry.getDynamicObject("purplan"); + if (purplan != null) { + DynamicObject rebm_purplan = BusinessDataServiceHelper.loadSingle(purplan.getPkValue(), "rebm_purplan"); + DynamicObjectCollection collection = rebm_purplan.getDynamicObjectCollection("entryentity"); - for (DynamicObject dynamicObject : collection) { - long id1 = purplanentry.getLong("id"); // 计划分录id - long id2 = dynamicObject.getLong("id"); - if (id1 == id2) { - totalAmount = totalAmount.add(dynamicObject.getBigDecimal("prucontrolamount")); - } + for (DynamicObject dynamicObject : collection) { + long id1 = purplanentry.getLong("id"); // 计划分录id + long id2 = dynamicObject.getLong("id"); + if (id1 == id2) { + totalAmount = totalAmount.add(dynamicObject.getBigDecimal("prucontrolamount")); } } } @@ -100,24 +96,20 @@ public class PurProjectSubmitOPPlugin extends AbstractOperationServicePlugIn { } } } - - // 累加需求对应金额 - for (BigDecimal value : XqMap.values()) { - totalAmount = totalAmount.add(value); - } } - // 采购立项_采购控制总金额(单头) - BigDecimal totalcontrol = dataEntity.getBigDecimal("totalcontrol"); - if (totalcontrol.compareTo(totalAmount) > 0) { - this.addErrorMessage(extendedDataEntity, "采购控制总金额不能大于采购申请总金额与规划金额之和"); + // 累加需求对应金额 + for (BigDecimal value : XqMap.values()) { + totalAmount = totalAmount.add(value); } } - break; - default: - break; - + // 采购立项_采购控制总金额(单头) + BigDecimal totalcontrol = dataEntity.getBigDecimal("totalcontrol"); + if (totalcontrol.compareTo(totalAmount) > 0) { + this.addErrorMessage(extendedDataEntity, "采购控制总金额不能大于采购申请总金额与规划金额之和"); + } + } } } });