From 1a7b7c276a56d96573aa814fe19532469e366908 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期六, 12 十月 2024 18:02:40 +0800
Subject: [PATCH] 领用&装机 信息统计

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java     |   27 +++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/PatientStatisticVO.java |    2 +
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java               |   53 ++++++++++++++++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java                  |   15 +++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java                   |    4 ++
 5 files changed, 101 insertions(+), 0 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 10926c0..9ce1e5b 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
@@ -322,6 +322,33 @@
         return success(patientStatisticVO);
     }
 
+    @GetMapping("/get-dev-ready-statistic")
+    @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<PatientStatisticVO> getDevReadyStatistic(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        PatientStatisticVO patientStatisticVO = queueService.getBedDevReadyStatistic(roomId, bedNo);
+        return success(patientStatisticVO);
+    }
+
+
+    @GetMapping("/get-dev-install-statistic")
+    @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<PatientStatisticVO> getDevInstallStatistic(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        PatientStatisticVO patientStatisticVO = queueService.getBedDevInstallStatistic(roomId, bedNo);
+        return success(patientStatisticVO);
+    }
+
     @GetMapping("/recall-patient")
     @Operation(summary = "杩囧彿鐥呬汉鍙洖")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/PatientStatisticVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/PatientStatisticVO.java
index df9b271..db59e55 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/PatientStatisticVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/PatientStatisticVO.java
@@ -11,6 +11,8 @@
 
     private Integer readyNum;
 
+    private Integer receivedNum;
+
     private Integer passedNum;
 
     private Integer queuingNum;
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
index 34aedca..eb8dfef 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
@@ -82,6 +82,21 @@
     Integer statusStatistic(@Param("statusList")List<Byte> statusList);
 
     @Select("<script>" +
+            "SELECT count(1) as total_in_status FROM lihu.queue where " +
+            " room_id = #{roomId} and bed_no = #{bedNo} " +
+            " and status in ( " +
+            " <foreach collection='statusList' separator=',' item='status'>" +
+            "  #{status} " +
+            " </foreach> ) " +
+            " and book_check_type in ( " +
+            " <foreach collection='checkTypes' separator=',' item='checkType'>" +
+            "  #{checkType} " +
+            " </foreach> ) " +
+            "</script>")
+
+    Integer checkTypeAndStatusStatistic( @Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("checkTypes")Integer[] checkTypes, @Param("statusList")List<Byte> statusList);
+
+    @Select("<script>" +
             "SELECT room_id, bed_no, count(1) as total_in_status FROM lihu.queue where status in (" +
             " <foreach collection='statusList' separator=',' item='status'>" +
             " #{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 f3cbfdb..c528bae 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
@@ -115,6 +115,10 @@
 
     PatientStatisticVO getPatientStatistic(Long roomId, String bedNo);
 
+    PatientStatisticVO getBedDevReadyStatistic(Long roomId, String bedNo);
+
+    PatientStatisticVO getBedDevInstallStatistic(Long roomId, String bedNo);
+
     Integer recallPatient(Long roomId, String bedNo, String patId);
 
     Integer patientJump(String patId, Byte jumped );
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 4485429..da4e17e 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
@@ -4,6 +4,7 @@
 import java.util.concurrent.*;
 import javax.annotation.Resource;
 
+import cn.lihu.jh.module.ecg.Utils;
 import cn.lihu.jh.module.ecg.controller.admin.room.vo.MonitorInfoVO;
 import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
 import cn.lihu.jh.module.ecg.dal.mysql.call.CallMapper;
@@ -61,6 +62,8 @@
     private DevRentMapper devRentMapper;
 
     ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
+
+    ConcurrentHashMap<String, RoomDO> mapRoomBed = new ConcurrentHashMap<>();
 
     @Override
     public Integer createqueue(QueueSaveReqVO createReqVO) {
@@ -409,6 +412,48 @@
         return patientStatisticVO;
     }
 
+    public PatientStatisticVO getBedDevInstallStatistic(Long roomId, String bedNo) {
+        PatientStatisticVO patientStatisticVO = new PatientStatisticVO();
+        List<BedQueueStatisticDO> bedQueueStatisticDOList = queueMapper.bedQueueStatistic(roomId, bedNo);
+        bedQueueStatisticDOList.forEach(item -> {
+            if (QueueStatusEnum.RECEIVED.getStatus() == item.getStatus()) {
+                patientStatisticVO.setReceivedNum(item.getTotalInStatus());
+            } else if (QueueStatusEnum.FINISH.getStatus() == item.getStatus()) {
+                patientStatisticVO.setFinishedNum(item.getTotalInStatus());
+            }
+        });
+
+        return patientStatisticVO;
+    }
+
+    public PatientStatisticVO getBedDevReadyStatistic(Long roomId, String bedNo) {
+        PatientStatisticVO patientStatisticVO = new PatientStatisticVO();
+        patientStatisticVO.setFinishedNum(0);
+        List<BedQueueStatisticDO> bedQueueStatisticDOList = queueMapper.bedQueueStatistic(roomId, bedNo);
+        bedQueueStatisticDOList.forEach(item -> {
+            if (QueueStatusEnum.READY.getStatus() == item.getStatus()) {
+                patientStatisticVO.setReadyNum(item.getTotalInStatus());
+            } else if (QueueStatusEnum.PASSED.getStatus() == item.getStatus()) {
+                patientStatisticVO.setPassedNum(item.getTotalInStatus());
+            } else if (QueueStatusEnum.RECEIVED.getStatus() == item.getStatus()) {
+                patientStatisticVO.setFinishedNum( item.getTotalInStatus() + patientStatisticVO.getFinishedNum() );
+            } else if (QueueStatusEnum.INSTALLING.getStatus() == item.getStatus()) {
+                patientStatisticVO.setFinishedNum( item.getTotalInStatus() + patientStatisticVO.getFinishedNum() );
+            } else if (QueueStatusEnum.FINISH.getStatus() == item.getStatus()) {
+                patientStatisticVO.setFinishedNum(item.getTotalInStatus() + patientStatisticVO.getFinishedNum());
+            }
+        });
+
+        RoomDO roomDO = getRoomDO(roomId, bedNo);
+        Integer[] checkTypes = roomDO.getCheckTypes();
+        List<Byte> statusList = new ArrayList<>();
+        statusList.add(QueueStatusEnum.WAITING.getStatus());
+        Integer num = queueMapper.checkTypeAndStatusStatistic(roomId, bedNo, checkTypes, statusList);
+        patientStatisticVO.setQueuingNum(num);
+
+        return patientStatisticVO;
+    }
+
     public void initCheckType() {
         queueServiceTxFunctions.initCheckType( );
     }
@@ -448,4 +493,12 @@
         return roomMapper.getRoomByDocId(docId);
     }
 
+    private RoomDO getRoomDO(Long roomId, String bedNo) {
+        RoomDO roomDO = mapRoomBed.get( Utils.formatRoomBed(roomId, bedNo) );
+        if ( null == roomDO)
+            roomDO = roomMapper.getRoom(roomId, bedNo);
+
+        return roomDO;
+    }
+
 }

--
Gitblit v1.9.3