package com.gyee.generation;

import com.gyee.common.util.DateUtils;
import com.gyee.generation.service.realtimelibrary.*;
import com.gyee.generation.util.SpringUtils;
import org.springframework.boot.SpringApplication;

import java.util.Calendar;
import java.util.Date;

public class RealTest {


    public static void main(String[] args) throws Exception {
        SpringApplication.run(GenerationMain.class, args);
        StatusService statusService = SpringUtils.getBean("statusService");
        CycleCalculationService cycleCalculationService = SpringUtils.getBean("cycleCalculationService");

        CalculationService calculationService = SpringUtils.getBean("calculationService");
        CycleCalculationRebuildService cycleCalculationRebuildService = SpringUtils.getBean("cycleCalculationRebuildService");
        RealtimeService realtimeService = SpringUtils.getBean("realtimeService");

        RegionCalreService regionCalreService = SpringUtils.getBean("regionCalreService");

        //        inputOrOutPutService.initialInputOrOutputSpeed();
        Calendar c = Calendar.getInstance();
        Date begin = null;
        Date end = null;
        //        CacheService cacheService= SpringUtils.getBean("cacheService");
        //        cacheService.initRedisCache();
        //
        c.set(Calendar.DAY_OF_MONTH, 1);

        c.set(Calendar.HOUR_OF_DAY, 23);
        c.set(Calendar.MINUTE, 59);
        c.set(Calendar.SECOND, 59);


        //
        c.setTime(DateUtils.truncate(c.getTime()));

        begin = new Date();
        System.out.println("设备指标记录调度程序执行开始!。。。。。。");

        cycleCalculationRebuildService.saveCyle(c.getTime());
        //        for(int i=0;i<19;i++)
        //        {
        //        realtimeService.savaRealtimeTargetWp();
        //        statusService.middleStatusReal();
        //       statusService.startStatusReal();
        //        calculationService.calWp();
        //        cycleCalculationService.saveCyle();

        c.add(Calendar.DAY_OF_MONTH, 1);
        System.out.println(c.getTime());
        System.out.println("完成一次!。。。。。。");
        //        }

        end = new Date();
        System.out.println("执行用时" + DateUtils.secondsDiff(begin, end) + "秒");
        System.out.println("设备指标记录调度程序执行结束!。。。。。。");


        //
        //        realtimeService.savaRealtimeTarget();

        //        regionCalreService.aqts();
        //
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.millisecondDiff(begin,end) +"秒");
        //        System.out.println("状态判定调度程序执行结束!。。。。。。");
        //        System.out.println("完成!。。。。。。");
        //
        //
        //
        //        //
        //        System.out.println("故障转换率记录调度程序执行开始!。。。。。。");
        //        TimelinessRateService timelinessRateService = SpringUtils.getBean("timelinessRateService");
        //        timelinessRateService.failRate(c.getTime());
        //        System.out.println("故障转换率记录调度程序执行结束!。。。。。。");
        //
        //        begin=new Date();
        //        System.out.println("切15分钟数据统计记录调度程序执行开始!。。。。。。");
        //        EquipmentInfo15minuteService equipmentInfo15minuteService = SpringUtils.getBean("equipmentInfo15minuteService");
        //        equipmentInfo15minuteService.calEquipmentInfo15minute(c.getTime());
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("切15分钟数据统计记录记录调度程序执行结束!。。。。。。");
        //
        //


        //        List<ProBasicEquipment> wtls= CacheContext.wpwtmap.get("SXJ_KGDL_GJY_FDC_STA");
        //        List<ProBasicEquipment> wtls= new ArrayList<>();
        //        for(ProBasicPowerstation wp: CacheContext.wpls)
        //        {
        //            if(wp.getId().contains("FDC"))
        //            {
        //                wtls.addAll(CacheContext.wpwtmap.get(wp.getId()));
        //            }
        //        }

        //        List<ProBasicEquipment> wtls= CacheContext.wpwtmap.get("SXJ_KGDL_GJY_FDC_STA");
        //
        //        while (true)
        //        {
        //            begin=new Date();
        //            System.out.println("切入切出状态切换记录调度程序执行开始!。。。。。。");
        //            inputOrOutPutService.inputOrOutputSpeed(c.getTime());
        //            end=new Date();
        //            System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //            System.out.println("切入切出状态切换记录调度程序执行结束!。。。。。。");
        //        }
        //
        //
        //        begin=new Date();
        //        System.out.println("初始化散点图调度程序执行开始!。。。。。。");
        //
        //
        //        initialRedisService.intialWtScatter();
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("初始化散点图度程序执行结束!。。。。。。");


