jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java
@@ -1,16 +1,12 @@ package cn.lihu.jh.module.ecg.config; import cn.lihu.jh.framework.common.exception.ServiceException; import cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants; import cn.lihu.jh.module.ecg.Utils; import cn.lihu.jh.module.ecg.enums.ErrorCodeConstants; 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; import cn.lihu.jh.module.system.api.dict.DictDataApi; import cn.lihu.jh.module.system.api.dict.dto.DictDataRespDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationStartedEvent; import org.springframework.context.event.EventListener; @@ -18,10 +14,7 @@ import javax.annotation.Resource; import java.time.LocalTime; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import static cn.lihu.jh.module.ecg.Constants.*; @@ -48,21 +41,7 @@ public void onApplicationEvent(ApplicationStartedEvent event) { log.info("应用启动完成,系统初始。。。"); String strQueueReadyMax = configApi.getConfigValueByKey(ECG_QUEUE_READY_MAX_KEY); int[] queueReadyMax = Arrays.stream(strQueueReadyMax.split(",")) .mapToInt(Integer::parseInt) .toArray(); List<DictDataRespDTO> dictDataRespDTOList = dictDataApi.getDictDataList("ecg_check_type"); if ( dictDataRespDTOList.size() != queueReadyMax.length) { log.error(ErrorCodeConstants.ECG_CONFIG_ERROR.getMsg()); } Integer checkTypeNum = dictDataRespDTOList.size() < queueReadyMax.length ? dictDataRespDTOList.size() : queueReadyMax.length; Map max = new HashMap<Integer, Integer>(); for (int i=0; i<checkTypeNum; i++) { max.put( Integer.valueOf(dictDataRespDTOList.get(i).getValue()), queueReadyMax[i]); } queueService.setCheckTypeReadyMax( max ); queueService.initCheckType(); BigScreenConfig bigScreenConfig = new BigScreenConfig(); Integer waitingSize = Integer.valueOf(configApi.getConfigValueByKey(ECG_SCREEN_PANE_WAITING_KEY)); jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentRespVO.java
@@ -89,7 +89,6 @@ @Schema(description = "预约检查类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @ExcelProperty(value = "预约检查类型", converter = DictConvert.class) @DictFormat("ecg_check_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 private Byte bookCheckType; @Schema(description = "预约来源:X系统、护士手动预约", requiredMode = Schema.RequiredMode.REQUIRED) jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/appointment/AppointmentDO.java
@@ -107,7 +107,6 @@ /** * 预约检查类型 * * 枚举 {@link TODO ecg_check_type 对应的类} */ private Byte bookCheckType; /** jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/checktype/CheckTypeMapper.java
@@ -6,7 +6,9 @@ import cn.lihu.jh.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.lihu.jh.framework.mybatis.core.mapper.BaseMapperX; import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO; import org.apache.ibatis.annotations.Mapper; import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; import cn.lihu.jh.module.ecg.enums.BedStatusEnum; import org.apache.ibatis.annotations.*; import cn.lihu.jh.module.ecg.controller.admin.checktype.vo.*; /** @@ -27,4 +29,9 @@ .orderByDesc(CheckTypeDO::getId)); } @Select("<script> " + "SELECT * FROM lihu.check_type;" + "</script>") List<CheckTypeDO> simpleCheckTypeList(); } jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java
@@ -20,7 +20,7 @@ */ public interface QueueService { void setCheckTypeReadyMax(Map<Integer, Integer> max); void initCheckType(); void startBiz(); void closeBiz(); jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
@@ -7,6 +7,7 @@ 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; import cn.lihu.jh.module.ecg.dal.mysql.checktype.CheckTypeMapper; import cn.lihu.jh.module.ecg.dal.mysql.devrent.DevRentMapper; import cn.lihu.jh.module.ecg.enums.DevRentStateEnum; import cn.lihu.jh.module.system.api.oauth2.OAuth2TokenApi; @@ -348,8 +349,8 @@ return patientStatisticVO; } public void setCheckTypeReadyMax(Map<Integer, Integer> max) { queueServiceTxFunctions.setCheckTypeReadyMax( max ); public void initCheckType() { queueServiceTxFunctions.initCheckType( ); } public void startBiz() { jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
@@ -4,10 +4,12 @@ import cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants; import cn.lihu.jh.framework.common.util.object.BeanUtils; import cn.lihu.jh.module.ecg.controller.admin.room.vo.MonitorInfoVO; import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO; import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueStatisticDO; import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; import cn.lihu.jh.module.ecg.dal.mysql.call.CallMapper; import cn.lihu.jh.module.ecg.dal.mysql.checktype.CheckTypeMapper; import cn.lihu.jh.module.ecg.dal.mysql.devrent.DevRentMapper; import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper; import cn.lihu.jh.module.ecg.dal.mysql.room.RoomMapper; @@ -22,6 +24,7 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.lihu.jh.framework.common.pojo.CommonResult.error; @@ -52,6 +55,10 @@ @Resource private DevRentMapper devRentMapper; @Resource private CheckTypeMapper checkTypeMapper; AtomicInteger openingFlag = new AtomicInteger(0); AtomicInteger curSeqNum = new AtomicInteger(0); @@ -63,7 +70,7 @@ // 基于类型的, 装机准备的优先队列 Map<Integer, PriorityBlockingQueue<BedQueueBO>> mapReadyPriorityQueue = new HashMap(); Map<Integer, Integer> mapCheckTypeVsReadyMax = null; Map<Integer, CheckTypeDO> mapCheckTypeVsReadyMax = null; /** * 已关闭 或者 关闭中,可以开通工位 @@ -402,8 +409,9 @@ openingFlag.set(flag); } public void setCheckTypeReadyMax(Map<Integer, Integer> max) { mapCheckTypeVsReadyMax = max; public void initCheckType() { List<CheckTypeDO> checkTypeDOList = checkTypeMapper.simpleCheckTypeList(); mapCheckTypeVsReadyMax = checkTypeDOList.stream().collect(Collectors.toMap(CheckTypeDO::getValue, checkType -> checkType)); } public BedQueueBO getBedQueueBO(Long roomId, String bedNo) { @@ -429,7 +437,8 @@ Integer[] checkTypes = roomDO.getCheckTypes(); Integer ret = 0; for (int i=0; i<checkTypes.length; i++) { Integer tmp = mapCheckTypeVsReadyMax.get(checkTypes[i]); CheckTypeDO checkTypeDO = mapCheckTypeVsReadyMax.get(checkTypes[i]); Integer tmp = checkTypeDO.getReadyNum(); ret = ret < tmp ? tmp : ret; //取大值 } return ret;