jinpengyong
2020-06-03 8143ce1b902f99d8333475aa06e3c08e5e4164cf
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
package com.moral.task;
 
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import com.moral.service.AlarmService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
 
@Component
public class AlarmTableInsertTask {
    private static transient Logger logger = LoggerFactory.getLogger(AlarmTableInsertTask.class);
 
    @Resource
    private AlarmService alarmService;
 
    @XxlJob("alarmDaily")
    public ReturnT insertAlarmDailyTable(String param) {
            alarmService.insertAlarmDaily();
            return new ReturnT(200, "插入天表成功");
 
    }
 
    @XxlJob("createAlarmSubTable")
    public ReturnT createAlarmSubTable(String param) {
        LocalDateTime time = LocalDateTime.now().plusMonths(1);
        String year = time.getYear() + "";
        String month = time.getMonthValue() + "";
        if (time.getMonthValue() < 10) {
            month = "0" + time.getMonthValue();
        }
        alarmService.createTable(year + month);
        ReturnT returnT = new ReturnT(200, "创建alarm年月分表成功");
        return returnT;
    }
}