|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private HistoryMinutelyService historyMinutelyService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private HistoryHourlyService historyHourlyService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private AlarmInfoService alarmInfoService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //分钟表创建任务 | 
|---|
|  |  |  | @XxlJob("createHistoryMinutelyTable") | 
|---|
|  |  |  | 
|---|
|  |  |  | historyMinutelyService.createTable(timeUnits + "_" + Constants.UN_ADJUST); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | XxlJobHelper.log(e.getMessage()); | 
|---|
|  |  |  | return ReturnT.FAIL; | 
|---|
|  |  |  | return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ReturnT.SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | historyFiveMinutelyService.createTable(timeUnits); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | XxlJobHelper.log(e.getMessage()); | 
|---|
|  |  |  | return ReturnT.FAIL; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|