1.增加组织过滤,仅限矿山本部及以下单位

2.台账代码调整
3.增加自动取数
This commit is contained in:
zhangzhiguo 2024-12-27 09:18:28 +08:00
parent 0956b6d924
commit 3d451abc07
16 changed files with 522 additions and 179 deletions

View File

@ -18,6 +18,7 @@ import java.text.SimpleDateFormat;
/**
* 单据界面插件
* 人员年度预算单界面插件
* 矿山新增二开
*/
public class AnnualBudgetPlugin extends AbstractBillPlugIn implements Plugin {

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
}

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
}

View File

@ -63,4 +63,6 @@ public class DefaultExpenseItemPlugin extends AbstractBillPlugIn implements Plu
}
}
}

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
}*/
return false;
}
}

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> 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

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
}

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
/**
* java.util.Date 转换为 java.time.LocalDate

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
}

View File

@ -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<String,Object> 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<String,Object> 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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
}

View File

@ -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())) {
// 点击取消的相关处理逻辑
}
}
}
}

View File

@ -15,6 +15,7 @@ import kd.sdk.plugin.Plugin;
/**
* 来往家居地配置界面插件
* 矿山二开新功能
*/
public class UserHomeConfPlugin extends AbstractBillPlugIn implements Plugin {

View File

@ -14,6 +14,7 @@ import kd.sdk.plugin.Plugin;
/**
* 人员探亲配置界面插件
* 矿山二开新功能
*/
public class UserVisitSetPlugin extends AbstractBillPlugIn implements Plugin {
//开发商标识

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
}

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
return false;
}
}

View File

@ -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<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> orgSer = subOrgIds.stream().collect(Collectors.toSet());
if(orgSer.contains(currentOrgId)){
return true;
}
}*/
return false;
}
}