From 68ff33beff11310e830b0615b5a81f83fad0f683 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 08 十一月 2026 23:33:14 +0800
Subject: [PATCH] ai优化

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java |  103 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 98 insertions(+), 5 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
index 6359151..64ab9e6 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
@@ -12,6 +12,7 @@
 import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
 import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO;
 import cn.lihu.jh.module.ecg.enums.QueueStatusEnum;
+import cn.lihu.jh.module.ecg.annotation.RequireBedOwner;
 import cn.lihu.jh.module.ecg.service.call.CallService;
 import cn.lihu.jh.module.ecg.service.queue.QueueService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -25,6 +26,7 @@
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 import static cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS;
@@ -42,9 +44,14 @@
     @Resource
     private QueueService queueService;
 
+    /** 銆愭湰娆′慨澶嶃�戞挙閿�"妫�鏌ュ畬鎴�"鏃跺洖婊氭鏌ュ崟鐘舵�佸苟鍙栨秷纭垂 */
+    @Resource
+    private cn.lihu.jh.module.ecg.service.devrent.DevRentService devRentService;
+
     @Resource
     private CallService callService;
 
+    @RequireBedOwner("鏆傚仠鎺ヨ瘖")
     @GetMapping("/bed-doctor-pause")
     @Operation(summary = "鍖荤敓鏆傚仠")
     @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
@@ -64,6 +71,7 @@
         return error(result);
     }
 
+    @RequireBedOwner("鎭㈠鎺ヨ瘖")
     @GetMapping("/bed-doctor-resume")
     @Operation(summary = "鍖荤敓鎭㈠")
     @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
@@ -86,12 +94,15 @@
     @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
     public CommonResult<Integer> bedDoctorOn(
             @RequestParam("roomId") Long roomId,
-            @RequestParam("bedNo") String bedNo)
+            @RequestParam("bedNo") String bedNo,
+            // 宸ヤ綅涓婚敭锛堝墠绔姹傞噷鏈潵灏卞甫锛夛細浼犲叆鏃朵紭鍏堟寜瀹冨畾浣嶏紝閬垮厤 bed_no 涓庤姹傚��
+            // 瀛樺湪鑲夌溂闅捐鲸鐨勫樊寮傦紙缁撳熬绌烘牸/澶у皬鍐�/鍏ㄨ锛夋椂"鏄庢槑绌洪棽鍗存洿鏂� 0 琛�"
+            @RequestParam(value = "id", required = false) Integer bedId)
     {
         Long userId = SecurityFrameworkUtils.getLoginUserId();
         String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
 
-        ErrorCode result = queueService.startBedDoctorOn(roomId, bedNo, userId, userNickname);
+        ErrorCode result = queueService.startBedDoctorOn(roomId, bedNo, userId, userNickname, bedId);
         if (result.equals(SUCCESS))
             return success(0);
 
@@ -167,6 +178,7 @@
         return result;
     }
 
