liujie
2026-05-21 34fb8efd9fef8a6ed0d7cbaff74f37f06bf2db60
admin-server/src/main/java/com/estate/expert/admin/stat/report/data/SystemReportData.java
@@ -15,7 +15,9 @@
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;
/**
@@ -32,6 +34,10 @@
    protected FuzzyResult sysResult;
    protected ScoreResult scoreResult;
    Map<Integer, Long> problemHazardCounts;
    long projectCheckCount;
    // 评估结果
    @Override
@@ -117,7 +123,9 @@
            return null;
        JSONObject result = new JSONObject();
        result.put("名称", node.getName());
        var name = node.getName();
        result.put("名称", name);
        result.put("问题清单标题", buildProblemListTitle(name));
        buildNode(result, node);
        var cfuzzyNode = getFuzzyNodeByPath(node.getPath());
@@ -141,7 +149,7 @@
                    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) {
@@ -172,6 +180,16 @@
        return result;
    }
    private String buildProblemListTitle(String name) {
        if (name == null || name.isBlank()) {
            return "问题清单";
        }
        if ("安全检查".equals(name)) {
            return "安全问题清单";
        }
        return name + "问题清单";
    }
    /**
     * 构建错误信息
     * @param nodePath 节点路径
@@ -182,7 +200,7 @@
        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(
@@ -190,16 +208,34 @@
                        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 记录