From ae24af77aaa940a64281f9f1bf2fe5ab3f9c68b8 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期五, 30 八月 2024 16:48:41 +0800
Subject: [PATCH] update

---
 jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java                   |    3 +
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueServiceImpl.java             |   37 ++++++++++++++++--
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextPatientCallable.java |   25 ++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueService.java                 |    5 ++
 4 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
index 7dbe8dc..0191cf8 100644
--- a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
+++ b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
@@ -16,5 +16,6 @@
     ErrorCode ROOM_INVALID_STATUS = new ErrorCode(1_010_002_001, "璇婂鍜岃瘖鐤楀簥鐘舵�佸紓甯�");
     ErrorCode QUEUE_NOT_EXISTS = new ErrorCode(1_010_003_000, "鎺掗槦涓嶅瓨鍦�");
     ErrorCode QUEUE_BED_ABNORMAL = new ErrorCode(1_010_003_001, "宸ヤ綅闃熷垪涓嶅瓨鍦�");
-    ErrorCode QUEUE_HAVE_PATIENT = new ErrorCode(1_010_003_001, "鎮h�呴槦鍒椾腑");
+    ErrorCode QUEUE_HAVE_PATIENT = new ErrorCode(1_010_003_002, "闃熷垪涓湁鎮h��");
+    ErrorCode QUEUE_NOT_READY_PATIENT = new ErrorCode(1_010_003_003, "娌℃湁鍑嗗涓殑鎮h��");
 }
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextPatientCallable.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextPatientCallable.java
new file mode 100644
index 0000000..9c58211
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextPatientCallable.java
@@ -0,0 +1,25 @@
+package cn.lihu.jh.module.ecg.service.queue;
+
+import cn.lihu.jh.framework.common.exception.ErrorCode;
+
+import java.util.concurrent.Callable;
+
+public class BedDoctorNextPatientCallable implements Callable<ErrorCode> {
+
+    QueueService queueService;
+    private Long roomId;
+    private String bedNo;
+
+    public BedDoctorNextPatientCallable(QueueService queueService, Long roomId, String bedNo)
+    {
+        super();
+        this.roomId = roomId;
+        this.bedNo = bedNo;
+        this.queueService = queueService;
+    }
+
+    public ErrorCode call() throws Exception {
+        return queueService.nextPatient(roomId, bedNo);
+    }
+
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueService.java
index 7bae87b..9a3bb4b 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueService.java
@@ -55,6 +55,7 @@
     ErrorCode startBedDoctorResume(Long roomId, String bedNo, Long docId, String docName);
     ErrorCode startBedDoctorOn(Long roomId, String bedNo, Long docId, String docName);
     ErrorCode startBedDoctorOff(Long roomId, String bedNo, Long docId, String docName);
+    ErrorCode startNextPatient(Long roomId, String bedNo);
 
     ErrorCode bedOpen(Long roomId, String bedNo);
     ErrorCode bedClose(Long roomId, String bedNo);
@@ -62,7 +63,10 @@
     ErrorCode bedDoctorResume(Long roomId, String bedNo, Long docId, String docName);
     ErrorCode bedDoctorOn(Long roomId, String bedNo, Long docId, String docName);
     ErrorCode bedDoctorOff(Long roomId, String bedNo, Long docId, String docName);
+    ErrorCode nextPatient(Long roomId, String bedNo);
+
     CommonResult<RoomRespVO> getRoom(Long roomId, String bedNo, Long docId);
+
     /**
      * 鑾峰緱鎺掗槦
      *
@@ -85,6 +89,7 @@
      */
     void queue(QueueSaveReqVO queueSaveReqVO);
 
+
     /**
      * 鎶婂尰鐢熷�欒瘖鐨勯槦鍒楀婊�
      */
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueServiceImpl.java
index 5b7e2ac..f6ca95c 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueServiceImpl.java
@@ -109,6 +109,7 @@
             e.printStackTrace();
         }
 
+        System.out.println("startBedOpen ========");
         return ECG_INNER_ERROR;
     }
 
@@ -125,6 +126,7 @@
             e.printStackTrace();
         }
 
+        System.out.println("startBedClose ========");
         return ECG_INNER_ERROR;
     }
 
@@ -143,6 +145,7 @@
             e.printStackTrace();
         }
 
+        System.out.println("startBedDoctorPause ========");
         return ECG_INNER_ERROR;
     }
 
@@ -161,6 +164,7 @@
             e.printStackTrace();
         }
 
+        System.out.println("startBedDoctorResume ========");
         return ECG_INNER_ERROR;
     }
 
@@ -179,6 +183,7 @@
             e.printStackTrace();
         }
 
+        System.out.println("startBedDoctorOn ========");
         return ECG_INNER_ERROR;
     }
 
@@ -197,6 +202,26 @@
             e.printStackTrace();
         }
 
+        System.out.println("startBedDoctorOff ========");
+        return ECG_INNER_ERROR;
+    }
+
+    @Override
+    public ErrorCode startNextPatient(Long roomId, String bedNo) {
+        Future<ErrorCode> future = singleThreadExecutor.submit(
+                new BedDoctorNextPatientCallable(this, roomId, bedNo)
+        );
+
+        try {
+            ErrorCode ret = future.get();
+            return ret;
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        } catch (ExecutionException e) {
+            e.printStackTrace();
+        }
+
+        System.out.println("startNextPatient ========");
         return ECG_INNER_ERROR;
     }
 
@@ -491,14 +516,15 @@
         startHurryUp();
     }
 
-    private void nextPatient(Long roomId, String bedNo) {
+    @Override
+    public ErrorCode nextPatient(Long roomId, String bedNo) {
         // 浠� DB 鎶� 搴忓彿鏈�灏忕殑 灏辫瘖鍑嗗涓殑浜� 璁剧疆涓哄氨璇婁腑
         Integer updateNum = queueMapper.updateQueueStatus(roomId, bedNo,
                 QueueStatusEnum.READY.getStatus(), QueueStatusEnum.ONSTAGE.getStatus());
 
         // 璇ュ伐浣� 娌℃湁 灏辫瘖鍑嗗涓� 浜哄憳
         if (null == updateNum || 0 == updateNum) {
-            return;
+            return QUEUE_NOT_READY_PATIENT;
         }
 
         // 浼樺厛闃熷垪涓� 璇ュ伐浣� 灏辫瘖鍑嗗涓汉鐨勬暟閲� 鍑忎竴
@@ -507,7 +533,8 @@
         priorityQueue.remove(bo);
         priorityQueue.offer(bo);
 
-        startHurryUp();
+        hurryup();
+        return SUCCESS;
     }
 
     public void finishNextPatient(Long roomId, String bedNo) {
@@ -515,7 +542,7 @@
         Integer ret =  queueMapper.updateQueueStatus(roomId, bedNo,
                 QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.FINISH.getStatus());
 
-        nextPatient(roomId, bedNo);
+        startNextPatient(roomId, bedNo);
     }
 
     public void passNextPatient(Long roomId, String bedNo) {
@@ -523,7 +550,7 @@
         Integer ret =  queueMapper.updateQueueStatus(roomId, bedNo,
                 QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.PASSED.getStatus());
 
-        nextPatient(roomId, bedNo);
+        startNextPatient(roomId, bedNo);
     }
 
     public List<QueueDO> getDoctorQueueByStatus(Long roomId, String bedNo, List<Byte> statusList) {

--
Gitblit v1.9.3