SaticScheduleTask.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. package com.gyee.datatraining.task;
  2. import com.gyee.datatraining.init.CacheContext;
  3. import com.gyee.datatraining.model.auto.Windpowerstation;
  4. import com.gyee.datatraining.model.auto.Windturbine;
  5. import com.gyee.datatraining.service.DatatrainingService;
  6. import com.gyee.datatraining.util.dd.LstmModelWt;
  7. import com.xxl.job.core.context.XxlJobHelper;
  8. import com.xxl.job.core.handler.annotation.XxlJob;
  9. import org.slf4j.Logger;
  10. import org.slf4j.LoggerFactory;
  11. import org.springframework.stereotype.Component;
  12. import javax.annotation.Resource;
  13. import java.util.List;
  14. import java.util.concurrent.Executor;
  15. /**
  16. * @ClassName : SaticScheduleTask
  17. * @Description : 调度
  18. */
  19. @Component
  20. public class SaticScheduleTask {
  21. private static Logger logger = LoggerFactory.getLogger(SaticScheduleTask.class);
  22. @Resource
  23. private DatatrainingService datatrainingService;
  24. @Resource
  25. private LstmModelWt lstmModelWt;
  26. @Resource
  27. private Executor executor;
  28. private static int produceTaskSleepTime = 10;
  29. //3.添加定时任务
  30. /**
  31. * 健康状态判定
  32. */
  33. // @Scheduled(cron = "0 0/1 * * * ?")
  34. //或直接指定时间间隔,例如:5秒
  35. //@Scheduled(fixedRate=5000)
  36. @XxlJob("datatraining-wtStateJudgment")
  37. public void configureTasks1() {
  38. XxlJobHelper.log("健康状态判定调度程序执行开始!........");
  39. try {
  40. datatrainingService.dataTraining();
  41. } catch (Exception e) {
  42. e.printStackTrace();
  43. }
  44. XxlJobHelper.log("健康状态判定调度任务处理完成!........");
  45. }
  46. /**
  47. * 风机未来4小时数据
  48. */
  49. //@Scheduled(cron = "0 0 0/1 * * ?")
  50. //或直接指定时间间隔,例如:5秒
  51. //@Scheduled(fixedRate=5000)
  52. @XxlJob("datatraining-nextFourHours")
  53. public void configureTasks2() {
  54. XxlJobHelper.log("风机未来4小时数据调度程序执行开始!........");
  55. try {
  56. for (int i = 0; i < CacheContext.wpls.size(); i++) {
  57. Windpowerstation wp=CacheContext.wpls.get(i);
  58. if (wp.getId().endsWith("FDC")) {
  59. List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
  60. try {
  61. Thread.sleep(produceTaskSleepTime);
  62. } catch (InterruptedException e1) {
  63. e1.printStackTrace();
  64. }
  65. new Thread(new StartTaskThread1(executor, i, wtls,wp, lstmModelWt)).start();
  66. }
  67. }
  68. } catch (Exception e) {
  69. e.printStackTrace();
  70. }
  71. XxlJobHelper.log("风机未来4小时数据调度任务处理完成!........");
  72. }
  73. /**
  74. * 风机未来1天数据
  75. */
  76. //@Scheduled(cron = "0 0 0/1 * * ?")
  77. //或直接指定时间间隔,例如:5秒
  78. //@Scheduled(fixedRate=5000)
  79. @XxlJob("datatraining-nextOneDays")
  80. public void configureTasks3() {
  81. XxlJobHelper.log("风机未来1天数据调度程序执行开始!........");
  82. try {
  83. for (int i = 0; i < CacheContext.wpls.size(); i++) {
  84. Windpowerstation wp=CacheContext.wpls.get(i);
  85. if (wp.getId().endsWith("FDC")) {
  86. List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
  87. try {
  88. Thread.sleep(produceTaskSleepTime);
  89. } catch (InterruptedException e1) {
  90. e1.printStackTrace();
  91. }
  92. new Thread(new StartTaskThread2(executor, i, wtls,wp, lstmModelWt)).start();
  93. }
  94. }
  95. } catch (Exception e) {
  96. e.printStackTrace();
  97. }
  98. XxlJobHelper.log("风机未来1天数据调度任务处理完成!........");
  99. }
  100. /**
  101. * 风机未来3天数据
  102. */
  103. //@Scheduled(cron = "0 0 0/1 * * ?")
  104. //或直接指定时间间隔,例如:5秒
  105. //@Scheduled(fixedRate=5000)
  106. @XxlJob("datatraining-nextThreeDays")
  107. public void configureTasks4() {
  108. XxlJobHelper.log("风机未来3天数据调度程序执行开始!........");
  109. try {
  110. for (int i = 0; i < CacheContext.wpls.size(); i++) {
  111. Windpowerstation wp=CacheContext.wpls.get(i);
  112. if (wp.getId().endsWith("FDC")) {
  113. List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
  114. try {
  115. Thread.sleep(produceTaskSleepTime);
  116. } catch (InterruptedException e1) {
  117. e1.printStackTrace();
  118. }
  119. new Thread(new StartTaskThread3(executor, i, wtls,wp, lstmModelWt)).start();
  120. }
  121. }
  122. } catch (Exception e) {
  123. e.printStackTrace();
  124. }
  125. XxlJobHelper.log("风机未来3天数据调度任务处理完成!........");
  126. }
  127. /**
  128. * 风机未来7天数据
  129. */
  130. //@Scheduled(cron = "0 0 0/1 * * ?")
  131. //或直接指定时间间隔,例如:5秒
  132. //@Scheduled(fixedRate=5000)
  133. @XxlJob("datatraining-nextSevenDays")
  134. public void configureTasks5() {
  135. XxlJobHelper.log("风机未来7天数据调度程序执行开始!........");
  136. try {
  137. for (int i = 0; i < CacheContext.wpls.size(); i++) {
  138. Windpowerstation wp=CacheContext.wpls.get(i);
  139. if (wp.getId().endsWith("FDC")) {
  140. List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
  141. try {
  142. Thread.sleep(produceTaskSleepTime);
  143. } catch (InterruptedException e1) {
  144. e1.printStackTrace();
  145. }
  146. new Thread(new StartTaskThread4(executor, i, wtls,wp, lstmModelWt)).start();
  147. }
  148. }
  149. } catch (Exception e) {
  150. e.printStackTrace();
  151. }
  152. XxlJobHelper.log("风机未来7天数据调度任务处理完成!........");
  153. }
  154. /**
  155. * 风机未来1个月数据
  156. */
  157. //@Scheduled(cron = "0 0 0/1 * * ?")
  158. //或直接指定时间间隔,例如:5秒
  159. //@Scheduled(fixedRate=5000)
  160. @XxlJob("datatraining-nextOneMonth")
  161. public void configureTasks6() {
  162. XxlJobHelper.log("风机未来1个月数据调度程序执行开始!........");
  163. try {
  164. for (int i = 0; i < CacheContext.wpls.size(); i++) {
  165. Windpowerstation wp=CacheContext.wpls.get(i);
  166. if (wp.getId().endsWith("FDC")) {
  167. List<Windturbine> wtls=CacheContext.wtsmap.get(wp.getId());
  168. try {
  169. Thread.sleep(produceTaskSleepTime);
  170. } catch (InterruptedException e1) {
  171. e1.printStackTrace();
  172. }
  173. new Thread(new StartTaskThread5(executor, i, wtls,wp, lstmModelWt)).start();
  174. }
  175. }
  176. } catch (Exception e) {
  177. e.printStackTrace();
  178. }
  179. XxlJobHelper.log("风机未来1个月数据调度任务处理完成!........");
  180. }
  181. }