From 2f17723ba57e2a38195c4a54bf98a3428e3287f1 Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Tue, 7 Jan 2025 15:31:45 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ontractbillContractpartyDefaultPlugin.java | 92 +++++++++++- .../plugin/form/CostcompanyDefaultPlugin.java | 138 ++++++++++++++++++ .../zcdev/fs/plugin/form/OrgCheckUtils.java | 20 ++- .../form/TriprCostcompanyDefaultPlugin.java | 128 ++++++++++++++++ 4 files changed, 371 insertions(+), 7 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java index 68deb2e..e5fe291 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java @@ -3,6 +3,15 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.ConfirmCallBackListener; +import kd.bos.form.MessageBoxOptions; +import kd.bos.form.control.events.BeforeItemClickEvent; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; @@ -22,14 +31,87 @@ public class ContractbillContractpartyDefaultPlugin extends AbstractBillPlugIn Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); //当前切换选择的组织 Long currentOrgId = RequestContext.get().getOrgId(); + Object company = this.getModel().getValue("costcompany");//核算组织 //当前所在的组织是属于矿山下的 - if(OrgCheckUtils.isKS(currentOrgId)){ - Object company = this.getModel().getValue("costcompany");//核算组织 - if(company!=null){ - DynamicObject companyObj = (DynamicObject)company; - this.getModel().setValue("contractparty",companyObj); + if(company!=null){ + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + QFilter numberFilter = new QFilter("number",QCP.equals,companyObj.getString("number")); + DynamicObject[] dynamicObjectOrg = BusinessDataServiceHelper.load("bos_org", "number,name", new QFilter[]{numberFilter}); + if(dynamicObjectOrg!=null){ + this.getModel().setValue("contractparty",dynamicObjectOrg[0]);//签约方名称 + this.getModel().setValue("partatypenew","bos_org");//甲方类型,枚举: bd_supplier :供应商 bd_customer :客户 bos_adminorg :公司(行政组织) bos_org :公司 + this.getModel().setValue("partanew",dynamicObjectOrg[0]);//甲方名称 + this.getView().updateView(); + } + //业务分类设置为默认 + QFilter nnumberFilter = new QFilter("number", QCP.equals,"MR"); + DynamicObject projectTypeObj = BusinessDataServiceHelper.loadSingle("er_projecttype", "createorg", new QFilter[]{nnumberFilter}); + if(projectTypeObj!=null){ + this.getModel().setValue("projecttype",projectTypeObj); + } + //费用项目设置为默认 + QFilter nameQFilterAccItem = new QFilter("number",QCP.equals,"MR"); + DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "id,number,name", new QFilter[]{nameQFilterAccItem}); + if(dynamicObjectAccItem!=null){ + DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity().getDynamicObjectCollection("expenseentryentity"); + for (DynamicObject dynamicObject : dynamicObjectCollection) { + dynamicObject.set("expenseitem",dynamicObjectAccItem); + } + } } } } + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户的主职部门(组织) + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + Object company = this.getModel().getValue("costcompany");//核算组织 + //当前所在的组织是属于矿山下的 + if(company!=null){ + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + //监听工具栏按钮点击事件 + this.addItemClickListeners("advcontoolbarap3"); + //this.addClickListeners("advcontoolbarap"); + } + } + } + + @Override + public void itemClick(ItemClickEvent evt) { + //费用项目设置为默认 + super.itemClick(evt); + //付款计划增行 + if (evt.getItemKey().equals("addloancheck1")) { + //业务分类设置为默认 + QFilter nnumberFilter = new QFilter("number", QCP.equals,"MR"); + DynamicObject projectTypeObj = BusinessDataServiceHelper.loadSingle("er_projecttype", "createorg", new QFilter[]{nnumberFilter}); + if(projectTypeObj!=null){ + this.getModel().setValue("projecttype",projectTypeObj); + } + //费用项目设置为默认 + QFilter nameQFilterAccItem = new QFilter("number",QCP.equals,"MR"); + DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "id,number,name", new QFilter[]{nameQFilterAccItem}); + if(dynamicObjectAccItem!=null){ + DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("expenseentryentity"); + if(!dynamicObjectCollection.isEmpty()){ + DynamicObject dynamicObject = dynamicObjectCollection.get(dynamicObjectCollection.size() - 1); + dynamicObject.set("expenseitem",dynamicObjectAccItem); + this.getView().updateView("expenseentryentity"); + } + } + } + } + + } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java new file mode 100644 index 0000000..cc222bd --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java @@ -0,0 +1,138 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +/** + * 对公报销单、费用报销单 成本中心默认值 + */ +public class CostcompanyDefaultPlugin extends AbstractBillPlugIn implements Plugin { + + + @Override + public void afterCreateNewData(EventObject e) { + super.afterCreateNewData(e); + setCostValue(); + } + + + @Override + public void propertyChanged(PropertyChangedArgs e) { + + String changeName = e.getProperty().getName(); + if (changeName.equals("costcompany") || changeName.equals("costdept")) { + setCostValue(); + } + super.propertyChanged(e); + } + + public void setCostValue(){ + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户的主职部门(组织) + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + Object company = this.getModel().getValue("costcompany");//核算组织 + //当前所在的组织是属于矿山下的 + if(company!=null){ + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + String companyNumber = companyObj.getString("number"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + //costcompany 费用承担公司 + //costdept 费用承担部门 + //费用明细分录 expenseentryentity + //费用明细分录-成本中心 std_entrycostcenter + DynamicObject costcompanyObj = null; + //如果费用承担公司是五家本部公司 + if(OrgCheckUtils.testCompanyNumberSet.contains(companyNumber) || OrgCheckUtils.ksNumber.equals(companyNumber)){ + //费用承担部门带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costdept"); + }else{ + //费用承担公司带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costcompany"); + } + + if(costcompanyObj!=null){ + DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("expenseentryentity"); + QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number")); + DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter}); + for (DynamicObject dynamicObject : dynamicObjectCollection) { + if(dynamicObjectAccItem!=null){ + dynamicObject.set("std_entrycostcenter",dynamicObjectAccItem[0]); + getView().updateView("expenseentryentity"); + } + } + } + } + } + } + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户的主职部门(组织) + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + Object company = this.getModel().getValue("costcompany");//核算组织 + //当前所在的组织是属于矿山下的 + if(company!=null){ + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + //监听工具栏按钮点击事件 + this.addItemClickListeners("advcontoolbarap3"); + //this.addClickListeners("advcontoolbarap"); + } + } + } + + @Override + public void itemClick(ItemClickEvent evt) { + //费用项目设置为默认 + + Object company = this.getModel().getValue("costcompany");//核算组织 + if (company!=null && evt.getItemKey().equals("addloancheck1")) { + DynamicObject companyObj = (DynamicObject)company; + String companyNumber = companyObj.getString("number"); + DynamicObject costcompanyObj = null; + //如果费用承担公司是五家本部公司 + if(OrgCheckUtils.testCompanyNumberSet.contains(companyNumber) || OrgCheckUtils.ksNumber.equals(companyNumber)){ + //费用承担部门带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costdept"); + }else{ + //费用承担公司带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costcompany"); + } + if(costcompanyObj!=null){ + DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("expenseentryentity"); + if(!dynamicObjectCollection.isEmpty()){ + //bos_costcenter + QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number")); + DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter}); + if(dynamicObjectAccItem!=null){ + DynamicObject dynamicObject = dynamicObjectCollection.get(dynamicObjectCollection.size() - 1); + dynamicObject.set("std_entrycostcenter",dynamicObjectAccItem[0]); + } + } + this.getView().updateView("expenseentryentity"); + } + } + super.itemClick(evt); + + } +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OrgCheckUtils.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OrgCheckUtils.java index c279b93..d83c94f 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OrgCheckUtils.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OrgCheckUtils.java @@ -7,18 +7,34 @@ import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.org.OrgUnitServiceHelper; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; public class OrgCheckUtils { + + public static String ksNumberTop = "10006431"; //矿山总部组织编码 + + + public static String ksNumber = "10006447";//矿山总部本部 + + //试点四家公司本部 + public static Set testCompanyNumberSet = new HashSet<>(); + static { + testCompanyNumberSet.add("10006461"); //南京本部 + testCompanyNumberSet.add("10006476"); //兖州本部 + testCompanyNumberSet.add("10007186"); //西安本部 + testCompanyNumberSet.add("10006939"); //天津本部 + } + + /** * 判断是否为矿山 */ public static boolean isKS(Long currentOrgId){ - String rootOrgCode = "10006431";//矿山总部组织编码 - QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + QFilter filterOrgId = new QFilter("number", QCP.equals,ksNumberTop);//中材矿山建设有限公司 DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); long orgId = adminOrg.getLong("id"); List orgIds = new ArrayList<>(1); diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java new file mode 100644 index 0000000..2f125a1 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java @@ -0,0 +1,128 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +/** + * 差旅报销单 成本中心默认值 + */ +public class TriprCostcompanyDefaultPlugin extends AbstractBillPlugIn implements Plugin { + + + @Override + public void afterCreateNewData(EventObject e) { + super.afterCreateNewData(e); + setCostValue(); + } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String changeName = e.getProperty().getName(); + if (changeName.equals("costcompany") || changeName.equals("costdept")) { + setCostValue(); + } + } + + public void setCostValue(){ + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户的主职部门(组织) + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + Object company = this.getModel().getValue("costcompany");//核算组织 + //当前所在的组织是属于矿山下的 + if(company!=null){ + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + String companyNumber = companyObj.getString("number"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + //costcompany 费用承担公司 + //costdept 费用承担部门 + //费用明细分录 expenseentryentity + //费用明细分录-成本中心 std_entrycostcenter + DynamicObject costcompanyObj = null; + //如果费用承担公司是五家本部公司 + if(OrgCheckUtils.testCompanyNumberSet.contains(companyNumber) || OrgCheckUtils.ksNumber.equals(companyNumber)){ + //费用承担部门带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costdept"); + }else{ + //费用承担公司带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costcompany"); + } + + if(costcompanyObj!=null){ + QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number")); + DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter}); + this.getModel().setValue("std_costcenter",dynamicObjectAccItem[0]); + getView().updateView("std_costcenter"); + } + } + } + } + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户的主职部门(组织) + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + Object company = this.getModel().getValue("costcompany");//核算组织 + //当前所在的组织是属于矿山下的 + if(company!=null){ + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + //监听工具栏按钮点击事件 + this.addItemClickListeners("advcontoolbarap3"); + //this.addClickListeners("advcontoolbarap"); + } + } + } + + @Override + public void itemClick(ItemClickEvent evt) { + //费用项目设置为默认 + + Object company = this.getModel().getValue("costcompany");//核算组织 + if (company!=null && evt.getItemKey().equals("addloancheck1")) { + DynamicObject companyObj = (DynamicObject)company; + String companyNumber = companyObj.getString("number"); + DynamicObject costcompanyObj = null; + //如果费用承担公司是五家本部公司 + if(OrgCheckUtils.testCompanyNumberSet.contains(companyNumber) || OrgCheckUtils.ksNumber.equals(companyNumber)){ + //费用承担部门带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costdept"); + }else{ + //费用承担公司带入到成本中心 + costcompanyObj= (DynamicObject)this.getModel().getValue("costcompany"); + } + if(costcompanyObj!=null){ + DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("expenseentryentity"); + if(!dynamicObjectCollection.isEmpty()){ + //bos_costcenter + QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number")); + DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter}); + if(dynamicObjectAccItem!=null){ + this.getModel().setValue("std_costcenter",dynamicObjectAccItem[0]); + } + } + } + } + super.itemClick(evt); + + } +}