        //        begin=new Date();
        //        System.out.println("切入切出统计调度程序执行开始!。。。。。。");
        //
        //
        //        inputOrOutPutService.inputOrOutput(c.getTime());
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("切入切出统计调度程序执行结束!。。。。。。");
        //
        //
        //
        //        begin=new Date();
        //        System.out.println("停机记录调度程序执行开始!。。。。。。");
        //        ShutdownnewService shutdownnewService= SpringUtils.getBean("shutdownnewService");
        //
        //        shutdownnewService.execShutdown(c.getTime());
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("停机记录调度程序执行结束!。。。。。。");
        //
        //
        //        begin=new Date();
        //        System.out.println("限电停机记录调度程序执行开始!。。。。。。");
        //        LimitEventnewService limitEventnewService= SpringUtils.getBean("limitEventnewService");
        ////
        //
        //       List<ProBasicPowerstation> wpls=new ArrayList<>();
        //
        ////        ProBasicPowerstation wp=  CacheContext.wpmap.get("SXJ_KGDL_GJY_FDC_STA");
        ////       wpls.add(wp);
        ////        List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get("SXJ_KGDL_GJY_FDC_STA");
        //        limitEventnewService.execBrownouts(c.getTime());
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("限电停机记录调度程序执行结束!。。。。。。");
        //
        //
        //        begin=new Date();
        //        System.out.println("曲线拟合调度程序执行开始!。。。。。。");
        //        PowerCurveFittingByTimeService powerCurveFittingByTimeService= SpringUtils.getBean("powerCurveFittingByTimeService");
        //
        ////        XxlJobHelper.log("日序执行开始!........");
        ////        powerCurveFittingByTimeService.cureFittingDay(c.getTime());
        ////        XxlJobHelper.log("日处理完成!........");
        ////
        //        XxlJobHelper.log("月序执行开始!........");
        //        powerCurveFittingByTimeService.cureFittingMonth(c.getTime(),"1");
        //        XxlJobHelper.log("月处理完成!........");
        ////
        ////        XxlJobHelper.log("年序执行开始!........");
        ////        powerCurveFittingByTimeService.cureFittingYear(c.getTime());
        ////        XxlJobHelper.log("年处理完成!........");
        ////
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("曲线拟合调度程序执行结束!。。。。。。");
        //
        //
        //        begin=new Date();
        //        System.out.println("场站指标记录调度程序执行开始!。。。。。。");
        //        WindPowerInfo1Service windPowerInfo1Service= SpringUtils.getBean("windPowerInfo1Service");
        //        WindPowerInfo2Service windPowerInfo2Service= SpringUtils.getBean("windPowerInfo2Service");
        //        WindPowerInfo3Service windPowerInfo3Service= SpringUtils.getBean("windPowerInfo3Service");
        //        WindPowerInfo4Service windPowerInfo4Service= SpringUtils.getBean("windPowerInfo4Service");
        //        WindPowerInfo5Service windPowerInfo5Service= SpringUtils.getBean("windPowerInfo5Service");
        //        WindPowerInfo6Service windPowerInfo6Service= SpringUtils.getBean("windPowerInfo6Service");
        //
        //        windPowerInfo1Service.calLineInfoDay(c.getTime());
        //        windPowerInfo1Service.calProjectInfoDay(c.getTime());
        //        windPowerInfo1Service.calWindpowerInfoDay(c.getTime());
        //        windPowerInfo1Service.calCompanyInfoDay(c.getTime());
        //        windPowerInfo1Service.calRegionInfoDay(c.getTime());
        //
        //        windPowerInfo2Service.calLineInfoDay(c.getTime());
        //        windPowerInfo2Service.calProjectInfoDay(c.getTime());
        //        windPowerInfo2Service.calWindpowerInfoDay(c.getTime());
        //        windPowerInfo2Service.calCompanyInfoDay(c.getTime());
        //        windPowerInfo2Service.calRegionInfoDay(c.getTime());
        //
        //        windPowerInfo3Service.calLineInfoDay(c.getTime());
        //        windPowerInfo3Service.calProjectInfoDay(c.getTime());
        //        windPowerInfo3Service.calWindpowerInfoDay(c.getTime());
        //        windPowerInfo3Service.calCompanyInfoDay(c.getTime());
        //        windPowerInfo3Service.calRegionInfoDay(c.getTime());
        //
        //        windPowerInfo4Service.calLineInfoDay(c.getTime());
        //        windPowerInfo4Service.calProjectInfoDay(c.getTime());
        //        windPowerInfo4Service.calWindpowerInfoDay(c.getTime());
        //        windPowerInfo4Service.calCompanyInfoDay(c.getTime());
        //        windPowerInfo4Service.calRegionInfoDay(c.getTime());
        //
        //        windPowerInfo5Service.calLineInfoDay(c.getTime());
        //        windPowerInfo5Service.calProjectInfoDay(c.getTime());
        //        windPowerInfo5Service.calWindpowerInfoDay(c.getTime());
        //        windPowerInfo5Service.calCompanyInfoDay(c.getTime());
        //        windPowerInfo5Service.calRegionInfoDay(c.getTime());
        //
        //        windPowerInfo6Service.calLineInfoDay(c.getTime());
        //        windPowerInfo6Service.calProjectInfoDay(c.getTime());
        //        windPowerInfo6Service.calWindpowerInfoDay(c.getTime());
        //        windPowerInfo6Service.calCompanyInfoDay(c.getTime());
        //        windPowerInfo6Service.calRegionInfoDay(c.getTime());
        //
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("场站指标记录调度程序执行结束!。。。。。。");
        //
        //
        //
        //        c.set(Calendar.DAY_OF_MONTH,9);
        //        for(int i=0;i<6;i++)
        //        {
        //            begin=new Date();
        //            System.out.println("设备指标记录调度程序执行开始!。。。。。。");
        //            EquipmentInfo1Service equipmentInfo1Service= SpringUtils.getBean("equipmentInfo1Service");
        //            EquipmentInfo2Service equipmentInfo2Service= SpringUtils.getBean("equipmentInfo2Service");
        //            EquipmentInfo3Service equipmentInfo3Service= SpringUtils.getBean("equipmentInfo3Service");
        //            EquipmentInfo4Service equipmentInfo4Service= SpringUtils.getBean("equipmentInfo4Service");
        //            EquipmentInfo5Service equipmentInfo5Service= SpringUtils.getBean("equipmentInfo5Service");
        //            EquipmentInfoDayTopService equipmentInfoDayTopService= SpringUtils.getBean("equipmentInfoDayTopService");
        //            WtAlysisDayService wtAlysisDayService= SpringUtils.getBean("wtAlysisDayService");
        //
        //            equipmentInfo1Service.calEquipmentInfoDay(c.getTime());
        //            equipmentInfo2Service.calEquipmentInfoDay(c.getTime());
        //
        //            equipmentInfo3Service.calEquipmentInfoDay(c.getTime());
        //
        //            equipmentInfo4Service.calEquipmentInfoDay(c.getTime());
        //
        //            equipmentInfo5Service.calEquipmentInfoDay(c.getTime());
        //
        //            equipmentInfoDayTopService.calEquipmentInfoDayTop(c.getTime());
        //            equipmentInfoDayTopService.calEquipmentInfoMonthTop(c.getTime());
        //            equipmentInfoDayTopService.calEquipmentInfoYearTop(c.getTime());
        //
        //            wtAlysisDayService.calEquipmentInfoDay(c.getTime());
        //            c.add(Calendar.DAY_OF_MONTH,1);
        //        }
        //
        //
        //
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("设备指标记录调度程序执行结束!。。。。。。");
        //
        //
        //
        //
        //        begin=new Date();
        //        System.out.println("功率一致性系数和拟合优度调度程序执行开始!。。。。。。");
        //        WindturbineGoodnessService windturbineGoodnessService= SpringUtils.getBean("windturbineGoodnessService");
        //
        //        windturbineGoodnessService.calWindturbineGoodness(c.getTime());
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("功率一致性系数和拟合优度调度程序执行结束!。。。。。。");
        //
        //        c.add(Calendar.DAY_OF_MONTH,-1);
        //        begin=new Date();
        //        System.out.println("设备数据和场站数据风资源调度程序执行开始!。。。。。。");
        //        WpwindDayInfoService wpwindDayInfoService= SpringUtils.getBean("wpwindDayInfoService");
        //        WtwindDayInfoService wtwindDayInfoService= SpringUtils.getBean("wtwindDayInfoService");
        //        wpwindDayInfoService.calWpwindDayInfo(c.getTime());
        //        wtwindDayInfoService.calWtwindDayInfo(c.getTime());
        //        end=new Date();
        //        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
        //        System.out.println("设备数据和场站数据风资源调度程序执行结束!。。。。。。");
    }
}
