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/controller/admin/doctor/DoctorController.java |  138 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 1 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 a3a4fe6..6359151 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
@@ -7,8 +7,10 @@
 import cn.lihu.jh.module.ecg.controller.admin.call.vo.CallSaveReqVO;
 import cn.lihu.jh.module.ecg.controller.admin.queue.vo.PatientStatisticVO;
 import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueRespVO;
+import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueSaveReqVO;
 import cn.lihu.jh.module.ecg.controller.admin.room.vo.RoomRespVO;
 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.service.call.CallService;
 import cn.lihu.jh.module.ecg.service.queue.QueueService;
@@ -54,8 +56,10 @@
         String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
 
         ErrorCode result = queueService.startBedDoctorPause(roomId, bedNo, userId, userNickname);
-        if (result.equals(SUCCESS))
+        if (result.equals(SUCCESS)) {
+            queueService.updateStop(roomId, bedNo);
             return success(SUCCESS.getCode());
+        }
 
         return error(result);
     }
@@ -109,6 +113,45 @@
             return success(SUCCESS.getCode());
 
         return error(result);
+    }
+
+    /**
+     * 閲婃斁**褰撳墠鐧诲綍鐢ㄦ埛**鍗犵敤鐨勫叏閮ㄨ瘖鐤楀簥浣嶏紙閫�鍑虹郴缁熸椂鑷姩绂诲骇锛夈��
+     *
+     * <p>鑳屾櫙锛氬尰鐢熷湪銆岃瘖瀹ら�夋嫨銆嶉〉閫夊ソ搴婁綅鍚庡嵆鍗犵敤璇ュ簥浣嶏紙{@code clinic_room.doc_id}锛夛紝
+     * 鑻ヤ竴鐩翠笉鐐广�岀搴с�嶅氨閫�鍑虹郴缁燂紝搴婁綅浼氫竴鐩存樉绀鸿鍗犵敤锛屽叾浠栧尰鐢熸棤娉曚娇鐢ㄣ��
+     *
+     * <p>涓� {@link #bedDoctorOff} 鐨勫尯鍒細
+     * <ul>
+     *   <li>{@code /bed-doctor-off} 闇�瑕佸墠绔紶 roomId + bedNo锛堢寮�鏌愪釜**鎸囧畾**搴婁綅锛夛紱</li>
+     *   <li>鏈帴鍙�**涓嶉渶瑕佷换浣曞弬鏁�**锛屾寜褰撳墠鐧诲綍鐢ㄦ埛鍙嶆煡鍏跺崰鐢ㄧ殑**鎵�鏈�**搴婁綅骞堕�愪竴閲婃斁銆�</li>
+     * </ul>
+     * 涔嬫墍浠ュ仛鎴�"鏃犲弬"锛氶��鍑虹櫥褰� / 绌洪棽瓒呮椂 / 浠ょ墝澶辨晥绛夊満鏅笅锛屽墠绔彲鑳藉凡缁忔嬁涓嶅埌
+     * 搴婁綅鐨� roomId/bedNo锛堟湰鍦扮紦瀛樺凡琚竻鐞嗭級锛屾鏃跺彧鑳界敱鏈嶅姟绔寜 userId 鍙嶆煡銆�
+     * 鏈嶅姟绔弽鏌ヤ篃鏇村彲闈� 鈥斺�� 鍓嶇缂撳瓨鐨勫簥浣嶈嫢琚鐞嗗憳鏀瑰姩杩囷紝灏变細鍑虹幇"閲婃斁涓嶆帀"銆�
+     *
+     * <p>骞傜瓑锛氭湭鍗犵敤浠讳綍搴婁綅鏃剁洿鎺ヨ繑鍥炴垚鍔熴��
+     */
+    @PostMapping("/release-my-beds")
+    @Operation(summary = "閲婃斁褰撳墠鐧诲綍鐢ㄦ埛鍗犵敤鐨勫叏閮ㄥ簥浣嶏紙閫�鍑虹郴缁熸椂鑷姩绂诲骇锛�")
+    public CommonResult<Boolean> releaseMyBeds() {
+        Long userId = SecurityFrameworkUtils.getLoginUserId();
+        if (userId == null) {
+            // 鏈櫥褰曪紙鎴栦护鐗屽凡澶辨晥锛夋椂鏃犲簥浣嶅彲閲婃斁锛屾寜鎴愬姛杩斿洖锛岄伩鍏嶅墠绔姤閿�
+            return success(true);
+        }
+        String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+        List<RoomDO> occupiedBeds = queueService.getDocRoomInfo(userId);
+        if (occupiedBeds == null || occupiedBeds.isEmpty()) {
+            return success(true);   // 鏈崰鐢ㄥ簥浣嶏紝鏃犻渶澶勭悊
+        }
+        log.info("[releaseMyBeds] 閫�鍑虹郴缁熻嚜鍔ㄧ搴�. userId={} nickname={} 鍗犵敤搴婁綅鏁�={}",
+                userId, userNickname, occupiedBeds.size());
+        for (RoomDO bed : occupiedBeds) {
+            // 閫愪釜閲婃斁锛涘崟涓け璐ヤ笉褰卞搷鍏跺畠搴婁綅
+            queueService.startBedDoctorOff(bed.getRoomId(), bed.getBedNo(), userId, userNickname);
+        }
+        return success(true);
     }
 
     @GetMapping("/bed-doctor-get")
