Browse Source

资料填报查看表单排序bug

liuyc 1 year ago
parent
commit
ccb7eb823d

+ 16 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -487,8 +487,10 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         if (tabsWithKeyword.isEmpty()) {
             return tabsWithoutKeyword;
         }
-        //对带有关键字的数据按照特定顺序排序
-        tabsWithKeyword.sort(Comparator.comparing(AppWbsTreeContractVO::getNodeName));
+
+        //将带有关键字的数据按照数字大小进行排序
+        tabsWithKeyword.sort(Comparator.comparingInt(this::getNumberFromNodeName));
+
         //将带有关键字的数据插入到对应表名后面
         List<AppWbsTreeContractVO> sortedTabs = new ArrayList<>();
         for (AppWbsTreeContractVO tabWithoutKeyword : tabsWithoutKeyword) {
@@ -504,6 +506,15 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         return sortedTabs;
     }
 
+    private int getNumberFromNodeName(AppWbsTreeContractVO tab) {
+        String nodeName = tab.getNodeName();
+        String[] parts = nodeName.split("_");
+        if (parts.length > 1) {
+            return Integer.parseInt(parts[parts.length - 1]); //取最后一个部分作为数字
+        }
+        return Integer.MAX_VALUE;
+    }
+
     @Override
     public List<WbsTreeContract> searchParentAllNode(long primaryKeyId, Long contractId) {
         return baseMapper.searchParentAllNode(primaryKeyId, contractId);
@@ -594,10 +605,10 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 wbsTreeContract.setCreateTime(new Date());
                 wbsTreeContract.setTabGroupId(tabGroupId);
                 wbsTreeContract.setSort(wbsInfo.getSort());
-                String nodeName="";
-                if(wbsTreeContractList2.size()>=1){
+                String nodeName = "";
+                if (wbsTreeContractList2.size() >= 1) {
                     nodeName = wbsTreeContractList2.get(wbsTreeContractList2.size() - 1).getNodeName();
-                }else{
+                } else {
                     nodeName = wbsTreeContract.getNodeName();
                 }