From 3d451abc07cbb47ea22980f6e0545b54bf9aefdb Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Fri, 27 Dec 2024 09:18:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=EF=BC=8C=E4=BB=85=E9=99=90=E7=9F=BF=E5=B1=B1=E6=9C=AC?= =?UTF-8?q?=E9=83=A8=E5=8F=8A=E4=BB=A5=E4=B8=8B=E5=8D=95=E4=BD=8D=202.?= =?UTF-8?q?=E5=8F=B0=E8=B4=A6=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4=203.?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=8F=96=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fs/plugin/form/AnnualBudgetPlugin.java | 1 + .../form/DailyloanbillExpAccPlugin.java | 51 +++++- .../form/DailyreimbursExpAccPlugin.java | 49 +++++- .../plugin/form/DefaultExpenseItemPlugin.java | 2 + .../plugin/form/OverseaStaysLimitPlugin.java | 66 ++++---- .../plugin/form/PrepaybillContractPlugin.java | 33 +++- .../plugin/form/PrepaybillExpAccPlugin.java | 49 +++++- .../PublicreimbursebillContractPlugin.java | 38 ++++- .../form/PublicreimbursebillExpAccPlugin.java | 51 +++++- .../TripreimbursebillAbroadAlertedPlugin.java | 147 +++++++++++------- .../form/TripstandAccmodationAutoPlugin.java | 59 +++++++ .../fs/plugin/form/UserHomeConfPlugin.java | 1 + .../fs/plugin/form/UserVisitSetPlugin.java | 1 + .../plugin/operate/ApprovalCheckFlowOp.java | 30 +++- .../operate/DailyreimbursVisitCheckOp.java | 38 ++++- .../plugin/operate/TripreimbursebillUpOp.java | 85 +++++----- 16 files changed, 522 insertions(+), 179 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripstandAccmodationAutoPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AnnualBudgetPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AnnualBudgetPlugin.java index 52a0ef7..03b27c2 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AnnualBudgetPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AnnualBudgetPlugin.java @@ -18,6 +18,7 @@ import java.text.SimpleDateFormat; /** * 单据界面插件 * 人员年度预算单界面插件 + * 矿山新增二开 */ public class AnnualBudgetPlugin extends AbstractBillPlugIn implements Plugin { diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java index 2d9bf3a..875be37 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java @@ -1,6 +1,7 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.CloneUtils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; @@ -20,9 +21,15 @@ 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import java.util.ArrayList; import java.util.EventObject; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 借款单会计科目与费用项目关联插件 @@ -56,14 +63,24 @@ public class DailyloanbillExpAccPlugin extends AbstractBillPlugIn implements Plu @Override public void registerListener(EventObject e) { super.registerListener(e); - BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); - fieldEdit.addBeforeF7SelectListener(this); - fieldEdit.addAfterF7SelectListener(this); - - BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); - fieldEditExpense.addBeforeF7SelectListener(this); - fieldEditExpense.addAfterF7SelectListener(this); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 costcompany + //costcompany 费用承担公司 + DynamicObject costcompany = (DynamicObject)this.getModel().getValue("costcompany"); + long costcompanyId = costcompany.getLong("id"); + if(isKS(currentOrgId) && isKS(costcompanyId)){ + BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); + fieldEdit.addBeforeF7SelectListener(this); + fieldEdit.addAfterF7SelectListener(this); + BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); + fieldEditExpense.addBeforeF7SelectListener(this); + fieldEditExpense.addAfterF7SelectListener(this); + } } @Override @@ -195,4 +212,24 @@ public class DailyloanbillExpAccPlugin extends AbstractBillPlugIn implements Plu } } } + + + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java index 45b8efe..ccba7c4 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java @@ -1,6 +1,7 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.CloneUtils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; @@ -20,9 +21,15 @@ 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import java.util.ArrayList; import java.util.EventObject; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 费用报销单会计科目与费用项目关联插件 @@ -53,13 +60,24 @@ public class DailyreimbursExpAccPlugin extends AbstractBillPlugIn implements Plu @Override public void registerListener(EventObject e) { super.registerListener(e); - BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); - fieldEdit.addBeforeF7SelectListener(this); - fieldEdit.addAfterF7SelectListener(this); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户的主职部门(组织) + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + //costcompany 费用承担公司 + DynamicObject costcompany = (DynamicObject)this.getModel().getValue("costcompany"); + long costcompanyId = costcompany.getLong("id"); + if(isKS(currentOrgId) && isKS(costcompanyId)){ + BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); + fieldEdit.addBeforeF7SelectListener(this); + fieldEdit.addAfterF7SelectListener(this); - BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); - fieldEditExpense.addBeforeF7SelectListener(this); - fieldEditExpense.addAfterF7SelectListener(this); + BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); + fieldEditExpense.addBeforeF7SelectListener(this); + fieldEditExpense.addAfterF7SelectListener(this); + } } @Override @@ -193,5 +211,22 @@ public class DailyreimbursExpAccPlugin extends AbstractBillPlugIn implements Plu } } } - + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DefaultExpenseItemPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DefaultExpenseItemPlugin.java index 8970465..a44bdf4 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DefaultExpenseItemPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DefaultExpenseItemPlugin.java @@ -63,4 +63,6 @@ public class DefaultExpenseItemPlugin extends AbstractBillPlugIn implements Plu } } + + } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java index 5b89067..c10455d 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java @@ -1,6 +1,7 @@ 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.IDataModel; @@ -18,10 +19,16 @@ 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.EventObject; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 国外住宿费标准 @@ -35,8 +42,16 @@ public class OverseaStaysLimitPlugin extends AbstractBillPlugIn implements Plugi @Override public void registerListener(EventObject e) { super.registerListener(e); - BasedataEdit fieldEdit = this.getView().getControl("zcgj_district_f7"); - fieldEdit.addBeforeF7SelectListener(this); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(isKS(currentOrgId)){ + BasedataEdit fieldEdit = this.getView().getControl("zcgj_district_f7"); + fieldEdit.addBeforeF7SelectListener(this); + } } @Override @@ -50,37 +65,24 @@ public class OverseaStaysLimitPlugin extends AbstractBillPlugIn implements Plugi } } - /*@Override - public void propertyChanged(PropertyChangedArgs e) { - super.propertyChanged(e); - String name = e.getProperty().getName(); - if("zcgj_district_f7".equals(name)){ - IDataModel model = this.getModel(); - ChangeData[] changeSet = e.getChangeSet(); - DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue(); - long id = newValue.getLong("id"); - //获取地域详细信息 - //bd_admindivision - DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country", - new QFilter[]{new QFilter("id", QCP.equals,id)}); - if(cityObj!=null){ - DynamicObject country = cityObj.getDynamicObject("country"); - long countryId = country.getLong("id"); - //获取所属国家 - //bd_country - DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode", - new QFilter[]{new QFilter("id", QCP.equals,countryId)}); - if(countryObj!=null){ - String twocountrycode = countryObj.getString("twocountrycode"); - String countname = countryObj.getString("name"); - if(!"CN".equals(twocountrycode)){ - //保存国家id - // this.getModel().setValue("zcgj_countryid",countryId); - } - } - } + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; } - }*/ + return false; + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java index 2ce2163..1f2156d 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java @@ -1,6 +1,7 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.CloneUtils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; @@ -22,12 +23,14 @@ 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; import java.time.LocalDate; import java.time.ZoneId; -import java.util.Date; -import java.util.EventObject; +import java.util.*; +import java.util.stream.Collectors; /** * 预付单去年合同提醒插件 @@ -44,7 +47,12 @@ public class PrepaybillContractPlugin extends AbstractBillPlugIn implements Plug @Override public void beforeDoOperation(BeforeDoOperationEventArgs args) { - if((args.getSource() instanceof Submit) ) { + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(isKS(currentOrgId) && (args.getSource() instanceof Submit) ) { Submit source = (Submit) args.getSource(); if (source.getOperateKey().equals("submit")) { //获取当前页面的数据包 @@ -71,7 +79,24 @@ public class PrepaybillContractPlugin extends AbstractBillPlugIn implements Plug } } - + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } /** * 将 java.util.Date 转换为 java.time.LocalDate * @param date java.util.Date diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java index 71a5c02..6ab12be 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java @@ -1,6 +1,7 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.CloneUtils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; @@ -20,9 +21,15 @@ 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import java.util.ArrayList; import java.util.EventObject; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 预付单会计科目与费用项目关联插件 @@ -56,13 +63,24 @@ public class PrepaybillExpAccPlugin extends AbstractBillPlugIn implements Plugin @Override public void registerListener(EventObject e) { super.registerListener(e); - BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); - fieldEdit.addBeforeF7SelectListener(this); - fieldEdit.addAfterF7SelectListener(this); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 costcompany + //costcompany 费用承担公司 + DynamicObject costcompany = (DynamicObject)this.getModel().getValue("costcompany"); + long costcompanyId = costcompany.getLong("id"); + if(isKS(currentOrgId) && isKS(costcompanyId)){ + BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); + fieldEdit.addBeforeF7SelectListener(this); + fieldEdit.addAfterF7SelectListener(this); - BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); - fieldEditExpense.addBeforeF7SelectListener(this); - fieldEditExpense.addAfterF7SelectListener(this); + BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); + fieldEditExpense.addBeforeF7SelectListener(this); + fieldEditExpense.addAfterF7SelectListener(this); + } } @@ -195,4 +213,23 @@ public class PrepaybillExpAccPlugin extends AbstractBillPlugIn implements Plugin } } } + + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java index a60b37b..8f37c90 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java @@ -1,17 +1,27 @@ 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.operate.Submit; import kd.bos.form.events.BeforeDoOperationEventArgs; 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; import java.time.LocalDate; import java.time.ZoneId; +import java.util.ArrayList; import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 对公报销单去年合同提醒插件 @@ -27,8 +37,13 @@ public class PublicreimbursebillContractPlugin extends AbstractBillPlugIn implem @Override public void beforeDoOperation(BeforeDoOperationEventArgs args) { - - if((args.getSource() instanceof Submit) ) { + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(isKS(currentOrgId)&&(args.getSource() instanceof Submit) ) { Submit source = (Submit) args.getSource(); if (source.getOperateKey().equals("submit")) { //获取当前页面的数据包 @@ -52,7 +67,24 @@ public class PublicreimbursebillContractPlugin extends AbstractBillPlugIn implem } } } - + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } /** * 将 java.util.Date 转换为 java.time.LocalDate diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java index b4bf7d3..bee6343 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java @@ -1,6 +1,7 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.CloneUtils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; @@ -20,9 +21,15 @@ 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import java.util.ArrayList; import java.util.EventObject; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 对公报销单会计科目与费用项目关联插件 @@ -56,14 +63,24 @@ public class PublicreimbursebillExpAccPlugin extends AbstractBillPlugIn implemen @Override public void registerListener(EventObject e) { super.registerListener(e); - BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); - fieldEdit.addBeforeF7SelectListener(this); - fieldEdit.addAfterF7SelectListener(this); - - BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); - fieldEditExpense.addBeforeF7SelectListener(this); - fieldEditExpense.addAfterF7SelectListener(this); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 costcompany + //costcompany 费用承担公司 + DynamicObject costcompany = (DynamicObject)this.getModel().getValue("costcompany"); + long costcompanyId = costcompany.getLong("id"); + if(isKS(currentOrgId) && isKS(costcompanyId)){ + BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); + fieldEdit.addBeforeF7SelectListener(this); + fieldEdit.addAfterF7SelectListener(this); + BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); + fieldEditExpense.addBeforeF7SelectListener(this); + fieldEditExpense.addAfterF7SelectListener(this); + } } @Override @@ -195,4 +212,24 @@ public class PublicreimbursebillExpAccPlugin extends AbstractBillPlugIn implemen } } } + + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } + } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java index 4de434d..5527ef1 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java @@ -1,6 +1,7 @@ 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.entity.datamodel.IDataModel; import kd.bos.entity.datamodel.events.ChangeData; @@ -8,13 +9,15 @@ 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 kd.bos.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; import java.io.InputStream; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * 差旅报销单国外住宿标准提醒插件 @@ -28,71 +31,95 @@ public class TripreimbursebillAbroadAlertedPlugin extends AbstractBillPlugIn imp @Override public void propertyChanged(PropertyChangedArgs e) { super.propertyChanged(e); - String name = e.getProperty().getName(); - //目的地变更 - if("to".equals(name)){ - IDataModel model = this.getModel(); - ChangeData[] changeSet = e.getChangeSet(); - DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue(); - if(newValue!=null){ - long id = newValue.getLong("id"); - //获取地域详细信息 - //bd_admindivision - DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country", - new QFilter[]{new QFilter("id", QCP.equals,id)}); - if(cityObj!=null){ - long cityId = cityObj.getLong("id"); - DynamicObject country = cityObj.getDynamicObject("country"); - long countryId = country.getLong("id"); - //获取所属国家 - //bd_country - DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode", - new QFilter[]{new QFilter("id", QCP.equals,countryId)}); - if(countryObj!=null){ - String twocountrycode = countryObj.getString("twocountrycode"); - String countname = countryObj.getString("name"); - if(!"CN".equals(twocountrycode)){ - DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_oversea_stays_limit", - "zcgj_district_f7,zcgj_country,zcgj_currency,zcgj_stays_criteria,zcgj_rate" - , new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)}); - BigDecimal otherAmount = BigDecimal.ZERO; - BigDecimal cirtyAmount = BigDecimal.ZERO; - BigDecimal rate = BigDecimal.ZERO; - String currencyName = ""; - String currencySign = ""; - if(load == null || load.length<1){ - // this.getView().showTipNotification("当前出差国家为:"+countname+",未设置住宿标准!"); - }else{ - Map map = new HashMap<>(); - for (DynamicObject dynamicObject : load) { - DynamicObject zcgjCountry = dynamicObject.getDynamicObject("zcgj_country"); - DynamicObject zcgjDistrictF7 = dynamicObject.getDynamicObject("zcgj_district_f7"); - DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency"); - BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria"); - BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate"); - rate=zcgjRate; - currencyName = zcgjCurrency.getString("name"); - if(zcgjDistrictF7 ==null ){ - otherAmount = zcgjStaysCriteria.multiply(zcgjRate); - }else if(cityId == zcgjDistrictF7.getLong("id")){ - cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(isKS(currentOrgId)){ + String name = e.getProperty().getName(); + //目的地变更 + if("to".equals(name)){ + IDataModel model = this.getModel(); + ChangeData[] changeSet = e.getChangeSet(); + DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue(); + if(newValue!=null){ + long id = newValue.getLong("id"); + //获取地域详细信息 + //bd_admindivision + DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country", + new QFilter[]{new QFilter("id", QCP.equals,id)}); + if(cityObj!=null){ + long cityId = cityObj.getLong("id"); + DynamicObject country = cityObj.getDynamicObject("country"); + long countryId = country.getLong("id"); + //获取所属国家 + //bd_country + DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode", + new QFilter[]{new QFilter("id", QCP.equals,countryId)}); + if(countryObj!=null){ + String twocountrycode = countryObj.getString("twocountrycode"); + String countname = countryObj.getString("name"); + if(!"CN".equals(twocountrycode)){ + DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_oversea_stays_limit", + "zcgj_district_f7,zcgj_country,zcgj_currency,zcgj_stays_criteria,zcgj_rate" + , new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)}); + BigDecimal otherAmount = BigDecimal.ZERO; + BigDecimal cirtyAmount = BigDecimal.ZERO; + BigDecimal rate = BigDecimal.ZERO; + String currencyName = ""; + String currencySign = ""; + if(load == null || load.length<1){ + // this.getView().showTipNotification("当前出差国家为:"+countname+",未设置住宿标准!"); + }else{ + Map map = new HashMap<>(); + for (DynamicObject dynamicObject : load) { + DynamicObject zcgjCountry = dynamicObject.getDynamicObject("zcgj_country"); + DynamicObject zcgjDistrictF7 = dynamicObject.getDynamicObject("zcgj_district_f7"); + DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency"); + BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria"); + BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate"); + rate=zcgjRate; + currencyName = zcgjCurrency.getString("name"); + if(zcgjDistrictF7 ==null ){ + otherAmount = zcgjStaysCriteria.multiply(zcgjRate); + }else if(cityId == zcgjDistrictF7.getLong("id")){ + cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate); + } + } + if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){ + this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币):"+otherAmount.setScale(4, RoundingMode.HALF_UP)+"元"); + }else if(!BigDecimal.ZERO.equals(cirtyAmount) ){ + this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币):"+cirtyAmount.setScale(4, RoundingMode.HALF_UP)+"元"); } - } - if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){ - this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币):"+otherAmount.setScale(4, RoundingMode.HALF_UP)+"元"); - }else if(!BigDecimal.ZERO.equals(cirtyAmount) ){ - this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币):"+cirtyAmount.setScale(4, RoundingMode.HALF_UP)+"元"); } } } } } + + InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("fs.properties"); } - - InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("fs.properties"); - System.out.println(); - - } } + + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripstandAccmodationAutoPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripstandAccmodationAutoPlugin.java new file mode 100644 index 0000000..5f2ccf0 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripstandAccmodationAutoPlugin.java @@ -0,0 +1,59 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.form.ConfirmCallBackListener; +import kd.bos.form.MessageBoxOptions; +import kd.bos.form.MessageBoxResult; +import kd.bos.form.control.events.BeforeClickEvent; +import kd.bos.form.control.events.BeforeItemClickEvent; +import kd.bos.form.events.MessageBoxClosedEvent; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +public class TripstandAccmodationAutoPlugin extends AbstractBillPlugIn implements Plugin { + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); +//监听工具栏按钮点击事件 + this.addItemClickListeners("zcgj_auto_get_data"); + this.addClickListeners("zcgj_auto_get_data"); + } + + @Override + public void beforeClick(BeforeClickEvent evt) { + super.beforeClick(evt); + } + + @Override + public void beforeItemClick(BeforeItemClickEvent evt) { + //工具栏上的所有按钮的点击都会激活itemClick和beforeItemClick方法, 需 //要开发人员实现不同按钮的逻辑 + if (evt.getItemKey().equals("zcgj_auto_get_data")) { + evt.setCancel(true); + ConfirmCallBackListener confirmCallBackListener = new ConfirmCallBackListener("submitconfirm", this); + //设置页面确认框,参数为:标题,选项框类型,回调监听 + this.getView().showConfirm("您确认提交该办公用品登记单吗?", MessageBoxOptions.YesNoCancel, confirmCallBackListener); + } + super.beforeItemClick(evt); + } + + @Override + public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) { + super.confirmCallBack(messageBoxClosedEvent); + //判断是否是对应确认框的点击回调事件 + if (("submitconfirm").equals(messageBoxClosedEvent.getCallBackId())) { + if (MessageBoxResult.Yes.equals(messageBoxClosedEvent.getResult())) { + //如果点击确认按钮,则调用提交操作 + // this.getView().invokeOperation("submit"); + this.getView().showMessage("你好"); + } else if (MessageBoxResult.No.equals(messageBoxClosedEvent.getResult())) { + + } else if (MessageBoxResult.Cancel.equals(messageBoxClosedEvent.getResult())) { + // 点击取消的相关处理逻辑。。。。 + } + } + + } +} \ No newline at end of file diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserHomeConfPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserHomeConfPlugin.java index 283d23a..75dda9d 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserHomeConfPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserHomeConfPlugin.java @@ -15,6 +15,7 @@ import kd.sdk.plugin.Plugin; /** * 来往家居地配置界面插件 + * 矿山二开新功能 */ public class UserHomeConfPlugin extends AbstractBillPlugIn implements Plugin { diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserVisitSetPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserVisitSetPlugin.java index f11ae39..9ba08cd 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserVisitSetPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/UserVisitSetPlugin.java @@ -14,6 +14,7 @@ import kd.sdk.plugin.Plugin; /** * 人员探亲配置界面插件 + * 矿山二开新功能 */ public class UserVisitSetPlugin extends AbstractBillPlugIn implements Plugin { //开发商标识 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/ApprovalCheckFlowOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/ApprovalCheckFlowOp.java index b45c5eb..87a89e7 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/ApprovalCheckFlowOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/ApprovalCheckFlowOp.java @@ -6,10 +6,13 @@ import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.entity.plugin.PreparePropertysEventArgs; import kd.bos.entity.validate.AbstractValidator; 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.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.bos.servicehelper.workflow.WorkflowServiceHelper; import kd.bos.workflow.api.AgentExecution; @@ -19,6 +22,7 @@ import kd.bos.workflow.engine.extitf.IWorkflowPlugin; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.util.*; +import java.util.stream.Collectors; /** * 判断当前审批人是否为提交人 @@ -26,6 +30,12 @@ import java.util.*; */ public class ApprovalCheckFlowOp extends AbstractOperationServicePlugIn { + @Override + public void onPreparePropertys(PreparePropertysEventArgs e) { + super.onPreparePropertys(e); + e.getFieldKeys().add("formid"); + e.getFieldKeys().add("id"); + } @Override public void onAddValidators(AddValidatorsEventArgs e) { @@ -45,7 +55,7 @@ public class ApprovalCheckFlowOp extends AbstractOperationServicePlugIn { String billId = dataEntity.getString("id"); String formid = dataEntity.getString("formid"); //获取报销人 - //DynamicObject applier = dataEntity.getDynamicObject("applier"); + //DynamicObject applier = dataEntity.getDynam+icObject("applier"); //long applierId = applier.getLong("id"); boolean isOk = true; //所有审批记录,从审批记录中获取已经审批过的人 @@ -69,4 +79,22 @@ public class ApprovalCheckFlowOp extends AbstractOperationServicePlugIn { } } + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java index 1461dc7..8334e74 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java @@ -2,6 +2,7 @@ package zcgj.zcdev.zcdev.fs.plugin.operate; import kd.bos.algo.DataSet; import kd.bos.algo.Row; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; @@ -10,7 +11,10 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs; import kd.bos.entity.validate.AbstractValidator; 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.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -18,6 +22,7 @@ import java.time.Month; import java.time.ZoneId; import java.time.temporal.TemporalAdjusters; import java.util.*; +import java.util.stream.Collectors; /** * 费用报销单探亲检查 @@ -42,7 +47,15 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn { @Override public void onAddValidators(AddValidatorsEventArgs e) { super.onAddValidators(e); - e.getValidators().add(new ValidatorExt()); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(isKS(currentOrgId)){ + e.getValidators().add(new ValidatorExt()); + } } class ValidatorExt extends AbstractValidator { @@ -76,7 +89,7 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn { //探亲类型 1:探望父母,2:探望配偶 String visitType = dataEntity.getString(prefix + "_visit_type"); - + //判断是否探亲 if(isVisit){ //获取当前人的探亲假配置 @@ -275,7 +288,7 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn { DataSet dateSet = QueryServiceHelper.queryDataSet( this.getClass().getName(), "er_dailyreimbursebill", - "id,billno,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_is_home as ishome", + "id,billno,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_is_home as ishome,", filterArray, null ); int goHomeCount = 0; @@ -371,5 +384,24 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn { } return LocalDate.of(date.getYear() - (years - 1), Month.JANUARY, 1); } + + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; + } + return false; + } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java index cad584e..c272d30 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java @@ -1,5 +1,6 @@ package zcgj.zcdev.zcdev.fs.plugin.operate; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.entity.ExtendedDataEntity; @@ -9,9 +10,18 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs; 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.servicehelper.org.OrgUnitServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 差旅报销单上浮20%控制 @@ -34,7 +44,15 @@ public class TripreimbursebillUpOp extends AbstractOperationServicePlugIn { @Override public void onAddValidators(AddValidatorsEventArgs e) { super.onAddValidators(e); - e.getValidators().add(new ValidatorExt()); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(isKS(currentOrgId)){ + e.getValidators().add(new ValidatorExt()); + } } class ValidatorExt extends AbstractValidator { @@ -79,53 +97,22 @@ public class TripreimbursebillUpOp extends AbstractOperationServicePlugIn { } } - /*@Override - public void beforeDoOperation(BeforeDoOperationEventArgs args) { - if((args.getSource() instanceof Submit) ){ - Submit source = (Submit)args.getSource(); - if(source.getOperateKey().equals("submit") ){ - //highseasontripstdshow - //提交时校验附件是否必填 - IDataModel model = this.getModel(); - String zsKey = String.valueOf(model.getValue("zcgj_zs_key")); - boolean isfloating20 = Boolean.parseBoolean(model.getValue("zcgj_isfloating20")+""); - - //获取当前费用为住宿的 - DynamicObjectCollection tripentryCollection = model.getEntryEntity("tripentry"); - //tripentry.get(0).getDynamicObjectCollection("entryentity").get(2).getDynamicObject("expenseitem").getString("number"); - for (DynamicObject tripentry : tripentryCollection) { - DynamicObjectCollection entryentityCollection = tripentry.getDynamicObjectCollection("entryentity"); - for (DynamicObject entryentity : entryentityCollection) { - DynamicObject expenseitem = entryentity.getDynamicObject("expenseitem"); - String zsNumber = expenseitem.getString("number"); - if(zsKey.equals(zsNumber)){ - BigDecimal orientryamount = entryentity.getBigDecimal("orientryamount");//报销金额 - BigDecimal tripstandardamount = entryentity.getBigDecimal("tripstandardamount");//差旅标准金额 - Integer caldaycount = entryentity.getInt("caldaycount");//标准天数 - //如果选择了上浮20%,则按照上浮20%进行判断 - if(isfloating20){ - //BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")).multiply(new BigDecimal(caldaycount)); - BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount)); - //-1表示小于,0是等于,1是大于 - if(orientryamount.compareTo(multiply) > 0){ - this.getView().showTipNotification("报销住宿超出标准!(上浮20%)"); - //取消提交操作 - args.setCancel(true); - } - }else{ - BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount)); - //-1表示小于,0是等于,1是大于 - if(orientryamount.compareTo(multiply) > 0){ - this.getView().showTipNotification("报销住宿超出标准!"); - //取消提交操作 - args.setCancel(true); - } - } - } - } - - } - } + /** + * 判断是否为矿山 + */ + public boolean isKS(Long currentOrgId){ + String rootOrgCode = "10006431";//矿山总部组织编码 + QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司 + DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId}); + long orgId = adminOrg.getLong("id"); + List orgIds = new ArrayList<>(1); + //orgIds.add(1692204547985902592L); + orgIds.add(orgId); + List subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true); + Set orgSer = subOrgIds.stream().collect(Collectors.toSet()); + if(orgSer.contains(currentOrgId)){ + return true; } - }*/ + return false; + } }