科目分类通用插件优化

This commit is contained in:
xuhaihui 2025-07-22 18:17:06 +08:00
parent 11d72a8bc5
commit bcd2e4acfc
1 changed files with 9 additions and 9 deletions

View File

@ -144,14 +144,14 @@ public class ReimbursementAccountTypePlugin extends AbstractBillPlugIn implement
//费用项目 //费用项目
String billFormId = ((BillView) this.getView()).getFormId();//单据标识 String billFormId = ((BillView) this.getView()).getFormId();//单据标识
DynamicObject costCompany = (DynamicObject) this.getModel().getValue("costcompany");//费用承担公司 DynamicObject costCompany = (DynamicObject) this.getModel().getValue("costcompany");//费用承担公司
DynamicObject costDept = (DynamicObject) this.getModel().getValue("costdept");//费用承担部门
long costCompanyId = costCompany.getLong("id");//费用承担公司id long costCompanyId = costCompany.getLong("id");//费用承担公司id
long userid = Long.parseLong(RequestContext.get().getUserId());//当前用户id
String userMainJob = UserServiceHelper.getUserMainJob(userid);//获取用户默认主职位
if (!OrgCheckUtils.isKS(costCompanyId)) { if (!OrgCheckUtils.isKS(costCompanyId)) {
//不是矿山不进入下面逻辑 //不是矿山不进入下面逻辑
return; return;
} }
DynamicObject costDept = (DynamicObject) this.getModel().getValue("costdept");//费用承担部门
long userid = Long.parseLong(RequestContext.get().getUserId());//当前用户id
String userMainJob = UserServiceHelper.getUserMainJob(userid);//获取用户默认主职位
ChangeData changeData = e.getChangeSet()[0]; ChangeData changeData = e.getChangeSet()[0];
int rowIndex = changeData.getRowIndex();//所选行 int rowIndex = changeData.getRowIndex();//所选行
DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("expenseentryentity");//分录 DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("expenseentryentity");//分录
@ -173,7 +173,7 @@ public class ReimbursementAccountTypePlugin extends AbstractBillPlugIn implement
} }
QFilter filter = new QFilter("zcgj_entryentity.zcgj_fee", QCP.equals, expenseItemId).and("zcgj_biztype", QCP.equals, typeKey); QFilter filter = new QFilter("zcgj_entryentity.zcgj_fee", QCP.equals, expenseItemId).and("zcgj_biztype", QCP.equals, typeKey);
DynamicObjectCollection AccountFeeCollection = QueryServiceHelper.query("zcgj_accountfee", DynamicObjectCollection AccountFeeCollection = QueryServiceHelper.query("zcgj_accountfee",
"zcgj_entryentity.zcgj_accounttype", new QFilter[]{filter});//费用与科目分类 "zcgj_entryentity.zcgj_accounttype", new QFilter[]{filter});//费用与科目分类
if (AccountFeeCollection != null && AccountFeeCollection.size() == 1) { if (AccountFeeCollection != null && AccountFeeCollection.size() == 1) {
//费用与科目分类中费用项目与科目分类为一对一的关系直接获取科目分类赋值 //费用与科目分类中费用项目与科目分类为一对一的关系直接获取科目分类赋值
@ -182,16 +182,16 @@ public class ReimbursementAccountTypePlugin extends AbstractBillPlugIn implement
} else if (AccountFeeCollection != null && AccountFeeCollection.size() > 1) { } else if (AccountFeeCollection != null && AccountFeeCollection.size() > 1) {
//费用与科目分类中费用项目与科目分类为一对多的关系先查询默认科目分类存在默认科目分类数据时如若通过费用承担公司与公司科目分类规则中查询到对应数据便直接赋值 //费用与科目分类中费用项目与科目分类为一对多的关系先查询默认科目分类存在默认科目分类数据时如若通过费用承担公司与公司科目分类规则中查询到对应数据便直接赋值
//如若没有则通过费用承担公司在组织分类中查询对应默认分类再通过组织分类配置表确认默认科目分类 //如若没有则通过费用承担公司在组织分类中查询对应默认分类再通过组织分类配置表确认默认科目分类部门属性职位人员分别存在不同逻辑
QFilter filter1 = new QFilter("zcgj_entryexpense.zcgj_expenseitem", QCP.equals, expenseItemId); QFilter filter1 = new QFilter("zcgj_entryexpense.zcgj_expenseitem", QCP.equals, expenseItemId);
DynamicObjectCollection orgTypeDefaultCollection = QueryServiceHelper.query("zcgj_orgtypedefault", DynamicObjectCollection orgTypeDefaultCollection = QueryServiceHelper.query("zcgj_orgtypedefault",
"zcgj_entryexpense.zcgj_yanzhou,zcgj_entryexpense.zcgj_xian,zcgj_entryexpense.zcgj_nanjing,zcgj_entryexpense.zcgj_tianjin", "zcgj_entryexpense.zcgj_yanzhou,zcgj_entryexpense.zcgj_xian,zcgj_entryexpense.zcgj_nanjing,zcgj_entryexpense.zcgj_tianjin",
new QFilter[]{filter1});//默认科目分类 new QFilter[]{filter1});//默认科目分类
if (orgTypeDefaultCollection != null && orgTypeDefaultCollection.size() == 1) { if (orgTypeDefaultCollection != null && orgTypeDefaultCollection.size() == 1) {
//默认科目分类中存在单条的费用项目 //默认科目分类中存在单条的费用项目
DynamicObject companyRule = BusinessDataServiceHelper.loadSingle("zcgj_companyrule", DynamicObject companyRule = BusinessDataServiceHelper.loadSingle("zcgj_companyrule",
new QFilter("zcgj_costcompany.id", QCP.equals, costCompanyId).toArray());//公司科目分类规则 new QFilter("zcgj_costcompany.id", QCP.equals, costCompanyId).toArray());//公司科目分类规则
if (companyRule != null) { if (companyRule != null) {
//公司科目分类规则中存在对应公司的信息 //公司科目分类规则中存在对应公司的信息
DynamicObjectCollection entryRuleCollection = companyRule.getDynamicObjectCollection("zcgj_entryrule");//公司费用分类规则分录 DynamicObjectCollection entryRuleCollection = companyRule.getDynamicObjectCollection("zcgj_entryrule");//公司费用分类规则分录
@ -254,7 +254,7 @@ public class ReimbursementAccountTypePlugin extends AbstractBillPlugIn implement
QFilter filter3 = new QFilter("entryentity.orgid", QCP.equals, costCompanyId); QFilter filter3 = new QFilter("entryentity.orgid", QCP.equals, costCompanyId);
DynamicObjectCollection wf_orgTypCollection = QueryServiceHelper.query("wf_orgtype", DynamicObjectCollection wf_orgTypCollection = QueryServiceHelper.query("wf_orgtype",
"number", new QFilter[]{filter3});//组织分类 "number", new QFilter[]{filter3});//组织分类
if (wf_orgTypCollection != null && wf_orgTypCollection.size() > 0) { if (wf_orgTypCollection != null && wf_orgTypCollection.size() > 0) {
List<String> numbers = new ArrayList<>(); List<String> numbers = new ArrayList<>();
@ -263,7 +263,7 @@ public class ReimbursementAccountTypePlugin extends AbstractBillPlugIn implement
numbers.add(number); numbers.add(number);
} }
DynamicObject orgCateGoryConfig = BusinessDataServiceHelper.loadSingle("zcgj_orgcategoryconfig", DynamicObject orgCateGoryConfig = BusinessDataServiceHelper.loadSingle("zcgj_orgcategoryconfig",
new QFilter("number", QCP.in, numbers).toArray());//组织分类配置表 new QFilter("number", QCP.in, numbers).toArray());//组织分类配置表
String accountType = null;//默认科目分类中的科目分类 String accountType = null;//默认科目分类中的科目分类
if (orgCateGoryConfig != null) { if (orgCateGoryConfig != null) {