EtlTaskManager.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * Copyright
  3. * All right reserved.
  4. * 项目名称:
  5. * 创建日期:2022/5/23
  6. */
  7. package org.springblade.etl;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder;
  10. import org.springblade.etl.service.*;
  11. import org.springblade.modules.business.project.base.service.IProjectBaseInfoService;
  12. import org.springblade.modules.business.rtu.base.service.IRtuBaseInfoService;
  13. import org.springblade.modules.business.rtu.data.service.IRtuDataGroundService;
  14. import org.springblade.modules.business.rtu.data.service.IRtuDataRainService;
  15. import org.springblade.modules.business.rtu.data.service.IRtuDataRiverService;
  16. import org.springblade.modules.business.rtu.data.service.IRtuDataRsvrService;
  17. import org.springblade.modules.business.rtumanage.service.IRtuManageService;
  18. import org.springblade.modules.business.warning.service.IOriginalWarningService;
  19. import org.springblade.modules.business.warning.service.IRtuWarningService;
  20. import org.springblade.modules.system.service.IDictBizService;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.data.redis.core.RedisTemplate;
  23. import org.springframework.kafka.core.KafkaTemplate;
  24. import org.springframework.messaging.simp.SimpMessagingTemplate;
  25. import org.springframework.scheduling.annotation.EnableScheduling;
  26. import org.springframework.scheduling.annotation.Scheduled;
  27. import org.springframework.stereotype.Component;
  28. import javax.annotation.Resource;
  29. import java.util.concurrent.*;
  30. /***
  31. * Date:2022/5/22
  32. * Title: 环境辐射与气象监测系统(KRS) 模块
  33. * Description:MODBUS TCP 协议传输 ,任务管理
  34. * @author swp
  35. * @version 1.0
  36. * Remark:认为有必要的其他信息
  37. */
  38. @Slf4j
  39. @Component
  40. @EnableScheduling
  41. public class EtlTaskManager {
  42. /**
  43. * 公共线程池
  44. **/
  45. private static ThreadFactory publicThreadFactory = new ThreadFactoryBuilder().setNameFormat("public-thread-pool-%d").build();
  46. private static ExecutorService publicThreadPool = new ThreadPoolExecutor(1, 1,
  47. 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1024), publicThreadFactory, new ThreadPoolExecutor.AbortPolicy());
  48. @Resource
  49. private IEtlWarningService etlWarningService;
  50. @Resource
  51. private IRtuWarningService rtuWarningService;
  52. @Resource
  53. private IRtuBaseInfoService rtuBaseInfoService;
  54. @Resource
  55. private IProjectBaseInfoService projectBaseInfoService;
  56. @Resource
  57. private IRtuDataRiverService dataRiverService;
  58. @Resource
  59. private IRtuDataRsvrService dataRsvrService;
  60. @Resource
  61. private IRtuDataRainService dataRainService;
  62. @Resource
  63. private IRtuDataGroundService dataGroundService;
  64. @Autowired
  65. private KafkaTemplate<String, String> kafkaTemplate;
  66. @Autowired
  67. private SimpMessagingTemplate messagingTemplate;
  68. @Autowired
  69. private RedisTemplate redisTemplate;
  70. @Resource
  71. private IDictBizService dictBizService;
  72. @Resource
  73. private IRtuManageService rtuManageService;
  74. @Resource
  75. private IOriginalWarningService originalWarningService;
  76. @Resource
  77. private IEtlRainDataService etlRainDataService;
  78. @Resource
  79. private IEtlRiverDataService etlRiverDataService;
  80. @Resource
  81. private IEtlRsvrDataService etlRsvrDataService;
  82. @Resource
  83. private IEtlGroundDataService etlGroundDataService;
  84. @Scheduled(cron = "0 0/5 * * * * ")
  85. public void warnTask() {
  86. try {
  87. // EtlRainDataTask task = new EtlRainDataTask(redisTemplate, etlRainDataService, dataRainService);
  88. // FutureTask<Integer> futureTask = new FutureTask<>(task);
  89. // publicThreadPool.execute(futureTask);
  90. // TestWarnTask task2 = new TestWarnTask(redisTemplate,kafkaTemplate,messagingTemplate,etlWarningService,rtuWarningService,rtuBaseInfoService,projectBaseInfoService,dataRainService,dataRiverService,dataRsvrService,dataGroundService,originalWarningService);
  91. // FutureTask<Integer> futureTask2 = new FutureTask<>(task2);
  92. // publicThreadPool.execute(futureTask2);
  93. // TestDataTask task = new TestDataTask(redisTemplate, kafkaTemplate, messagingTemplate, etlWarningService, rtuWarningService, rtuBaseInfoService, projectBaseInfoService, dataRainService, dataRiverService, dataRsvrService, dataGroundService, dictBizService, rtuManageService,etlRainDataService,etlRiverDataService,etlRsvrDataService,etlGroundDataService);
  94. // FutureTask<Integer> futureTask = new FutureTask<>(task);
  95. // publicThreadPool.execute(futureTask);
  96. } catch (Exception e) {
  97. log.error("{}", e.getMessage());
  98. }
  99. }
  100. }