企业成本核算优化自动取数逻辑

This commit is contained in:
xuhaihui 2025-11-19 17:43:14 +08:00
parent 33a2fb4345
commit 59e3fc65fd
1 changed files with 21 additions and 3 deletions

View File

@ -50,6 +50,7 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
if (entryCollection.size() > 0) { if (entryCollection.size() > 0) {
entryCollection.clear(); entryCollection.clear();
} }
QFilter filter = new QFilter("zcgj_org", QCP.equals, org1.getPkValue());//核算组织 QFilter filter = new QFilter("zcgj_org", QCP.equals, org1.getPkValue());//核算组织
filter.and(new QFilter("zcgj_period", QCP.equals, period1.getPkValue()));//期间 filter.and(new QFilter("zcgj_period", QCP.equals, period1.getPkValue()));//期间
// filter.and(new QFilter("zcgj_isnew", QCP.equals, true));//是否最新 // filter.and(new QFilter("zcgj_isnew", QCP.equals, true));//是否最新
@ -67,18 +68,31 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
(debitLocal instanceof String && ((String) debitLocal).equals("0"))) { (debitLocal instanceof String && ((String) debitLocal).equals("0"))) {
continue; continue;
} }
QFilter[] qFilter = new QFilter[]{new QFilter("id", QCP.equals, rptAssistBalanceGx.get("zcgj_account"))};//科目ID QFilter[] qFilter = new QFilter[]{new QFilter("id", QCP.equals, rptAssistBalanceGx.get("zcgj_account"))};//科目ID
DynamicObject bd_accountview = BusinessDataServiceHelper.loadSingle("bd_accountview", DynamicObject bd_accountview = BusinessDataServiceHelper.loadSingle("bd_accountview",
"id,number,name", qFilter);//"会计科目" "id,number,name", qFilter);//"会计科目"
if (bd_accountview == null) { if (bd_accountview == null) {
continue; continue;
} }
QFilter filter3 = new QFilter("zcgj_companyblentry.zcgj_org", QCP.equals, org1.getPkValue());//组织
DynamicObject zcgj_companybelong = QueryServiceHelper.queryOne("zcgj_companybelong", "id",
new QFilter[]{filter3});//"公司归属区域"
Long id = 0L;
if (zcgj_companybelong != null) {
id = (Long) zcgj_companybelong.get("id");
}
QFilter filter1 = new QFilter("zcgj_acccostentry.zcgj_accountnumber", QCP.equals, bd_accountview.getString("number"));//科目编码 QFilter filter1 = new QFilter("zcgj_acccostentry.zcgj_accountnumber", QCP.equals, bd_accountview.getString("number"));//科目编码
filter1.and(new QFilter("zcgj_belongcompany", QCP.equals, id));
DynamicObject zcgj_accountcost = QueryServiceHelper.queryOne("zcgj_accountcost", DynamicObject zcgj_accountcost = QueryServiceHelper.queryOne("zcgj_accountcost",
"id,zcgj_acccostentry.zcgj_costtype,zcgj_acccostentry.zcgj_sectype", "id,zcgj_acccostentry.zcgj_costtype,zcgj_acccostentry.zcgj_sectype",
new QFilter[]{filter1});//"会计科目与成本项目" new QFilter[]{filter1});//"会计科目与成本项目"
QFilter[] qFilters = new QFilter[]{new QFilter("name", QCP.equals, rptAssistBalanceGx.get("zcgj_processname"))};//工序名称 QFilter[] qFilters = new QFilter[]{new QFilter("name", QCP.equals, rptAssistBalanceGx.get("zcgj_processname"))};//工序名称
DynamicObject ec_ecbd_pro_cbs = BusinessDataServiceHelper.loadSingle("ec_ecbd_pro_cbs", "id", qFilters);//"项目工序" DynamicObject ec_ecbd_pro_cbs = BusinessDataServiceHelper.loadSingle("ec_ecbd_pro_cbs", "id", qFilters);//"项目工序"
QFilter filter2 = new QFilter("fiaccountorg", QCP.equals, org1.getPkValue());//财务记账组织 QFilter filter2 = new QFilter("fiaccountorg", QCP.equals, org1.getPkValue());//财务记账组织
filter2.and(new QFilter("billstatus", QCP.equals, "C"));//单据状态 filter2.and(new QFilter("billstatus", QCP.equals, "C"));//单据状态
DynamicObject[] ec_projects = BusinessDataServiceHelper.load("ec_project", "id,zcgj_init", new QFilter[]{filter2});// "项目" DynamicObject[] ec_projects = BusinessDataServiceHelper.load("ec_project", "id,zcgj_init", new QFilter[]{filter2});// "项目"
@ -129,17 +143,21 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
for (DynamicObject ec_project : ec_projects) { for (DynamicObject ec_project : ec_projects) {
boolean zcgj_init = ec_project.getBoolean("zcgj_init");//默认项目 boolean zcgj_init = ec_project.getBoolean("zcgj_init");//默认项目
if (zcgj_init) { if (zcgj_init) {
DynamicObject ec_project_f7 = BusinessDataServiceHelper.loadSingle("ec_project_f7", "id", DynamicObject ec_project_f7 = BusinessDataServiceHelper.loadSingle("ec_project_f7", "id",
new QFilter[]{new QFilter("id", QCP.equals, ec_project.getPkValue())});//项目 new QFilter[]{new QFilter("id", QCP.equals, ec_project.getPkValue())});//"项目"
newEntry.set("project", ec_project_f7);//"项目"
newEntry.set("project", ec_project_f7);//项目
newEntrySubEntryEntity.set("zcgj_project", ec_project_f7);//项目 newEntrySubEntryEntity.set("zcgj_project", ec_project_f7);//项目
break; break;
} }
} }
Object project = newEntry.get("project"); Object project = newEntry.get("project");
if (project == null) { if (project == null) {
DynamicObject ec_project_f7 = BusinessDataServiceHelper.loadSingle("ec_project_f7", "id", DynamicObject ec_project_f7 = BusinessDataServiceHelper.loadSingle("ec_project_f7", "id",
new QFilter[]{new QFilter("id", QCP.equals, ec_projects[0].getPkValue())});//项目 new QFilter[]{new QFilter("id", QCP.equals, ec_projects[0].getPkValue())});//"项目"
newEntry.set("project", ec_project_f7);//项目 newEntry.set("project", ec_project_f7);//项目
newEntrySubEntryEntity.set("zcgj_project", ec_project_f7);//项目 newEntrySubEntryEntity.set("zcgj_project", ec_project_f7);//项目
} }