+    @RequireBedOwner("鍙彿锛氬彇涓嬩竴浣嶆偅鑰�")
     @GetMapping("/finish-next-patient")
     @Operation(summary = "甯歌鍙彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -193,6 +205,7 @@
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
+    @RequireBedOwner("棰嗙敤锛氬彇涓嬩竴浣嶆偅鑰�")
     @GetMapping("/finish-receive-next-patient")
     @Operation(summary = "棰嗙敤鍙彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -219,6 +232,7 @@
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
+    @RequireBedOwner("瑁呮満锛氬彇涓嬩竴浣嶆偅鑰�")
     @GetMapping("/finish-install-next-patient")
     @Operation(summary = "瑁呮満鍙彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -262,6 +276,7 @@
     }
 
     // 甯歌妫�鏌ヨ繃鍙枫�侀鐢ㄨ繃鍙�
+    @RequireBedOwner("杩囧彿")
     @GetMapping("/pass-next-patient")
     @Operation(summary = "杩囧彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -286,6 +301,7 @@
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
+    @RequireBedOwner("瑁呮満杩囧彿")
     @GetMapping("/pass-install-next-patient")
     @Operation(summary = "瀹夎杩囧彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -312,6 +328,7 @@
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
+    @RequireBedOwner("閲嶅彨")
     @GetMapping("/call-again")
     @Operation(summary = "[甯歌妫�鏌鎴朳棰嗙敤] 閲嶅彨銆佹偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -342,6 +359,7 @@
     }
 
 
+    @RequireBedOwner("閲嶅彨锛堝畨瑁咃級")
     @GetMapping("/call-install-again")
     @Operation(summary = "閲嶅彨銆佹偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -382,7 +400,64 @@
             @RequestParam("bedNo") String bedNo)
     {
         List<QueueDO> queueDOList = queueService.getCheckRelatedPatient(roomId, bedNo);
+        // 銆愯嚜鍔╄瘖鏂�戠幇鍦哄娆″嚭鐜�"鍒楄〃鏄┖鐨�"鍗寸湅涓嶅嚭鍘熷洜锛氳繖閲屾妸**鍓嶇闂殑宸ヤ綅 + 鍚庣杩斿洖鍑犳潯**
+        // 鎵撳嚭鏉ワ紝閰嶅悎鎺ュ彛涓�璧风湅灏辫兘绔嬪埢鍖哄垎"鍓嶇闂敊宸ヤ綅 / 鍚庣纭疄娌℃暟鎹� / 椤甸潰娌″埛鏂�"銆�
+        log.info("[getToBeCheckedPatientList] roomId={} bedNo=[{}] 鐧诲綍浜�={} 鈫� 杩斿洖 {} 鏉�",
+                roomId, bedNo, SecurityFrameworkUtils.getLoginUserId(),
+                null == queueDOList ? 0 : queueDOList.size());
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
+    }
+
+    @GetMapping("/get-room-waiting-list")
+    @Operation(summary = "鍙栨湰璇婂銆屾帓闃熶腑锛堟湭鍒嗛厤宸ヤ綅锛夈�嶆偅鑰呭垪琛�")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "121")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "F1")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<List<QueueRespVO>> getRoomWaitingList(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        // 銆愭湰璇婂鏈垎閰嶃�戝�欒瘖鍒楄〃鍙惈"宸插垎娴佸埌鏈伐浣�"鐨勬偅鑰咃紱杩欓噷鎶�"鏈伐浣嶆鏌ョ被鍨嬨��
+        // 杩樻病鍒嗛厤宸ヤ綅"鐨勬帓闃熸偅鑰咃紙澶у睆鑳界湅鍒般�佸伐浣滃彴鍘熷厛鐪嬩笉鍒帮級鍗曠嫭杩斿洖锛屼緵鍖荤敓鎵嬪伐鎷夊叆銆�
+        List<QueueDO> queueDOList = queueService.getUnassignedWaitingPatient(roomId, bedNo);
+        log.info("[getRoomWaitingList] roomId={} bedNo=[{}] 鐧诲綍浜�={} 鈫� 鏈垎閰嶆帓闃熶腑 {} 鏉�",
+                roomId, bedNo, SecurityFrameworkUtils.getLoginUserId(),
+                null == queueDOList ? 0 : queueDOList.size());
+        return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
+    }
+
+    @RequireBedOwner("鎷夊叆鎺掗槦鎮h��")
+    @GetMapping("/pull-waiting-patient")
+    @Operation(summary = "鎶娿�屾帓闃熶腑銆嶇殑鎮h�呮墜宸ユ媺鍏ユ湰宸ヤ綅")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "121")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "F1")
+    @Parameter(name = "id", description = "鎺掗槦琛宨d", required = true, example = "123")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<String> pullWaitingPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo,
+            @RequestParam("id") Integer id)
+    {
+        ErrorCode result = queueService.pullWaitingPatient(roomId, bedNo, id);
+        if (result.equals(SUCCESS))
+            return success("鎿嶄綔鎴愬姛");
+
+        return error(result);
+    }
+
+    @RequireBedOwner("绔嬪嵆琛ヤ汉")
+    @GetMapping("/hurry-up-now")
+    @Operation(summary = "绔嬪嵆琛ヤ汉锛堟墜鍔ㄨЕ鍙戞湰宸ヤ綅鑷姩鍒嗘祦锛屽苟杩斿洖璇婃柇淇℃伅锛�")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "121")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "F1")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<Map<String, Object>> hurryUpNow(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        // 鐜板満鑷晳 + 鑷姪璇婃柇锛氬�欒瘖鍖轰负绌烘椂鐐逛竴涓嬶紝绔嬪埢寰楀埌
+        // 銆岀郴缁熷紑璇婄姸鎬� / 鏄惁鍋滄鍊欒瘖 / 鍊欒瘖涓婇檺 / 琛ヤ汉鍓嶅悗浜烘暟 / 缁撹銆嶃��
+        return success(queueService.hurryUpNow(roomId, bedNo));
     }
 
     @GetMapping("/get-to-be-installed-list")
