合同成本核算自动取数逻辑优化
This commit is contained in:
parent
ddf8cb028a
commit
c81122c3ab
|
|
@ -1,6 +1,7 @@
|
||||||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
|
import kd.bos.dataentity.OperateOption;
|
||||||
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.entity.LocaleString;
|
import kd.bos.dataentity.entity.LocaleString;
|
||||||
|
|
@ -11,8 +12,15 @@ import kd.bos.entity.MainEntityType;
|
||||||
import kd.bos.entity.ValueMapItem;
|
import kd.bos.entity.ValueMapItem;
|
||||||
import kd.bos.entity.datamodel.events.ChangeData;
|
import kd.bos.entity.datamodel.events.ChangeData;
|
||||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||||
|
import kd.bos.entity.operate.OperateOptionConst;
|
||||||
|
import kd.bos.entity.operate.result.OperationResult;
|
||||||
import kd.bos.entity.property.ComboProp;
|
import kd.bos.entity.property.ComboProp;
|
||||||
|
import kd.bos.form.ConfirmCallBackListener;
|
||||||
|
import kd.bos.form.MessageBoxOptions;
|
||||||
|
import kd.bos.form.MessageBoxResult;
|
||||||
|
import kd.bos.form.control.events.BeforeItemClickEvent;
|
||||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
|
import kd.bos.form.events.MessageBoxClosedEvent;
|
||||||
import kd.bos.form.field.BasedataEdit;
|
import kd.bos.form.field.BasedataEdit;
|
||||||
import kd.bos.form.field.ComboEdit;
|
import kd.bos.form.field.ComboEdit;
|
||||||
import kd.bos.form.field.ComboItem;
|
import kd.bos.form.field.ComboItem;
|
||||||
|
|
@ -24,6 +32,8 @@ import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.QueryServiceHelper;
|
import kd.bos.servicehelper.QueryServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -35,12 +45,13 @@ import java.util.*;
|
||||||
* 3:子分录成本分解结构过滤逻辑
|
* 3:子分录成本分解结构过滤逻辑
|
||||||
* 工序即为成本分解结构
|
* 工序即为成本分解结构
|
||||||
*/
|
*/
|
||||||
public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
|
public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener, Plugin {
|
||||||
@Override
|
@Override
|
||||||
public void registerListener(EventObject e) {
|
public void registerListener(EventObject e) {
|
||||||
super.registerListener(e);
|
super.registerListener(e);
|
||||||
BasedataEdit cbs = (BasedataEdit) this.getControl("zcgj_cbs");
|
BasedataEdit cbs = (BasedataEdit) this.getControl("zcgj_cbs");
|
||||||
cbs.addBeforeF7SelectListener(this);
|
cbs.addBeforeF7SelectListener(this);
|
||||||
|
this.addItemClickListeners("advcontoolbarap");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -114,10 +125,60 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements Before
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeItemClick(BeforeItemClickEvent evt) {
|
||||||
|
super.beforeItemClick(evt);
|
||||||
|
if (evt.getItemKey().equals("zcgj_autofetch")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
||||||
|
super.confirmCallBack(messageBoxClosedEvent);
|
||||||
|
//判断是否是对应确认框的点击回调事件
|
||||||
|
if (("autogetdata").equals(messageBoxClosedEvent.getCallBackId())) {
|
||||||
|
if (MessageBoxResult.Yes.equals(messageBoxClosedEvent.getResult())) {
|
||||||
|
autoFetchData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||||
super.beforeDoOperation(args);
|
super.beforeDoOperation(args);
|
||||||
FormOperate formOperate = (FormOperate) args.getSource();
|
FormOperate formOperate = (FormOperate) args.getSource();
|
||||||
if ("autogetdata".equals(formOperate.getOperateKey())) {
|
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);
|
||||||
|
}
|
||||||
|
} else if ("autogetdata".equals(formOperate.getOperateKey())) {
|
||||||
|
DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//企业费用成本分摊明细分录
|
||||||
|
if (entryEntityCollection.size() > 0) {
|
||||||
|
args.setCancel(true);
|
||||||
|
ConfirmCallBackListener confirmCallBackListener = new ConfirmCallBackListener("autogetdata", this);
|
||||||
|
//设置页面确认框,参数为:标题,选项框类型,回调监听
|
||||||
|
this.getView().showConfirm("自动取数将清空列表数据,您确认执行吗?", MessageBoxOptions.YesNo, confirmCallBackListener);
|
||||||
|
} else {
|
||||||
|
autoFetchData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动取数处理方法
|
||||||
|
*/
|
||||||
|
private void autoFetchData() {
|
||||||
//自动取数
|
//自动取数
|
||||||
Object org = this.getModel().getValue("org");//所属组织
|
Object org = this.getModel().getValue("org");//所属组织
|
||||||
if (org == null) {
|
if (org == null) {
|
||||||
|
|
@ -330,32 +391,29 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements Before
|
||||||
});
|
});
|
||||||
|
|
||||||
entryCollection.clear();
|
entryCollection.clear();
|
||||||
|
StringBuilder costTypeBuilder = new StringBuilder();
|
||||||
|
for (int i = 0; i < sortedEntries.size(); i++) {
|
||||||
|
DynamicObject dynamicObject = sortedEntries.get(i);
|
||||||
|
String costtype = dynamicObject.getString("costtype");
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
costTypeBuilder.append("+");
|
||||||
|
}
|
||||||
|
costTypeBuilder.append(costtype);
|
||||||
|
}
|
||||||
|
String mergedCostTypes = costTypeBuilder.toString();
|
||||||
|
this.getModel().setValue("description", mergedCostTypes);
|
||||||
// 按排序后的顺序添加数据
|
// 按排序后的顺序添加数据
|
||||||
entryCollection.addAll(sortedEntries);
|
entryCollection.addAll(sortedEntries);
|
||||||
|
|
||||||
this.getView().updateView("entryentity");//刷新分录
|
|
||||||
this.getView().updateView("zcgj_subentryentity");//刷新分录
|
|
||||||
this.getModel().endInit();
|
this.getModel().endInit();
|
||||||
this.getView().invokeOperation("save");//保存用于刷新
|
OperateOption option = OperateOption.create();
|
||||||
|
option.setVariableValue(OperateOptionConst.ISSHOWMESSAGE, "false");
|
||||||
|
OperationServiceHelper.executeOperate("save", this.getView().getEntityId(),
|
||||||
|
new DynamicObject[]{this.getModel().getDataEntity()}, option);
|
||||||
|
this.getView().showSuccessNotification("已完成取数");
|
||||||
this.getView().invokeOperation("refresh");//刷新全局页面
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static Integer getSortValue(String type) {
|
private static Integer getSortValue(String type) {
|
||||||
if ("10.".equals(type)) return 10;
|
if ("10.".equals(type)) return 10;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue