From 5563291ef374d5b6279c4b62e3f773892ffcd5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=BA=91?= <赵云@gentronhealth.com> Date: Wed, 13 May 2026 18:12:13 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#475:=20=E3=80=90=E4=BD=8F=E9=99=A2?= =?UTF-8?q?=E5=8C=BB=E7=94=9F=E5=B7=A5=E4=BD=9C=E7=AB=99=E3=80=91=E5=BC=80?= =?UTF-8?q?=E7=AB=8B=E6=A3=80=E6=9F=A5=E7=94=B3=E8=AF=B7=E5=8D=95=E6=8A=A5?= =?UTF-8?q?=E9=94=99"=E8=AF=B7=E5=85=88=E9=85=8D=E7=BD=AE=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E6=97=B6=E9=97=B4=E6=AE=B5=E7=9A=84=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=A7=91=E5=AE=A4"=E5=90=8E=EF=BC=8C=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=BB=8D=E7=94=9F=E6=88=90=E7=94=B3=E8=AF=B7=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:saveRequestForm 方法中,执行科室配置校验(activityOrganizationConfig.isEmpty)位于 saveOrUpdate(requestForm) 之后,导致即使校验失败抛出异常,RequestForm 记录已被写入数据库。 修复:将校验逻辑移至方法开头,在任何数据库操作之前执行,确保校验失败时不产生任何脏数据。 Co-Authored-By: Claude Opus 4.7 --- .../impl/RequestFormManageAppServiceImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java index fa71860e8..4dd649fad 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java @@ -76,6 +76,13 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer @Override @Transactional(rollbackFor = Exception.class) public R saveRequestForm(RequestFormSaveDto requestFormSaveDto, String typeCode) { + // 诊疗执行科室配置校验(必须在任何数据库操作之前) + List activityOrganizationConfig = + requestFormManageAppMapper.getActivityOrganizationConfig(typeCode); + if (activityOrganizationConfig.isEmpty()) { + throw new ServiceException("请先配置当前时间段的执行科室"); + } + // 诊疗处方号 String prescriptionNo; // 申请单ID @@ -142,12 +149,6 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer // 诊疗集合 List activityList = requestFormSaveDto.getActivityList(); log.info("保存申请单,typeCode={}, activityListSize={}, encounterId={}", typeCode, activityList != null ? activityList.size() : 0, encounterId); - // 诊疗执行科室配置 - List activityOrganizationConfig = - requestFormManageAppMapper.getActivityOrganizationConfig(typeCode); - if (activityOrganizationConfig.isEmpty()) { - throw new ServiceException("请先配置当前时间段的执行科室"); - } for (ActivitySaveDto activitySaveDto : activityList) { serviceRequest = new ServiceRequest();