Quellcode durchsuchen

档案-目录同步
1、根据质检那边节点顺序进行同步

LHB vor 2 Tagen
Ursprung
Commit
6ea41e66d3

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml

@@ -68,6 +68,7 @@
     <resultMap id="treeNodeResultMap6" type="org.springblade.manager.vo.WbsTreeContractVO6">
         <id column="id" property="id"/>
         <result column="parentId" property="parentId"/>
+        <result column="p_id" property="pId"/>
         <result column="primaryKeyId" property="pKeyId"/>
         <result column="title" property="title"/>
         <result column="value" property="value"/>
@@ -464,6 +465,7 @@
         SELECT
         d.p_key_id AS "primaryKeyId",
         d.id,
+        d.p_id,
         d.parent_id AS "parentId",
         IFNULL(if(length(trim(full_name)) > 0, full_name, node_name),node_name) AS title,
         d.node_name AS "nodeName",

+ 25 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArTreeContractInitServiceImpl.java

@@ -11,6 +11,7 @@ import org.springblade.manager.feign.ProjectClient;
 import org.springblade.manager.mapper.ArchiveTreeContractMapper;
 import org.springblade.manager.service.IContractInfoService;
 import org.springblade.manager.service.IProjectInfoService;
+import org.springblade.manager.utils.ComplexStringComparator;
 import org.springblade.manager.utils.ForestNodeMerger;
 import org.springblade.common.utils.ForestNodeMergerEx;
 import org.springblade.manager.vo.*;
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 @Service
 @AllArgsConstructor
@@ -413,7 +415,29 @@ public class ArTreeContractInitServiceImpl {
         }
 
         Long rootId = 0L;
-        for (WbsTreeContractVO6 wbsTreeVO2 : wbsTreeContractVO6s) {
+
+        //合同段添加排序
+        //现根据父节点分组
+        ArrayList<WbsTreeContractVO6> wbsTreeContractVO6s2 = new ArrayList<>();
+
+        Map<Long, List<WbsTreeContractVO6>> collect = wbsTreeContractVO6s.stream().collect(Collectors.groupingBy(WbsTreeContractVO6::getPId));
+        for (Long l : collect.keySet()) {
+            List<WbsTreeContractVO6> wbsTreeContractVO6s1 = collect.get(l);
+            // 修改比较器链,处理空值情况
+            Comparator<WbsTreeContractVO6> safeComparator = Comparator
+                    .comparing(WbsTreeContractVO6::getSort, Comparator.nullsFirst(Comparator.naturalOrder()))
+                    .thenComparing(new ComplexStringComparator<>(obj ->
+                            obj.getTitle() != null ? obj.getTitle() : ""))
+                    .thenComparing(
+                            WbsTreeContractVO6::getPKeyId,
+                            Comparator.nullsLast(Comparator.reverseOrder()));
+            wbsTreeContractVO6s1.sort(safeComparator);
+            IntStream.range(0, wbsTreeContractVO6s1.size())
+                    .forEach(i -> wbsTreeContractVO6s1.get(i).setSort(i + 1));
+            wbsTreeContractVO6s2.addAll(wbsTreeContractVO6s1);
+        }
+
+        for (WbsTreeContractVO6 wbsTreeVO2 : wbsTreeContractVO6s2) {
             //不要中间交工,质量评定和开工报告作为目录节点
             //wbsMap.put(wbsTreeVO2.getId(),wbsTreeVO2);