<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.predict.mapper.WfStatPeriodDataMapper">

    <resultMap type="WfStatPeriodData" id="WfStatPeriodDataResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="dataTime" column="data_time"/>
        <result property="p1" column="p1"/>
        <result property="p2" column="p2"/>
        <result property="p0" column="p0"/>
        <result property="avgWindSpeed" column="avg_wind_speed"/>
        <result property="avgTemp" column="avg_temp"/>
        <result property="energy" column="energy"/>
        <result property="dataFlag" column="data_flag"/>
    </resultMap>

    <sql id="selectWfStatPeriodDataVo">
        select windplant_no, data_time, p1, p2, p0, avg_wind_speed, avg_temp, energy, data_flag from wf_stat_period_data
    </sql>

    <select id="selectWfStatPeriodDataList" parameterType="WfStatPeriodData" resultMap="WfStatPeriodDataResult">
        <include refid="selectWfStatPeriodDataVo"/>
        <where>
            <if test="windplantNo != null ">and windplant_no = #{windplantNo}</if>
            <if test="p1 != null ">and p1 = #{p1}</if>
            <if test="p2 != null ">and p2 = #{p2}</if>
            <if test="p0 != null ">and p0 = #{p0}</if>
            <if test="avgWindSpeed != null ">and avg_wind_speed = #{avgWindSpeed}</if>
            <if test="avgTemp != null ">and avg_temp = #{avgTemp}</if>
            <if test="energy != null ">and energy = #{energy}</if>
            <if test="dataFlag != null ">and data_flag = #{dataFlag}</if>
            <if test="params.beginDataTime != null and params.beginDataTime != '' and params.endDataTime != null and params.endDataTime != ''">
                and data_time between to_date(#{params.beginDataTime},'yyyy-MM-dd HH24:MI:SS') and
                to_date(#{params.endDataTime},'yyyy-MM-dd HH24:MI:SS')
            </if>
            <if test="dataTime != null ">and data_time = #{dataTime}</if>
        </where>
        order by data_time asc
    </select>

    <select id="selectWfStatPeriodDataById" parameterType="Long" resultMap="WfStatPeriodDataResult">
        <include refid="selectWfStatPeriodDataVo"/>
        where windplant_no = #{windplantNo} order by data_time asc
    </select>

    <select id="selectWfStatPeriodData" parameterType="WfStatPeriodData" resultMap="WfStatPeriodDataResult">
        <include refid="selectWfStatPeriodDataVo"/>
        where windplant_no = #{windplantNo} and data_time = #{dataTime}
    </select>

    <select id="selectWfStatPeriodData1" parameterType="WfStatPeriodData" resultMap="WfStatPeriodDataResult">
        <include refid="selectWfStatPeriodDataVo"/>
        where windplant_no = #{windplantNo} and data_time > #{dataTime}
    </select>

</mapper>