liujie
2026-05-16 d6968f0c33f2ce53018af4b0d6bae79a91f2332a
admin-server/src/main/java/com/estate/expert/admin/stat/report/data/ReportDataBase.java
@@ -16,6 +16,7 @@
import org.springframework.util.StringUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -45,6 +46,7 @@
        var result = buildReportInfo();
        result.put("工程概况", buildProjectInfo());
        result.put("设备信息", buildDeviceInfo());
        result.put("设备分组信息", buildDeviceGroupInfo());
        result.put("评估结果", buildEvalInfo());
        return result;
    }
@@ -61,9 +63,11 @@
     */
    protected JSONObject buildReportInfo() {
        JSONObject result = new JSONObject();
        var reportDate = LocalDate.now();
        result.put("项目名称", project.getName());
        result.put("报告编号", template.getNumber() + "-" + String.format("%08d", reportId));
        result.put("报告日期", LocalDate.now());
        result.put("报告日期", reportDate);
        result.put("报告日期中文", reportDate.format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
        result.put("公司名称", "四川信立隆第三方评估咨询有限公司");
        return result;
    }
@@ -92,6 +96,40 @@
    }
    /**
     * 按设备类型汇总设备信息,供新版报告模板使用
     * @return 设备分组信息
     */
    protected List<Object> buildDeviceGroupInfo() {
        Map<String, List<Device>> groupedDevices = devices.stream()
                .sorted(Comparator.comparing(device -> device.getType() != null ? device.getType().ordinal() : Integer.MAX_VALUE))
                .collect(Collectors.groupingBy(
                        device -> device.getType() != null ? device.getType().getDesc() : "",
                        LinkedHashMap::new,
                        Collectors.toList()
                ));
        List<Object> groupInfos = new ArrayList<>();
        groupedDevices.forEach((deviceType, groupDevices) -> {
            var deviceNumbers = groupDevices.stream()
                    .map(Device::getManufacturerNumber)
                    .filter(StringUtils::hasText)
                    .collect(Collectors.toList());
            if (deviceNumbers.isEmpty()) {
                deviceNumbers.add("");
            }
            for (int i = 0; i < deviceNumbers.size(); i++) {
                JSONObject groupInfo = new JSONObject();
                groupInfo.put("设备类型", i == 0 ? deviceType : "");
                groupInfo.put("设备数量", i == 0 ? groupDevices.size() : "");
                groupInfo.put("设备编号", deviceNumbers.get(i));
                groupInfos.add(groupInfo);
            }
        });
        return groupInfos;
    }
    /**
     * 构建错误级别
     * @param node 节点
     * @return 错误级别
@@ -114,6 +152,10 @@
            info.put("比例", formatPercent(count * 1.0 / totalErrors));
            errorInfos.add(info);
        }
        result.put("一级隐患数量", node.getData().getTotalErrorCounts()[0]);
        result.put("二级隐患数量", node.getData().getTotalErrorCounts()[1]);
        result.put("三级隐患数量", node.getData().getTotalErrorCounts()[2]);
        result.put("四级隐患数量", node.getData().getTotalErrorCounts()[3]);
        result.put("分项", errorInfos);
        return result;
    }
@@ -144,7 +186,7 @@
        }
        info.put("工程类型", project.getType().getDesc());
        info.put("工程规模", project.getProjectCost());
        info.put("工程规模", project.getScale());
        if (projectInfo != null) {
            info.put("项目简介", projectInfo.getDetail());