Browse Source

修改灵敏感知-问题线索3

main
sjh 1 year ago
parent
commit
e43d55c17e
  1. 99
      src/main/java/com/biutag/supervision/service/RiskScoreRuleService.java

99
src/main/java/com/biutag/supervision/service/RiskScoreRuleService.java

@ -17,6 +17,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@RequiredArgsConstructor
@Service
@ -31,33 +33,78 @@ public class RiskScoreRuleService extends ServiceImpl<RiskScoreRuleMapper, RiskS
List<RiskClassModel> riskClasses = riskScoreRuleMapper.selectListAll();
List<RiskClassModel> treeList = riskClasses.stream().filter(item -> item.getPid() != 0).toList();
List<Model> models = modelService.list();
List<RiskTree> list = new ArrayList<>();
list.addAll(rootsList.stream().map(item -> {
RiskTree node = new RiskTree();
node.setId(item.getId());
node.setRiskName(item.getName());
node.setSize(item.getSize());
node.setType("modelClass");
List<RiskTree> children = models.stream().filter(
model -> {
for (RiskClassModel riskClassModel : treeList) {
boolean b = item.getId().equals(riskClassModel.getPid()) && riskClassModel.getId().equals(model.getRiskScoreRuleId());
System.out.println("测试1当前item:【id:" + item.getId() + ",pid:" + item.getPid()
+ "】,当前model:【id:" + model.getId() + ",risk_id:" + model.getRiskScoreRuleId()
+ "】,当前riskClassModel:【id:" + riskClassModel.getId() + ",pid:" + riskClassModel.getPid()
+ ",name:" + riskClassModel.getName() + ",size:" + riskClassModel.getSize());
return b;
}
System.out.println("测试2当前item:【id:" + item.getId() + ",pid:" + item.getPid()
+ "】,当前model:【id:" + model.getId() + ",risk_id:" + model.getRiskScoreRuleId()
+ "】");
return false;
// id, root item根目录
Map<Integer, RiskClassModel> map = rootsList.stream().collect(Collectors.toMap(RiskClassModel::getId, Function.identity(), (newVal, oldVal) -> newVal));
// pid, treeList 子目录
Map<Integer, List<RiskClassModel>> treeMap = treeList.stream().collect(Collectors.groupingBy(RiskClassModel::getPid));
// Map<Integer, List<Model>> modelMap = models.stream().collect(Collectors.groupingBy(Model::getRiskScoreRuleId));
// pid,子目录
Map<Integer, List<RiskTree>> rootChildren = new HashMap<>();
for (Map.Entry<Integer, List<RiskClassModel>> entry : treeMap.entrySet()) {
List<RiskClassModel> trees = entry.getValue();
List<RiskTree> children = new ArrayList<>();
for (RiskClassModel tree : trees) {
for (Model model : models) {
if (tree.getId().equals(model.getRiskScoreRuleId())) {
RiskTree node = new RiskTree();
node.setId(model.getId());
node.setRiskName(model.getModelName());
// node.setSize(tree.getSize());
node.setType("modelClass");
children.add(node);
}
).map(RiskTree::of).toList();
node.setChildren(children);
return node;
}).toList());
return list;
}
}
rootChildren.put(entry.getKey(), children);
}
List<RiskTree> result = new ArrayList<>();
for (Map.Entry<Integer, RiskClassModel> map1 : map.entrySet()) {
Integer key = map1.getKey();
RiskClassModel value = map1.getValue();
if (rootChildren.containsKey(key)) {
RiskTree node = new RiskTree();
node.setId(value.getId());
node.setRiskName(value.getName());
node.setSize(value.getSize());
node.setType("modelClass");
node.setChildren(rootChildren.get(key));
result.add(node);
}
}
return result;
// List<RiskTree> list = new ArrayList<>();
// list.addAll(rootsList.stream().map(item -> {
// RiskTree node = new RiskTree();
// node.setId(item.getId());
// node.setRiskName(item.getName());
// node.setSize(item.getSize());
// node.setType("modelClass");
// List<RiskTree> children = models.stream().filter(
// model -> {
// for (RiskClassModel riskClassModel : treeList) {
// boolean b = item.getId().equals(riskClassModel.getPid()) && riskClassModel.getId().equals(model.getRiskScoreRuleId());
// System.out.println("测试1当前item:【id:" + item.getId() + ",pid:" + item.getPid()
// + "】,当前model:【id:" + model.getId() + ",risk_id:" + model.getRiskScoreRuleId()
// + "】,当前riskClassModel:【id:" + riskClassModel.getId() + ",pid:" + riskClassModel.getPid()
// + ",name:" + riskClassModel.getName() + ",size:" + riskClassModel.getSize());
// return b;
// }
// System.out.println("测试2当前item:【id:" + item.getId() + ",pid:" + item.getPid()
// + "】,当前model:【id:" + model.getId() + ",risk_id:" + model.getRiskScoreRuleId()
// + "】");
// return false;
// }
// ).map(RiskTree::of).toList();
// node.setChildren(children);
// return node;
// }).toList());
// return list;
}
public List<RiskScoreRuleTree> oldBuildTree() {

Loading…
Cancel
Save