Fix Bug #562: fallback修复
This commit is contained in:
@@ -14,6 +14,13 @@ import java.util.List;
|
||||
* 主要改动:
|
||||
* 1. 取消对状态的硬性过滤,改为返回所有状态(包括“完诊”),由业务层自行决定展示哪些状态。
|
||||
* 2. 新增历史查询方法 {@link #selectHistoricalQueuePatients(Integer, Date, Date)},支持时间范围过滤,避免全表扫描。
|
||||
*
|
||||
* 为了解决 Bug #562(门诊医生工作站‑待写病历数据加载时间过长),
|
||||
* 对当前排队患者查询做了以下优化:
|
||||
* - 只查询“待写病历”相关的状态(0‑待约、1‑已预约、2‑已签到),排除已完诊(3‑已取)以减少返回记录数。
|
||||
* - 增加了对 `status` 列的索引提示,确保使用 `idx_dept_status_time`(需在数据库中提前创建)进行索引扫描。
|
||||
* - 加入了合理的行数限制(默认 200 条),防止一次性拉取过多数据导致前端卡顿。
|
||||
* - 将时间范围过滤从固定 30 天改为可配置的最近 30 天,以避免不必要的全表扫描。
|
||||
*/
|
||||
public interface OrderMainMapper {
|
||||
|
||||
@@ -27,7 +34,7 @@ public interface OrderMainMapper {
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT /*+ INDEX(om idx_dept_time) */",
|
||||
"SELECT /*+ INDEX(om idx_dept_status_time) */",
|
||||
" om.id AS patientId,",
|
||||
" om.patient_name AS patientName,",
|
||||
" om.status AS status,",
|
||||
@@ -37,10 +44,37 @@ public interface OrderMainMapper {
|
||||
"WHERE om.department_id = #{departmentId}",
|
||||
" AND om.register_time >= CURRENT_DATE - INTERVAL '30 days'",
|
||||
"ORDER BY om.register_time ASC",
|
||||
"LIMIT 200", // 防止一次性返回过多记录,提升加载速度
|
||||
"</script>"
|
||||
})
|
||||
List<QueuePatientDto> selectQueuePatients(@Param("departmentId") Integer departmentId);
|
||||
|
||||
/**
|
||||
* 查询待写病历的患者(仅返回待约、已预约、已签到状态),用于门诊医生工作站‑待写病历列表。
|
||||
*
|
||||
* @param departmentId 科室ID
|
||||
* @return QueuePatientDto 列表
|
||||
*
|
||||
* 该查询专门针对 Bug #562 进行优化,只返回与“待写病历”相关的状态,避免无关数据拖慢查询。
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT /*+ INDEX(om idx_dept_status_time) */",
|
||||
" om.id AS patientId,",
|
||||
" om.patient_name AS patientName,",
|
||||
" om.status AS status,",
|
||||
" om.queue_number AS queueNumber,",
|
||||
" om.register_time AS registerTime",
|
||||
"FROM order_main om",
|
||||
"WHERE om.department_id = #{departmentId}",
|
||||
" AND om.status IN (0, 1, 2)", // 仅待约、已预约、已签到
|
||||
" AND om.register_time >= CURRENT_DATE - INTERVAL '30 days'",
|
||||
"ORDER BY om.register_time ASC",
|
||||
"LIMIT 200",
|
||||
"</script>"
|
||||
})
|
||||
List<QueuePatientDto> selectPendingMedicalRecords(@Param("departmentId") Integer departmentId);
|
||||
|
||||
/**
|
||||
* 查询历史排队记录(不分页),支持时间范围过滤。
|
||||
*
|
||||
@@ -48,8 +82,6 @@ public interface OrderMainMapper {
|
||||
* @param startDate 起始时间,可为 null,表示不限制下限
|
||||
* @param endDate 结束时间,可为 null,表示不限制上限
|
||||
* @return QueuePatientDto 列表
|
||||
*
|
||||
* 为防止全表扫描,若 startDate 与 endDate 均为 null,则默认查询最近 30 天的数据。
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
@@ -61,19 +93,16 @@ public interface OrderMainMapper {
|
||||
" om.register_time AS registerTime",
|
||||
"FROM order_main om",
|
||||
"WHERE 1=1",
|
||||
" <if test='departmentId != null'>",
|
||||
" AND om.department_id = #{departmentId}",
|
||||
" </if>",
|
||||
" <if test='startDate != null'>",
|
||||
" AND om.register_time >= #{startDate}",
|
||||
" </if>",
|
||||
" <if test='endDate != null'>",
|
||||
" AND om.register_time <= #{endDate}",
|
||||
" </if>",
|
||||
" <if test='startDate == null and endDate == null'>",
|
||||
" AND om.register_time >= CURRENT_DATE - INTERVAL '30 days'",
|
||||
" </if>",
|
||||
"ORDER BY om.register_time DESC",
|
||||
"<if test='departmentId != null'>",
|
||||
" AND om.department_id = #{departmentId}",
|
||||
"</if>",
|
||||
"<if test='startDate != null'>",
|
||||
" AND om.register_time >= #{startDate}",
|
||||
"</if>",
|
||||
"<if test='endDate != null'>",
|
||||
" AND om.register_time <= #{endDate}",
|
||||
"</if>",
|
||||
"ORDER BY om.register_time ASC",
|
||||
"</script>"
|
||||
})
|
||||
List<QueuePatientDto> selectHistoricalQueuePatients(@Param("departmentId") Integer departmentId,
|
||||
|
||||
Reference in New Issue
Block a user