1.数据表自定义的时间(我要11和00分开 )

2.启动类添加定时任务逻辑
@MapperScan("com.test.mapper")
public class TestApplication {
private SetUpMapper setUpMapper;
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
//定时任务 @PostConstruct不要丢了
public void scheduleTasks() {
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);
String morning = setUpMapper.selectOneById(5).getParameter().split("-")[1];
//获取小时11,Integer.parseInt(morning.split(":")[0]
//获取分钟00,Integer.parseInt(morning.split(":")[1]
scheduler.schedule(() -> {
System.ou.println("下班啦");
}, getTimeUntilNextExecution(Integer.parseInt(morning.split(":")[0]), Integer.parseInt(morning.split(":")[1])), TimeUnit.SECONDS);
private long getTimeUntilNextExecution(int hour, int minute) {
Calendar now = Calendar.getInstance();
Calendar nextExecutionTime = Calendar.getInstance();
nextExecutionTime.set(Calendar.HOUR_OF_DAY, hour);
nextExecutionTime.set(Calendar.MINUTE, minute);
nextExecutionTime.set(Calendar.SECOND, 0);
if (now.after(nextExecutionTime)) {
// 如果当前时间已经过了指定时间点,则推迟到第二天
nextExecutionTime.add(Calendar.DAY_OF_MONTH, 1);
return (nextExecutionTime.getTimeInMillis() - now.getTimeInMillis()) / 1000;
