package com.moral.api.task; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.moral.api.service.HistoryFiveMinutelyService; 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; //分钟表创建任务 @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; } }