From 2e45c6c029a1ef7677a9f01fc54cdd8d2ade419a Mon Sep 17 00:00:00 2001 From: wzk <2438381872@qq.com> Date: Fri, 7 Nov 2025 13:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8D=95=E7=A7=91=E5=AE=A4=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E7=9A=84=E5=8F=96=E8=8D=AF=E8=8D=AF=E6=88=BF=E8=8D=AF?= =?UTF-8?q?=E5=9C=A8=E5=8C=BB=E7=94=9F=E5=BC=80=E5=A4=84=E6=96=B9=E8=8D=AF?= =?UTF-8?q?=E5=81=9A=E5=A5=BD=E8=BF=87=E6=BB=A4=E9=99=90=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E7=BB=B4=E6=8A=A4=E7=9A=84=E8=8D=AF=E6=88=BF?= =?UTF-8?q?/=E8=8D=AF=E5=BA=93=E6=88=96=E8=80=85=E8=8D=AF=E5=93=81?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BF=87=E6=BB=A4=E6=8E=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DoctorStationAdviceAppServiceImpl.java | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java index 6995a5c6..27b7d0fe 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java @@ -140,6 +140,17 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp adviceUtils.subtractInventory(adviceInventoryList, adviceDraftInventoryList); // 查询取药科室配置 List medLocationConfig = doctorStationAdviceAppMapper.getMedLocationConfig(organizationId); + // 将配置转为 {categoryCode -> 允许的locationId集合} + Map> allowedLocByCategory = new HashMap<>(); + if (medLocationConfig != null && !medLocationConfig.isEmpty()) { + for (AdviceInventoryDto cfg : medLocationConfig) { + if (cfg.getCategoryCode() == null || cfg.getLocationId() == null) { + continue; + } + allowedLocByCategory.computeIfAbsent(String.valueOf(cfg.getCategoryCode()), k -> new HashSet<>()) + .add(cfg.getLocationId()); + } + } // 费用定价子表信息 List childCharge = doctorStationAdviceAppMapper .getChildCharge(ConditionCode.LOT_NUMBER_COST.getCode(), chargeItemDefinitionIdList); @@ -163,6 +174,19 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp .filter(e -> baseDto.getAdviceDefinitionId().equals(e.getItemId()) && baseDto.getAdviceTableName().equals(e.getItemTable())) .collect(Collectors.toList()); + // 当存在按科室配置时:仅保留被允许的药房/药库的库存; + // 若该药品类别未在配置中出现,则视为不可开立(清空库存以便前端过滤掉) + if (!allowedLocByCategory.isEmpty()) { + Set allowedLoc = + allowedLocByCategory.get(String.valueOf(baseDto.getCategoryCode())); + if (allowedLoc == null || allowedLoc.isEmpty()) { + inventoryList = Collections.emptyList(); + } else { + inventoryList = inventoryList.stream() + .filter(inv -> allowedLoc.contains(inv.getLocationId())) + .collect(Collectors.toList()); + } + } // 库存信息 baseDto.setInventoryList(inventoryList); // 设置默认产品批号 @@ -174,18 +198,15 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp baseDto.setDefaultLotNumber(hasInventoryList.get(0).getLotNumber()); } } - if (!inventoryList.isEmpty() && !medLocationConfig.isEmpty()) { - // 第一步:在medLocationConfig中匹配categoryCode - AdviceInventoryDto result1 = medLocationConfig.stream() - .filter(dto -> baseDto.getCategoryCode().equals(dto.getCategoryCode())).findFirst() - .orElse(null); - if (result1 != null) { - // 第二步:在inventoryList中匹配locationId - AdviceInventoryDto result2 = inventoryList.stream() - .filter(dto -> result1.getLocationId().equals(dto.getLocationId())).findFirst() - .orElse(null); - if (result2 != null && result2.getLotNumber() != null) { - baseDto.setDefaultLotNumber(result2.getLotNumber()); + if (!inventoryList.isEmpty() && !allowedLocByCategory.isEmpty()) { + Set allowedLoc = + allowedLocByCategory.get(String.valueOf(baseDto.getCategoryCode())); + if (allowedLoc != null && !allowedLoc.isEmpty()) { + AdviceInventoryDto hit = inventoryList.stream() + .filter(inv -> allowedLoc.contains(inv.getLocationId())) + .findFirst().orElse(null); + if (hit != null && hit.getLotNumber() != null) { + baseDto.setDefaultLotNumber(hit.getLotNumber()); } } }