企业成本核算添加子分录成本分解结构过滤逻辑
This commit is contained in:
parent
5bfdca9099
commit
549aa0dda2
|
|
@ -5,10 +5,15 @@ import kd.bos.dataentity.entity.DynamicObject;
|
|||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.field.BasedataEdit;
|
||||
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.list.ListShowParameter;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
|
@ -21,12 +26,15 @@ import java.util.*;
|
|||
* 企业成本核算表单插件
|
||||
* 说明:1:点击自动取数按钮获取核算余额表
|
||||
* 2:子分录成本分解结构跟随父分录成本分解结构赋值
|
||||
* 3:子分录成本分解结构过滤逻辑
|
||||
* 工序即为成本分解结构
|
||||
*/
|
||||
public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
||||
public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
BasedataEdit cbs = (BasedataEdit) this.getControl("zcgj_cbs");
|
||||
cbs.addBeforeF7SelectListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -47,6 +55,28 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
}
|
||||
}
|
||||
|
||||
public void beforeF7Select(BeforeF7SelectEvent arg0) {
|
||||
String name = arg0.getProperty().getName();
|
||||
if (StringUtils.equals(name, "zcgj_cbs")) {
|
||||
//成本核算维度明细-成本分解结构
|
||||
int row = arg0.getRow();
|
||||
ListShowParameter parameter = (ListShowParameter) arg0.getFormShowParameter();
|
||||
arg0.setCancel(true);
|
||||
DynamicObject project = (DynamicObject) this.getModel().getValue("zcgj_project", row);//成本核算维度明细-成本分解结构
|
||||
if (project == null) {
|
||||
this.getView().showMessage(ResManager.loadKDString("请先选择工程项目。", "EntCostSplitEditPlugin_0", "ec-ecco-formplugin", new Object[0]));
|
||||
arg0.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
QFilter qFilter = new QFilter("project", "=", project.getPkValue());
|
||||
qFilter = qFilter.and(new QFilter("isleaf", "=", true));
|
||||
parameter.getListFilterParameter().setFilter(qFilter);
|
||||
parameter.setFormId("bos_listf7");
|
||||
this.getView().showForm(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate formOperate = (FormOperate) args.getSource();
|
||||
|
|
@ -172,19 +202,13 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
}
|
||||
}
|
||||
|
||||
// 如果成本项为null,则跳过该行
|
||||
if (costType == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
String uniqueKey = "";
|
||||
if (processName != null && !processName.isEmpty()) {
|
||||
// 存在工序时,按照工序+成本项+二级分类去重
|
||||
uniqueKey = "PROCESS_" + processName + "_" + costType.toString() + "_" + (secType != null ? secType.toString() : "");
|
||||
uniqueKey = "PROCESS_" + processName + "_" + (costType != null ? costType.toString() : "") + "_" + (secType != null ? secType.toString() : "");
|
||||
} else {
|
||||
// 如果没有工序,则按照成本项+二级分类去重
|
||||
uniqueKey = "NONE_" + costType.toString() + "_" + (secType != null ? secType.toString() : "");
|
||||
uniqueKey = "NONE_" + (costType != null ? costType.toString() : "") + "_" + (secType != null ? secType.toString() : "");
|
||||
}
|
||||
|
||||
DynamicObject existingEntry = summaryMap.get(uniqueKey);
|
||||
|
|
@ -270,14 +294,18 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
Integer sortValue2 = COST_TYPE_SORT_MAP.get(str2);
|
||||
|
||||
if (sortValue1 == null && sortValue2 == null) return 0;
|
||||
if (sortValue1 == null) return 1;
|
||||
if (sortValue2 == null) return -1;
|
||||
if (sortValue1 == null) return -1;
|
||||
if (sortValue2 == null) return 1;
|
||||
|
||||
return sortValue1.compareTo(sortValue2);
|
||||
});
|
||||
|
||||
// 按排序后的顺序添加数据
|
||||
// 按排序后的顺序添加数据,且跳过成本项为空的分录行
|
||||
for (DynamicObject entry : sortedEntries) {
|
||||
Object costtype = entry.get("costtype");
|
||||
if (costtype == null) {
|
||||
continue;
|
||||
}
|
||||
entryCollection.add(entry);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue