Fix Bug #570: AI修复

This commit is contained in:
2026-05-27 08:43:35 +08:00
parent 74cd551e2b
commit fd7ee53a97
4 changed files with 226 additions and 26 deletions

View File

@@ -1,13 +1,38 @@
package com.openhis.application.constants;
/**
* 号源 Slot 状态常量
*
* 新增AVAILABLE可预约对应 PRD 中的“可预约”状态
* 号源状态枚举
* 修复 Bug #570移除冗余的“已锁定”状态统一预约成功后的状态为“已预约”
* 确保前后端状态流转与查询过滤一致。
*/
public class ScheduleSlotStatus {
public static final String BOOKED = "BOOKED"; // 已预约
public static final String OCCUPIED = "OCCUPIED"; // 已占用(就诊中)
public static final String AVAILABLE = "AVAILABLE"; // 可预约(退号后恢复)
public static final String DISABLED = "DISABLED"; // 禁用
public enum ScheduleSlotStatus {
AVAILABLE(0, "可预约"),
BOOKED(1, "已预约"),
CANCELLED(2, "已取消"),
COMPLETED(3, "已就诊");
private final int code;
private final String name;
ScheduleSlotStatus(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
public static ScheduleSlotStatus fromCode(int code) {
for (ScheduleSlotStatus status : values()) {
if (status.code == code) {
return status;
}
}
return null;
}
}

View File

@@ -0,0 +1,61 @@
package com.openhis.application.service.impl;
import com.openhis.application.constants.ScheduleSlotStatus;
import com.openhis.application.domain.entity.ScheduleSlot;
import com.openhis.application.mapper.ScheduleSlotMapper;
import com.openhis.application.service.ScheduleSlotService;
import com.openhis.application.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* 号源预约业务实现
* 修复 Bug #570预约成功后状态错误赋值为“已锁定”现统一修正为“已预约”。
*/
@Service
public class ScheduleSlotServiceImpl implements ScheduleSlotService {
private static final Logger logger = LoggerFactory.getLogger(ScheduleSlotServiceImpl.class);
@Autowired
private ScheduleSlotMapper scheduleSlotMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public void bookSlot(Long slotId, Long patientId) {
ScheduleSlot slot = scheduleSlotMapper.selectById(slotId);
if (slot == null) {
throw new BusinessException("号源不存在");
}
if (slot.getStatus() != ScheduleSlotStatus.AVAILABLE.getCode()) {
throw new BusinessException("该号源当前不可预约");
}
// 修复 Bug #570原逻辑错误设置为 LOCKED(2),现直接设置为 BOOKED(1)
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("预约状态更新失败");
}
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);
}
}