package com.gyee.generation;


import com.gyee.generation.service.EquipmentInfo5Service;
import com.gyee.generation.service.EquipmentInfoDayTopService;
import com.gyee.generation.service.ReCalSevice;
import com.gyee.generation.service.WtAlysisDayService;
import com.gyee.generation.util.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.mybatis.spring.annotation.MapperScan;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;


/**
 * @ClassName : GenerationMain
 * @Author : xieshengjie
 * @Date: 2022/2/28 14:55
 * @Description :
 */
@SpringBootApplication
@EnableFeignClients
@EnableScheduling   // 启用定时任务调度
@EnableAsync        // 启用异步执行
@MapperScan({"com.gyee.generation.mapper"})
public class GenerationMain {


    public static void main(String[] args) throws Exception {
        SpringApplication.run(GenerationMain.class, args);

        System.out.println("启动完成");

        //        /*************************风机历史计算服务**************************/
        Calendar c1 = Calendar.getInstance();

        c1.add(Calendar.DAY_OF_MONTH, -1);
        ReCalSevice reCalSevice = SpringUtils.getBean("reCalSevice");

        Calendar c = Calendar.getInstance();
        Logger logger = LoggerFactory.getLogger(GenerationMain.class);

        //        //重算风机
        reCalSevice.calWt(c.getTime());

        while (true) {

            Date begin = new Date();
            Date end = null;
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            logger.info(df.format(c.getTime()).toString());


//            EquipmentInfo1Service equipmentInfo1Service = SpringUtils.getBean("equipmentInfo1Service");
//            EquipmentInfo2Service equipmentInfo2Service = SpringUtils.getBean("equipmentInfo2Service");
//            EquipmentInfo3Service equipmentInfo3Service = SpringUtils.getBean("equipmentInfo3Service");


//            equipmentInfo1Service.calEquipmentInfoDay(begin);
//            logger.info("equipmentInfo1Service完成一次!。。。。。。");
//            TimeUnit.SECONDS.sleep(3);
//            equipmentInfo2Service.calEquipmentInfoDay(begin);
//            logger.info("equipmentInfo2Service完成一次!。。。。。。");
//            TimeUnit.SECONDS.sleep(3);
//            equipmentInfo3Service.calEquipmentInfoDay(begin);
//            logger.info("equipmentInfo3Service完成一次!。。。。。。");
//            TimeUnit.SECONDS.sleep(3);
            logger.info("equipmentInfo5Service开始!。。。。。。");
            EquipmentInfo5Service equipmentInfo5Service = SpringUtils.getBean("equipmentInfo5Service");
            TimeUnit.SECONDS.sleep(3);
//            EquipmentInfo4Service equipmentInfo4Service = SpringUtils.getBean("equipmentInfo4Service");
//            TimeUnit.SECONDS.sleep(3);
            equipmentInfo5Service.calEquipmentInfoDay(begin);
            logger.info("equipmentInfo5Service完成一次!。。。。。。");
//            logger.info("equipmentInfo4Service开始!。。。。。。");
//            equipmentInfo4Service.calEquipmentInfoDay(begin);
//            logger.info("equipmentInfo4Service完成一次!。。。。。。");

            WtAlysisDayService wtAlysisDayService = SpringUtils.getBean("wtAlysisDayService");

            EquipmentInfoDayTopService equipmentInfoDayTopService = SpringUtils.getBean("equipmentInfoDayTopService");
            equipmentInfoDayTopService.calEquipmentInfoDayTop(begin);
            equipmentInfoDayTopService.calEquipmentInfoMonthTop(begin);
            equipmentInfoDayTopService.calEquipmentInfoYearTop(begin);

            TimeUnit.SECONDS.sleep(3);
            logger.info("wtAlysisyService开始!。。。。。。");
            wtAlysisDayService.calEquipmentInfoDay(begin);
            logger.info("wtAlysisyService完成!。。。。。。");
            end = new Date();
            logger.info(df.format(end).toString());
            logger.info("完成一次!。。。。。。");
            logger.info("执行用时" + com.gyee.generation.util.DateUtils.secondsDiff(begin, end) + "秒");

            TimeUnit.MINUTES.sleep(15);
        }
        //
        //        /*************************风机历史计算服务**************************/
        //
        //
        //        /*************************逆变器历史计算服务**************************/
        //        Calendar c = Calendar.getInstance();
        //        Logger logger = LoggerFactory.getLogger(GenerationMain.class);
        //
        //        while (true) {
        //
        //            Date begin = new Date();
        //            Date end = null;
        //            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //            logger.info(df.format(c.getTime()).toString());
        //
        //
        //            EquipmentInfo1Service equipmentInfo1Service = SpringUtils.getBean("equipmentInfo1Service");
        //            EquipmentInfo2Service equipmentInfo2Service = SpringUtils.getBean("equipmentInfo2Service");
        //            EquipmentInfo3Service equipmentInfo3Service = SpringUtils.getBean("equipmentInfo3Service");
        //
        //
        //            equipmentInfo1Service.calEquipmentInfoDay(begin);
        //            TimeUnit.SECONDS.sleep(3);
        //            equipmentInfo2Service.calEquipmentInfoDay(begin);
        //            TimeUnit.SECONDS.sleep(3);
        //            equipmentInfo3Service.calEquipmentInfoDay(begin);
        //            TimeUnit.SECONDS.sleep(3);
        //
        //
        //            end = new Date();
        //            logger.info(df.format(end).toString());
        //            logger.info("完成一次!。。。。。。");
        //            logger.info("执行用时" + com.gyee.generation.util.DateUtils.secondsDiff(begin, end) + "秒");
        //            TimeUnit.MINUTES.sleep(15);
        //        }
        //
        //        /*************************逆变器历史计算服务**************************/
        //
        //
        //        /*************************15分钟实时状态计算服务**************************/
        //        Calendar c = Calendar.getInstance();
        //
        //
        //        while (true) {
        //
        //            Date begin = new Date();
        //            Date end = null;
        //            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //            System.out.println(df.format(c.getTime()).toString());
        //
        //
        //
        //
        //            CycleCalculationService cycleCalculationService= SpringUtils.getBean("cycleCalculationService");
        //
        //            cycleCalculationService.saveCyle();
        //
        //
        //            end = new Date();
        //            System.out.println(df.format(end).toString());
        //            System.out.println("完成一次!。。。。。。");
        //            System.out.println("执行用时" + com.gyee.generation.util.DateUtils.secondsDiff(begin, end) + "秒");
        //            Thread.sleep(3000);
        //        }
        //
        //        /*************************状态实时状态计算服务**************************/
        //
        //        /*************************健康管理测点导出**************************/
        //        Calendar c = Calendar.getInstance();
        //
        //
        //        Date begin = new Date();
        //        Date end = null;
        //        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //        System.out.println(df.format(c.getTime()).toString());
        //
        //
        //        InitialPointGoldenXkByEqService initialPointGoldenXkByEqService = SpringUtils.getBean("initialPointGoldenXkByEqService");
        //
        //        initialPointGoldenXkByEqService.initalJkfc();
        //        initialPointGoldenXkByEqService.initalJkfj();
        //
        //
        //        end = new Date();
        //        System.out.println(df.format(end).toString());
        //        System.out.println("完成一次!。。。。。。");
        //        System.out.println("执行用时" + com.gyee.generation.util.DateUtils.secondsDiff(begin, end) + "秒");
        //
        //
        //        /*************************健康管理测点导出**************************/
        //
        //
        // /*************************redis缓存**************************/
        //        Calendar c = Calendar.getInstance();
        //
        //
        //        Date begin = new Date();
        //        Date end = null;
        //        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //        System.out.println(df.format(c.getTime()).toString());
        //
        //
        //        CacheService cacheService= SpringUtils.getBean("cacheService");
        //        cacheService.initRedisCache();
        //
        //        end = new Date();
        //        System.out.println(df.format(end).toString());
        //        System.out.println("完成一次!。。。。。。");
        //        System.out.println("执行用时" + com.gyee.generation.util.DateUtils.secondsDiff(begin, end) + "秒");
        //
        //
        //        /*************************redis缓存**************************/
        //


        /*************************重算设备历史数据**************************/
//        Calendar c = Calendar.getInstance();
//
//
//        c.add(Calendar.DAY_OF_MONTH, -1);
//        ReCalSevice reCalSevice = SpringUtils.getBean("reCalSevice");
//        //        //重算风机
//                reCalSevice.calWt(c.getTime());
        //重算逆变器
//        reCalSevice.calIn(c.getTime());


        /*************************重算设备历史数据**************************/


    }
}