@@ -438,6 +513,9 @@
         return success(patientStatisticVO);
     }
 
+    // 銆愭湰闇�姹偮锋帓闃熼槦鍒椾緵鏈嶅姟鍙板垎璇婅皟搴︿娇鐢ㄣ�戜笉鍐嶅仛銆屽伐浣嶄富浜恒�嶆牎楠岋細
+    // 鍒嗚瘖鍙颁笉鍗犲骇锛坈linic_room.doc_id 鏄潗璇婂尰鐢燂級锛屽惁鍒欏繀鎶� 1010002003銆屽洿瑙傛ā寮忥紝涓嶈兘鎵ц璇ユ搷浣溿�嶃��
+    // 浠嶄繚鐣� @PreAuthorize('ecg:doctor:task') 鏉冮檺鐐广��
     @GetMapping("/recall-pass-waiting-patient")
     @Operation(summary = "杩囧彿-鎺掗槦涓� 鎮h�呭彫鍥�")
     @Parameter(name = "patId", description = "鎮h�呯紪鍙�", required = true, example = "B2")
@@ -454,6 +532,7 @@
         return success("鎿嶄綔鎴愬姛");
     }
 
+    // 銆愭湰闇�姹偮锋帓闃熼槦鍒椾緵鏈嶅姟鍙板垎璇婅皟搴︿娇鐢ㄣ�戜笉鍐嶅仛銆屽伐浣嶄富浜恒�嶆牎楠岋紙鍘熷洜鍚屼笂锛夈��
     @GetMapping("/recall-patient")
     @Operation(summary = "杩囧彿鐥呬汉鍙洖")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -475,6 +554,7 @@
         return success("鎿嶄綔鎴愬姛");
     }
 
