|
@@ -22,39 +22,38 @@ public class IndicatorService {
|
|
}
|
|
}
|
|
|
|
|
|
public R<List<TreeNode>> initTreeIndicator() {
|
|
public R<List<TreeNode>> initTreeIndicator() {
|
|
- List<PerCfgIndicator> indicators = perCfgIndicatorMapper.all();
|
|
|
|
- Map<String, List<TreeNode>> m = new HashMap<>();
|
|
|
|
TreeNode allTree = new TreeNode("指标选择", "指标选择", new ArrayList<>());
|
|
TreeNode allTree = new TreeNode("指标选择", "指标选择", new ArrayList<>());
|
|
allTree.setSpread(true);
|
|
allTree.setSpread(true);
|
|
- List<TreeNode> res = new ArrayList<>();
|
|
|
|
- res.add(allTree);
|
|
|
|
- indicators.forEach(i -> {
|
|
|
|
- String indicatorType = i.getIndicatorType();
|
|
|
|
- String indicatorCn = i.getIndicatorCn();
|
|
|
|
- String indicatorId = String.valueOf(i.getIndicatorId());
|
|
|
|
- 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)));
|
|
|
|
|
|
+ List<TreeNode> res = getTreeNodes(allTree);
|
|
return R.ok(res);
|
|
return R.ok(res);
|
|
}
|
|
}
|
|
|
|
|
|
public R<List<TreeNode>> allIndicator() {
|
|
public R<List<TreeNode>> allIndicator() {
|
|
|
|
+ TreeNode allTree = new TreeNode("所有指标", "所有指标", new ArrayList<>());
|
|
|
|
+ List<TreeNode> res = getTreeNodes(allTree);
|
|
|
|
+ return R.ok(res);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生成指标树节点
|
|
|
|
+ *
|
|
|
|
+ * @param allTree 所有树
|
|
|
|
+ * @return {@link List}<{@link TreeNode}>
|
|
|
|
+ */
|
|
|
|
+ private List<TreeNode> getTreeNodes(TreeNode allTree) {
|
|
List<PerCfgIndicator> indicators = perCfgIndicatorMapper.all();
|
|
List<PerCfgIndicator> indicators = perCfgIndicatorMapper.all();
|
|
Map<String, List<TreeNode>> m = new HashMap<>();
|
|
Map<String, List<TreeNode>> m = new HashMap<>();
|
|
- TreeNode allTree = new TreeNode("所有指标", "所有指标", new ArrayList<>());
|
|
|
|
List<TreeNode> res = new ArrayList<>();
|
|
List<TreeNode> res = new ArrayList<>();
|
|
res.add(allTree);
|
|
res.add(allTree);
|
|
indicators.forEach(i -> {
|
|
indicators.forEach(i -> {
|
|
String indicatorType = i.getIndicatorType();
|
|
String indicatorType = i.getIndicatorType();
|
|
String indicatorCn = i.getIndicatorCn();
|
|
String indicatorCn = i.getIndicatorCn();
|
|
- String indicatorId = i.getIndicatorEn();
|
|
|
|
|
|
+ String indicatorId = String.valueOf(i.getIndicatorId());
|
|
TreeNode t = new TreeNode(indicatorCn, indicatorId, null);
|
|
TreeNode t = new TreeNode(indicatorCn, indicatorId, null);
|
|
m.putIfAbsent(indicatorType, new ArrayList<>());
|
|
m.putIfAbsent(indicatorType, new ArrayList<>());
|
|
m.get(indicatorType).add(t);
|
|
m.get(indicatorType).add(t);
|
|
});
|
|
});
|
|
m.forEach((k, v) -> allTree.getChildren().add(new TreeNode(k, k, v)));
|
|
m.forEach((k, v) -> allTree.getChildren().add(new TreeNode(k, k, v)));
|
|
- return R.ok(res);
|
|
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
}
|
|
}
|