| | |
| | | public class QueueServiceImpl implements QueueService { |
| | | |
| | | @Resource |
| | | private ConfigApi configApi; |
| | | |
| | | @Resource |
| | | private RoomService roomService; |
| | | |
| | | @Resource |
| | | private queueMapper queueMapper; |
| | | |
| | | @Resource |
| | |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | @Override |
| | | public void startHurryUp() { |
| | | singleThreadExecutor.execute( () -> { |
| | | hurryup(); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void startBedReload() { |
| | | singleThreadExecutor.execute( () -> { |
| | | bedReload(); |
| | | hurryup(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 已关闭 或者 关闭中,可以开通工位 |
| | |
| | | // DB update |
| | | List statusList = new ArrayList<BedStatusEnum>(); |
| | | statusList.add(BedStatusEnum.DOCTOR_ON); |
| | | statusList.add(BedStatusEnum.PAUSE); |
| | | Integer updateNum = roomMapper.setBedDoctorOff(roomId, bedNo, docId, BedStatusEnum.OPENING, statusList); |
| | | if ( null==updateNum || 0 == updateNum ) { |
| | | log.error("bedDoctorOff DB invalid status. " + roomId + " " + bedNo); |
| | | return ROOM_INVALID_STATUS; |
| | | } |
| | | |
| | | // 如果是在 PAUSE 状态离座的,需要重新加回 优先队列 |
| | | if (bedQueueBO.getStatus().equals(BedStatusEnum.PAUSE.getStatus())) { |
| | | if (!priorityQueue.contains(bedQueueBO)) { |
| | | priorityQueue.offer(bedQueueBO); |
| | | } else { |
| | | log.error("bedDoctorResume priorityQueue still exist!. " + roomId + " " + bedNo); |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | } |
| | | |
| | | bedQueueBO.setStatus(BedStatusEnum.OPENING.getStatus()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void resetScheduler() { |
| | | ScheduledTaskRegistrar taskRegistrar = DynamicSchedulingConfig.static_scheduledTaskRegistrar; |
| | | taskRegistrar.getScheduledTasks().forEach(ScheduledTask::cancel); |
| | | |
| | | String strOpenCloseTime = configApi.getConfigValueByKey(ECG_OPENING_TIME_KEY); |
| | | List<LocalTime> list = Utils.parseOpeningTime(strOpenCloseTime); |
| | | LocalTime openingTime = list.get(0); |
| | | LocalTime closeTime = list.get(1); |
| | | String openCronExpression = String.format("0 %d %d * * ?", openingTime.getMinute(), openingTime.getHour()); |
| | | String closeCronExpression = String.format("0 %d %d * * ?", closeTime.getMinute(), closeTime.getHour()); |
| | | |
| | | String strRoomResetTime = configApi.getConfigValueByKey(ECG_ROOM_RESET_TIME_KEY); |
| | | LocalTime roomResetTime = Utils.parseTime(strRoomResetTime); |
| | | String roomResetCronExpression = String.format("0 %d %d * * ?", roomResetTime.getMinute(), roomResetTime.getHour()); |
| | | |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Opening Task executed at: " + System.currentTimeMillis()); |
| | | startBiz(); |
| | | }, openCronExpression)); |
| | | |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Close Task executed at: " + System.currentTimeMillis()); |
| | | closeBiz(); |
| | | }, closeCronExpression)); |
| | | |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Room Reset Task executed at: " + System.currentTimeMillis()); |
| | | roomService.resetRoom(); |
| | | }, roomResetCronExpression)); |
| | | |
| | | taskRegistrar.afterPropertiesSet(); |
| | | } |
| | | |
| | | @Override |
| | | public Integer recallPatient(Long roomId, String bedNo, String patId) { |
| | | Integer updateNum = queueMapper.recallPassedPatient(roomId, bedNo, patId, |
| | | QueueStatusEnum.PASSED.getStatus(), QueueStatusEnum.PASSED_RETURN.getStatus()); |
| | |
| | | public void monitorInfo() { |
| | | log.info("map " + mapBedVsQueue.size() + " priority " + priorityQueue.size() |
| | | + " opening " + openingFlag.get()); |
| | | } |
| | | |
| | | private void startHurryUp() { |
| | | singleThreadExecutor.execute( () -> { |
| | | hurryup(); |
| | | }); |
| | | } |
| | | |
| | | private void startBedReload() { |
| | | singleThreadExecutor.execute( () -> { |
| | | bedReload(); |
| | | hurryup(); |
| | | }); |
| | | } |
| | | |
| | | } |