package com.gyee.benchmarkinghistroy.task; import com.gyee.benchmarkinghistroy.service.benchmarking.BenchmarkingHistroyService; import com.gyee.benchmarkinghistroy.service.infoday.InfodayService; import com.gyee.benchmarkinghistroy.service.specific.SpecificService; import com.gyee.benchmarkinghistroy.service.threerate.ThreeRateService; import com.gyee.common.util.DateUtils; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; import java.util.Date; /** * @ClassName : SaticScheduleTask * @Author : xieshengjie * @Date: 2021/1/21 19:43 * @Description : 调度 */ @Configuration //1.主要用于标记配置类,兼备Component的效果。 @EnableScheduling // 2.开启定时任务 public class SaticScheduleTask { @Resource private BenchmarkingHistroyService benchmarkingHistroyService; @Resource private SpecificService specificService; @Resource private InfodayService infodayService; @Resource private ThreeRateService threeRateService; //3.添加定时任务 /** * 风机绩效榜调度 */ @Scheduled(cron = "0 0 1 * * ?") //或直接指定时间间隔,例如:5秒 //@Scheduled(fixedRate=5000) private void configureTasks1() { Date yestday = DateUtils.getYestday(new Date()); String date = DateUtils.toDate1(yestday); String data1 = DateUtils.toDate1(new Date()); try { //集团需把后三个去掉 benchmarkingHistroyService.saveEquipmentdayinfo(date,date); benchmarkingHistroyService.saveEquipmentdaydetailed(date,date); // benchmarkingHistroyService.saveOperationrecord(date,date); // benchmarkingHistroyService.saveBeanchmarkList(date,date); } catch (Exception e) { e.printStackTrace(); } } /** * 生成对标首页 */ @Scheduled(cron = "0 0 4 * * ?") //或直接指定时间间隔,例如:5秒 //@Scheduled(fixedRate=5000) private void configureTasks2() { Date yestday = DateUtils.getYestday(new Date()); String date = DateUtils.toDate1(yestday); String data1 = DateUtils.toDate1(new Date()); try { benchmarkingHistroyService.saveBenchmark(date,date); } catch (Exception e) { e.printStackTrace(); } } /** * 专题分析调度 */ @Scheduled(cron = "0 0 3 * * ?") //或直接指定时间间隔,例如:5秒 //@Scheduled(fixedRate=5000) private void configureTasks3() { Date yestday = DateUtils.getYestday(new Date()); String date = DateUtils.toDate1(yestday); specificService.saveWindpowerspecificinfoday(date,date); } /** * 存储日信息表 * (原计算服务) */ @Scheduled(cron = "0 30 0 * * ?") //或直接指定时间间隔,例如:5秒 //@Scheduled(fixedRate=5000) private void configureTasks4() { Date yestday = DateUtils.getYestday(new Date()); String date = DateUtils.toDate1(yestday); infodayService.saveWindturbineinfoday(date,date); infodayService.saveWindturbineinfoday3(date,date); infodayService.saveWindpowerinfoday(date,date); infodayService.saveWindpowerinfoday3(date,date); } /** * 专题分析调度 */ @Scheduled(cron = "0 0 1 * * ?") //或直接指定时间间隔,例如:5秒 //@Scheduled(fixedRate=5000) private void configureTasks5() { Date yestday = DateUtils.getYestday(new Date()); String date = DateUtils.toDate1(yestday); threeRateService.FailRate(date,date); threeRateService.ResetAngStateRate(date,date); } }