package com.ruoyi;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.ucp.entity.PointInfo;
import com.ruoyi.ucp.entity.StationInfoDay;
import com.ruoyi.ucp.feign.AdapterApi;
import com.ruoyi.ucp.service.*;
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.Date;
import java.util.List;
import java.util.stream.Collectors;

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

    @Resource
    private AdapterApi adapter;
    @Resource
    private IPointInfoService pointService;
    @Resource
    private IStationInfoDayService stationInfoDayService;
    @Resource
    private IStationInfoHourService stationInfoHourService;
    @Resource
    private IMethodService methodService;
    @Resource
    private ILineInfoDayService lineInfoDayService;
    @Resource
    private IStateAiService stateAiService;
    @Resource
    private RedisTemplate redisTemplate;

    @Test
    public void test() {
        // 创建日期范围生成器
        /*DateTime start = DateUtil.parse("2023-05-24");
        DateTime end = DateUtil.parse("2024-05-24");
        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
        for (DateTime time : range) {
            System.out.println(DateUtil.date().toString()+"："+time.toString());
        }*/

        Date date = DateUtil.date().toJdkDate();
        //calcTurbineSsztAi(date);
    }

    /*public void getData(String uniformcode){
        PointInfo pi = new PointInfo();
        pi.
    }*/

    public String pointInfos2Keys(List<PointInfo> entity) {
        return entity.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
    }

    public URI taosGoldenUriTest() {
        return URI.create("http://127.0.0.1:8011/ts");
    }

    public List<StationInfoDay> getStationinfoByDate(Date date) {
        QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
        wrapper.eq("record_date", date);
        return stationInfoDayService.list(wrapper);
    }

}
