| | |
| | | protected List<Object> buildErrorInfo(String nodePath) { |
| | | var suffix = nodePath + "/"; |
| | | var errors = new ArrayList<>(); |
| | | // 按 problem.id 去重,相同问题只保留第一个记录 |
| | | var nodeRecords = records.stream() |
| | | .filter(record -> record.getProblem() != null && |
| | | record.getProblem().getHierarchyPath() != null && |
| | | record.getProblem().getHierarchyPath().startsWith(suffix)) |
| | | .collect(java.util.stream.Collectors.toMap( |
| | | record -> record.getProblem().getId(), |
| | | record -> record, |
| | | (existing, replacement) -> existing // 保留第一个遇到的记录 |
| | | )) |
| | | .values() |
| | | .stream() |
| | | // 按照record.errorLevel排序 |
| | | .sorted(Comparator.comparing(ErrorRecord::getLevel, Comparator.nullsLast(Comparator.naturalOrder()))) |
| | | .toList(); |