SaticScheduleTask.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package com.gyee.benchmarkinghistroy.task;
  2. import com.gyee.benchmarkinghistroy.service.benchmarking.BenchmarkingHistroyService;
  3. import com.gyee.benchmarkinghistroy.service.infoday.InfodayService;
  4. import com.gyee.benchmarkinghistroy.service.specific.SpecificService;
  5. import com.gyee.benchmarkinghistroy.service.threerate.ThreeRateService;
  6. import com.gyee.common.util.DateUtils;
  7. import org.springframework.context.annotation.Configuration;
  8. import org.springframework.scheduling.annotation.EnableScheduling;
  9. import org.springframework.scheduling.annotation.Scheduled;
  10. import javax.annotation.Resource;
  11. import java.util.Date;
  12. /**
  13. * @ClassName : SaticScheduleTask
  14. * @Author : xieshengjie
  15. * @Date: 2021/1/21 19:43
  16. * @Description : 调度
  17. */
  18. @Configuration //1.主要用于标记配置类,兼备Component的效果。
  19. @EnableScheduling // 2.开启定时任务
  20. public class SaticScheduleTask {
  21. @Resource
  22. private BenchmarkingHistroyService benchmarkingHistroyService;
  23. @Resource
  24. private SpecificService specificService;
  25. @Resource
  26. private InfodayService infodayService;
  27. @Resource
  28. private ThreeRateService threeRateService;
  29. //3.添加定时任务
  30. /**
  31. * 风机绩效榜调度
  32. */
  33. @Scheduled(cron = "0 0 1 * * ?")
  34. //或直接指定时间间隔,例如:5秒
  35. //@Scheduled(fixedRate=5000)
  36. private void configureTasks1() {
  37. Date yestday = DateUtils.getYestday(new Date());
  38. String date = DateUtils.toDate1(yestday);
  39. String data1 = DateUtils.toDate1(new Date());
  40. try {
  41. //集团需把后三个去掉
  42. benchmarkingHistroyService.saveEquipmentdayinfo(date,date);
  43. benchmarkingHistroyService.saveEquipmentdaydetailed(date,date);
  44. // benchmarkingHistroyService.saveOperationrecord(date,date);
  45. // benchmarkingHistroyService.saveBeanchmarkList(date,date);
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. }
  49. }
  50. /**
  51. * 生成对标首页
  52. */
  53. @Scheduled(cron = "0 0 4 * * ?")
  54. //或直接指定时间间隔,例如:5秒
  55. //@Scheduled(fixedRate=5000)
  56. private void configureTasks2() {
  57. Date yestday = DateUtils.getYestday(new Date());
  58. String date = DateUtils.toDate1(yestday);
  59. String data1 = DateUtils.toDate1(new Date());
  60. try {
  61. benchmarkingHistroyService.saveBenchmark(date,date);
  62. } catch (Exception e) {
  63. e.printStackTrace();
  64. }
  65. }
  66. /**
  67. * 专题分析调度
  68. */
  69. @Scheduled(cron = "0 0 3 * * ?")
  70. //或直接指定时间间隔,例如:5秒
  71. //@Scheduled(fixedRate=5000)
  72. private void configureTasks3() {
  73. Date yestday = DateUtils.getYestday(new Date());
  74. String date = DateUtils.toDate1(yestday);
  75. specificService.saveWindpowerspecificinfoday(date,date);
  76. }
  77. /**
  78. * 存储日信息表
  79. * (原计算服务)
  80. */
  81. @Scheduled(cron = "0 30 0 * * ?")
  82. //或直接指定时间间隔,例如:5秒
  83. //@Scheduled(fixedRate=5000)
  84. private void configureTasks4() {
  85. Date yestday = DateUtils.getYestday(new Date());
  86. String date = DateUtils.toDate1(yestday);
  87. infodayService.saveWindturbineinfoday(date,date);
  88. infodayService.saveWindturbineinfoday3(date,date);
  89. infodayService.saveWindpowerinfoday(date,date);
  90. infodayService.saveWindpowerinfoday3(date,date);
  91. }
  92. /**
  93. * 专题分析调度
  94. */
  95. @Scheduled(cron = "0 0 1 * * ?")
  96. //或直接指定时间间隔,例如:5秒
  97. //@Scheduled(fixedRate=5000)
  98. private void configureTasks5() {
  99. Date yestday = DateUtils.getYestday(new Date());
  100. String date = DateUtils.toDate1(yestday);
  101. threeRateService.FailRate(date,date);
  102. threeRateService.ResetAngStateRate(date,date);
  103. }
  104. }