From 28e68c33134c4934bdeee1498992c29a989f8878 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期五, 15 五月 2026 10:44:04 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/estate_expert

---
 admin-server/src/main/java/com/estate/expert/admin/stat/report/data/ReportDataBase.java |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/admin-server/src/main/java/com/estate/expert/admin/stat/report/data/ReportDataBase.java b/admin-server/src/main/java/com/estate/expert/admin/stat/report/data/ReportDataBase.java
index 7883ea5..02fd682 100644
--- a/admin-server/src/main/java/com/estate/expert/admin/stat/report/data/ReportDataBase.java
+++ b/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;
     }

--
Gitblit v1.7.1