xuhy
2024-12-16 1734f2d56162a1fdb556632dc36fcef0ca57851c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.jilongda.manage.utils;
 
 
import com.jilongda.manage.model.TLineUp;
import com.jilongda.manage.service.TLineUpService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
 
 
/**
 * 定时任务工具类
 */
@Component
public class TaskUtil {
    
    @Resource
    private TLineUpService lineUpService;
 
    // 每天晚上9点执行的定时任务
    @Scheduled(cron = "0 0 23 * * ?")
    public void taskNineDay() {
        try {
            System.err.println("执行每天晚上定时任务 排号修改状态");
            List<TLineUp> list = lineUpService.lambdaQuery().eq(TLineUp::getStatus, 1).list();
            for (TLineUp tLineUp : list) {
                tLineUp.setStatus(5);
            }
            lineUpService.updateBatchById(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}