package com.ruoyi;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateRange;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.ucp.entity.*;
import com.ruoyi.ucp.feign.AdapterApi;
import com.ruoyi.ucp.service.*;
import com.ruoyi.ucp.util.CalcCache;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.net.URI;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;

@SpringBootTest//classes = RuoYiApp.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
@RunWith(SpringRunner.class)
public class NewTests {

    @Resource
    private JavaFunctionJobHandler task;

    @Test
    public void test() {
//        task.calcTurbineRFDLSameDay();
//        task.calcTurbine5s2SameDay();
        /*Map<Double, Double> a1 = CalcCache.fitcoef.get("GJNY_SXGS_JSL_F_WT_0001_EQ");
        Map<Double, Double> a3 = CalcCache.fitcoef.get("GJNY_SXGS_JSL_F_WT_0003_EQ");
        TreeMap<Double, Double> b1 = new TreeMap<>();
        TreeMap<Double, Double> b3 = new TreeMap<>();
        b1.putAll(a1);
        b3.putAll(a3);
        StrBuilder sb = new StrBuilder();
        for (Double v : b1.keySet()) {
            sb.append(v).append(",");
        }
        System.out.println(sb);
        StrBuilder sb2 = new StrBuilder();
        for (Double v : b1.values()) {
            sb2.append(v).append(",");
        }
        System.out.println(sb2);
        StrBuilder sb3 = new StrBuilder();
        for (Double v : b3.values()) {
            sb3.append(v).append(",");
        }
        System.out.println(sb3);
        System.out.println();*/

//        Date date = DateUtil.date();
//        task.ambientTemperature();

//        task.calcTurbine5s2(date);
//        task.calcLineRfdl(date);

//        task.calcStationZhcyRfDl(date,"GJNY_SXGS_XZ_FDC_STA");
//        task.writeReportPool(date);
//        task.writeReportPoolProject(date);

//        task.calcTurbine5s2(date);
//        task.calcStationSwGwCyRdl(date,"GJNY_SXGS_XZ_FDC_STA");
//        task.calcStationZhcyRfDl(date);
//        task.writeReportPool(date);
//        task.writeReportPoolPjfs2(date);
//        task.SwdlRepair(date);
//        task.calcLineRfdl(date);
//        task.calcTurbineStateMin(date);
//        calcStationZhcydl(date);
//        calcNhglZs(date);
        // 创建日期范围生成器
        DateTime date = DateUtil.date();
        task.calcTurbine5s2(date);


//        DateTime start = DateUtil.parse("2023-06-27");
//        DateTime end = DateUtil.parse("2023-09-27");
//        task.calcGlqxnhSurplus(start, end);
//        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
//        for (DateTime date : range) {
//            System.out.println(DateUtil.date().toString() + "：" + date.toString());

            /*task.calcLineRfdl(date);
            //上网购网厂用电量
            task.calcStationSwGwCyRdl(date);
            //计算综合厂用电量
            task.calcStationZhcyRfDl(date);*/


//            task.calcTurbineRFDL(date);
//            task.writeReportPoolPjfs2(date);
        //安全天数
//            calcAQTS(time.toJdkDate());
            /*task.calcLineRfdl(date,"GJNY_SXGS_ZZ_FDC_STA");
            task.calcStationSwGwCyRdl(date);
            task.calcStationZhcyRfDl(date);
            task.calcLineSwGWCyDl(date);
            task.writeReportPool(date);
            task.writeReportPoolProject(date);*/
//            task.calcLineSwGWCyDl(date,"GJNY_SXGS_XZ_FDC_STA");
//            task.writeReportPoolProject(date);
//            //计算综合厂用电量
//            task.calcStationZhcydl(date);
//
            /*task.calcTurbineRFDL(date);
            task.calcStationRfdlFj(date);
            task.calcTurbine5s2(date);
            task.writeReportPool5SPjfsLlfdl(date);*/

//            task.writeReportPool(date);
//            int test = task.test(date, "zuozhuang.610825F02Y0AFA10GS009DQ0251DG02RAW00", 1320);
//            System.out.println(test);


            /*task.calcLineRfdlSameDay();
            task.calcStationSwGwCyDlSameDay();
            task.calcStationZhcyRfDlSameDay();
            task.calcLineSwGWCyDlSameDay();
            task.writeReportPoolSameDay();
            task.writeReportPoolProjectSameDay();*/
//    }
//        calcTurbineRFDL(date);
//        task.calcTurbine5s2(date);
//        writeReportPool(date);

//        task.calcStationSspjfs();
        /*while (true) {
            task.calcRealtimeTurbineZt();
            ThreadUtil.sleep(1000);
        }*/
//        task.calcRealtimeTurbineZt();
    }

    @Test
    public void test2() {
        // 创建日期范围生成器
        DateTime start = DateUtil.parse("2024-10-12");
        DateTime end = DateUtil.parse("2024-10-14");
        DateRange range = DateUtil.range(start, end, DateField.HOUR_OF_DAY);
        for (DateTime date : range) {
            System.out.println(DateUtil.date() + "：" + date);
            task.calcAQTS(date);
//            task.calcLineRfdl(date,"GJNY_SXGS_JSL_FDC_STA");
//            task.calcStationSwGwCyRdl(date,"GJNY_SXGS_JSL_FDC_STA");
//            task.calcStationZhcyRfDl(date,"GJNY_SXGS_JSL_FDC_STA");
//            task.calcLineSwGWCyDl(date,"GJNY_SXGS_JSL_FDC_STA");
//            task.writeReportPool(date);
//            task.writeReportPoolProject(date);
//            task.calcStationHourPjglRfdl(DateUtil.date());
        }
//        task.calcStationHourPjglRfdl(DateUtil.date());
//        DateTime date = DateUtil.date();
//        task.calcStationHourPJGL(date);
//        task.calcLineRfdl(date);
//        task.calcStationHourRFDL(date);
//        task.calcTurbinePjfsPjglKyglLlglMin(DateUtil.date(), 15);
//        task.calcStationLlglKyglSjglAgcMin(date, 15);
    }

}
