123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- package com.gyee.datatraining.task;
- import com.gyee.datatraining.init.CacheContext;
- import com.gyee.datatraining.model.auto.Windpowerstation;
- import com.gyee.datatraining.model.auto.Windturbine;
- import com.gyee.datatraining.service.DatatrainingService;
- import com.gyee.datatraining.util.dd.LstmModelWt;
- import com.xxl.job.core.context.XxlJobHelper;
- import com.xxl.job.core.handler.annotation.XxlJob;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.stereotype.Component;
- import javax.annotation.Resource;
- import java.util.List;
- import java.util.concurrent.Executor;
- /**
- * @ClassName : SaticScheduleTask
- * @Description : 调度
- */
- @Component
- public class SaticScheduleTask {
- private static Logger logger = LoggerFactory.getLogger(SaticScheduleTask.class);
- @Resource
- private DatatrainingService datatrainingService;
- @Resource
- private LstmModelWt lstmModelWt;
- @Resource
- private Executor executor;
- private static int produceTaskSleepTime = 10;
- //3.添加定时任务
- /**
- * 健康状态判定
- */
- // @Scheduled(cron = "0 0/1 * * * ?")
- //或直接指定时间间隔,例如:5秒
- //@Scheduled(fixedRate=5000)
- @XxlJob("datatraining-wtStateJudgment")
- public void configureTasks1() {
- XxlJobHelper.log("健康状态判定调度程序执行开始!........");
- try {
- datatrainingService.dataTraining();
- } catch (Exception e) {
- e.printStackTrace();
- }
- XxlJobHelper.log("健康状态判定调度任务处理完成!........");
- }
- /**
- * 风机未来4小时数据
- */
- //@Scheduled(cron = "0 0 0/1 * * ?")
- //或直接指定时间间隔,例如:5秒
- //@Scheduled(fixedRate=5000)
- @XxlJob("datatraining-nextFourHours")
- public void configureTasks2() {
- XxlJobHelper.log("风机未来4小时数据调度程序执行开始!........");
- try {
- for (int i = 0; i < CacheContext.wpls.size(); i++) {
- Windpowerstation wp=CacheContext.wpls.get(i);
- if (wp.getId().endsWith("FDC")) {
- List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
- try {
- Thread.sleep(produceTaskSleepTime);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- new Thread(new StartTaskThread1(executor, i, wtls,wp, lstmModelWt)).start();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- XxlJobHelper.log("风机未来4小时数据调度任务处理完成!........");
- }
- /**
- * 风机未来1天数据
- */
- //@Scheduled(cron = "0 0 0/1 * * ?")
- //或直接指定时间间隔,例如:5秒
- //@Scheduled(fixedRate=5000)
- @XxlJob("datatraining-nextOneDays")
- public void configureTasks3() {
- XxlJobHelper.log("风机未来1天数据调度程序执行开始!........");
- try {
- for (int i = 0; i < CacheContext.wpls.size(); i++) {
- Windpowerstation wp=CacheContext.wpls.get(i);
- if (wp.getId().endsWith("FDC")) {
- List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
- try {
- Thread.sleep(produceTaskSleepTime);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- new Thread(new StartTaskThread2(executor, i, wtls,wp, lstmModelWt)).start();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- XxlJobHelper.log("风机未来1天数据调度任务处理完成!........");
- }
- /**
- * 风机未来3天数据
- */
- //@Scheduled(cron = "0 0 0/1 * * ?")
- //或直接指定时间间隔,例如:5秒
- //@Scheduled(fixedRate=5000)
- @XxlJob("datatraining-nextThreeDays")
- public void configureTasks4() {
- XxlJobHelper.log("风机未来3天数据调度程序执行开始!........");
- try {
- for (int i = 0; i < CacheContext.wpls.size(); i++) {
- Windpowerstation wp=CacheContext.wpls.get(i);
- if (wp.getId().endsWith("FDC")) {
- List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
- try {
- Thread.sleep(produceTaskSleepTime);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- new Thread(new StartTaskThread3(executor, i, wtls,wp, lstmModelWt)).start();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- XxlJobHelper.log("风机未来3天数据调度任务处理完成!........");
- }
- /**
- * 风机未来7天数据
- */
- //@Scheduled(cron = "0 0 0/1 * * ?")
- //或直接指定时间间隔,例如:5秒
- //@Scheduled(fixedRate=5000)
- @XxlJob("datatraining-nextSevenDays")
- public void configureTasks5() {
- XxlJobHelper.log("风机未来7天数据调度程序执行开始!........");
- try {
- for (int i = 0; i < CacheContext.wpls.size(); i++) {
- Windpowerstation wp=CacheContext.wpls.get(i);
- if (wp.getId().endsWith("FDC")) {
- List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
- try {
- Thread.sleep(produceTaskSleepTime);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- new Thread(new StartTaskThread4(executor, i, wtls,wp, lstmModelWt)).start();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- XxlJobHelper.log("风机未来7天数据调度任务处理完成!........");
- }
- /**
- * 风机未来1个月数据
- */
- //@Scheduled(cron = "0 0 0/1 * * ?")
- //或直接指定时间间隔,例如:5秒
- //@Scheduled(fixedRate=5000)
- @XxlJob("datatraining-nextOneMonth")
- public void configureTasks6() {
- XxlJobHelper.log("风机未来1个月数据调度程序执行开始!........");
- try {
- for (int i = 0; i < CacheContext.wpls.size(); i++) {
- Windpowerstation wp=CacheContext.wpls.get(i);
- if (wp.getId().endsWith("FDC")) {
- List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
- try {
- Thread.sleep(produceTaskSleepTime);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- new Thread(new StartTaskThread5(executor, i, wtls,wp, lstmModelWt)).start();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- XxlJobHelper.log("风机未来1个月数据调度任务处理完成!........");
- }
- }
|