From b74f6bf3f9e40d9d3a931f2c4d5e04dcc36ddee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E4=BD=97?= Date: Sun, 31 May 2026 00:41:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(#630):=20=E8=AF=B7=E4=BF=AE=E5=A4=8D=20Bug?= =?UTF-8?q?=20#630=EF=BC=9A[=E9=97=A8=E8=AF=8A=E5=8C=BB=E7=94=9F=E7=AB=99]?= =?UTF-8?q?=20=E7=82=B9=E5=87=BB=E9=80=89=E6=8B=A9=E7=8E=B0=E8=AF=8A?= =?UTF-8?q?=E6=82=A3=E8=80=85=E5=88=97=E8=A1=A8=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: - ** - 门诊医生站点击现诊患者后,右侧病历区域加载失败,抛出异常。经过全链路分析(前端→Controller→Service→Mapper→DB),定位到两个可能的问题点: - 1. `DoctorStationEmrController.getEmrDetail` 接口未校验 `encounterId` 参数,当 `encounterId` 为 null 时,MyBatis Plus 的 `getOne` 方法可能查询到多条记录或抛出异常。 - 2. `DoctorStationEmrController.getPatientEmrHistory` 接口未校验 `patientId` 参数,可能导致查询条件异常。 修复: - ** - 在 `DoctorStationEmrAppServiceImpl.getPatientEmrHistory` 方法中增加 `patientId` 空值校验,为空时返回空分页结果,避免查询异常。 - 在 `DoctorStationEmrAppServiceImpl.getEmrDetail` 方法中增加 `encounterId` 空值校验,为空时直接返回 null;同时将 `emrService.getOne` 的第二个参数设为 `false`,避免多条记录时抛出异常。 - 修改文件:** - `openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java` - 编译验证:** - 运行 `mvn compile -pl openhis-application -am`,编译成功,无新增错误。 --- .../impl/DoctorStationEmrAppServiceImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java index 38cc522cf..8282df46f 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java @@ -126,6 +126,10 @@ public class DoctorStationEmrAppServiceImpl implements IDoctorStationEmrAppServi */ @Override public R getPatientEmrHistory(PatientEmrDto patientEmrDto, Integer pageNo, Integer pageSize) { + // 校验参数 + if (patientEmrDto.getPatientId() == null) { + return R.ok(new Page<>(pageNo, pageSize)); + } Page page = emrService.page(new Page<>(pageNo, pageSize), new LambdaQueryWrapper().eq(Emr::getPatientId, patientEmrDto.getPatientId())); return R.ok(page); @@ -140,8 +144,12 @@ public class DoctorStationEmrAppServiceImpl implements IDoctorStationEmrAppServi */ @Override public R getEmrDetail(Long encounterId) { + // 校验参数 + if (encounterId == null) { + return R.ok(null); + } // 先查询门诊病历(emr表) - Emr emrDetail = emrService.getOne(new LambdaQueryWrapper().eq(Emr::getEncounterId, encounterId)); + Emr emrDetail = emrService.getOne(new LambdaQueryWrapper().eq(Emr::getEncounterId, encounterId), false); if (emrDetail != null) { return R.ok(emrDetail); }