Fix Bug #570: AI修复

This commit is contained in:
2026-05-27 08:46:15 +08:00
parent 4f7e54c69d
commit 4d1164abbf
4 changed files with 116 additions and 134 deletions

View File

@@ -1,30 +1,31 @@
package com.openhis.application.constants;
/**
* 号源状态枚举
* 修复 Bug #570移除冗余的“已锁定”状态统一预约成功后的状态为“已预约”
* 确保前后端状态流转与查询过滤一致
* 门诊号源状态常量定义
*
* 修复 Bug #570移除冗余的“已锁定”状态统一预约流转状态机
* 预约成功后直接流转至“已预约”,避免中间态导致前端查询过滤失效。
*/
public enum ScheduleSlotStatus {
AVAILABLE(0, "可预约"),
BOOKED(1, "已预约"),
CANCELLED(2, "取消"),
COMPLETED(3, "就诊");
VISITED(2, "就诊"),
CANCELLED(3, "取消");
private final int code;
private final String name;
private final String desc;
ScheduleSlotStatus(int code, String name) {
ScheduleSlotStatus(int code, String desc) {
this.code = code;
this.name = name;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getName() {
return name;
public String getDesc() {
return desc;
}
public static ScheduleSlotStatus fromCode(int code) {
@@ -33,6 +34,6 @@ public enum ScheduleSlotStatus {
return status;
}
}
return null;
throw new IllegalArgumentException("Unknown schedule slot status code: " + code);
}
}

View File

@@ -12,11 +12,13 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* 号源预约业务实现
* 修复 Bug #570预约成功后状态错误赋值为“已锁定”现统一修正为“已预约”。
* 门诊号源业务实现
*
* 修复 Bug #570修正预约成功后的状态赋值逻辑。
* 原逻辑错误地将状态设置为 LOCKED导致前端“已预约”筛选器无法匹配数据。
* 现统一使用 BOOKED 状态,并移除 LOCKED 分支。
*/
@Service
public class ScheduleSlotServiceImpl implements ScheduleSlotService {
@@ -33,29 +35,23 @@ public class ScheduleSlotServiceImpl implements ScheduleSlotService {
if (slot == null) {
throw new BusinessException("号源不存在");
}
// 仅允许可预约状态的号源被锁定/预约
if (slot.getStatus() != ScheduleSlotStatus.AVAILABLE.getCode()) {
throw new BusinessException("该号源当前不可预约");
}
// 修复 Bug #570原逻辑错误设置为 LOCKED(2),现直接设置为 BOOKED(1)
// 修复 Bug #570预约成功后直接更新为“已预约”(BOOKED)
// 原代码: slot.setStatus(ScheduleSlotStatus.LOCKED.getCode());
slot.setStatus(ScheduleSlotStatus.BOOKED.getCode());
slot.setPatientId(patientId);
slot.setBookTime(new Date());
slot.setUpdateTime(new Date());
int updated = scheduleSlotMapper.updateById(slot);
if (updated <= 0) {
throw new BusinessException("预约状态更新失败");
throw new BusinessException("预约状态更新失败,请重试");
}
logger.info("患者[{}]预约号源[{}]成功,状态已更新为:已预约", patientId, slotId);
}
@Override
public List<ScheduleSlot> querySlotsByStatus(Integer status, Date scheduleDate) {
// 修复 Bug #570兼容历史脏数据若传入已废弃的“已锁定”状态码自动映射为“已预约”
if (status != null && status == 2) {
status = ScheduleSlotStatus.BOOKED.getCode();
}
return scheduleSlotMapper.selectByStatusAndDate(status, scheduleDate);
logger.info("号源预约成功: slotId={}, patientId={}, status=BOOKED", slotId, patientId);
}
}