| | |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import org.springframework.scheduling.annotation.SchedulingConfigurer; |
| | | import org.springframework.scheduling.config.CronTask; |
| | | import org.springframework.scheduling.config.ScheduledTask; |
| | | import org.springframework.scheduling.config.ScheduledTaskRegistrar; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | LocalTime roomResetTime = Utils.parseTime(strRoomResetTime); |
| | | String roomResetCronExpression = String.format("0 %d %d * * ?", roomResetTime.getMinute(), roomResetTime.getHour()); |
| | | |
| | | taskRegistrar.addCronTask(() -> { |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Opening Task executed at: " + System.currentTimeMillis()); |
| | | queueService.startBiz(); |
| | | }, openCronExpression); |
| | | }, openCronExpression)); |
| | | |
| | | taskRegistrar.addCronTask(() -> { |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Close Task executed at: " + System.currentTimeMillis()); |
| | | queueService.closeBiz(); |
| | | }, closeCronExpression); |
| | | }, closeCronExpression)); |
| | | |
| | | taskRegistrar.addCronTask(() -> { |
| | | taskRegistrar.scheduleCronTask(new CronTask(() -> { |
| | | System.out.println("Room Reset Task executed at: " + System.currentTimeMillis()); |
| | | roomService.resetRoom(); |
| | | }, roomResetCronExpression); |
| | | }, roomResetCronExpression)); |
| | | } |
| | | |
| | | } |