| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.lihu.jh.module.ecg.Utils; |
| | | import cn.lihu.jh.module.ecg.config.DynamicSchedulingConfig; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; |
| | | import cn.lihu.jh.module.ecg.service.room.RoomService; |
| | | import org.springframework.scheduling.config.CronTask; |
| | |
| | | private ConfigApi configApi; |
| | | |
| | | @Resource |
| | | private ScheduledTaskRegistrar taskRegistrar; |
| | | |
| | | @Resource |
| | | private QueueService queueService; |
| | | |
| | | @Resource |
| | | private RoomService roomService; |
| | | |
| | | |
| | | @Resource |
| | | private queueMapper queueMapper; |
| | |
| | | |
| | | @Override |
| | | public void resetScheduler() { |
| | | Set<ScheduledTask> taskList = taskRegistrar.getScheduledTasks(); |
| | | taskList.forEach((task)->task.cancel()); |
| | | ScheduledTaskRegistrar taskRegistrar = DynamicSchedulingConfig.static_scheduledTaskRegistrar; |
| | | taskRegistrar.getScheduledTasks().forEach(ScheduledTask::cancel); |
| | | |
| | | String strOpenCloseTime = configApi.getConfigValueByKey(ECG_OPENING_TIME_KEY); |
| | | List<LocalTime> list = Utils.parseOpeningTime(strOpenCloseTime); |
| | |
| | | |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Opening Task executed at: " + System.currentTimeMillis()); |
| | | queueService.startBiz(); |
| | | startBiz(); |
| | | }, openCronExpression)); |
| | | |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Close Task executed at: " + System.currentTimeMillis()); |
| | | queueService.closeBiz(); |
| | | closeBiz(); |
| | | }, closeCronExpression)); |
| | | |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Room Reset Task executed at: " + System.currentTimeMillis()); |
| | | roomService.resetRoom(); |
| | | }, roomResetCronExpression)); |
| | | |
| | | taskRegistrar.afterPropertiesSet(); |
| | | } |
| | | |
| | | @Override |