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, "éå䏿æ£è "); ErrorCode QUEUE_NOT_READY_PATIENT = new ErrorCode(1_010_003_003, "没æåå¤ä¸çæ£è "); ErrorCode PATIENT_NOT_EXISTS = new ErrorCode(1_010_004_000, "æ£è ä¸åå¨"); } 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"; } 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); jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/callingscreen/CallingRespVO.java
ÎļþÃû´Ó jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/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; 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); } } 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)); } } 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; 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" + 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; } 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); } 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; } } 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; } } 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); }