From 0bea516b3063bad9093aeb3383b16cc9706bd6db Mon Sep 17 00:00:00 2001 From: eight <641137800@qq.com> Date: 星期四, 05 九月 2024 16:19:18 +0800 Subject: [PATCH] update --- jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java | 3 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingScreenController.java | 97 +++++++++++++ jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/queueDO.java | 4 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/queueMapper.java | 54 +++++-- jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingRespVO.java | 14 + jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/BigScreenConfig.java | 9 + jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java | 15 + jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java | 1 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/queueController.java | 33 ---- jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java | 24 -- jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenService.java | 31 ++++ jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenServiceImpl.java | 111 +++++++++++++++ jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/queueService.java | 4 13 files changed, 326 insertions(+), 74 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 a54cb16..b48b328 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 @@ -21,4 +21,5 @@ ErrorCode QUEUE_BED_EXIST = new ErrorCode(1_010_003_001, "宸ヤ綅闃熷垪宸插瓨鍦�"); ErrorCode QUEUE_HAVE_PATIENT = new ErrorCode(1_010_003_002, "闃熷垪涓湁鎮h��"); ErrorCode QUEUE_NOT_READY_PATIENT = new ErrorCode(1_010_003_003, "娌℃湁鍑嗗涓殑鎮h��"); + ErrorCode PATIENT_NOT_EXISTS = new ErrorCode(1_010_004_000, "鎮h�呬笉瀛樺湪"); } diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java index 2d66d97..19cf433 100644 --- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java @@ -4,5 +4,6 @@ static final String ECG_OPENING_TIME_KEY = "ecg.openingtime"; static final String ECG_QUEUE_READY_MAX_KEY = "ecg.queue.ready.max"; static final String ECG_ROOM_RESET_TIME_KEY = "ecg.room.reset.time"; - + static final String ECG_SCREEN_PANE_WAITING_KEY = "ecg.screen.pane.waiting"; + static final String ECG_SCREEN_PANE_PASSED_KEY = "ecg.screen.pane.passed"; } diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java index 147e4b9..fe02bbf 100644 --- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java @@ -1,6 +1,8 @@ package cn.lihu.jh.module.ecg.config; import cn.lihu.jh.module.ecg.Utils; +import cn.lihu.jh.module.ecg.service.callingscreen.BigScreenConfig; +import cn.lihu.jh.module.ecg.service.callingscreen.CallingScreenService; import cn.lihu.jh.module.ecg.service.config.EcgConfigService; import cn.lihu.jh.module.ecg.service.queue.QueueService; import cn.lihu.jh.module.infra.api.config.ConfigApi; @@ -12,8 +14,7 @@ import java.time.LocalTime; import java.util.List; -import static cn.lihu.jh.module.ecg.Constants.ECG_OPENING_TIME_KEY; -import static cn.lihu.jh.module.ecg.Constants.ECG_QUEUE_READY_MAX_KEY; +import static cn.lihu.jh.module.ecg.Constants.*; @Component public class MySpringEventListener { @@ -27,6 +28,9 @@ @Resource QueueService queueService; + @Resource + CallingScreenService callingScreenService; + @EventListener public void onApplicationEvent(ApplicationStartedEvent event) { System.out.println("搴旂敤鍚姩瀹屾垚锛岀郴缁熷垵濮嬨�傘�傘��"); @@ -34,6 +38,13 @@ Integer queueReadyMax = Integer.valueOf(configApi.getConfigValueByKey(ECG_QUEUE_READY_MAX_KEY)); queueService.setQueueReadyMax( queueReadyMax ); + BigScreenConfig bigScreenConfig = new BigScreenConfig(); + Integer waitingSize = Integer.valueOf(configApi.getConfigValueByKey(ECG_SCREEN_PANE_WAITING_KEY)); + Integer passedSize = Integer.valueOf(configApi.getConfigValueByKey(ECG_SCREEN_PANE_PASSED_KEY)); + bigScreenConfig.setWaitingSize( waitingSize); + bigScreenConfig.setPassedSize( passedSize); + callingScreenService.setBigScreenConfig(bigScreenConfig); + String strOpenCloseTime = configApi.getConfigValueByKey(ECG_OPENING_TIME_KEY); List<LocalTime> list = Utils.parseOpeningTime(strOpenCloseTime); LocalTime openingTime = list.get(0); diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/CallingRespVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingRespVO.java similarity index 78% rename from jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/CallingRespVO.java rename to jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingRespVO.java index ace003d..9ae076a 100644 --- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/CallingRespVO.java +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingRespVO.java @@ -1,8 +1,9 @@ -package cn.lihu.jh.module.ecg.controller.admin.queue.vo; +package cn.lihu.jh.module.ecg.controller.admin.callingscreen; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.models.security.SecurityScheme; import lombok.Data; import java.time.LocalDate; @@ -32,6 +33,13 @@ @ExcelProperty("鎺掗槦搴忓彿") private Integer seqNum; + /** + * 10:鎺掗槦涓� 20:鍊欒瘖鍑嗗 30:灏辫瘖涓� 40:灏辫瘖瀹屾垚 50:杩囧彿 60:杩囨湡 + */ + @Schema(description = "鎺掗槦鐘舵��", example = "1") + @ExcelProperty("鎺掗槦鐘舵��") + private Byte status; + @Schema(description = "杩囧彿鏍囪", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("杩囧彿鏍囪") private Byte passed; @@ -40,6 +48,10 @@ @ExcelProperty("棰勭害杩囨湡鏍囪") private Byte expired; + @Schema(description = "璇煶鍙彿鏍囪", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("璇煶鍙彿鏍囪") + private Integer called; + @Schema(description = "鎻掗槦鏍囪", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("鎻掗槦鏍囪") private Byte jumpFlag; diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingScreenController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingScreenController.java new file mode 100644 index 0000000..329f324 --- /dev/null +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingScreenController.java @@ -0,0 +1,97 @@ +package cn.lihu.jh.module.ecg.controller.admin.callingscreen; + +import cn.hutool.extra.servlet.ServletUtil; +import cn.lihu.jh.framework.apilog.core.annotation.ApiAccessLog; +import cn.lihu.jh.framework.common.exception.ErrorCode; +import cn.lihu.jh.framework.common.pojo.CommonResult; +import cn.lihu.jh.framework.common.pojo.PageParam; +import cn.lihu.jh.framework.common.pojo.PageResult; +import cn.lihu.jh.framework.common.util.object.BeanUtils; +import cn.lihu.jh.framework.excel.core.util.ExcelUtils; +import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueuePageReqVO; +import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueRespVO; +import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueSaveReqVO; +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.callingscreen.CallingScreenService; +import cn.lihu.jh.module.ecg.service.config.EcgConfigService; +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 org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.annotation.security.PermitAll; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static cn.lihu.jh.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +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; + +@Tag(name = "鍙彿灞� ") +@RestController +@RequestMapping("/ecg/screen") +@Validated +public class CallingScreenController { + + @Resource + private CallingScreenService callingScreenService; + + @Resource + private EcgConfigService ecgConfigService; + + @GetMapping("/calling-data") + @Operation(summary = "澶у睆鍙彿鏁版嵁") + @PermitAll + public CommonResult<Map<Integer, List<CallingRespVO>>> callingData() + { + Map<Integer, List<QueueDO>> map = callingScreenService.callingData(); + + Map<Integer, List<CallingRespVO>> mapVO = new HashMap<>(); + + map.keySet().forEach( key -> { + mapVO.put(key, BeanUtils.toBean(map.get(key), CallingRespVO.class)); + }); + + return success( mapVO ); + } + + @GetMapping("/room-screen-data") + @Operation(summary = "璇婇棿灞忔暟鎹�") + @PermitAll + public CommonResult<List<CallingRespVO>> callingDataRoom(HttpServletRequest request) + { + String reqIp = ServletUtil.getClientIP(request); + + List<Byte> queueStatusList = new ArrayList<>(); + queueStatusList.add(QueueStatusEnum.READY.getStatus()); + queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); + queueStatusList.add(QueueStatusEnum.PASSED.getStatus()); + + List<QueueDO> queueDOList = callingScreenService.getRoomQueue(reqIp, queueStatusList); + return success(BeanUtils.toBean(queueDOList, CallingRespVO.class)); + } + + @GetMapping("/mark-called") + @Operation(summary = "璇婇棿灞忔暟鎹�") + @PermitAll + public CommonResult<Integer> markCalled(@RequestParam("patId") String patId) + { + ErrorCode result = callingScreenService.markCalled(patId); + if (result.equals(SUCCESS)) + return success(0); + + return error(result); + } +} 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 4ae696f..5997673 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 @@ -2,13 +2,9 @@ import cn.hutool.extra.servlet.ServletUtil; import cn.lihu.jh.framework.common.exception.ErrorCode; -import cn.lihu.jh.framework.common.util.servlet.ServletUtils; -import cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils; -import cn.lihu.jh.module.ecg.controller.admin.room.vo.RoomRespVO; +import cn.lihu.jh.module.ecg.controller.admin.callingscreen.CallingRespVO; import cn.lihu.jh.module.ecg.enums.QueueStatusEnum; import cn.lihu.jh.module.ecg.service.config.EcgConfigService; -import cn.lihu.jh.module.ecg.service.config.EcgConfigServiceImpl; -import org.springframework.scheduling.config.ScheduledTaskRegistrar; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; @@ -158,33 +154,6 @@ public CommonResult<Integer> resetScheduler() { ecgConfigService.resetScheduler(); return success(0); - } - - @GetMapping("/calling-data") - @Operation(summary = "澶у睆鍙彿鏁版嵁") - @PreAuthorize("@ss.hasPermission('ecg:queue:setting')") - public CommonResult<List<CallingRespVO>> callingData( - @RequestParam("waitingNum") Integer waitingNum, - @RequestParam("passedNum") Integer passedNum) - { - List<QueueDO> queueDOList = queueService.callingData(waitingNum, passedNum); - return success( BeanUtils.toBean(queueDOList, CallingRespVO.class) ); - } - - @GetMapping("/room-screen-data") - @Operation(summary = "璇婇棿灞忔暟鎹�") - @PermitAll - public CommonResult<List<CallingRespVO>> callingDataRoom(HttpServletRequest request) - { - String reqIp = ServletUtil.getClientIP(request); - - List<Byte> queueStatusList = new ArrayList<>(); - queueStatusList.add(QueueStatusEnum.READY.getStatus()); - queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); - queueStatusList.add(QueueStatusEnum.PASSED.getStatus()); - - List<QueueDO> queueDOList = queueService.getRoomQueue(reqIp, queueStatusList); - return success(BeanUtils.toBean(queueDOList, CallingRespVO.class)); } } diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/queueDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/queueDO.java index 3ec3ca0..e138e8e 100644 --- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/queueDO.java +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/queueDO.java @@ -68,6 +68,10 @@ */ private Byte expired; /** + * 璇煶鍙彿鏍囪 + */ + private Integer called; + /** * 鎻掗槦鏍囪 */ private Byte jumpFlag; 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 64fed4b..0bbaaaf 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 @@ -40,6 +40,37 @@ Integer getMaxSeqNum(); @Select("<script>" + + "SELECT * FROM lihu.queue " + + "where room_id = #{roomId} and status in (" + + " <foreach collection='statusList' separator=',' item='status'>" + + " #{status} " + + " </foreach> )" + + " order by seq_num" + + "</script>") + List<QueueDO> getRoomQueueByStatus(@Param("roomId")Long roomId, @Param("statusList")List<Byte> statusList); + + @Select("<script>" + + "SELECT * FROM lihu.queue " + + "where status in (" + + " <foreach collection='statusList' separator=',' item='status'>" + + " #{status} " + + " </foreach> )" + + " order by seq_num" + + "</script>") + List<QueueDO> getQueueByStatus( @Param("statusList")List<Byte> statusList); + + @Select("<script>" + + "SELECT * FROM lihu.queue " + + "where id >= #{from} and status in (" + + " <foreach collection='statusList' separator=',' item='status'>" + + " #{status} " + + " </foreach> )" + + " limit #{size} " + + " order by id" + + "</script>") + List<QueueDO> getPartialQueueByStatus( @Param("statusList")List<Byte> statusList, @Param("from") Integer from, @Param("size") Integer size); + + @Select("<script>" + "SELECT count(1) as total_in_status FROM lihu.queue where status in (" + " <foreach collection='statusList' separator=',' item='status'>" + " #{status} " + @@ -63,21 +94,6 @@ "</script>") List<BedQueueStatisticDO> bedQueueStatistic(@Param("roomId")Long roomId, @Param("bedNo")String bedNo); - @Update("update lihu.queue set status = #{newStatus} where seq_num = \n" + - "(select a.min_seq_num from \n" + - " (select min(seq_num) as min_seq_num from lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus}) a )") - Integer updateQueueStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus); - - @Select("<script>" + - "SELECT * FROM lihu.queue " + - "where room_id = #{roomId} and status in (" + - " <foreach collection='statusList' separator=',' item='status'>" + - " #{status} " + - " </foreach> )" + - " order by seq_num" + - "</script>") - List<QueueDO> getRoomQueueByStatus(@Param("roomId")Long roomId, @Param("statusList")List<Byte> statusList); - @Select("<script>" + "SELECT * FROM lihu.queue " + "where room_id = #{roomId} and bed_no = #{bedNo} and status in (" + @@ -88,6 +104,14 @@ "</script>") List<QueueDO> getDoctorQueueByStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("statusList")List<Byte> statusList); + @Update( "update lihu.queue set called = 1 where pat_id = #{patId}" ) + Integer markCalled(@Param("patId")String patId); + + @Update("update lihu.queue set status = #{newStatus} where seq_num = \n" + + "(select a.min_seq_num from \n" + + " (select min(seq_num) as min_seq_num from lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus}) a )") + Integer updateQueueStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus); + @Update("update lihu.queue set status = #{newStatus}, room_id = #{roomId}, room_name = #{roomName}, \n" + " bed_no = #{bedNo}, seq_num = #{seqNum} where id = \n" + " (select a.id from \n" + diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/BigScreenConfig.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/BigScreenConfig.java new file mode 100644 index 0000000..9078b33 --- /dev/null +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/BigScreenConfig.java @@ -0,0 +1,9 @@ +package cn.lihu.jh.module.ecg.service.callingscreen; + +import lombok.Data; + +@Data +public class BigScreenConfig { + Integer waitingSize; + Integer passedSize; +} diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenService.java new file mode 100644 index 0000000..bb9d394 --- /dev/null +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenService.java @@ -0,0 +1,31 @@ +package cn.lihu.jh.module.ecg.service.callingscreen; + +import cn.lihu.jh.framework.common.exception.ErrorCode; +import cn.lihu.jh.framework.common.pojo.CommonResult; +import cn.lihu.jh.framework.common.pojo.PageResult; +import cn.lihu.jh.module.ecg.controller.admin.queue.vo.PatientStatisticVO; +import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueuePageReqVO; +import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueSaveReqVO; +import cn.lihu.jh.module.ecg.controller.admin.room.vo.MonitorInfoVO; +import cn.lihu.jh.module.ecg.controller.admin.room.vo.RoomRespVO; +import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +/** + * 鎺掗槦 Service 鎺ュ彛 + * + * @author 鑺嬮亾婧愮爜 + */ +public interface CallingScreenService { + + void setBigScreenConfig(BigScreenConfig bigScreenConfig); + + Map<Integer, List<QueueDO>> callingData(); + + List<QueueDO> getRoomQueue(String ip, List<Byte> statusList); + + ErrorCode markCalled(String patientId); +} diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenServiceImpl.java new file mode 100644 index 0000000..8815e4d --- /dev/null +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/callingscreen/CallingScreenServiceImpl.java @@ -0,0 +1,111 @@ +package cn.lihu.jh.module.ecg.service.callingscreen; + +import cn.lihu.jh.framework.common.exception.ErrorCode; +import cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants; +import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; +import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; +import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper; +import cn.lihu.jh.module.ecg.dal.mysql.room.RoomMapper; +import cn.lihu.jh.module.ecg.enums.QueueStatusEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.*; + +import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.PATIENT_NOT_EXISTS; + +/** + * 鎺掗槦 Service 瀹炵幇绫� + * + * @author 鑺嬮亾婧愮爜 + */ +@Service +@Validated +@Slf4j +public class CallingScreenServiceImpl implements CallingScreenService { + + @Resource + private queueMapper queueMapper; + + @Resource + private RoomMapper roomMapper; + + BigScreenConfig bigScreenConfig; + + Integer waitingFrom = 0; + Integer passedFrom = 0; + + @Override + public void setBigScreenConfig(BigScreenConfig bigScreenConfig) { + this.bigScreenConfig = bigScreenConfig; + } + + @Override + public Map<Integer, List<QueueDO>> callingData() { + List<Byte> queueStatusList = new ArrayList<>(); + queueStatusList.add(QueueStatusEnum.READY.getStatus()); + queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); + List<QueueDO> listReady = queueMapper.getQueueByStatus( queueStatusList ); + + queueStatusList.clear(); + queueStatusList.add(QueueStatusEnum.WAITING.getStatus()); + queueStatusList.add(QueueStatusEnum.RECALLED.getStatus()); + List<QueueDO> listWaiting = queueMapper.getPartialQueueByStatus( queueStatusList, waitingFrom, bigScreenConfig.waitingSize ); + if (listWaiting.size() < bigScreenConfig.waitingSize && waitingFrom != 0) { + List<QueueDO> listWaiting_next = queueMapper.getPartialQueueByStatus( queueStatusList, 0, bigScreenConfig.waitingSize - listWaiting.size()); + listWaiting.addAll(listWaiting_next); + } + if (listWaiting.size() < bigScreenConfig.waitingSize) { + waitingFrom = 0; + } else { + waitingFrom = listWaiting.getLast().getId(); + } + + queueStatusList.clear(); + queueStatusList.add(QueueStatusEnum.PASSED.getStatus()); + List<QueueDO> listPassed = queueMapper.getPartialQueueByStatus( queueStatusList, passedFrom, bigScreenConfig.passedSize ); + if (listPassed.size() < bigScreenConfig.passedSize && passedFrom != 0) { + List<QueueDO> listPassed_next = queueMapper.getPartialQueueByStatus( queueStatusList, 0, bigScreenConfig.passedSize - listPassed.size()); + listPassed.addAll(listPassed_next); + } + if (listPassed.size() < bigScreenConfig.passedSize) { + passedFrom = 0; + } else { + passedFrom = listPassed.getLast().getId(); + } + + log.info( " waitingFrom: {} passedFrom: {} ", waitingFrom, passedFrom); + + Map<Integer, List<QueueDO>> map = new HashMap<>(); + map.put(1, listReady); + map.put(2, listWaiting); + map.put(3, listPassed); + return map; + } + + @Override + public List<QueueDO> getRoomQueue(String ip, List<Byte> statusList) { + List<RoomDO> roomDOList = roomMapper.queueByIp(ip); + Optional<RoomDO> optionalQueueDO = roomDOList.stream().filter(item -> StringUtils.hasLength(item.getIp())).findFirst(); + if (!optionalQueueDO.isPresent()) { + return new ArrayList<QueueDO>(); + } + + Long roomId = optionalQueueDO.get().getRoomId(); + List<QueueDO> queueDOList = queueMapper.getRoomQueueByStatus(roomId, statusList); + return queueDOList; + } + + @Override + public ErrorCode markCalled(String patientId) { + Integer rowNum = queueMapper.markCalled(patientId); + if (rowNum == 1) + return GlobalErrorCodeConstants.SUCCESS; + + return PATIENT_NOT_EXISTS; + } + +} 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 0a4345d..6c6136a 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 @@ -57,6 +57,11 @@ Integer queueReadyMax = 0; + Integer bigScrenWaitingSize = 5; + Integer bigScrenPassedSize = 5; + Integer bigScrenWaitingFrom = 0; + Integer bigScrenPassedFrom = 0; + @Override public Integer createqueue(QueueSaveReqVO createReqVO) { // 鎻掑叆 @@ -678,25 +683,6 @@ public void monitorInfo() { log.info("map " + mapBedVsQueue.size() + " priority " + priorityQueue.size() + " opening " + openingFlag.get()); - } - - @Override - public List<QueueDO> callingData(Integer waitingNum, Integer passedNum) { - //queueMapper. - return null; - } - - @Override - public List<QueueDO> getRoomQueue(String ip, List<Byte> statusList) { - List<RoomDO> roomDOList = roomMapper.queueByIp(ip); - Optional<RoomDO> optionalQueueDO = roomDOList.stream().filter(item -> StringUtils.hasLength(item.getIp())).findFirst(); - if (!optionalQueueDO.isPresent()) { - return new ArrayList<QueueDO>(); - } - - Long roomId = optionalQueueDO.get().getRoomId(); - List<QueueDO> queueDOList = queueMapper.getRoomQueueByStatus(roomId, statusList); - return queueDOList; } } 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 576de33..c671170 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 @@ -118,8 +118,4 @@ Integer patientJump(String patId, Byte jumped ); void monitorInfo(); - - List<QueueDO> callingData(Integer waitingNum, Integer passedNum); - - List<QueueDO> getRoomQueue(String ip, List<Byte> statusList); } -- Gitblit v1.9.3