Procházet zdrojové kódy

feat: 添加查询所有指标接口

weijianghai před 2 roky
rodič
revize
1d5ebc926c

+ 10 - 1
src/main/java/com/nokia/hb/controller/IndicatorController.java

@@ -22,9 +22,18 @@ public class IndicatorController {
     /**
      * 查询指标树形结构
      */
-    @Operation(summary = "查询指标树形结构")
+    @Operation(summary = "查询指标树形结构(添加修改指标模板)")
     @PostMapping("/api/initTreeIndicator")
     public R<List<TreeNode>> initTreeIndicator() {
         return indicatorService.initTreeIndicator();
     }
+
+    /**
+     * 查询指标树形结构
+     */
+    @Operation(summary = "查询指标树形结构(所有指标)")
+    @PostMapping("/api/allIndicator")
+    public R<List<TreeNode>> allIndicator() {
+        return indicatorService.allIndicator();
+    }
 }

+ 18 - 0
src/main/java/com/nokia/hb/service/IndicatorService.java

@@ -39,4 +39,22 @@ public class IndicatorService {
         m.forEach((k, v) -> allTree.getChildren().add(new TreeNode(k, k, v)));
         return R.ok(res);
     }
+
+    public R<List<TreeNode>> allIndicator() {
+        List<PerCfgIndicator> indicators = perCfgIndicatorMapper.all();
+        Map<String, List<TreeNode>> m = new HashMap<>();
+        TreeNode allTree = new TreeNode("所有指标", "所有指标", new ArrayList<>());
+        List<TreeNode> res = new ArrayList<>();
+        res.add(allTree);
+        indicators.forEach(i -> {
+            String indicatorType = i.getIndicatorType();
+            String indicatorCn = i.getIndicatorCn();
+            String indicatorId = i.getIndicatorEn();
+            TreeNode t = new TreeNode(indicatorCn, indicatorId, null);
+            m.putIfAbsent(indicatorType, new ArrayList<>());
+            m.get(indicatorType).add(t);
+        });
+        m.forEach((k, v) -> allTree.getChildren().add(new TreeNode(k, k, v)));
+        return R.ok(res);
+    }
 }