From ca64d931ce30254e34d64ce28cf3a53e54a9159f Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期一, 26 八月 2024 09:32:50 +0800
Subject: [PATCH] update

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/queueController.java |   15 +++--
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomPageReqVO.java |    5 +
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomSaveReqVO.java |    6 +
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueServiceImpl.java         |   27 +++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java              |    7 +
 sql/mysql/jh.sql                                                                                                |    3 
 jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/BedStatusEnum.java                    |   49 ++++++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomRespVO.java    |    6 +
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomDO.java             |   14 +++-
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomStatisticsDO.java   |    2 
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueService.java             |   10 +-
 11 files changed, 120 insertions(+), 24 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/BedStatusEnum.java b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/BedStatusEnum.java
new file mode 100644
index 0000000..47a256d
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/BedStatusEnum.java
@@ -0,0 +1,49 @@
+package cn.lihu.jh.module.ecg.enums;
+
+import cn.lihu.jh.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 閫氱敤鐘舵�佹灇涓�
+ *
+ * @author 鑺嬮亾婧愮爜
+ */
+@Getter
+@AllArgsConstructor
+public enum BedStatusEnum implements IntArrayValuable {
+    CLOSED((byte)0, "宸插叧闂�"),
+    CLOSING((byte)1, "鍏抽棴涓�"),
+    OPENING((byte)10, "宸插紑閫�"),
+    DOCTOR_ON((byte)20, "鏈夊尰鐢�"),
+    PAUSE((byte)30, "鏆傚仠");
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BedStatusEnum::getStatus).toArray();
+
+    /**
+     * 鐘舵�佸��
+     */
+    private final Byte status;
+    /**
+     * 鐘舵�佸悕
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+/*
+    public static boolean isEnable(Integer status) {
+        return ObjUtil.equal(ENABLE.status, status);
+    }
+
+    public static boolean isDisable(Integer status) {
+        return ObjUtil.equal(DISABLE.status, status);
+    }
+*/
+
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/queueController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/queueController.java
index 413f552..3174a56 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/queueController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/queueController.java
@@ -95,12 +95,15 @@
                         BeanUtils.toBean(list, QueueRespVO.class));
     }
 
