企业成本核算优化
This commit is contained in:
parent
3c6d06f4af
commit
e128b0c883
|
|
@ -13,9 +13,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 企业成本核算表单插件
|
||||
|
|
@ -180,9 +178,31 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
}
|
||||
}
|
||||
|
||||
// 清空原集合并添加汇总后的数据
|
||||
// 在添加数据前进行排序
|
||||
entryCollection.clear();
|
||||
for (DynamicObject entry : summaryMap.values()) {
|
||||
// 将summaryMap转换为List并按成本项数值排序
|
||||
List<DynamicObject> sortedEntries = new ArrayList<>(summaryMap.values());
|
||||
sortedEntries.sort((entry1, entry2) -> {
|
||||
Object costType1 = entry1.get("costtype");
|
||||
Object costType2 = entry2.get("costtype");
|
||||
|
||||
// 处理null值情况 - 将null值放在最后
|
||||
if (costType1 == null && costType2 == null) return 0;
|
||||
if (costType1 == null) return 1; // null值排在后面
|
||||
if (costType2 == null) return -1; // null值排在后面
|
||||
|
||||
// 提取数值部分进行比较
|
||||
String value1 = costType1.toString().replaceAll("[^0-9]", "");
|
||||
String value2 = costType2.toString().replaceAll("[^0-9]", "");
|
||||
|
||||
int num1 = value1.isEmpty() ? 0 : Integer.parseInt(value1);
|
||||
int num2 = value2.isEmpty() ? 0 : Integer.parseInt(value2);
|
||||
|
||||
return Integer.compare(num1, num2);
|
||||
});
|
||||
|
||||
// 按排序后的顺序添加数据
|
||||
for (DynamicObject entry : sortedEntries) {
|
||||
entryCollection.add(entry);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue