From 6907c7dbc84cfbf93fff3ce1cfb5569af8302792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B3=E7=BE=BD?= <关羽@gentronhealth.com> Date: Thu, 14 May 2026 03:14:03 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#481:=20[=E4=BD=8F=E9=99=A2?= =?UTF-8?q?=E6=8A=A4=E5=A3=AB=E7=AB=99-=E5=8C=BB=E5=98=B1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C]=20=E8=8D=AF=E5=93=81=E5=BA=93=E5=AD=98=E5=85=85?= =?UTF-8?q?=E8=B6=B3=E4=BD=86=E6=89=A7=E8=A1=8C=E6=97=B6=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=B8=8D=E8=B6=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: AdviceUtils.checkExeMedInventory() 中硬编码 performLocation == locationId 的匹配条件, 当医嘱的 performLocation 指向的药房没有该药品库存时(库存实际在其他药房),匹配失败导致"库存不足"错误。 修复策略: 采用两步匹配法 - 1. 先按 performLocation 匹配指定药房的库存(添加 null 容错) 2. 若指定药房无匹配,则放宽条件跨所有药房聚合库存 Co-Authored-By: Claude Opus 4.7 --- .../web/doctorstation/utils/AdviceUtils.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/utils/AdviceUtils.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/utils/AdviceUtils.java index 0f930c292..37b1a3cc9 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/utils/AdviceUtils.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/utils/AdviceUtils.java @@ -178,15 +178,26 @@ public class AdviceUtils { // 生命提示信息集合 List tipsList = new ArrayList<>(); for (MedicationRequestUseExe medicationRequestUseExe : medUseExeList) { - // 聚合同一位置所有批次的库存总量 + // 第一步:按 performLocation 匹配指定药房的库存 List matchedInventories = adviceInventory.stream() .filter(inventoryDto -> medicationRequestUseExe.getMedicationId().equals(inventoryDto.getItemId()) && CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(inventoryDto.getItemTable()) - && medicationRequestUseExe.getPerformLocation().equals(inventoryDto.getLocationId()) + && (medicationRequestUseExe.getPerformLocation() == null + || medicationRequestUseExe.getPerformLocation().equals(inventoryDto.getLocationId())) // 如果选择了具体的批次号,校验库存时需要加上批次号的匹配条件 && (StringUtils.isEmpty(medicationRequestUseExe.getLotNumber()) || medicationRequestUseExe.getLotNumber().equals(inventoryDto.getLotNumber()))) .collect(Collectors.toList()); + // 第二步:如果指定药房没有匹配到库存,则放宽条件查询所有药房的库存 + if (matchedInventories.isEmpty()) { + matchedInventories = adviceInventory.stream() + .filter(inventoryDto -> medicationRequestUseExe.getMedicationId().equals(inventoryDto.getItemId()) + && CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(inventoryDto.getItemTable()) + // 如果选择了具体的批次号,校验库存时需要加上批次号的匹配条件 + && (StringUtils.isEmpty(medicationRequestUseExe.getLotNumber()) + || medicationRequestUseExe.getLotNumber().equals(inventoryDto.getLotNumber()))) + .collect(Collectors.toList()); + } // 匹配到库存信息 if (!matchedInventories.isEmpty()) { // 聚合所有批次的可用库存