From 2bc90e242eceb83d9aa80d48ea9f991c0f9b99c6 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 12 十二月 2024 19:47:57 +0800
Subject: [PATCH] 工位选择界面 诊室按照room id排序

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java |  198 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 144 insertions(+), 54 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 9ce1e5b..e89911a 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
@@ -28,8 +28,7 @@
 import static cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS;
 import static cn.lihu.jh.framework.common.pojo.CommonResult.error;
 import static cn.lihu.jh.framework.common.pojo.CommonResult.success;
-import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.ECG_INNER_ERROR;
-import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.PATIENT_NOT_EXISTS;
+import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
 
 @Tag(name = "绠$悊鍚庡彴 - 鍖荤敓鍙彿")
 @RestController
@@ -136,15 +135,12 @@
     {
         queueService.finishNextPatient(roomId, bedNo);
 
-        List<Byte> queueStatusList = new ArrayList<>();
-        queueStatusList.add(QueueStatusEnum.RECALLED.getStatus());
-        queueStatusList.add(QueueStatusEnum.READY.getStatus());
-        queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
-        queueStatusList.add(QueueStatusEnum.PASSED.getStatus());
-        List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+        List<QueueDO> queueDOList = queueService.getToBeCheckedPatient(roomId, bedNo);
 
         // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
-        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        QueueDO onStageItem = queueDOList.stream().filter(item ->
+                item.getStatus() == QueueStatusEnum.ONSTAGE.getStatus() && item.getAffinityItem() == 0
+        ).findFirst().orElse(null);
         if (null != onStageItem) {
             CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
             callSaveReqVO.setId(null);
@@ -165,15 +161,12 @@
     {
         queueService.finishReceiveNextPatient(roomId, bedNo);
 
-        List<Byte> queueStatusList = new ArrayList<>();
-        queueStatusList.add(QueueStatusEnum.RECALLED.getStatus());
-        queueStatusList.add(QueueStatusEnum.READY.getStatus());
-        queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
-        queueStatusList.add(QueueStatusEnum.PASSED.getStatus());
-        List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+        List<QueueDO> queueDOList = queueService.getToBeCheckedPatient(roomId, bedNo);
 
         // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
-        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        QueueDO onStageItem = queueDOList.stream().filter(item ->
+                item.getStatus() == QueueStatusEnum.ONSTAGE.getStatus() && item.getAffinityItem() == 0
+        ).findFirst().orElse(null);
         if (null != onStageItem) {
             CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
             callSaveReqVO.setId(null);
@@ -194,26 +187,38 @@
     {
         queueService.finishInstallNextPatient(roomId, bedNo);
 
-        List<Byte> queueStatusList = new ArrayList<>();
-        queueStatusList.add(QueueStatusEnum.RECEIVED.getStatus());
-        List<QueueDO> queueDOList = queueService.getRoomQueueByStatus(roomId, queueStatusList);
+        List<QueueDO> queueDOList = queueService.getToBeInstalledPatient(roomId, bedNo); // 寰呭畨瑁呯殑鎮h��
 
-        queueStatusList.clear();
-        queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus());
-        List<QueueDO> installingQueueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
-        queueDOList.addAll(0, installingQueueDOList );
-
+        List<QueueDO> installingQueueDOList = queueDOList.stream().filter(queueDO ->
+                queueDO.getStatus() == QueueStatusEnum.INSTALLING.getStatus() && queueDO.getAffinityItem() == 0
+        ).toList();
         // 杩囨护鍑�  [瀹夎涓璢 鐨勶紝鍑嗗鍙彿   璇ュ伐浣嶅簲璇� 鏈�澶氬彧鏈変竴涓� [瀹夎涓璢
         if (installingQueueDOList.size() > 0) {
             QueueDO onStageItem = installingQueueDOList.getFirst();
             CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
             callSaveReqVO.setId(null);
+            callSaveReqVO.setCallType(1); // 瑁呮満鍙彿
             callService.createCall(callSaveReqVO);
         }
 
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
+    // 甯歌妫�鏌ヨ繃鍙枫�侀鐢ㄨ繃鍙�
+    @GetMapping("/pass-waiting-patient")
+    @Operation(summary = "杩囧彿鎺掗槦涓偅鑰�")
+    @Parameter(name = "patId", description = "鎮h�呯紪鍙�", required = true, example = "20247845")
+    @Parameter(name = "checkType", description = "棰勭害妫�鏌ョ被鍨�", required = true, example = "100")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<Integer> passWaitingPatient(
+            @RequestParam("patId") String patId,
+            @RequestParam("checkType") Integer checkType)
+    {
+        queueService.passWaitingPatient( patId, checkType );
+        return success(0);
+    }
+
+    // 甯歌妫�鏌ヨ繃鍙枫�侀鐢ㄨ繃鍙�
     @GetMapping("/pass-next-patient")
     @Operation(summary = "杩囧彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -225,12 +230,7 @@
     {
         queueService.passNextPatient(roomId, bedNo);
 
-        List<Byte> queueStatusList = new ArrayList<>();
-        queueStatusList.add(QueueStatusEnum.RECALLED.getStatus());
-        queueStatusList.add(QueueStatusEnum.READY.getStatus());
-        queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
-        queueStatusList.add(QueueStatusEnum.PASSED.getStatus());
-        List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+        List<QueueDO> queueDOList = queueService.getToBeCheckedPatient(roomId, bedNo);
 
         // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
         QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
@@ -243,16 +243,42 @@
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
-    @GetMapping("/call-again")
-    @Operation(summary = "閲嶅彨銆佹偅鑰�")
+    @GetMapping("/pass-install-next-patient")
+    @Operation(summary = "瀹夎杩囧彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
     @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
     @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
-    public CommonResult<String> callAgainPatient(
+    public CommonResult<List<QueueRespVO>> passInstallNextPatient(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo)
     {
-        List<Byte> queueStatusList = new ArrayList<>();
+        queueService.passInstallNextPatient(roomId, bedNo);
+
+        List<QueueDO> queueDOList = queueService.getToBeInstalledPatient(roomId, bedNo);
+
+        List<QueueDO> installingQueueDOList = queueDOList.stream().filter(queueDO -> queueDO.getStatus() == QueueStatusEnum.INSTALLING.getStatus()).toList();
+        // 杩囨护鍑�  [瀹夎涓璢 鐨勶紝鍑嗗鍙彿   璇ュ伐浣嶅簲璇� 鏈�澶氬彧鏈変竴涓� [瀹夎涓璢
+        if (installingQueueDOList.size() > 0) {
+            QueueDO onStageItem = installingQueueDOList.getFirst();
+            CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+            callSaveReqVO.setId(null);
+            callSaveReqVO.setCallType(1); // 瑁呮満鍙彿
+            callService.createCall(callSaveReqVO);
+        }
+
+        return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
+    }
+
+    @GetMapping("/call-again")
+    @Operation(summary = "[甯歌妫�鏌鎴朳棰嗙敤] 閲嶅彨銆佹偅鑰�")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<String> callPatientAgain(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        List<Integer> queueStatusList = new ArrayList<>();
         queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
         List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
 
@@ -272,40 +298,60 @@
         return success("鎿嶄綔鎴愬姛");
     }
 
-    @GetMapping("/get-patient-list")
-    @Operation(summary = "鍙栨偅鑰呭垪琛�")
+
+    @GetMapping("/call-install-again")
+    @Operation(summary = "閲嶅彨銆佹偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
     @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
     @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
-    public CommonResult<List<QueueRespVO>> getPatientList(
+    public CommonResult<String> callInstallingPatientAgain(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo)
     {
-        List<Byte> queueStatusList = new ArrayList<>();
-        queueStatusList.add(QueueStatusEnum.RECALLED.getStatus());
-        queueStatusList.add(QueueStatusEnum.READY.getStatus());
-        queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
-        queueStatusList.add(QueueStatusEnum.PASSED.getStatus());
+        List<Integer> queueStatusList = new ArrayList<>();
+        queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus());
         List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+
+        if (queueDOList.isEmpty())
+            return success("鏃犲畨瑁呬腑鐨勬偅鑰�");
+
+        if (queueDOList.size() > 1) {
+            log.error("room {} bed {} have {} 瀹夎涓殑鎮h��", roomId, bedNo, queueDOList.size());
+            return error(ECG_INNER_ERROR);
+        }
+
+        QueueDO onStageItem = queueDOList.get(0);
+        CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+        callSaveReqVO.setId(null);
+        callSaveReqVO.setCallType(1); // 瑁呮満鍙彿
+        callService.callAgain(callSaveReqVO);
+
+        return success("鎿嶄綔鎴愬姛");
+    }
+
+    @GetMapping("/get-to-be-checked-list")
+    @Operation(summary = "鍙� [甯歌妫�鏌 鎴� [寰呴鐢╙ 鎮h�呭垪琛�")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<List<QueueRespVO>> getToBeCheckedPatientList(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        List<QueueDO> queueDOList = queueService.getToBeCheckedPatient(roomId, bedNo);
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
-    @GetMapping("/get-received-patient-list")
-    @Operation(summary = "鍙栧凡棰嗙敤鎮h�呭垪琛�")
+    @GetMapping("/get-to-be-installed-list")
+    @Operation(summary = "鍙� [寰呭畨瑁匽 鎮h�呭垪琛�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
     @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
     @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
-    public CommonResult<List<QueueRespVO>> getReceivedPatientList(
+    public CommonResult<List<QueueRespVO>> getToBeInstalledPatientList(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo)
     {
-        List<Byte> queueStatusList = new ArrayList<>();
-        queueStatusList.add(QueueStatusEnum.RECEIVED.getStatus());
-        List<QueueDO> queueDOList = queueService.getRoomQueueByStatus(roomId, queueStatusList);
-
-        queueStatusList.clear();
-        queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus());
-        queueDOList.addAll(0, queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList) );
+        List<QueueDO> queueDOList = queueService.getToBeInstalledPatient(roomId, bedNo);
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
@@ -349,6 +395,22 @@
         return success(patientStatisticVO);
     }
 
+    @GetMapping("/recall-pass-waiting-patient")
+    @Operation(summary = "杩囧彿-鎺掗槦涓� 鎮h�呭彫鍥�")
+    @Parameter(name = "patId", description = "鎮h�呯紪鍙�", required = true, example = "B2")
+    @Parameter(name = "checkType", description = "棰勭害妫�鏌ョ被鍨�", required = true, example = "100")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<String> recallPatient(
+            @RequestParam("patId") String patId,
+            @RequestParam("checkType") Integer checkType)
+    {
+        Integer result = queueService.recallPassWaitingPatient(patId, checkType);
+        if (null == result || 0 == result)
+            return error(PATIENT_NOT_EXISTS);
+
+        return success("鎿嶄綔鎴愬姛");
+    }
+
     @GetMapping("/recall-patient")
     @Operation(summary = "杩囧彿鐥呬汉鍙洖")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
@@ -358,9 +420,37 @@
     public CommonResult<String> recallPatient(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo,
-            @RequestParam("patId") String patId )
+            @RequestParam("patId") String patId,
+            @RequestParam("checkType") Integer checkType,
+            @RequestParam("roomId_operator") Long roomId_operator,
+            @RequestParam("bedNo_operator") String bedNo_operator )
     {
-        Integer result = queueService.recallPatient(roomId, bedNo, patId);
+        Integer result = queueService.recallPatient(roomId, bedNo, patId, checkType);
+        if (null == result || 0 == result)
+            return error(PATIENT_NOT_EXISTS);
+
+        return success("鎿嶄綔鎴愬姛");
+    }
+
+    @GetMapping("/recall-install-patient")
+    @Operation(summary = "杩囧彿瀹夎鐥呬汉鍙洖")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
+    @Parameter(name = "patId", description = "鎮h�呯紪鍙�", required = true, example = "B2")
+    @Parameter(name = "checkType", description = "妫�鏌ョ被鍨�", required = true, example = "100")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<String> recallInstallPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo,
+            @RequestParam("patId") String patId,
+            @RequestParam("checkType") Integer checkType,
+            @RequestParam("roomId_operator") Long roomId_operator,
+            @RequestParam("bedNo_operator") String bedNo_operator )
+    {
+        if (roomId != roomId_operator)
+            return error(QUEUE_RECALL_INSTALL_NOT_CUR_ROOM);
+
+        Integer result = queueService.recallInstallPatient(roomId, bedNo, patId, checkType, roomId_operator, bedNo_operator);
         if (null == result || 0 == result)
             return error(PATIENT_NOT_EXISTS);
 

--
Gitblit v1.9.3