Compare commits
2 Commits
41030db6be
...
cb1c6602f3
Author | SHA1 | Date |
---|---|---|
|
cb1c6602f3 | |
|
0fa1844eeb |
|
@ -0,0 +1,127 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
|
import kd.bos.bill.BillShowParameter;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
||||||
|
import kd.bos.dataentity.utils.StringUtils;
|
||||||
|
import kd.bos.form.control.EntryGrid;
|
||||||
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
|
import kd.bos.form.events.HyperLinkClickEvent;
|
||||||
|
import kd.bos.form.events.HyperLinkClickListener;
|
||||||
|
import kd.bos.form.operate.FormOperate;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.QueryServiceHelper;
|
||||||
|
import kd.ec.basedata.common.utils.OpenPageUtils;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目综合成本核算表单插件
|
||||||
|
*/
|
||||||
|
public class ProCostSplitBillPlugin extends AbstractBillPlugIn implements HyperLinkClickListener {
|
||||||
|
@Override
|
||||||
|
public void registerListener(EventObject e) {
|
||||||
|
super.registerListener(e);
|
||||||
|
EntryGrid entryGrid = this.getView().getControl("zcgj_entryentity");
|
||||||
|
if (entryGrid != null) {
|
||||||
|
entryGrid.addHyperClickListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||||
|
super.beforeDoOperation(args);
|
||||||
|
FormOperate formOperate = (FormOperate) args.getSource();
|
||||||
|
if ("autogetdata".equals(formOperate.getOperateKey())) {
|
||||||
|
//自动取数分摊
|
||||||
|
Object org = this.getModel().getValue("org");//所属组织
|
||||||
|
if (org != null) {
|
||||||
|
DynamicObject org1 = (DynamicObject) org;
|
||||||
|
Object billno = this.getModel().getValue("billno");//单据编码
|
||||||
|
DynamicObject period = (DynamicObject) this.getModel().getValue("period");//期间
|
||||||
|
Date endDate;
|
||||||
|
if (period != null) {
|
||||||
|
endDate = period.getDate("enddate");//期间-结束日期
|
||||||
|
} else {
|
||||||
|
this.getView().showTipNotification("请先填写期间");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DynamicObjectCollection entryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_entryentity");//费用明细分录
|
||||||
|
DynamicObjectType entryType = entryCollection.getDynamicObjectType();
|
||||||
|
if (entryCollection.size() > 0) {
|
||||||
|
entryCollection.clear();
|
||||||
|
}
|
||||||
|
QFilter filter = new QFilter("costcompany", QCP.equals, org1.getPkValue());//费用承担公司
|
||||||
|
filter.and(new QFilter("billstatus", QCP.in, new String[]{"G"}));//单据状态
|
||||||
|
filter.and(new QFilter("bizdate", QCP.less_equals, endDate));//申请日期
|
||||||
|
DynamicObjectCollection er_dailyReimburseBillCollection = QueryServiceHelper.query("er_dailyreimbursebill",
|
||||||
|
"id,billno,applier,bizdate,costdept,costcompany,expenseentryentity.std_entrycostcenter,expenseentryentity.expenseitem," +
|
||||||
|
"expenseentryentity.zcgj_accounttype,expenseentryentity.expenseamount,expenseentryentity.taxrate,expenseentryentity.taxamount," +
|
||||||
|
"expenseentryentity.orientryamount,expenseentryentity.remark,expenseentryentity.id",
|
||||||
|
new QFilter[]{filter});//费用报销单
|
||||||
|
for (DynamicObject er_dailyReimburseBill : er_dailyReimburseBillCollection) {
|
||||||
|
Object expenseentryentityId = er_dailyReimburseBill.get("expenseentryentity.id");//报销单分录id
|
||||||
|
DynamicObjectCollection ecco_procostsplit = QueryServiceHelper.query("ecco_procostsplit", "zcgj_entryentity.zcgj_materialentryid",
|
||||||
|
new QFilter[]{new QFilter("zcgj_entryentity.zcgj_materialentryid", QCP.equals, expenseentryentityId)
|
||||||
|
.and("billno", QCP.not_in, billno)});//项目综合成本核算
|
||||||
|
if (ecco_procostsplit != null && ecco_procostsplit.size() > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DynamicObject newEntry = new DynamicObject(entryType);
|
||||||
|
newEntry.set("zcgj_materialentryid", expenseentryentityId);
|
||||||
|
newEntry.set("zcgj_dailyld", er_dailyReimburseBill.get("id"));//单据ID
|
||||||
|
newEntry.set("zcgj_entrybillno", er_dailyReimburseBill.get("billno"));//单据编码
|
||||||
|
newEntry.set("zcgj_bizdate", er_dailyReimburseBill.get("bizdate"));// 业务日期
|
||||||
|
|
||||||
|
Object applier = er_dailyReimburseBill.get("applier");// 申请人
|
||||||
|
newEntry.set("zcgj_applier", loadSingleData("bos_user", applier));
|
||||||
|
Object costdept = er_dailyReimburseBill.get("costdept");// 费用承担部门
|
||||||
|
newEntry.set("zcgj_costdept", loadSingleData("bos_org", costdept));
|
||||||
|
Object costcompany = er_dailyReimburseBill.get("costcompany");// 费用承担公司
|
||||||
|
newEntry.set("zcgj_costcompany", loadSingleData("bos_org", costcompany));
|
||||||
|
Object std_entrycostcenter = er_dailyReimburseBill.get("expenseentryentity.std_entrycostcenter");// 成本中心
|
||||||
|
newEntry.set("zcgj_entrycostcenter", loadSingleData("bos_costcenter", std_entrycostcenter));
|
||||||
|
Object expenseitem = er_dailyReimburseBill.get("expenseentryentity.expenseitem");// 费用项目
|
||||||
|
newEntry.set("zcgj_expenseitem", loadSingleData("er_expenseitemedit", expenseitem));
|
||||||
|
Object zcgj_accounttype = er_dailyReimburseBill.get("expenseentryentity.zcgj_accounttype");// 科目属性
|
||||||
|
newEntry.set("zcgj_accounttype", loadSingleData("zcgj_accounttype", zcgj_accounttype));
|
||||||
|
|
||||||
|
newEntry.set("zcgj_expenseamount", er_dailyReimburseBill.get("expenseentryentity.expenseamount"));
|
||||||
|
newEntry.set("zcgj_taxrate", er_dailyReimburseBill.get("expenseentryentity.taxrate"));
|
||||||
|
newEntry.set("zcgj_taxamount", er_dailyReimburseBill.get("expenseentryentity.taxamount"));
|
||||||
|
newEntry.set("zcgj_orientryamount", er_dailyReimburseBill.get("expenseentryentity.orientryamount"));
|
||||||
|
newEntry.set("zcgj_remark", er_dailyReimburseBill.get("expenseentryentity.remark"));
|
||||||
|
|
||||||
|
entryCollection.add(newEntry);
|
||||||
|
}
|
||||||
|
this.getView().updateView("zcgj_entryentity");//刷新分录
|
||||||
|
} else {
|
||||||
|
this.getView().showTipNotification("请先填写所属组织");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) {
|
||||||
|
String fieldName = hyperLinkClickEvent.getFieldName();
|
||||||
|
if (StringUtils.equals(fieldName, "zcgj_entrybillno")) {
|
||||||
|
//费用明细分录-单据编码
|
||||||
|
int rowIndex = hyperLinkClickEvent.getRowIndex();
|
||||||
|
DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_entryentity");//费用明细分录
|
||||||
|
DynamicObject entryEntity = entryEntityCollection.get(rowIndex);
|
||||||
|
BillShowParameter billShowParameter = OpenPageUtils.buildBillShowParam(entryEntity.get("zcgj_dailyld"), "er_dailyreimbursebill");//费用报销单
|
||||||
|
this.getView().showForm(billShowParameter);//打开费用报销单
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DynamicObject loadSingleData(String entityName, Object id) {
|
||||||
|
if (id == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
QFilter[] qFilters = new QFilter[]{new QFilter("id", QCP.equals, id)};
|
||||||
|
return BusinessDataServiceHelper.loadSingle(entityName, "id", qFilters);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue