|
|
@@ -103,6 +103,7 @@ import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.rmi.ServerException;
|
|
|
+import java.text.Collator;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.Function;
|
|
|
@@ -5478,6 +5479,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
// 排序方法:先按pId排序,pId相同则按sort排序(null值排在最后)
|
|
|
// 排序方法:按照层级顺序排序(分部 -> 子分部 -> 分项 -> 子分项)
|
|
|
+ //sort相同按名称首字母排序
|
|
|
private List<WbsTreeContract> sortLeafNodes(List<WbsTreeContract> nodes, List<WbsTreeContract> projects) {
|
|
|
return nodes.stream()
|
|
|
.sorted((node1, node2) -> {
|
|
|
@@ -5505,7 +5507,11 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
if (result != 0) return result;
|
|
|
|
|
|
// 5. 如果所有层级sort都相同,按当前节点sort排序
|
|
|
- return compareSortValue(node1.getSort(), node2.getSort());
|
|
|
+ result = compareSortValue(node1.getSort(), node2.getSort());
|
|
|
+ if (result != 0) return result;
|
|
|
+
|
|
|
+ // 6. 如果sort也相同,按照名称首字母排序(支持中英文混合)
|
|
|
+ return compareTitle(node1.getNodeName(), node2.getNodeName());
|
|
|
})
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
@@ -5587,6 +5593,27 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return sort1.compareTo(sort2);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 比较标题(名称)首字母(支持中英文混合和大写字母)
|
|
|
+ */
|
|
|
+ private int compareTitle(String title1, String title2) {
|
|
|
+ if (title1 == null && title2 == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (title1 == null) {
|
|
|
+ return 1; // null值排在后面
|
|
|
+ }
|
|
|
+ if (title2 == null) {
|
|
|
+ return -1; // null值排在后面
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用Collator进行中英文混合排序,设置强度为PRIMARY忽略大小写差异
|
|
|
+ Collator collator = Collator.getInstance(Locale.CHINA);
|
|
|
+ collator.setStrength(Collator.PRIMARY); // 忽略大小写、重音等差异
|
|
|
+
|
|
|
+ return collator.compare(title1, title2);
|
|
|
+ }
|
|
|
+
|
|
|
// 根据叶子节点类型填充工程数据
|
|
|
private void fillEngineeringDataByLeafType(Row row, List<WbsTreeContract> projects, List<Long> ancestorIds,
|
|
|
Map<Integer, List<CellRangeAddress>> mergeMap, int rowNum,
|