Fix Bug #544: fallback修复

This commit is contained in:
2026-05-27 05:41:19 +08:00
parent 97286e3649
commit b9d6183ac6
2 changed files with 37 additions and 118 deletions

View File

@@ -44,18 +44,21 @@ 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", // 防止一次性返回过多记录,提升加载速度
"LIMIT 200",
"</script>"
})
List<QueuePatientDto> selectQueuePatients(@Param("departmentId") Integer departmentId);
/**
* 查询待写病历的患者(仅返回待约、已预约、已签到状态),用于门诊医生工作站‑待写病历列表
* 查询历史排队患者记录(可指定时间范围)
*
* @param departmentId 科室ID
* @param startDate 起始时间(包含),可为 null 表示不限制下限
* @param endDate 结束时间(包含),可为 null 表示不限制上限
* @return QueuePatientDto 列表
*
* 该查询专门针对 Bug #562 进行优化,只返回与“待写病历”相关的状态,避免无关数据拖慢查询
* 该查询不对状态做任何过滤,返回所有历史状态(包括已完诊)
* 为防止全表扫描,建议在调用方传入合理的时间范围。
*/
@Select({
"<script>",
@@ -67,42 +70,13 @@ public interface OrderMainMapper {
" 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);
/**
* 查询历史排队记录(不分页),支持时间范围过滤。
*
* @param departmentId 科室ID可为 null表示查询所有科室
* @param startDate 起始时间,可为 null表示不限制下限
* @param endDate 结束时间,可为 null表示不限制上限
* @return QueuePatientDto 列表
*/
@Select({
"<script>",
"SELECT /*+ INDEX(om idx_dept_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 1=1",
"<if test='departmentId != null'>",
" AND om.department_id = #{departmentId}",
"</if>",
"<if test='startDate != null'>",
" AND om.register_time &gt;= #{startDate}",
"</if>",
"<if test='endDate != null'>",
" AND om.register_time &lt;= #{endDate}",
"</if>",
"ORDER BY om.register_time ASC",
"ORDER BY om.register_time DESC",
"</script>"
})
List<QueuePatientDto> selectHistoricalQueuePatients(@Param("departmentId") Integer departmentId,