From 7bc725bea3fa8e02e952635dcbb1a493e4a74a13 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期六, 12 十月 2024 11:41:41 +0800
Subject: [PATCH] update

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java |  242 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 229 insertions(+), 13 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 ab7e56f..a3b5fee 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
@@ -3,14 +3,19 @@
 import cn.lihu.jh.framework.common.exception.ErrorCode;
 import cn.lihu.jh.framework.common.pojo.CommonResult;
 import cn.lihu.jh.framework.common.util.object.BeanUtils;
+import cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils;
+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.room.vo.RoomRespVO;
 import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
 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;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -18,24 +23,113 @@
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
+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;
 
 @Tag(name = "绠$悊鍚庡彴 - 鍖荤敓鍙彿")
 @RestController
 @RequestMapping("/ecg/doctor")
 @Validated
+@Slf4j
 public class DoctorController {
 
     @Resource
     private QueueService queueService;
 
+    @Resource
+    private CallService callService;
+
+    @GetMapping("/bed-doctor-pause")
+    @Operation(summary = "鍖荤敓鏆傚仠")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
+    public CommonResult<Integer> bedPause(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        Long userId = SecurityFrameworkUtils.getLoginUserId();
+        String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+        ErrorCode result = queueService.startBedDoctorPause(roomId, bedNo, userId, userNickname);
+        if (result.equals(SUCCESS))
+            return success(SUCCESS.getCode());
+
+        return error(result);
+    }
+
+    @GetMapping("/bed-doctor-resume")
+    @Operation(summary = "鍖荤敓鎭㈠")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
+    public CommonResult<Integer> bedResume(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        Long userId = SecurityFrameworkUtils.getLoginUserId();
+        String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+        ErrorCode result = queueService.startBedDoctorResume(roomId, bedNo, userId, userNickname);
+        if (result.equals(SUCCESS))
+            return success(SUCCESS.getCode());
+
+        return error(result);
+    }
+
+    @GetMapping("/bed-doctor-on")
+    @Operation(summary = "鍖荤敓鍏ュ骇")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
+    public CommonResult<Integer> bedDoctorOn(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        Long userId = SecurityFrameworkUtils.getLoginUserId();
+        String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+        ErrorCode result = queueService.startBedDoctorOn(roomId, bedNo, userId, userNickname);
+        if (result.equals(SUCCESS))
+            return success(0);
+
+        return error(result);
+    }
+
+    @GetMapping("/bed-doctor-off")
+    @Operation(summary = "鍖荤敓绂诲骇")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
+    public CommonResult<Integer> bedDoctorOff(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        Long userId = SecurityFrameworkUtils.getLoginUserId();
+        String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+        ErrorCode result = queueService.startBedDoctorOff(roomId, bedNo, userId, userNickname);
+        if (result.equals(SUCCESS))
+            return success(SUCCESS.getCode());
+
+        return error(result);
+    }
+
+    @GetMapping("/bed-doctor-get")
+    @Operation(summary = "鍖荤敓宸ヤ綅鑾峰彇")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:state')")
+    public CommonResult<RoomRespVO> bedDoctorGet(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        Long userId = SecurityFrameworkUtils.getLoginUserId();
+
+        CommonResult<RoomRespVO> result = queueService.getRoom(roomId, bedNo, userId);
+        return result;
+    }
+
     @GetMapping("/finish-next-patient")
-    @Operation(summary = "瀹屾垚銆佷笅涓�浣嶆偅鑰�")
+    @Operation(summary = "甯歌鍙彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
     @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
-    @PreAuthorize("@ss.hasPermission('ecg:doctor:nextpatient')")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
     public CommonResult<List<QueueRespVO>> finishNextPatient(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo)
@@ -43,10 +137,78 @@
         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.getDoctorQueueByStatus(roomId, bedNo, queueStatusList);
+        List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+
+        // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
+        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        if (null != onStageItem) {
+            CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+            callSaveReqVO.setId(null);
+            callService.createCall(callSaveReqVO);
+        }
+
+        return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
+    }
+
+    @GetMapping("/finish-receive-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<List<QueueRespVO>> finishReceiveNextPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        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);
+
+        // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
+        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        if (null != onStageItem) {
+            CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+            callSaveReqVO.setId(null);
+            callService.createCall(callSaveReqVO);
+        }
+
+        return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
+    }
+
+    @GetMapping("/finish-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<List<QueueRespVO>> finishInstallNextPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        queueService.finishInstallNextPatient(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);
+
+        // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
+        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        if (null != onStageItem) {
+            CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+            callSaveReqVO.setId(null);
+            callService.createCall(callSaveReqVO);
+        }
+
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
@@ -54,7 +216,7 @@
     @Operation(summary = "杩囧彿銆佷笅涓�浣嶆偅鑰�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
     @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
-    @PreAuthorize("@ss.hasPermission('ecg:doctor:nextpatient')")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
     public CommonResult<List<QueueRespVO>> passNextPatient(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo)
@@ -62,27 +224,82 @@
         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.getDoctorQueueByStatus(roomId, bedNo, queueStatusList);
+        List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+
+        // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
+        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        if (null != onStageItem) {
+            CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+            callSaveReqVO.setId(null);
+            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> callAgainPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        List<Byte> queueStatusList = new ArrayList<>();
+        queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
+        List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+
+        if (queueDOList.isEmpty())
+            return success("鏃犲氨璇婁腑鎮h��");
+
+        if (queueDOList.size() > 1) {
+            log.error("room {} bed {} have {} 灏辫瘖涓偅鑰�", roomId, bedNo, queueDOList.size());
+            return error(ECG_INNER_ERROR);
+        }
+
+        QueueDO onStageItem = queueDOList.get(0);
+        CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+        callSaveReqVO.setId(null);
+        callService.callAgain(callSaveReqVO);
+
+        return success("鎿嶄綔鎴愬姛");
     }
 
     @GetMapping("/get-patient-list")
     @Operation(summary = "鍙栨偅鑰呭垪琛�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
     @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
-    @PreAuthorize("@ss.hasPermission('ecg:doctor:patientlist')")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
     public CommonResult<List<QueueRespVO>> getPatientList(
             @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<QueueDO> queueDOList = queueService.getDoctorQueueByStatus(roomId, bedNo, queueStatusList);
+        List<QueueDO> queueDOList = queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList);
+        return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
+    }
+
+    @GetMapping("/get-received-patient-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(
+            @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);
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
@@ -90,7 +307,7 @@
     @Operation(summary = "鍙栨偅鑰呯粺璁�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
     @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
-    @PreAuthorize("@ss.hasPermission('ecg:doctor:patientstatistic')")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
     public CommonResult<PatientStatisticVO> getPatientStatistic(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo)
@@ -100,11 +317,11 @@
     }
 
     @GetMapping("/recall-patient")
-    @Operation(summary = "杩囨湡鐥呬汉鍙洖")
+    @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")
-    @PreAuthorize("@ss.hasPermission('ecg:doctor:patient')")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
     public CommonResult<String> recallPatient(
             @RequestParam("roomId") Long roomId,
             @RequestParam("bedNo") String bedNo,
@@ -112,10 +329,9 @@
     {
         Integer result = queueService.recallPatient(roomId, bedNo, patId);
         if (null == result || 0 == result)
-            return error( new ErrorCode(201, "鎵句笉鍒版偅鑰�") );
+            return error(PATIENT_NOT_EXISTS);
 
-        return success("success");
+        return success("鎿嶄綔鎴愬姛");
     }
-
 
 }

--
Gitblit v1.9.3