cjl
2023-07-27 20f693a9af9e90931ecb004700ec96453d05cecb
screen-job/src/main/java/com/moral/api/task/HistoryTableInsertTask.java
@@ -3,28 +3,35 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.moral.api.entity.HistoryDaily;
import com.moral.api.service.HistoryDailyService;
import com.moral.api.service.HistoryFiveMinutelyService;
import com.moral.api.service.HistoryHourlyService;
import com.moral.api.service.HistoryMonthlyService;
import com.moral.api.service.HistoryWeeklyService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import javax.xml.crypto.Data;
import java.util.Date;
@Component
public class HistoryTableInsertTask {
    @Autowired
    private HistoryFiveMinutelyService historyFiveMinutelyService;
    @Autowired
    private HistoryHourlyService historyHourlyService;
    @Autowired
    private HistoryDailyService historyDailyService;
    @Autowired
    private HistoryFiveMinutelyService historyFiveMinutelyService;
    private HistoryWeeklyService historyWeeklyService;
    @Autowired
    private HistoryMonthlyService historyMonthlyService;
    //5分钟数据统计
    @XxlJob("insertHistoryFiveMinutely")
@@ -33,7 +40,7 @@
            historyFiveMinutelyService.insertHistoryFiveMinutely();
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return ReturnT.FAIL;
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
@@ -42,11 +49,71 @@
    @XxlJob("insertHistoryDaily")
    public ReturnT insertHistoryDaily() {
        try {
            historyDailyService.insertHistoryDaily();
            Date now = new Date();
            historyDailyService.insertHistoryDaily(null);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
    //周数据统计
    @XxlJob("insertHistoryWeekly")
    public ReturnT insertHistoryWeekly() {
        try {
            historyWeeklyService.insertHistoryWeekly();
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
    //月数据统计
    @XxlJob("insertHistoryMonthly")
    public ReturnT insertHistoryMonthly() {
        try {
            historyMonthlyService.insertHistoryMonthly();
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
    //缺失小时数据补充
    @XxlJob("historyHourlySupplement")
    public ReturnT historyHourlySupplement() {
        try {
            historyHourlyService.insertHistoryHourly();
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
    //设备小时数据,最大值,最小值,均值统计任务
    @XxlJob("insertHistoryHourlyComplete")
    public ReturnT insertHistoryHourlyComplete(){
        try {
            historyHourlyService.insertHistoryHourlyComplete();
        } catch (Exception e) {
            e.printStackTrace();
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
    @XxlJob("dateToChangShu")
    public ReturnT dateToChangShu(){
        try {
            historyHourlyService.dateToChangShu(null);
        } catch (Exception e) {
            e.printStackTrace();
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
}