Browse Source

数据中心首页统计排序

lxz 1 year ago
parent
commit
17f36c5957

+ 31 - 0
src/main/java/com/sooka/sponest/data/index/service/impl/IndexViewServiceImpl.java

@@ -143,9 +143,40 @@ public class IndexViewServiceImpl extends BaseServiceImpl implements IndexViewSe
         indexViewInfo.setCount(totalCount);
         basicList.add(indexViewInfo);
 
+// 使用自定义的 Comparator 对 basicList 进行排序
+        basicList.sort(customComparator);
         return basicList;
     }
 
+    //排序
+    Comparator<IndexViewInfo> customComparator = (info1, info2) -> {
+        // 按照顺序进行比较
+        List<String> order = Arrays.asList(
+                "林业基础数据",
+                "农业基础数据",
+                "水利基础数据",
+                "环保基础数据",
+                "应急基础数据",
+                "交通基础数据",
+                "自然资源基础数据",
+                "消防基础数据",
+                "共有基础数据类型"
+        );
+
+        int index1 = order.indexOf(info1.getCategory());
+        int index2 = order.indexOf(info2.getCategory());
+
+        if (index1 < index2) {
+            return -1;
+        } else if (index1 > index2) {
+            return 1;
+        } else {
+            // 如果类别相同,按照数据数量降序排列
+            return info2.getCount().compareTo(info1.getCount());
+        }
+    };
+
+
     /**
      * 获取一网通办数据
      *