diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/impl/OutpatientRegistrationAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/impl/OutpatientRegistrationAppServiceImpl.java index ef6f7bd16..c92887ae4 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/impl/OutpatientRegistrationAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/impl/OutpatientRegistrationAppServiceImpl.java @@ -660,10 +660,12 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra return appointmentOrder.getId(); } - // 只有已预约(1)的号源才能退号,对应签到后的 BOOKED 状态 + // 已预约(1)或已签到(3)的号源都能退号 ScheduleSlot slot = scheduleSlotMapper.selectById(slotId); - if (slot == null || !SlotStatus.BOOKED.getValue().equals(slot.getStatus())) { - log.warn("退号跳过:槽位非已预约状态, slotId={}, status={}", slotId, + if (slot == null || + (!SlotStatus.BOOKED.getValue().equals(slot.getStatus()) && + !SlotStatus.CHECKED_IN.getValue().equals(slot.getStatus()))) { + log.warn("退号跳过:槽位状态不允许退号, slotId={}, status={}", slotId, slot != null ? slot.getStatus() : null); return appointmentOrder.getId(); } @@ -676,11 +678,8 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra Long poolId = scheduleSlotMapper.selectPoolIdBySlotId(slotId); if (poolId != null) { - schedulePoolMapper.update(null, - new LambdaUpdateWrapper() - .setSql("booked_num = booked_num - 1, version = version + 1") - .set(SchedulePool::getUpdateTime, new Date()) - .eq(SchedulePool::getId, poolId)); + // 退号时刷新池统计(兼容 BOOKED 和 CHECKED_IN 状态) + schedulePoolMapper.refreshPoolStats(poolId, SlotStatus.BOOKED.getValue(), SlotStatus.LOCKED.getValue()); } return appointmentOrder.getId(); } catch (Exception e) { diff --git a/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml b/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml index fd0ca01fb..8deea84ab 100755 --- a/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml +++ b/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml @@ -340,8 +340,8 @@ OR d.is_stopped = FALSE ) - - AND = 1 + + AND ( = 1 OR = 3) AND ( d.is_stopped IS NULL OR d.is_stopped = FALSE