Browse Source

客户端元素PL表排序

liuyc 2 years ago
parent
commit
1b27c7c68f

+ 37 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -413,11 +413,10 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
 
 
     @Override
     @Override
     public List<AppWbsTreeContractVO> searchNodeAllTable(String primaryKeyId, String tableOwner, String contractId, String projectId) {
     public List<AppWbsTreeContractVO> searchNodeAllTable(String primaryKeyId, String tableOwner, String contractId, String projectId) {
-
-        //由于fegin 调用时,获取不到UserId
-        Long userId = -1L;
-        if (primaryKeyId.indexOf(":") >= 0) {
-            String ds[] = primaryKeyId.split(":");
+        //由于Feign调用时,获取不到UserId
+        Long userId;
+        if (primaryKeyId.contains(":")) {
+            String[] ds = primaryKeyId.split(":");
             primaryKeyId = ds[0];
             primaryKeyId = ds[0];
             userId = Long.parseLong(ds[1]);
             userId = Long.parseLong(ds[1]);
             if (userId == -1L) {
             if (userId == -1L) {
@@ -460,10 +459,41 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
             }
             }
             tableOwnerList = Func.toStrList(tableOwners);
             tableOwnerList = Func.toStrList(tableOwners);
         }
         }
-        return baseMapper.selectWbsTreeContractList(tableOwnerNumbers, wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(),
-                wbsTreeContract.getContractId(), wbsTreeContract.getId(), wbsTreeContract.getContractIdRelation(), tableOwnerList);
+        List<AppWbsTreeContractVO> resultTabs = baseMapper.selectWbsTreeContractList(tableOwnerNumbers, wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(), wbsTreeContract.getContractId(), wbsTreeContract.getId(), wbsTreeContract.getContractIdRelation(), tableOwnerList);
+        return this.sortTabs(resultTabs);
     }
     }
 
 
+    private List<AppWbsTreeContractVO> sortTabs(List<AppWbsTreeContractVO> tabs) {
+        List<AppWbsTreeContractVO> tabsWithPL = new ArrayList<>();
+        List<AppWbsTreeContractVO> tabsWithoutPL = new ArrayList<>();
+        //分离带有_PL_关键字和不带关键字的数据
+        for (AppWbsTreeContractVO tab : tabs) {
+            if (tab.getNodeName().contains("_PL_")) {
+                tabsWithPL.add(tab);
+            } else {
+                tabsWithoutPL.add(tab);
+            }
+        }
+        //如果没有带有_PL_关键字的数据,直接返回原列表
+        if (tabsWithPL.isEmpty()) {
+            return tabsWithoutPL;
+        }
+        //将带有_PL_关键字的数据插入到对应表名后面
+        List<AppWbsTreeContractVO> sortedTabs = new ArrayList<>();
+        for (AppWbsTreeContractVO tabWithoutPL : tabsWithoutPL) {
+            sortedTabs.add(tabWithoutPL);
+            String tabName = tabWithoutPL.getNodeName();
+            String tabNameWithPLPrefix = tabName + "_PL_";
+            for (AppWbsTreeContractVO tabWithPL : tabsWithPL) {
+                if (tabWithPL.getNodeName().startsWith(tabNameWithPLPrefix)) {
+                    sortedTabs.add(tabWithPL);
+                }
+            }
+        }
+        return sortedTabs;
+    }
+
+
     @Override
     @Override
     public List<WbsTreeContract> searchParentAllNode(long primaryKeyId, Long contractId) {
     public List<WbsTreeContract> searchParentAllNode(long primaryKeyId, Long contractId) {
         return baseMapper.searchParentAllNode(primaryKeyId, contractId);
         return baseMapper.searchParentAllNode(primaryKeyId, contractId);