From 560813d009f2a84457c1f72f00f9ff1720f0ea64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B3=E7=BE=BD?= <关羽@gentronhealth.com> Date: Thu, 14 May 2026 17:16:18 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#412:=20=E9=97=A8=E8=AF=8A=E5=8C=BB?= =?UTF-8?q?=E7=94=9F=E7=AB=99=EF=BC=9A=E4=BC=A0=E6=9F=93=E7=97=85=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E5=8D=A1=E4=BF=9D=E5=AD=98=E5=A4=B1=E8=B4=A5=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BeanUtils.copyProperties 不支持 DTO 中 LocalDate/LocalDateTime 到实体中 java.util.Date 的类型转换,导致 onsetDate、diagDate、reportDate、deathDate 等日期字段在拷贝后为 null。新增手动类型转换逻辑确保日期字段正确保存。 Co-Authored-By: Claude Opus 4.7 --- .../DoctorStationDiagnosisAppServiceImpl.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationDiagnosisAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationDiagnosisAppServiceImpl.java index 11174386c..2a1fd9356 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationDiagnosisAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationDiagnosisAppServiceImpl.java @@ -36,6 +36,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.Date; import java.util.*; @@ -598,6 +601,25 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn InfectiousDiseaseReport infectiousDiseaseReport = new InfectiousDiseaseReport(); BeanUtils.copyProperties(infectiousDiseaseReportDto, infectiousDiseaseReport); + // BeanUtils.copyProperties 不支持 LocalDate/LocalDateTime 到 java.util.Date 的类型转换,需手动处理 + if (infectiousDiseaseReportDto.getOnsetDate() != null) { + infectiousDiseaseReport.setOnsetDate( + Date.from(infectiousDiseaseReportDto.getOnsetDate().atStartOfDay(ZoneId.systemDefault()).toInstant())); + } + if (infectiousDiseaseReportDto.getDiagDate() != null) { + infectiousDiseaseReport.setDiagDate( + Date.from(infectiousDiseaseReportDto.getDiagDate().atZone(ZoneId.systemDefault()).toInstant())); + } + // deathDate / reportDate 同理 + if (infectiousDiseaseReportDto.getDeathDate() != null) { + infectiousDiseaseReport.setDeathDate( + Date.from(infectiousDiseaseReportDto.getDeathDate().atStartOfDay(ZoneId.systemDefault()).toInstant())); + } + if (infectiousDiseaseReportDto.getReportDate() != null) { + infectiousDiseaseReport.setReportDate( + Date.from(infectiousDiseaseReportDto.getReportDate().atStartOfDay(ZoneId.systemDefault()).toInstant())); + } + /** * 设置创建人、删除状态、租户ID */