-    @GetMapping("/opening-setting")
-    @Operation(summary = "寮�璇婅缃�")
-    @PreAuthorize("@ss.hasPermission('ecg:queue:setting')")
-    public CommonResult<Integer> openingSetting() {
-        // 浠嶥B鍚屾宸ヤ綅鐨勬偅鑰呴槦鍒楁暟鎹埌 宸ヤ綅浼樺厛闃熷垪, 鍙兘鏈夋柊寮�宸ヤ綅
-        queueService.initBedQueueAndSeqNumFromDB();
+    @GetMapping("/bed-control")
+    @Operation(summary = "宸ヤ綅鎺у埗")
+    @PreAuthorize("@ss.hasPermission('ecg:queue:bedcontrol')")
+    public CommonResult<Integer> bedControl(
+        @RequestParam("roomId") Long roomId,
+        @RequestParam("bedNo") String bedNo,
+        @RequestParam("status") Integer status)
+    {
+        queueService.bedControl(roomId, bedNo, status);
         return success(0);
     }
 
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomPageReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomPageReqVO.java
index 54431fa..99d343d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomPageReqVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomPageReqVO.java
@@ -25,7 +25,10 @@
     private String bedNo;
 
     @Schema(description = "寮�璇婄姸鎬�")
-    private Boolean onstage;
+    private Integer status;
+
+    @Schema(description = "鍖荤敓鍚�")
+    private String doctorName;
 
     @Schema(description = "鍒涘缓鏃堕棿")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomRespVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomRespVO.java
index cb522f1..a892bd4 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomRespVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomRespVO.java
@@ -30,7 +30,11 @@
 
     @Schema(description = "寮�璇婄姸鎬�", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("寮�璇婄姸鎬�")
-    private Boolean onstage;
+    private Integer status;
+
+    @Schema(description = "鍖荤敓鍚�", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("鍖荤敓鍚�")
+    private String doctorName;
 
     @Schema(description = "鍒涘缓鏃堕棿", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("鍒涘缓鏃堕棿")
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomSaveReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomSaveReqVO.java
index 03786de..ba2d9f2 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomSaveReqVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/vo/RoomSaveReqVO.java
@@ -29,7 +29,9 @@
     private String bedNo;
 
     @Schema(description = "寮�璇婄姸鎬�", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotNull
-    private Boolean onstage;
+    private Integer status;
+
+    @Schema(description = "鍖荤敓鍚�", requiredMode = Schema.RequiredMode.REQUIRED)
+    private String doctorName;
 
 }
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomDO.java
index ac0b47f..0fde66d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomDO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomDO.java
@@ -39,9 +39,13 @@
      * 璇婄枟搴婄紪鍙�
      */
     private String bedNo;
-    /**
-     * 璇婄枟搴婂紑璇婄姸鎬�
-     */
-    private Boolean onstage;
 
-}
\ No newline at end of file
+    /**
+     * 璇婄枟搴婄姸鎬�  0:鍋滆瘖 10:寮�璇� 20:鏆傚仠
+     */
+    private Integer status;
+    /**
+     * 鍖荤敓鍚�
+     */
+    private String doctorName;
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomStatisticsDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomStatisticsDO.java
index cb7e2dc..d1b16fd 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomStatisticsDO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/room/RoomStatisticsDO.java
@@ -6,5 +6,5 @@
 public class RoomStatisticsDO {
     Long roomId;
     String roomName;
-    Integer bedNum;
+    Integer bedNo;
 }
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java
index 7298f70..0f0a194 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java
@@ -11,6 +11,7 @@
 import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomStatisticsDO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 /**
  * 璇婂鍜岃瘖鐤楀簥 Mapper
@@ -31,7 +32,9 @@
     @Select({ "SELECT room_id, room_name, count(1) as bed_num FROM lihu.clinic_room group by room_id;" })
     List<RoomStatisticsDO> roomStatistic();
 
-    @Select({ "SELECT id, room_id, room_name, bed_no, onstage FROM lihu.clinic_room where onstage=true;" })
+    @Select({ "SELECT id, room_id, room_name, bed_no, status, doctor_name FROM lihu.clinic_room where status > 0;" })
     List<RoomDO> simpleRoomList();
 
-}
\ No newline at end of file
+    @Update( "update lihu.clinic_room set status=#{status} where room_id=#{roomId} and bed_no=#{bedNo}" )
+    Integer setBedStatus(Long roomId, String bedNo, Integer status);
+}
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 2555762..c342b25 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
@@ -40,6 +40,11 @@
     void deletequeue(Integer id);
 
     /**
+     *
+     */
+    Integer bedControl(Long roomId, String bedNo, Integer status);
+
+    /**
      * 鑾峰緱鎺掗槦
      *
      * @param id 缂栧彿
@@ -60,11 +65,6 @@
      * @param queueSaveReqVO
      */
     void queue(QueueSaveReqVO queueSaveReqVO);
-
-    /**
-     * 绯荤粺閲嶅惎鏃讹紝浠嶥B鍚屾宸ヤ綅鐨勬偅鑰呴槦鍒楁暟鎹埌 宸ヤ綅浼樺厛闃熷垪
-     */
-    void initBedQueueAndSeqNumFromDB();
 
     /**
      * 鎶婂尰鐢熷�欒瘖鐨勯槦鍒楀婊�
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 6bdd64e..8a806d3 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
@@ -77,6 +77,33 @@
         queueMapper.deleteById(id);
     }
 
+    @Override
+    public Integer bedControl(Long roomId, String bedNo, Integer status) {
+        // 钀ヤ笟鏈熼棿涓嶈兘鍏抽棴宸ヤ綅
+        if ( status == 0 && openingFlag.get() == 1 )
+            return 301;
+
+        // 褰撳墠鐘舵��
+        roomMapper.select
+
+        // DB update
+        Integer updateNum = roomMapper.setBedStatus(roomId, bedNo, status);
+        if ( null==updateNum || 0 == updateNum )
+            return 310;
+
+        if ( status == 10 ) {
+            BedQueueBO bedQueueBO = new BedQueueBO();
+            bedQueueBO.setRoomId(roomId);
+            bedQueueBO.setBedNo(bedNo);
+            bedQueueBO.setMaxQueueNum(MAX_QUEUE_NUM);
+            bedQueueBO.setQueueNum(new AtomicInteger(0));
+            priorityQueue.offer(bedQueueBO);
+            mapBedVsQueue.put(String.format("%09d%s", bedQueueBO.roomId, bedQueueBO.bedNo), bedQueueBO);
+        }
+
+        return 0;
+    }
+
     private void validatequeueExists(Integer id) {
         if (queueMapper.selectById(id) == null) {
             throw exception(QUEUE_NOT_EXISTS);
diff --git a/sql/mysql/jh.sql b/sql/mysql/jh.sql
index aa49538..79a456c 100644
--- a/sql/mysql/jh.sql
+++ b/sql/mysql/jh.sql
@@ -80,7 +80,8 @@
   `room_id` BIGINT NOT NULL COMMENT '璇婂缂栧彿',
   `room_name` varchar(10) NOT NULL COMMENT '璇婂鍚嶇О',
   `bed_no` varchar(10) NOT NULL COMMENT '璇婄枟搴婄紪鍙�',
-  `onstage` bit(1) 1 COMMENT '寮�璇�',
+  `status` int 0 COMMENT '0:鍋滆瘖 10:寮�璇� 20:鏆傚仠',
+  `doctor_name` varchar(10) NOT NULL COMMENT '鍖荤敓鍚嶇О',
   `tenant_id` int DEFAULT 1 COMMENT '绉熸埛缂栧彿',
   `creator` varchar(10) DEFAULT '' COMMENT '鍒涘缓鑰�',
   `create_time` datetime NOT NULL COMMENT '鍒涘缓鏃堕棿',

--
Gitblit v1.9.3