企业成本核算表单插件优化取数逻辑和添加子分录赋值逻辑
This commit is contained in:
parent
206a9e7e47
commit
3d242fe726
|
@ -4,6 +4,7 @@ import kd.bos.bill.AbstractBillPlugIn;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
||||||
|
import kd.bos.dataentity.resource.ResManager;
|
||||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
import kd.bos.form.operate.FormOperate;
|
import kd.bos.form.operate.FormOperate;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
|
@ -51,38 +52,40 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
||||||
filter.and(new QFilter("zcgj_isnew", QCP.equals, true));//是否最新
|
filter.and(new QFilter("zcgj_isnew", QCP.equals, true));//是否最新
|
||||||
DynamicObjectCollection rptAssistBalanceGxCollection = QueryServiceHelper.query("zcgj_rpt_assistbalancegx",
|
DynamicObjectCollection rptAssistBalanceGxCollection = QueryServiceHelper.query("zcgj_rpt_assistbalancegx",
|
||||||
"id,zcgj_account,zcgj_processname",
|
"id,zcgj_account,zcgj_processname",
|
||||||
new QFilter[]{filter});//核算维度余额取数表(矿山工序维度)
|
new QFilter[]{filter});//"核算维度余额取数表(矿山工序维度)"
|
||||||
|
|
||||||
for (DynamicObject rptAssistBalanceGx : rptAssistBalanceGxCollection) {
|
for (DynamicObject rptAssistBalanceGx : rptAssistBalanceGxCollection) {
|
||||||
QFilter[] qFilter = new QFilter[]{new QFilter("id", QCP.equals, rptAssistBalanceGx.get("zcgj_account"))};
|
QFilter[] qFilter = new QFilter[]{new QFilter("id", QCP.equals, rptAssistBalanceGx.get("zcgj_account"))};
|
||||||
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 filter1 = new QFilter("zcgj_acccostentry.zcgj_accountname", QCP.equals, bd_accountview.getString("name"));//科目名称
|
QFilter filter1 = new QFilter("zcgj_acccostentry.zcgj_accountnumber", QCP.equals, bd_accountview.getString("number"));//科目编码
|
||||||
filter1.and(new QFilter("zcgj_acccostentry.zcgj_accountnumber", QCP.equals, bd_accountview.getString("number")));//科目编码
|
|
||||||
// filter1.and(new QFilter("zcgj_org", QCP.equals, org1.getPkValue()));//组织
|
|
||||||
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});// "项目"
|
||||||
|
|
||||||
if (ec_ecbd_pro_cbs == null && zcgj_accountcost == null && ec_projects.length == 0) {
|
if (ec_ecbd_pro_cbs == null && zcgj_accountcost == null && ec_projects.length == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DynamicObject newEntry = new DynamicObject(entryType);
|
DynamicObject newEntry = new DynamicObject(entryType);
|
||||||
|
DynamicObjectCollection subEntryEntityCollection = newEntry.getDynamicObjectCollection("zcgj_subentryentity");//成本核算维度明细
|
||||||
|
DynamicObjectType subEntryEntityType = subEntryEntityCollection.getDynamicObjectType();
|
||||||
|
DynamicObject newEntrySubEntryEntity = new DynamicObject(subEntryEntityType);
|
||||||
if (ec_projects.length != 0) {
|
if (ec_projects.length != 0) {
|
||||||
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);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,19 +94,42 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ec_ecbd_pro_cbs != null) {
|
if (ec_ecbd_pro_cbs != null) {
|
||||||
newEntry.set("cbs", ec_ecbd_pro_cbs);//成本分解结构
|
newEntry.set("cbs", ec_ecbd_pro_cbs);//成本分解结构
|
||||||
|
newEntrySubEntryEntity.set("zcgj_cbs", ec_ecbd_pro_cbs);
|
||||||
}
|
}
|
||||||
if (zcgj_accountcost != null) {
|
if (zcgj_accountcost != null) {
|
||||||
newEntry.set("costtype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_costtype"));//成本项
|
newEntry.set("costtype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_costtype"));//成本项
|
||||||
newEntry.set("zcgj_sectype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_sectype"));//二级分类
|
newEntry.set("zcgj_sectype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_sectype"));//二级分类
|
||||||
|
newEntrySubEntryEntity.set("zcgj_costtype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_costtype"));
|
||||||
|
newEntrySubEntryEntity.set("zcgj_sectype1", zcgj_accountcost.get("zcgj_acccostentry.zcgj_sectype"));
|
||||||
}
|
}
|
||||||
entryCollection.add(newEntry);
|
entryCollection.add(newEntry);
|
||||||
|
subEntryEntityCollection.add(newEntrySubEntryEntity);
|
||||||
}
|
}
|
||||||
this.getView().updateView("entryentity");//刷新分录
|
this.getView().updateView("entryentity");//刷新分录
|
||||||
|
this.getView().updateView("zcgj_subentryentity");//刷新分录
|
||||||
this.getModel().endInit();
|
this.getModel().endInit();
|
||||||
|
this.getView().invokeOperation("save");
|
||||||
|
this.getView().invokeOperation("refresh");
|
||||||
|
} else if ("newentry1".equals(formOperate.getOperateKey())) {
|
||||||
|
//成本核算维度明细子分录增行按钮
|
||||||
|
int rowIndex = this.getModel().getEntryCurrentRowIndex("entryentity");//企业费用成本分摊明细分录行索引
|
||||||
|
int rowCount = this.getModel().getEntryRowCount("entryentity");//企业费用成本分摊明细分录总行数
|
||||||
|
if (rowCount > 0 && rowIndex >= 0) {
|
||||||
|
int subInd = this.getModel().createNewEntryRow("zcgj_subentryentity");//新增子分录行数
|
||||||
|
this.getModel().setValue("zcgj_project", this.getModel().getValue("project", rowIndex), subInd);
|
||||||
|
this.getModel().setValue("zcgj_cbs", this.getModel().getValue("cbs", rowIndex), subInd);
|
||||||
|
this.getModel().setValue("zcgj_costtype", this.getModel().getValue("costtype", rowIndex), subInd);
|
||||||
|
this.getModel().setValue("zcgj_sectype1", this.getModel().getValue("zcgj_sectype", rowIndex), subInd);
|
||||||
|
args.setCancel(true);
|
||||||
|
} else {
|
||||||
|
this.getView().showTipNotification(ResManager.loadKDString("请先选中1行企业费用成本分摊明细分录行数据", "MaterialCostBillPlugin_1", "ec-ecco-formplugin", new Object[0]));
|
||||||
|
args.setCancel(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue