From fce96ef468291fb9a0e6a4d34ab371315e9485d4 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期六, 03 十月 2026 00:59:44 +0800
Subject: [PATCH] ai优化
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java | 138 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 126 insertions(+), 12 deletions(-)
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
index a9c331c..485c620 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
@@ -54,11 +54,16 @@
@Select("""
<script>
SELECT * FROM lihu.queue
- where room_id = #{roomId} and status in (
+ where room_id = #{roomId} and deleted = 0 and status in (
<foreach collection='statusList' separator=',' item='status'>
#{status}
</foreach> )
- order by status desc, seq_num, book_timeslot
+ order by case
+ when status = 30 then 0
+ when status in (3, 5) then 1
+ else 2
+ end,
+ seq_num, book_timeslot
</script>
""")
@Results({
@@ -66,14 +71,31 @@
})
List<QueueDO> getRoomQueueByStatus(@Param("roomId")Long roomId, @Param("statusList")List<Integer> statusList);
- @Select("<script>" +
- "SELECT * FROM lihu.queue " +
- "where status in (" +
- " <foreach collection='statusList' separator=',' item='status'>" +
- " #{status} " +
- " </foreach> )" +
- " order by status desc, seq_num, book_timeslot" +
- "</script>")
+ /**
+ * 澶у睆鍙栨暟銆�
+ * <p>
+ * 鎺掑簭瑙勫垯锛堥渶姹�8锛夛細**灏辫瘖涓�(30) 缃《 鈫� 杩囧彿(3/5) 涓庣瓑鍊�(10/15/20/12) 鎸夋帓闃熷簭鍙� seq_num 鍗囧簭娣锋帓**銆�
+ * 鍘熷厛鐢� {@code order by status desc}锛屼細鎶婅繃鍙�(3/5)鎺掑埌姣忎竴鍒楁渶搴曢儴锛�
+ * 鍦� {@code overflow-y:auto} 鐨勫垪閲屾粴涓嶅埌锛岀瓑鍚屼簬"杩囧彿涓嶆樉绀�"銆�
+ * <p>
+ * 鍚屾椂琛ヤ笂 {@code deleted = 0}锛氭湰鏂规硶鏄嚜瀹氫箟 {@code @Select}锛�
+ * 浼氱粫杩� MyBatis-Plus 鐨� {@code @TableLogic} 閫昏緫鍒犻櫎杩囨护銆�
+ */
+ @Select("""
+ <script>
+ SELECT * FROM lihu.queue
+ where deleted = 0 and status in (
+ <foreach collection='statusList' separator=',' item='status'>
+ #{status}
+ </foreach> )
+ order by case
+ when status = 30 then 0
+ when status in (3, 5) then 1
+ else 2
+ end,
+ seq_num, book_timeslot
+ </script>
+ """)
@Results({
@Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
})
@@ -150,6 +172,7 @@
@Select("<script>" +
"SELECT count(1) as total_in_status FROM lihu.queue where " +
+ " deleted = 0 and book_date = CURDATE() and " +
" status in ( " +
" <foreach collection='statusList' separator=',' item='status'>" +
" #{status} " +
@@ -172,6 +195,7 @@
@Select("<script>" +
"SELECT status, count(1) as total_in_status FROM lihu.queue where " +
+ " deleted = 0 and book_date = CURDATE() and " +
" room_id = #{roomId} and bed_no = #{bedNo} " +
" group by status " +
"</script>")
@@ -179,6 +203,7 @@
@Select("<script>" +
"SELECT status, count(1) as total_in_status FROM lihu.queue where " +
+ " deleted = 0 and book_date = CURDATE() and " +
" room_id = #{roomId} " +
" group by status " +
"</script>")
@@ -186,7 +211,8 @@
@Select("<script>" +
"SELECT count(1) FROM lihu.queue " +
- "where room_id = #{roomId} and bed_no = #{bedNo} and status in (" +
+ "where deleted = 0 and book_date = CURDATE() and " +
+ " room_id = #{roomId} and bed_no = #{bedNo} and status in (" +
" <foreach collection='statusList' separator=',' item='status'>" +
" #{status} " +
" </foreach> )" +
@@ -196,7 +222,7 @@
@Select("""
<script>
SELECT * FROM lihu.queue
- where room_id = #{roomId} and bed_no = #{bedNo} and status in (
+ where deleted = 0 and room_id = #{roomId} and bed_no = #{bedNo} and status in (
<foreach collection='statusList' separator=',' item='status'>
#{status}
</foreach> )
@@ -213,6 +239,48 @@
and status = #{curStatus} order by seq_num, book_timeslot limit 1
""")
QueueDO getBedFirstQueueItemByStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("curStatus")Integer curStatus);
+
+ /**
+ * 銆愰渶姹�2 鐩稿叧缂洪櫡淇銆戞寜銆屽伐浣� + 鎮h�� + 妫�鏌ョ被鍨� + 鐘舵�併��**绮剧‘**瀹氫綅闃熷垪琛屻��
+ * <p>
+ * 鐢ㄤ簬鏇夸唬 {@link #getBedFirstQueueItemByStatus}锛氬悗鑰呭彧鎸�"宸ヤ綅 + 鐘舵�佸彇 seq_num 鏈�灏忕殑涓�鏉�"锛�
+ * 褰撳尰鐢熷厛鐐�"鏀惧純妫�鏌�"锛堜細鎶婅鎮h�呯疆涓� 40锛夊悗鍐嶇偣"妫�鏌ュ畬鎴�"鏃讹紝
+ * 浼氬彇鍒�**涓嬩竴浣嶆偅鑰�**骞舵妸浠栬缃负宸插畬鎴愶紙璇﹁ DevRentServiceImpl.routineFinishOperation锛夈��
+ */
+ @Select("""
+ SELECT * from lihu.queue
+ where room_id = #{roomId} and bed_no = #{bedNo}
+ and status = #{curStatus}
+ and pat_id = #{patId}
+ and book_check_type = #{checkType}
+ and TO_DAYS(book_date) = TO_DAYS(NOW())
+ order by seq_num limit 1
+ """)
+ @Results({
+ @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
+ })
+ QueueDO getBedQueueItemByPatAndStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
+ @Param("patId")String patId, @Param("checkType")Integer checkType,
+ @Param("curStatus")Integer curStatus);
+
+ /**
+ * 鎸夊伐浣� + 鐘舵�� + 浠婃棩鍙�**鏈�杩戞洿鏂�**鐨勪竴鏉°��
+ * <p>
+ * 姣斻�宻eq_num 鏈�灏忋�嶆洿璐村悎"褰撳墠姝e湪灏辫瘖/瑁呮満鐨勯偅浣嶆偅鑰�"锛歴eq_num 鏈�灏忔槸鏈椂娈垫渶鏃╂帓闃熺殑锛�
+ * 鑰� update_time 鏈�鏂版墠鏄垰琚彨鍙锋帹杩涘埌璇ョ姸鎬佺殑銆�
+ */
+ @Select("""
+ SELECT * from lihu.queue
+ where room_id = #{roomId} and bed_no = #{bedNo}
+ and status = #{curStatus}
+ and TO_DAYS(book_date) = TO_DAYS(NOW())
+ order by update_time desc, seq_num limit 1
+ """)
+ @Results({
+ @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
+ })
+ QueueDO getBedLatestQueueItemByStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
+ @Param("curStatus")Integer curStatus);
@Select("""
SELECT * from lihu.queue where apply_no = #{applyNo} and status = #{curStatus} order by seq_num, book_timeslot limit 1
@@ -326,6 +394,52 @@
Integer queueJump(@Param("patId")String patId, @Param("bookCheckType")Integer bookCheckType,
@Param("curStatus")Integer curStatus, @Param("jumped")Byte jumped );
+ // ==================== 闇�姹�2锛氳鐐广�屽彨鍙� / 妫�鏌ュ畬鎴愩�嶇殑鎾ら攢 ====================
+
+ /**
+ * 鎾ら攢銆屾鏌ュ畬鎴愩�嶏細鎶婃湰宸ヤ綅浠婃棩鐨�**鎸囧畾鎮h��**浠� 宸插氨璇�(40) 閫�鍥� 鍊欒瘖涓�(20)銆�
+ * <p>
+ * 蹇呴』鎸� {@code pat_id + book_check_type + 浠婃棩} 绮剧‘瀹氫綅锛�**涓嶈兘**鍙寜
+ * "宸ヤ綅 + status=40 鍙栫涓�鏉�"鈥斺�旈偅浼氬湪鏈熼棿宸插彨涓嬩竴浣嶆偅鑰呮椂璇敼浠栦汉锛堣
+ * {@code DevRentServiceImpl.routineFinishOperation} 鐨勬棦鏈夌己闄凤級銆�
+ * <p>
+ * {@code passed = 0} 鏄负浜嗚鎮h�呴噸鏂板洖鍒版甯稿�欒瘖搴忓垪锛堥潪"杩囧彿"鎬侊級銆�
+ */
+ @Update("update lihu.queue set status = #{newStatus}, passed = 0 " +
+ " where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus} " +
+ " and pat_id = #{patId} and book_check_type = #{checkType} " +
+ " and TO_DAYS(book_date) = TO_DAYS(NOW())")
+ Integer undoFinishPatient(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
+ @Param("patId")String patId, @Param("checkType")Integer checkType,
+ @Param("curStatus")Integer curStatus, @Param("newStatus")Integer newStatus);
+
+ /**
+ * 鎾ら攢銆岃鐐瑰彨鍙枫�嶏細鎶婃湰宸ヤ綅褰撳墠 灏辫瘖涓�(30) 鐨勬偅鑰呴��鍥� 鍊欒瘖涓�(20)銆�
+ * <p>
+ * 浠呮寜宸ヤ綅+鐘舵�佸畾浣嶏紙"褰撳墠姝e湪灏辫瘖鐨勯偅涓�浣�"锛夛紝涓嶄娇鐢� seq_num 瀛愭煡璇紝
+ * 閬垮厤涓� {@code updateBedQueueStatus} 鐨勫啓娉曟贩娣嗐��
+ */
+ @Update("update lihu.queue set status = #{newStatus} " +
+ " where id = " +
+ " (select a.id from " +
+ " (select id from lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} " +
+ " and status = #{curStatus} and TO_DAYS(book_date) = TO_DAYS(NOW()) " +
+ " order by seq_num, book_timeslot limit 1) a)")
+ Integer undoCallPatient(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
+ @Param("curStatus")Integer curStatus, @Param("newStatus")Integer newStatus);
+
+ /**
+ * 鍙栨湰宸ヤ綅浠婃棩**鏈�杩戜竴浣嶅凡瀹屾垚**鐨勬偅鑰咃紙鐢ㄤ簬鐣岄潰鎻愮ず"鍙挙閿�鐨勬槸璋�"锛夈��
+ */
+ @Select("SELECT * FROM lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} " +
+ " and status = #{status} and TO_DAYS(book_date) = TO_DAYS(NOW()) " +
+ " order by update_time desc, seq_num desc limit 1")
+ @Results({
+ @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
+ })
+ QueueDO getBedLastFinishedQueueItem(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
+ @Param("status")Integer status);
+
//@Update("TRUNCATE TABLE lihu.queue")
@Delete("delete from lihu.queue where TO_DAYS(book_date) != TO_DAYS(NOW())")
void clearQueue();
--
Gitblit v1.9.3