xing
2023-02-23 c75e6f4696634d626c5569794c6349593853223a
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
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.yssh.controller;
 
 
import com.yssh.service.Yssh2dreliService;
import com.yssh.service.Yssh3dreliService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
 
/**
 * 定时任务处理数据控制器
 *
 * @author xingjs
 * @date 2023/02/06
 */
@Component("sqlDataTask")
public class DealDataTaksController {
 
    @Autowired
    private Yssh2dreliService yssh2dreliService;
 
    @Autowired
    private Yssh3dreliService yssh3dreliService;
 
 
    //每天晚上23:59:00点执行
    @Scheduled(cron = "0 59 23 * * ?")
    public void createTable() {
        yssh2dreliService.create2dreliTable();
        System.out.println("========创建2维热力表执行完毕======== ");
        yssh3dreliService.create3dreliTable();
        System.out.println("========创建3维热力执行完毕======== ");
    }
 
 
    /**
     * 删除前几年数据
     * //删除前一年的数据 每天晚上0点执行
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void deletePreviousYearsData() {
        yssh2dreliService.drop2dreliTable();
        System.out.println("========删除2维热力表执行完毕======== ");
        yssh3dreliService.drop3dreliTable();
        System.out.println("========删除3维热力执行完毕======== ");
    }
 
 
 
}