燕山石化项目数据提取服务
xing
2023-02-24 08c8552eb977f27304a4785e5a671905463d83c1
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
package com.terra.bigdata.util;
 
import com.terra.bigdata.service.Yssh3dreliService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.text.SimpleDateFormat;
import java.util.Date;
 
/**
 * 定时任务处理数据控制器
 *
 * @author xingjs
 * @date 2023/02/06
 */
//@Component("sqlDataTask")
public class ScheduledTasksUtils {
 
    //定时任务表达式
    @Value("${task.cron}")
    private String timingTaskExpression;
 
    @Autowired
    private Yssh3dreliService yssh3dreliService;
 
 
    //每天晚上23:59:00点执行创建第二天的数据表
    @Scheduled(cron = "0 59 23 * * ?")
    public void createTable() {
        System.out.println("执行有参方法,参数为:" + timingTaskExpression);
        //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维热力执行完毕======== ");
    }
 
}