/**
 * Copyright
 * All right reserved.
 * 项目名称:
 * 创建日期:2022/5/23
 */
package org.springblade.etl;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;


/***
 * Date:2022/5/22
 * Title:  ETL模块
 * Description： 定时任务管理
 * @author swp
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@Slf4j
@Component
@EnableScheduling
public class EtlTaskManager {

	/**
	 * 公共线程池
	 **/
//	private static ThreadFactory publicThreadFactory = new ThreadFactoryBuilder().setNameFormat("etl-thread-pool-%d").build();
//	private static ExecutorService publicThreadPool = new ThreadPoolExecutor(1, 1,
//		0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1024), publicThreadFactory, new ThreadPoolExecutor.AbortPolicy());


	@Autowired
	private KafkaTemplate<String, String> kafkaTemplate;

	@Autowired
	private RedisTemplate redisTemplate;
//
//	@Resource
//	private IEtlRainDataService etlRainDataService;
//
//	@Resource
//	private IRtuDataRainService rtuDataRainService;
//
//	@Resource
//	private IEtlRiverDataService etlRiverDataService;
//
//	@Resource
//	private IRtuDataRiverService rtuDataRiverService;
//
//	@Resource
//	private IEtlRsvrDataService etlRsvrDataService;
//
//	@Resource
//	private IRtuDataRsvrService rtuDataRsvrService;
//
//	@Resource
//	private IEtlGroundDataService etlGroundDataService;
//
//	@Resource
//	private IRtuDataGroundService rtuDataGroundService;
//
//	@Resource
//	private IEtlMvAttStBaseService etlMvAttStBaseService;
//
//	@Resource
//	private IMvAttStBaseService mvAttStBaseService;
//
//	@Resource
//	private IRtuBaseInfoService rtuBaseInfoService;

	@Value("${spring.task-config.etl-task}")
	boolean etlTask;
//
//	@Resource
//	private TaskManager taskManager;

//	@Scheduled(cron = "0 0 0/1 * * ?")
//	public void attStBaseReadTask() {
//		try {
//			if (etlTask) {
//				EtlMvAttStBaseDataTask mvAttStBaseDataTask = new EtlMvAttStBaseDataTask(etlMvAttStBaseService, mvAttStBaseService);
//				FutureTask<Integer> futureTask = new FutureTask<>(mvAttStBaseDataTask);
//				taskManager.submitTask(futureTask);
//			}
//		} catch (Exception e) {
//			log.error("{}", e.getMessage());
//		}
//	}

//	@Scheduled(cron = "0 0/5 * * * ?")
//	public void rtuDataReadTask() {
//		try {
//			if (etlTask) {
//				EtlRtuDataTask etlRtuDataTask = new EtlRtuDataTask(kafkaTemplate, redisTemplate, rtuBaseInfoService, etlRainDataService, rtuDataRainService, etlRiverDataService, rtuDataRiverService, etlRsvrDataService, rtuDataRsvrService, etlGroundDataService, rtuDataGroundService);
//				FutureTask<Integer> futureTask = new FutureTask<>(etlRtuDataTask);
//				taskManager.submitTask(futureTask);
//			}
//		} catch (Exception e) {
//			log.error("{}", e.getMessage());
//		}
//	}

}