@@ -457,4 +500,97 @@
         return success("鎿嶄綔鎴愬姛");
     }
 
+    // ==================== 闇�姹�2锛氭挙閿�銆屽彨鍙� / 妫�鏌ュ畬鎴愩�� ====================
+
+    @GetMapping("/undo-finish-patient")
+    @Operation(summary = "鎾ら攢妫�鏌ュ畬鎴愶細宸插氨璇�(40) 鈫� 鍊欒瘖涓�(20)")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "A1")
+    @Parameter(name = "patId", description = "鎮h�呯紪鍙�", required = true, example = "913639423")
+    @Parameter(name = "checkType", description = "妫�鏌ョ被鍨�", required = true, example = "100")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<String> undoFinishPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo,
+            @RequestParam("patId") String patId,
+            @RequestParam("checkType") Integer checkType) {
+        // 璇存槑锛氬繀椤绘寜 patId + checkType 绮剧‘瀹氫綅锛岄伩鍏嶈鎾ら攢鍏朵粬鎮h�咃紙鏃㈡湁缂洪櫡瑙� DevRentServiceImpl锛�
+        Integer result = queueService.undoFinishPatient(roomId, bedNo, patId, checkType);
+        if (null == result || 0 == result) {
+            return error(APPOINTMENT_NOT_EXISTS);
+        }
+        return success("宸叉挙閿�妫�鏌ュ畬鎴愶紝鎮h�呭凡杩斿洖鍊欒瘖鍖�");
+    }
+
+    @GetMapping("/undo-call-patient")
+    @Operation(summary = "鎾ら攢鍙彿锛氬氨璇婁腑(30) 鈫� 鍊欒瘖涓�(20)")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "A1")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<String> undoCallPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo) {
+        Integer result = queueService.undoCallPatient(roomId, bedNo);
+        if (null == result || 0 == result) {
+            return error(QUEUE_NOT_EXISTS);
+        }
+        return success("宸叉挙閿�鍙彿锛屾偅鑰呭凡杩斿洖鍊欒瘖鍖�");
+    }
+
+    @GetMapping("/last-finished-patient")
+    @Operation(summary = "鍙栨湰宸ヤ綅浠婃棩鏈�杩戜竴浣嶅凡瀹屾垚鎮h�咃紙渚涙挙閿�鎻愮ず锛�")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "A1")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<QueueRespVO> lastFinishedPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo) {
+        QueueDO queueDO = queueService.getBedLastFinishedQueueItem(roomId, bedNo);
+        return success(BeanUtils.toBean(queueDO, QueueRespVO.class));
+    }
+
+    // ==================== 闇�姹�3锛氬仠姝㈠�欒瘖寮�鍏� ====================
+
+    @GetMapping("/stop-ready")
+    @Operation(summary = "鍋滄鍊欒瘖锛氫笉鍐嶆柊澧炲�欒瘖鎮h�咃紙宸叉湁鍊欒瘖浠嶅彲鍙彿锛�")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "A1")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<Boolean> stopReady(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo) {
+        ErrorCode ec = queueService.setStopReady(roomId, bedNo, true);
+        if (!SUCCESS.getCode().equals(ec.getCode())) {
+            return error(ec);
+        }
+        return success(true);
+    }
+
+    @GetMapping("/resume-ready")
+    @Operation(summary = "鎭㈠鍊欒瘖锛氶噸鏂板紑濮嬫帴鏀跺�欒瘖鎮h��")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "A1")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<Boolean> resumeReady(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo) {
+        ErrorCode ec = queueService.setStopReady(roomId, bedNo, false);
+        if (!SUCCESS.getCode().equals(ec.getCode())) {
+            return error(ec);
+        }
+        return success(true);
+    }
+
+    @GetMapping("/get-stop-ready")
+    @Operation(summary = "鏌ヨ鍋滄鍊欒瘖鐘舵��")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "A1")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<Boolean> getStopReady(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo) {
+        Boolean stop = queueService.getStopReady(roomId, bedNo);
+        return success(stop != null && stop);
+    }
+
 }

--
Gitblit v1.9.3