package com.cpp.web.mapper.cloud;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cpp.web.domain.cloud.ForecastPowerShortTermCloud;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * idp_forecast_power_short_term
 *
 * @author tl
 * @date 2024-09-23 15:28:33
 */
@Mapper
public interface ForecastPowerShortTermCloudMapper extends BaseMapper<ForecastPowerShortTermCloud> {
    @Select("SELECT * FROM (  \n" +
            "    SELECT *,  \n" +
            "           ROW_NUMBER() OVER (PARTITION BY time ORDER BY forecast_how_long_ago ASC) as rn  \n" +
            "    FROM cpp_forecast_power_short_term_cloud  \n" +
            "    WHERE station_code = #{stationCode}  \n" +
            "      AND time BETWEEN #{startTime} AND #{endTime}  \n" +
            ") subquery  \n" +
            "WHERE rn = 1;")
    List<ForecastPowerShortTermCloud> findByTimeBetweenAndStationCode(@Param("stationCode") String stationCode,@Param("startTime") Date startTime,@Param("endTime") Date endTime);
}
