فهرست منبع

fix(health-report): 编辑报告时同步更新 report_date 字段

liaoxg 6 روز پیش
والد
کامیت
e616ce8920
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      cfc-backend/src/main/java/com/etotem/cfc/service/HealthReportService.java

+ 15 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/HealthReportService.java

@@ -1745,6 +1745,21 @@ public class HealthReportService {
         if (scoreSource.get("shannonIndex") != null) {
             oldReport.setShannonIndex(scoreSource.get("shannonIndex").toString());
         }
+        // 用户可手动修正报告日期(AI 解析结果不准确时)
+        Object reportDateObj = scoreSource.get("reportDate");
+        if (reportDateObj != null && !String.valueOf(reportDateObj).trim().isEmpty()) {
+            String reportDateStr = String.valueOf(reportDateObj).trim();
+            try {
+                java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
+                java.util.Date parsedDate = sdf.parse(reportDateStr);
+                if (parsedDate != null) {
+                    oldReport.setReportDate(new java.sql.Date(parsedDate.getTime()));
+                    log.info("报告日期已更新: reportId={}, reportDate={}", reportId, reportDateStr);
+                }
+            } catch (Exception e) {
+                log.warn("reportDate 格式解析失败 reportId={}, value={}: {}", reportId, reportDateStr, e.getMessage());
+            }
+        }
         oldReport.setUpdatedAt(new Date());
         healthReportMapper.updateById(oldReport);