Эх сурвалжийг харах

下载模板添加层级名称

cr 1 өдөр өмнө
parent
commit
064b1acced

+ 10 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -547,6 +547,16 @@ public class WbsTreeContractController extends BladeController {
         // 获取节点及祖先节点信息用于构建文件名
         WbsTreeContract node = wbsTreeContractServiceImpl.getById(nodeId);
         List<WbsTreeContract> ancestorsList = wbsTreeContractServiceImpl.getAncestorsList(node.getAncestorsPId());
+        // 按照指定的nodeType顺序排序: 1, 18, 2, 3, 4, 5, 6
+        ancestorsList.sort((a, b) -> {
+            List<Integer> order = Arrays.asList(1, 18, 2, 3, 4, 5, 6);
+            Integer typeA = a.getNodeType();
+            Integer typeB = b.getNodeType();
+            return Integer.compare(
+                    order.indexOf(typeA != null ? typeA : -1),
+                    order.indexOf(typeB != null ? typeB : -1)
+            );
+        });
         for (WbsTreeContract ancestor : ancestorsList) {
             if (18 == ancestor.getNodeType()) {
                 excelName.append(ancestor.getNodeName());