| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | |
| | | protected FuzzyResult sysResult; |
| | | |
| | | protected ScoreResult scoreResult; |
| | | |
| | | Map<Integer, Long> problemHazardCounts; |
| | | |
| | | long projectCheckCount; |
| | | |
| | | // 评估结果 |
| | | @Override |
| | |
| | | info.put("类别", n.getName()); |
| | | info.put("序号", index.getAndIncrement() + 1); |
| | | buildNode(info, n); |
| | | |
| | | |
| | | // 从fuzzyNode中获取评价 |
| | | var fuzzyNode = getFuzzyNodeByPath(n.getPath()); |
| | | if(fuzzyNode != null && fuzzyNode.getData() != null && fuzzyNode.getData().getRiskLevel() != null) { |
| | |
| | | var errors = new ArrayList<>(); |
| | | // 按 problem.id 去重,相同问题只保留第一个记录 |
| | | var nodeRecords = records.stream() |
| | | .filter(record -> record.getProblem() != null && |
| | | .filter(record -> record.getProblem() != null && |
| | | record.getProblem().getHierarchyPath() != null && |
| | | record.getProblem().getHierarchyPath().startsWith(suffix)) |
| | | .collect(java.util.stream.Collectors.toMap( |
| | |
| | | record -> record, |
| | | (existing, replacement) -> existing // 保留第一个遇到的记录 |
| | | )) |
| | | .values(); |
| | | |
| | | .values() |
| | | .stream() |
| | | // 按照record.errorLevel排序 |
| | | .sorted(Comparator.comparing(ErrorRecord::getLevel, Comparator.nullsLast(Comparator.naturalOrder()))) |
| | | .toList(); |
| | | |
| | | for(var record : nodeRecords){ |
| | | var subItem = buildRecordDetail(record); |
| | | subItem.put("项目级别", errorNodeName(record)); |
| | | subItem.put("同类隐患出现频次", getProblemHazardCount(record)); |
| | | subItem.put("检查频次", getProblemCheckCount(record)); |
| | | errors.add(subItem); |
| | | } |
| | | return errors; |
| | | } |
| | | |
| | | private long getProblemHazardCount(ErrorRecord record) { |
| | | var problemId = record != null && record.getProblem() != null ? record.getProblem().getId() : null; |
| | | if (problemId == null || problemHazardCounts == null) { |
| | | return 0L; |
| | | } |
| | | return problemHazardCounts.getOrDefault(problemId, 0L); |
| | | } |
| | | |
| | | private long getProblemCheckCount(ErrorRecord record) { |
| | | return Math.max(projectCheckCount, 0L); |
| | | } |
| | | |
| | | /** |
| | | * 构建错误节点名称 |
| | | * @param record 记录 |