From db6ffd6a99b46bd27173503c10aa4cd1afc9c775 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期三, 25 十一月 2026 11:16:33 +0800
Subject: [PATCH] 算税优化
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java | 192 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 192 insertions(+), 0 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 14c7549..4dd2914 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
@@ -285,6 +285,55 @@
@Param("curStatus")Integer curStatus);
/**
+ * 鎸夈�屽伐浣� + 鎮h�� + 妫�鏌ョ被鍨� + 鐘舵��**闆嗗悎**銆嶅彇涓�琛岋紙浠婃棩锛屽彿鏈�灏忥級銆�
+ *
+ * <p>銆愭湰闇�姹偮蜂笉鍙彿鐩存帴妫�鏌ャ�戠敤浜庛�屾鏌ュ畬鎴愩�嶆椂鏀跺熬**浠栬嚜宸辩殑**鎺掗槦琛岋細
+ * 浠庡伐浣滃彴鍙充晶鍒楄〃鐐广�屾鏌ャ�嶅姞杞界殑鎮h�咃紝鍏ㄧ▼涓嶄細琚疆涓恒�屽氨璇婁腑(30)銆�
+ * 锛堝洜涓鸿姹備笉涓婂ぇ灞忋�佷笉鍙彿锛夛紝瀹屾垚妫�鏌ユ椂灏辨病鏈� 30 鐨勮鍙互鏀� 40锛�
+ * 鑻ヤ笉澶勭悊浠栦細涓�鐩寸暀鍦ㄥ�欒瘖鍒楄〃鍜屽ぇ灞忎笂銆�
+ *
+ * <p>鍏佽鐨勭姸鎬侊細鎺掗槦涓�(10)/宸插彫鍥�(15)/鍑嗗涓�(20)鈥斺�旈兘鏄�"杩樻病鍋氬畬"鐨勭姸鎬併��
+ */
+ @Select("<script>" +
+ "SELECT * from lihu.queue " +
+ "where room_id = #{roomId} and bed_no = #{bedNo} " +
+ " and pat_id = #{patId} and book_check_type = #{checkType} " +
+ " and status in ( " +
+ " <foreach collection='statusList' separator=',' item='_status'>#{_status}</foreach> " +
+ " ) " +
+ " and TO_DAYS(book_date) = TO_DAYS(NOW()) " +
+ "order by seq_num limit 1" +
+ "</script>")
+ @Results({
+ @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
+ })
+ QueueDO getBedQueueItemByPatAndStatuses(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
+ @Param("patId")String patId, @Param("checkType")Integer checkType,
+ @Param("statusList")List<Integer> statusList);
+
+ /**
+ * 鍙栥�岃繕娌″垎閰嶅伐浣嶃�嶇殑鎺掗槦琛岋紙{@code bed_no} 涓虹┖锛屼粖鏃ワ紝鍙锋渶灏忥級銆�
+ *
+ * <p>鍦烘櫙鍚屼笂锛氬尰鐢熷湪銆屾湰璇婂鎺掗槦涓紙鏈垎閰嶅伐浣嶏級銆嶉噷鐩存帴鐐广�屾鏌ャ�嶅仛鎺夋煇浣嶆偅鑰咃紝
+ * 璇ヨ娌℃湁 room/bed锛屽畬鎴愭鏌ユ椂瑕佹寜鎮h�� + 妫�鏌ラ」鐩妸瀹冩敹灏俱��
+ */
+ @Select("<script>" +
+ "SELECT * from lihu.queue " +
+ "where pat_id = #{patId} and book_check_type = #{checkType} " +
+ " and (bed_no is null or trim(bed_no) = '') " +
+ " and status in ( " +
+ " <foreach collection='statusList' separator=',' item='_status'>#{_status}</foreach> " +
+ " ) " +
+ " and TO_DAYS(book_date) = TO_DAYS(NOW()) " +
+ "order by seq_num limit 1" +
+ "</script>")
+ @Results({
+ @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
+ })
+ QueueDO getUnassignedQueueItemByPatAndStatuses(@Param("patId")String patId, @Param("checkType")Integer checkType,
+ @Param("statusList")List<Integer> statusList);
+
+ /**
* 鎸夊伐浣� + 鐘舵�� + 浠婃棩鍙�**鏈�杩戞洿鏂�**鐨勪竴鏉°��
* <p>
* 姣斻�宻eq_num 鏈�灏忋�嶆洿璐村悎"褰撳墠姝e湪灏辫瘖/瑁呮満鐨勯偅浣嶆偅鑰�"锛歴eq_num 鏈�灏忔槸鏈椂娈垫渶鏃╂帓闃熺殑锛�
@@ -447,6 +496,27 @@
@Param("bedNo")String bedNo, @Param("curStatus")Integer curStatus, @Param("newStatus")Integer newStatus);
/**
+ * 銆愪慨澶嵚风幇鍦洪棶棰樸�戞妸鏌愬伐浣嶄笂鐨勩�屽噯澶囦腑/宸插彫鍥�/浜插拰銆嶆偅鑰�**閫�鍥炪�屾帓闃熶腑銆�**锛屽苟娓呯┖璇婂/宸ヤ綅銆�
+ *
+ * <p>鐢ㄤ簬銆岀鐞嗗憳娓呯┖宸ヤ綅銆嶄笌銆岄棴璇娿�嶃�傚師瀹炵幇鍙敼 `clinic_room`锛屾偅鑰呬粛鎸傚湪杩欎釜宸ヤ綅涓婏紝
+ * 鑰屽伐浣嶅凡缁忔病浜轰簡 鈥斺�� 浠栦滑鏃笉鍦ㄤ换浣曞尰鐢熺殑鍊欒瘖鍒楄〃閲岋紝涔熶笉鍦�
+ * 銆屾湰璇婂鎺掗槦涓紙鏈垎閰嶏級銆嶉噷锛堥偅涓垪琛ㄥ彧鏌� {@code status=10 涓� bed_no 涓虹┖}锛夛紝
+ * 绛変簬"娑堝け"锛屽彧鑳界瓑姣忔棩閲嶇疆銆傞��鍥炲悗鍗冲彲琚叾瀹冨紑璇婂伐浣嶉噸鏂板垎娴� / 鎵嬪伐銆屾媺鍏ャ�嶃��
+ *
+ * <p>鍚屾椂鎶� {@code affinity_item} 澶嶄綅涓� 0锛氫翰鍜岄」閲嶆柊鍙樻垚鐙珛鐨勬帓闃熸偅鑰咃紝
+ * 涓嬫琚垎娴佹椂浼氱敱浜插拰閫昏緫閲嶆柊鎸傚埌涓婚」涓婏紙{@code procAffinityWhenPreempt}锛夈��
+ */
+ @Update("<script>" +
+ "update lihu.queue " +
+ "set status = #{newStatus}, room_id = 0, room_name = '', bed_no = null, affinity_item = 0 " +
+ "where room_id = #{roomId} and bed_no = #{bedNo} and deleted = 0 " +
+ " and status in ( <foreach collection='statusList' separator=',' item='_status'>#{_status}</foreach> )" +
+ "</script>")
+ Integer releaseBedPatientsToWaiting(@Param("roomId") Long roomId, @Param("bedNo") String bedNo,
+ @Param("newStatus") Integer newStatus,
+ @Param("statusList") List<Integer> statusList);
+
+ /**
* 銆愭湰闇�姹偮峰苟鍙戝姞鍥恒�戞寜涓婚敭 + **褰撳墠鐘舵��**鏉′欢鎺ㄨ繘鐘舵�侊紙鍙彿锛氬�欒瘖涓�(20) 鈫� 灏辫瘖涓�(30)锛夈��
*
* <p>涓轰粈涔堥渶瑕佸畠锛歿@code nextPatient} 鍘熸潵鏄�"鍏堟煡鏈�灏忓彿鐨勫�欒瘖琛� 鈫� updateById"锛�
@@ -546,5 +616,127 @@
//@Update("TRUNCATE TABLE lihu.queue")
@Delete("delete from lihu.queue where TO_DAYS(book_date) != TO_DAYS(NOW())")
void clearQueue();
+
+ // ========================================================================
+ // 鍏变韩鍊欒瘖姹狅紙check_type.share_pool = 1锛岃瑙� _prep/鏂规-1-2璇婂鍏变韩鍊欒瘖姹�.md锛�
+ //
+ // 姹犱腑鎮h�呯殑鍒ゅ畾锛歴tatus = 20(鍑嗗涓�) 涓� **鏈粦瀹氳瘖瀹�**锛坆ed_no 涓虹┖锛夈��
+ // 涓�"宸茬粦瀹氭煇宸ヤ綅鐨� 20"鍖哄垎锛氬悗鑰� room_id/bed_no 鏈夊�硷紝浠嶆寜宸ヤ綅鏌ャ��
+ // ========================================================================
+
+ /**
+ * 鍙栧叡浜睜/鍏变韩鎺掗槦涓�屽彿鏈�灏忋�嶇殑涓�浣嶏紙浠婃棩锛屾湭缁戝畾璇婂锛夈��
+ *
+ * <p>{@code curStatus}=20 鍙�"鍑嗗涓�"锛�=10 鍙�"鎺掗槦涓�"锛堟睜绌烘椂鍙彿鐨勫厹搴曪級銆�
+ * 鎺掑簭涓庣幇鏈夊彨鍙蜂竴鑷达細鍔犳�ヤ紭鍏� 鈫� 鎺掗槦鍙� 鈫� 鏃舵 鈫� 鍒涘缓鏃堕棿銆�
+ */
+ @Select("<script>" +
+ "SELECT * FROM lihu.queue WHERE deleted = 0 AND status = #{curStatus} " +
+ " AND (bed_no IS NULL OR TRIM(bed_no) = '') " +
+ " AND book_check_type IN ( " +
+ " <foreach collection='checkTypeArray' separator=',' item='_t'>#{_t}</foreach> " +
+ " ) " +
+ " AND TO_DAYS(book_date) = TO_DAYS(NOW()) " +
+ "ORDER BY jump_flag DESC, CASE WHEN seq_num IS NULL THEN 1 ELSE 0 END, seq_num, book_timeslot, create_time " +
+ "LIMIT 1" +
+ "</script>")
+ @Results({
+ @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
+ })
+ QueueDO selectSharedFirst(@Param("curStatus") Integer curStatus,
+ @Param("checkTypeArray") Integer[] checkTypeArray);
+
+ /**
+ * 鍙栧叡浜睜/鍏变韩鎺掗槦涓殑鎮h�呭垪琛紙宸ヤ綔鍙般�屽叡浜�欒瘖鍖恒�嶇敤锛夈��
+ */
+ @Select("<script>" +
+ "SELECT * FROM lihu.queue WHERE deleted = 0 AND status = #{curStatus} " +
+ " AND (bed_no IS NULL OR TRIM(bed_no) = '') " +
+ " AND book_check_type IN ( " +
+ " <foreach collection='checkTypeArray' separator=',' item='_t'>#{_t}</foreach> " +
+ " ) " +
+ " AND TO_DAYS(book_date) = TO_DAYS(NOW()) " +
+ "ORDER BY jump_flag DESC, CASE WHEN seq_num IS NULL THEN 1 ELSE 0 END, seq_num, book_timeslot, create_time" +
+ "</script>")
+ @Results({
+ @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
+ })
+ List<QueueDO> selectSharedList(@Param("curStatus") Integer curStatus,
+ @Param("checkTypeArray") Integer[] checkTypeArray);
+
+ /**
+ * 缁熻鍏变韩姹犲綋鍓嶃�屽噯澶囦腑涓旀湭缁戝畾銆嶇殑浜烘暟锛堢敤浜庢睜瀹归噺鎺у埗锛夈��
+ */
+ @Select("<script>" +
+ "SELECT COUNT(1) FROM lihu.queue WHERE deleted = 0 AND status = 20 " +
+ " AND (bed_no IS NULL OR TRIM(bed_no) = '') " +
+ " AND book_check_type IN ( " +
+ " <foreach collection='checkTypeArray' separator=',' item='_t'>#{_t}</foreach> " +
+ " ) " +
+ " AND TO_DAYS(book_date) = TO_DAYS(NOW())" +
+ "</script>")
+ Integer countSharedPool(@Param("checkTypeArray") Integer[] checkTypeArray);
+
+ /**
+ * 鎶娿�屾帓闃熶腑(10)銆嶆彁鍗囦负鍏变韩姹犮�屽噯澶囦腑(20)銆嶏紝淇濇寔涓嶇粦瀹氳瘖瀹ゃ��
+ * <p>{@code and status = 10} 淇濊瘉骞跺彂涓嬪彧鏈変竴鏂规姠鍒拌琛屻��
+ */
+ @Update("update lihu.queue set status = 20, room_id = 0, room_name = '', bed_no = null " +
+ " where id = #{id} and status = 10 and deleted = 0")
+ Integer promoteToSharedPool(@Param("id") Integer id);
+
+ /**
+ * 銆屾媺鍏ャ�嶅叡浜睜鎮h�咃細鎶婃睜涓�屽噯澶囦腑(20) 鏈粦瀹氥�嶇殑琛岀粦瀹氬埌鏈伐浣嶏紙鐘舵�佷粛涓� 20锛夈��
+ * <p>{@code bed_no 涓虹┖} 鏄苟鍙戜繚鎶わ細姹犱腑鍚屼竴琛屽彧浼氳涓�涓瘖瀹ゆ媺璧般��
+ */
+ @Update("update lihu.queue set room_id = #{roomId}, room_name = #{roomName}, bed_no = #{bedNo} " +
+ " where id = #{id} and status = 20 and (bed_no is null or trim(bed_no) = '') and deleted = 0")
+ Integer bindSharedPoolItem(@Param("id") Integer id, @Param("roomId") Long roomId,
+ @Param("roomName") String roomName, @Param("bedNo") String bedNo);
+
+ /**
+ * 鍙彿锛氭妸鍏变韩姹�(20)/鍏变韩鎺掗槦涓�(10)鐨勬偅鑰呮敼涓恒�屽氨璇婁腑(30)銆嶅苟缁戝畾鍒板彨鍙疯瘖瀹ゃ��
+ * <p>{@code and status = #{curStatus}} 淇濊瘉涓や釜璇婂鍚屾椂鍙悓涓�浜烘椂鍙湁涓�涓垚鍔熴��
+ */
+ @Update("update lihu.queue set status = 30, room_id = #{roomId}, room_name = #{roomName}, bed_no = #{bedNo} " +
+ " where id = #{id} and status = #{curStatus} and deleted = 0")
+ Integer callSharedItem(@Param("id") Integer id, @Param("roomId") Long roomId,
+ @Param("roomName") String roomName, @Param("bedNo") String bedNo,
+ @Param("curStatus") Integer curStatus);
+
+ /**
+ * 闂瘖/璺ㄥぉ鏀跺熬锛氭妸鍏变韩姹犻噷鏈粦瀹氱殑銆屽噯澶囦腑(20)銆嶉��鍥炪�屾帓闃熶腑(10)銆嶃��
+ */
+ @Update("update lihu.queue set status = 10, room_id = 0, room_name = '', bed_no = null " +
+ " where status = 20 and (bed_no is null or trim(bed_no) = '') and deleted = 0")
+ Integer releaseSharedPoolToWaiting();
+
+ /**
+ * 鍏变韩椤圭洰銆岃繃鍙�(5)銆嶅彫鍥烇細**鍥炲叡浜睜**锛堟竻绌鸿瘖瀹�/宸ヤ綅锛岀疆涓烘帓闃熶腑(10)锛夛紝
+ * 闅忓悗鐢辨睜濉厖鍣ㄦ寜瀹归噺鎻愬崌涓哄噯澶囦腑锛屼换涓�璇婂閮藉彲鍙��
+ */
+ @Update("update lihu.queue set status = #{newStatus}, passed = 1, room_id = 0, room_name = '', bed_no = null " +
+ " where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus} " +
+ " and pat_id = #{patId} and book_check_type = #{checkType} and deleted = 0")
+ Integer recallPassedPatientToPool(@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) 鈫� 鎺掗槦涓�(10)锛屽苟娓呯┖璇婂/宸ヤ綅锛堝洖鍏变韩姹狅級銆�
+ */
+ @Update("update lihu.queue set status = 10, room_id = 0, room_name = '', bed_no = null " +
+ " where id = #{id} and status = 30 and deleted = 0")
+ Integer undoCallToSharedPool(@Param("id") Integer id);
+
+ /**
+ * 鍏变韩椤圭洰銆屾挙閿�瀹屾垚銆嶏細宸插氨璇�(40) 鈫� 鎺掗槦涓�(10)锛屽苟娓呯┖璇婂/宸ヤ綅锛堝洖鍏变韩姹狅級銆�
+ */
+ @Update("update lihu.queue set status = 10, passed = 0, room_id = 0, room_name = '', bed_no = null " +
+ " where room_id = #{roomId} and bed_no = #{bedNo} and status = 40 " +
+ " and pat_id = #{patId} and book_check_type = #{checkType} " +
+ " and TO_DAYS(book_date) = TO_DAYS(NOW())")
+ Integer undoFinishToSharedPool(@Param("roomId") Long roomId, @Param("bedNo") String bedNo,
+ @Param("patId") String patId, @Param("checkType") Integer checkType);
}
--
Gitblit v1.9.3