From 81df7a6c44338532c8aa13995166b0e7eaa8cc83 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Tue, 17 Dec 2024 15:53:49 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=90=88=E5=90=8C,?= =?UTF-8?q?=E8=B4=B9=E7=94=A8=E7=99=BB=E8=AE=B0=E6=A0=B9=E6=8D=AE=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=90=BA=E5=B8=A6=E9=A1=B9=E7=9B=AE=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91(=E7=BC=BA=E7=9C=81=E5=80=BC:=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit S --- .../formplugin/ContractProjectFormPlugin.java | 79 +++++++++++++++++++ .../ReconPayreqProjectFormPlugin.java | 78 ++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 main/java/shkd/repc/recon/formplugin/ContractProjectFormPlugin.java create mode 100644 main/java/shkd/repc/recon/formplugin/ReconPayreqProjectFormPlugin.java diff --git a/main/java/shkd/repc/recon/formplugin/ContractProjectFormPlugin.java b/main/java/shkd/repc/recon/formplugin/ContractProjectFormPlugin.java new file mode 100644 index 0000000..c3594c7 --- /dev/null +++ b/main/java/shkd/repc/recon/formplugin/ContractProjectFormPlugin.java @@ -0,0 +1,79 @@ +package shkd.repc.recon.formplugin; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; + +import java.util.EventObject; + +public class ContractProjectFormPlugin extends AbstractBillPlugIn { + + @Override + public void afterBindData(EventObject e) { + super.afterBindData(e); + //根据组织携带项目 + updateRenovationProject(); + } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + //根据组织携带项目 + if ("org".equals(name)) { + updateRenovationProject(); + } + } + + private void updateRenovationProject() { + DynamicObject org = (DynamicObject) this.getModel().getValue("org"); + + // 只有在需求组织不为空的情况下才进行查询 + if (org != null) { + setRenovationProjectByOrg(org); + } else { + // 组织为空,清空项目 + this.getModel().setValue("project", null); + this.getView().updateView("project"); + } + } + + private void setRenovationProjectByOrg(DynamicObject org) { + // 检查 org 是否为 null + if (org == null) { + return; // 如果为 null,直接返回 + } + + // 采购项目 + 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 projectbill1 = projectbills[0]; + if (projectbill1 != null) { + //项目建立F7 + DynamicObject add = BusinessDataServiceHelper.loadSingle("repmd_project_f7", + new QFilter[]{new QFilter("number", QCP.equals, projectbill1.getString("number"))}); + if (add != null) { + projectbill = add; + } + } + } else { + DynamicObject add = BusinessDataServiceHelper.loadSingle("repmd_project_f7", + new QFilter[]{new QFilter("number", QCP.equals, "XM-202412-008")}); + if (add != null) { + projectbill = add; + } + } + + // 设置项目并更新视图 + this.getModel().setValue("project", projectbill); + this.getView().updateView("project"); + } + +} diff --git a/main/java/shkd/repc/recon/formplugin/ReconPayreqProjectFormPlugin.java b/main/java/shkd/repc/recon/formplugin/ReconPayreqProjectFormPlugin.java new file mode 100644 index 0000000..4946296 --- /dev/null +++ b/main/java/shkd/repc/recon/formplugin/ReconPayreqProjectFormPlugin.java @@ -0,0 +1,78 @@ +package shkd.repc.recon.formplugin; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; + +import java.util.EventObject; + +public class ReconPayreqProjectFormPlugin extends AbstractBillPlugIn { + + @Override + public void afterBindData(EventObject e) { + super.afterBindData(e); + //根据组织携带项目 + updateRenovationProject(); + } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + //根据组织携带项目 + if ("org".equals(name)) { + updateRenovationProject(); + } + } + + private void updateRenovationProject() { + DynamicObject org = (DynamicObject) this.getModel().getValue("org"); + + // 只有在需求组织不为空的情况下才进行查询 + if (org != null) { + setRenovationProjectByOrg(org); + } else { + // 组织为空,清空项目 + this.getModel().setValue("project", null); + this.getView().updateView("project"); + } + } + + private void setRenovationProjectByOrg(DynamicObject org) { + // 检查 org 是否为 null + if (org == null) { + return; // 如果为 null,直接返回 + } + + // 采购项目 + 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 projectbill1 = projectbills[0]; + if (projectbill1 != null) { + //项目建立F7 + DynamicObject add = BusinessDataServiceHelper.loadSingle("repmd_project_f7", + new QFilter[]{new QFilter("number", QCP.equals, projectbill1.getString("number"))}); + if (add != null) { + projectbill = add; + } + } + } else { + DynamicObject add = BusinessDataServiceHelper.loadSingle("repmd_project_f7", + new QFilter[]{new QFilter("number", QCP.equals, "XM-202412-008")}); + if (add != null) { + projectbill = add; + } + } + + // 设置项目并更新视图 + this.getModel().setValue("project", projectbill); + this.getView().updateView("project"); + } +}