Fix Bug #570: AI修复
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.openhis.web.outpatient.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 门诊号源预约 Mapper
|
||||
* 修复 Bug #570:规范号源状态流转,移除“已锁定”状态,确保预约成功后状态正确落库为 2(已预约)
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppointmentSlotMapper {
|
||||
|
||||
/**
|
||||
* 预约成功后更新号源状态
|
||||
* 修复点:status 直接置为 2(已预约),绑定 order_id,移除历史遗留的 status=4(已锁定) 逻辑
|
||||
*/
|
||||
@Update("UPDATE adm_schedule_slot SET status = 2, order_id = #{orderId}, update_time = NOW() " +
|
||||
"WHERE id = #{slotId} AND status = 1")
|
||||
int updateSlotToBooked(@Param("slotId") Long slotId, @Param("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* 根据状态查询号源列表
|
||||
* 修复点:支持按 status=2 精确查询,兼容前端“已预约”筛选条件
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT id, slot_no, doctor_name, dept_name, schedule_date, status, order_id " +
|
||||
"FROM adm_schedule_slot " +
|
||||
"WHERE 1=1 " +
|
||||
"<if test='status != null'> AND status = #{status} </if>" +
|
||||
" ORDER BY schedule_date ASC, slot_no ASC" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> selectSlotsByStatus(@Param("status") Integer status);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.openhis.web.outpatient.service;
|
||||
|
||||
import com.openhis.web.outpatient.mapper.AppointmentSlotMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 门诊预约服务实现
|
||||
* 修复 Bug #570:简化预约状态流转,确保事务内直接落库为“已预约”状态
|
||||
*/
|
||||
@Service
|
||||
public class AppointmentServiceImpl implements AppointmentService {
|
||||
|
||||
private final AppointmentSlotMapper slotMapper;
|
||||
|
||||
public AppointmentServiceImpl(AppointmentSlotMapper slotMapper) {
|
||||
this.slotMapper = slotMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bookSlot(Long slotId, Long orderId) {
|
||||
if (slotId == null || orderId == null) {
|
||||
throw new IllegalArgumentException("预约核心参数缺失:slotId, orderId 均不可为空");
|
||||
}
|
||||
|
||||
// 修复 Bug #570:直接更新为已预约(2),不再经过中间态或错误状态
|
||||
int updated = slotMapper.updateSlotToBooked(slotId, orderId);
|
||||
if (updated == 0) {
|
||||
throw new RuntimeException("号源状态异常或已被他人预约,请刷新后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user