+    // 銆愭湰闇�姹偮锋帓闃熼槦鍒椾緵鏈嶅姟鍙板垎璇婅皟搴︿娇鐢ㄣ�戜笉鍐嶅仛銆屽伐浣嶄富浜恒�嶆牎楠岋紙鍘熷洜鍚屼笂锛夈��
     @GetMapping("/recall-install-patient")
     @Operation(summary = "杩囧彿瀹夎鐥呬汉鍙洖")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -490,10 +570,15 @@
             @RequestParam("roomId_operator") Long roomId_operator,
             @RequestParam("bedNo_operator") String bedNo_operator )
     {
-        if (roomId != roomId_operator)
-            return error(QUEUE_RECALL_INSTALL_NOT_CUR_ROOM);
+        // 銆愭湰闇�姹偮锋帓闃熼槦鍒椾緵鏈嶅姟鍙板垎璇婅皟搴︿娇鐢ㄣ�戝幓鎺夈�屾搷浣滆�呭伐浣嶅繀椤荤瓑浜庢偅鑰呭伐浣嶃�嶇殑鏍¢獙锛�
+        //   路 鍒嗚瘖鍙颁笉鍗犲骇锛宺oomId_operator / bedNo_operator 鍙兘鏄┖鎴栦笌鏈嶅姟鍙板綋鍓嶅伐浣嶄笉涓�鑷达紱
+        //   路 鎺掗槦闃熷垪椤典紶鐨勬槸**闃熷垪琛屽唴鐨勫伐浣�**锛屾湰鏉ヤ篃鍙敤浜庝翰鍜岄」閲嶆柊瀹氫綅銆�
+        // 鍘熸牎楠岋細if (roomId != roomId_operator) return error(QUEUE_RECALL_INSTALL_NOT_CUR_ROOM);
+        // 鐜板湪锛氭搷浣滆�呭伐浣嶇己澶辨椂锛岄��鍖栦负鐢ㄦ偅鑰呴槦鍒楄涓婄殑宸ヤ綅锛坮oomId/bedNo锛夈��
+        Long operatorRoomId = (null != roomId_operator) ? roomId_operator : roomId;
+        String operatorBedNo = (null != bedNo_operator && !bedNo_operator.isEmpty()) ? bedNo_operator : bedNo;
 
-        Integer result = queueService.recallInstallPatient(roomId, bedNo, patId, checkType, roomId_operator, bedNo_operator);
+        Integer result = queueService.recallInstallPatient(roomId, bedNo, patId, checkType, operatorRoomId, operatorBedNo);
         if (null == result || 0 == result)
             return error(PATIENT_NOT_EXISTS);
 
@@ -502,6 +587,7 @@
 
     // ==================== 闇�姹�2锛氭挙閿�銆屽彨鍙� / 妫�鏌ュ畬鎴愩�� ====================
 
+    @RequireBedOwner("鎾ら攢妫�鏌ュ畬鎴�")
     @GetMapping("/undo-finish-patient")
     @Operation(summary = "鎾ら攢妫�鏌ュ畬鎴愶細宸插氨璇�(40) 鈫� 鍊欒瘖涓�(20)")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -519,9 +605,14 @@
         if (null == result || 0 == result) {
             return error(APPOINTMENT_NOT_EXISTS);
         }
+        // 銆愭湰娆′慨澶嶃�戝彧鍥炴粴闃熷垪鐘舵�佹槸涓嶅鐨勶細妫�鏌ュ崟(dev_rent)浠嶅仠鍦ㄣ�屽父瑙勬鏌ュ畬鎴�(60)銆嶏紝
+        // 鍓嶇鍐嶆瀹屾垚鏃跺彇涓嶅埌銆屽緟妫�鏌ャ�嶅崟锛坮entId 涓虹┖锛夆啋 鍚庣鎶ャ�岃鍏堥绾︾‘璁ゃ�嶃��
+        // 杩欓噷鎶婃鏌ュ崟鍥炴粴鎴愩�屽緟妫�鏌ャ�嶅苟鍙栨秷纭垂锛堝唴閮ㄥ凡 try/catch锛屽け璐ヤ笉褰卞搷鎾ら攢缁撴灉锛夈��
+        devRentService.rollbackRoutineFinish(patId, checkType);
         return success("宸叉挙閿�妫�鏌ュ畬鎴愶紝鎮h�呭凡杩斿洖鍊欒瘖鍖�");
     }
 
+    @RequireBedOwner("鎾ら攢鍙彿")
     @GetMapping("/undo-call-patient")
     @Operation(summary = "鎾ら攢鍙彿锛氬氨璇婁腑(30) 鈫� 鍊欒瘖涓�(20)")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -551,6 +642,7 @@
 
     // ==================== 闇�姹�3锛氬仠姝㈠�欒瘖寮�鍏� ====================
 
+    @RequireBedOwner("鍋滄鍊欒瘖")
     @GetMapping("/stop-ready")
     @Operation(summary = "鍋滄鍊欒瘖锛氫笉鍐嶆柊澧炲�欒瘖鎮h�咃紙宸叉湁鍊欒瘖浠嶅彲鍙彿锛�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -566,6 +658,7 @@
         return success(true);
     }
 
+    @RequireBedOwner("鎭㈠鍊欒瘖")
     @GetMapping("/resume-ready")
     @Operation(summary = "鎭㈠鍊欒瘖锛氶噸鏂板紑濮嬫帴鏀跺�欒瘖鎮h��")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")

--
Gitblit v1.9.3