企业成本核算表单优化
This commit is contained in:
parent
adb793af06
commit
a8d526bea8
|
|
@ -5,6 +5,8 @@ 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.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.orm.query.QCP;
|
||||
|
|
@ -18,6 +20,8 @@ import java.util.*;
|
|||
/**
|
||||
* 企业成本核算表单插件
|
||||
* 说明:1:点击自动取数按钮获取核算余额表
|
||||
* 2:子分录成本分解结构跟随父分录成本分解结构赋值
|
||||
* 工序即为成本分解结构
|
||||
*/
|
||||
public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
||||
@Override
|
||||
|
|
@ -25,6 +29,24 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
super.registerListener(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
super.propertyChanged(e);
|
||||
String key = e.getProperty().getName();
|
||||
if ("cbs".equals(key)) {
|
||||
//企业费用成本分摊明细分录-成本分解结构
|
||||
//子分录跟随父分录字段赋值逻辑
|
||||
ChangeData changeData = e.getChangeSet()[0];
|
||||
DynamicObject dataEntity = changeData.getDataEntity();
|
||||
DynamicObject cbs = (DynamicObject) changeData.getNewValue();//成本分解结构新值
|
||||
DynamicObjectCollection subEntryEntityCollection = dataEntity.getDynamicObjectCollection("zcgj_subentryentity");//成本核算维度明细
|
||||
for (DynamicObject subEntryEntity : subEntryEntityCollection) {
|
||||
subEntryEntity.set("zcgj_cbs", cbs);//成本核算维度明细-成本分解结构
|
||||
}
|
||||
this.getView().updateView("zcgj_subentryentity");//刷新成本核算维度明细
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate formOperate = (FormOperate) args.getSource();
|
||||
|
|
@ -105,10 +127,8 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
Object costType = zcgj_accountcost != null ? zcgj_accountcost.get("zcgj_acccostentry.zcgj_costtype") : null; // 成本项
|
||||
Object secType = zcgj_accountcost != null ? zcgj_accountcost.get("zcgj_acccostentry.zcgj_sectype") : null; // 二级分类
|
||||
|
||||
/* // 替换原有的单一条件检查代码,使用以下代码块:
|
||||
String secTypeName = "";
|
||||
String costTypeName = "";
|
||||
|
||||
if (secType != null) {
|
||||
if (secType instanceof DynamicObject) {
|
||||
DynamicObject secTypeObj = (DynamicObject) secType;
|
||||
|
|
@ -117,7 +137,6 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
secTypeName = secType.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (costType != null) {
|
||||
if (costType instanceof DynamicObject) {
|
||||
DynamicObject costTypeObj = (DynamicObject) costType;
|
||||
|
|
@ -127,19 +146,45 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
}
|
||||
}
|
||||
|
||||
// 如果二级分类为"70.55"且成本项为"70",则跳过该条记录
|
||||
// 如果二级分类为"70.55"且成本项为"70",则对该行的成本金额进行扣减
|
||||
if ("70.55".equals(secTypeName) && "70.".equals(costTypeName)) {
|
||||
QFilter filter5 = new QFilter("billstatus", QCP.equals, "C");//单据状态
|
||||
filter5.and(new QFilter("zcgj_entryentity.zcgj_assperiod", QCP.equals, period1.getPkValue()));//折旧期间
|
||||
filter5.and(new QFilter("zcgj_entryentity.zcgj_headusedept", QCP.equals, org1.getPkValue()));//使用部门
|
||||
DynamicObject eceq_equipinfo = QueryServiceHelper.queryOne("eceq_equipinfo",
|
||||
"id,zcgj_entryentity.zcgj_shareamount",
|
||||
new QFilter[]{filter5});//"设备详情"
|
||||
if (eceq_equipinfo != null) {
|
||||
BigDecimal zcgj_shareamount = eceq_equipinfo.getBigDecimal("zcgj_entryentity.zcgj_shareamount");//设备详情的成本金额
|
||||
|
||||
// 扣减成本金额
|
||||
Object currentAmount = rptAssistBalanceGx.get("zcgj_debitlocal");
|
||||
BigDecimal newAmount = new BigDecimal(currentAmount != null ? currentAmount.toString() : "0")
|
||||
.subtract(zcgj_shareamount != null ? zcgj_shareamount : BigDecimal.ZERO);
|
||||
|
||||
// 确保不会出现负数
|
||||
if (newAmount.compareTo(BigDecimal.ZERO) < 0) {
|
||||
newAmount = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 更新rptAssistBalanceGx中的金额
|
||||
rptAssistBalanceGx.set("zcgj_debitlocal", newAmount);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果成本项为null,则跳过该行
|
||||
if (costType == null) {
|
||||
continue;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
String uniqueKey = "";
|
||||
if (processName != null && !processName.isEmpty()) {
|
||||
// 存在工序时,按照工序+成本项+二级分类去重
|
||||
uniqueKey = "PROCESS_" + processName + "_" + (costType != null ? costType.toString() : "") + "_" + (secType != null ? secType.toString() : "");
|
||||
uniqueKey = "PROCESS_" + processName + "_" + costType.toString() + "_" + (secType != null ? secType.toString() : "");
|
||||
} else {
|
||||
// 如果没有工序,则按照成本项+二级分类去重
|
||||
uniqueKey = "NONE_" + (costType != null ? costType.toString() : "") + "_" + (secType != null ? secType.toString() : "");
|
||||
uniqueKey = "NONE_" + costType.toString() + "_" + (secType != null ? secType.toString() : "");
|
||||
}
|
||||
|
||||
DynamicObject existingEntry = summaryMap.get(uniqueKey);
|
||||
|
|
@ -214,10 +259,10 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
Object costType1 = entry1.get("costtype");
|
||||
Object costType2 = entry2.get("costtype");
|
||||
|
||||
// 处理null值情况 - 将null值放在最后
|
||||
// 处理null值情况 - 将null值放在前面
|
||||
if (costType1 == null && costType2 == null) return 0;
|
||||
if (costType1 == null) return 1; // null值排在后面
|
||||
if (costType2 == null) return -1; // null值排在后面
|
||||
if (costType1 == null) return -1; // null值排在前面
|
||||
if (costType2 == null) return 1; // null值排在前面
|
||||
|
||||
// 提取数值部分进行比较
|
||||
String value1 = costType1.toString().replaceAll("[^0-9]", "");
|
||||
|
|
|
|||
Loading…
Reference in New Issue