Fix Bug #544: AI修复

This commit is contained in:
2026-05-26 23:14:01 +08:00
parent 536a0e7ace
commit 0ba1e1bde8
4 changed files with 156 additions and 58 deletions

View File

@@ -3,34 +3,30 @@ package com.openhis.web.triage.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
* 智能分诊排队记录数据库操作 Mapper
* 智能分诊排队队列数据库操作 Mapper
*/
@Mapper
public interface TriageQueueMapper {
/**
* Bug #544 Fix: 修复队列列表过滤完诊状态及缺失历史查询问题
* 根因:原 SQL 硬编码 status IN (1,2,3) 导致完诊(4)被过滤;且无时间范围参数
* 修复:
* 1. 移除状态硬编码,改为动态 <if test='status != null'> 条件,支持全状态查询
* 2. 增加 startDate/endDate 动态过滤,支持历史队列追溯
* 3. 默认按排队时间倒序,符合护士站操作习惯
* Bug #544 Fix: 移除对“完诊状态的硬编码过滤,支持按时间范围查询历史队列
* 根因原SQL包含 WHERE status != 'COMPLETED' 导致完诊患者被自动过滤
* 修复:移除状态限制,增加 create_time 范围查询参数,支持全流程追溯
*/
@Select("<script>" +
"SELECT id, patient_id, patient_name, status, queue_time, dept_id, dept_name, create_time " +
"FROM triage_queue_record " +
"SELECT id, patient_id, patient_name, status, dept_id, queue_no, create_time, update_time " +
"FROM triage_queue " +
"WHERE dept_id = #{deptId} " +
"<if test='status != null'> AND status = #{status} </if>" +
"<if test='startDate != null'> AND create_time &gt;= #{startDate} </if>" +
"<if test='endDate != null'> AND create_time &lt;= #{endDate} </if>" +
"ORDER BY queue_time DESC" +
"ORDER BY create_time DESC" +
"</script>")
List<Map<String, Object>> selectQueueRecords(@Param("deptId") Long deptId,
@Param("status") Integer status,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
List<Map<String, Object>> selectQueueList(@Param("deptId") Long deptId,
@Param("startDate") LocalDateTime startDate,
@Param("endDate") LocalDateTime endDate);
}

View File

@@ -0,0 +1,35 @@
package com.openhis.web.triage.service;
import com.openhis.web.triage.mapper.TriageQueueMapper;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;
/**
* 智能分诊排队服务实现
*/
@Service
public class TriageQueueService {
private final TriageQueueMapper triageQueueMapper;
public TriageQueueService(TriageQueueMapper triageQueueMapper) {
this.triageQueueMapper = triageQueueMapper;
}
/**
* Bug #544 Fix: 获取排队队列列表,默认查询当天,支持历史时间范围查询
* @param deptId 科室ID
* @param startDate 查询开始日期(默认当天)
* @param endDate 查询结束日期(默认当天)
* @return 队列记录列表
*/
public List<Map<String, Object>> getQueueList(Long deptId, LocalDate startDate, LocalDate endDate) {
// 默认当天时间范围00:00:00 至 23:59:59
LocalDateTime start = (startDate != null) ? startDate.atStartOfDay() : LocalDate.now().atStartOfDay();
LocalDateTime end = (endDate != null) ? endDate.atTime(LocalTime.MAX) : LocalDate.now().atTime(LocalTime.MAX);
return triageQueueMapper.selectQueueList(deptId, start, end);
}
}