cjl
2024-08-09 a022ae9804d0c2f402711b6b5202319d853919cf
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.moral.api.task;
 
import com.moral.api.service.AlarmInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.moral.api.service.HistoryFiveMinutelyService;
import com.moral.api.service.HistoryHourlyService;
import com.moral.api.service.HistoryMinutelyService;
import com.moral.constant.Constants;
import com.moral.util.DateUtils;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
 
@Component
public class CreateTableTask {
 
    @Autowired
    private HistoryFiveMinutelyService historyFiveMinutelyService;
 
    @Autowired
    private HistoryMinutelyService historyMinutelyService;
 
    @Autowired
    private HistoryHourlyService historyHourlyService;
 
    @Autowired
    private AlarmInfoService alarmInfoService;
 
 
    //分钟表创建任务
    @XxlJob("createHistoryMinutelyTable")
    public ReturnT createHistoryMinutelyTable() {
        String timeUnits = DateUtils.getDateStringOfMon(1, DateUtils.yyyyMM_EN);
        try {
            //已校准分钟表
            historyMinutelyService.createTable(timeUnits);
            //未校准分钟表
            historyMinutelyService.createTable(timeUnits + "_" + Constants.UN_ADJUST);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
 
    //5分钟表创建任务
    @XxlJob("createHistoryFiveMinutelyTable")
    public ReturnT createHistoryFiveMinutelyTable() {
        String timeUnits = DateUtils.getDateStringOfMon(1, DateUtils.yyyyMM_EN);
        try {
            historyFiveMinutelyService.createTable(timeUnits);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
 
    //小时表创建任务
    @XxlJob("createHistoryHourlyTable")
    public ReturnT createHistoryHourlyTable() {
        String timeUnits = DateUtils.getDateStringOfMon(1, DateUtils.yyyyMM_EN);
        try {
            //已校准小时表
            historyHourlyService.createTable(timeUnits);
            //未校准小时表
            historyHourlyService.createTable(timeUnits + "_" + Constants.UN_ADJUST);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
 
    //包含最大值,最小值,平均值的小时表创建任务
    @XxlJob("createHistoryHourlyCompleteTable")
    public ReturnT createHistoryHourlyCompleteTable(){
        String timeUnits = DateUtils.getDateStringOfMon(1, DateUtils.yyyyMM_EN);
        try {
            historyHourlyService.createTableComplete(timeUnits);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
 
    //小时表创建任务
    @XxlJob("createAlarmInfoTable")
    public ReturnT createAlarmInfoTable() {
        String timeUnits = DateUtils.getDateStringOfMon(1, DateUtils.yyyyMM_EN);
        try {
            alarmInfoService.createTable(timeUnits);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
}