<?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.WfDaPfErrIntervalMapper">

    <resultMap type="WfDaPfErrInterval" id="WfDaPfErrIntervalResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="modelNo" column="model_no"/>
        <result property="dataTime" column="data_time"/>
        <result property="maxInterval95" column="max_interval95"/>
        <result property="maxInterval90" column="max_interval90"/>
        <result property="maxInterval85" column="max_interval85"/>
        <result property="maxInterval80" column="max_interval80"/>
        <result property="maxInterval75" column="max_interval75"/>
        <result property="maxInterval70" column="max_interval70"/>
        <result property="maxInterval65" column="max_interval65"/>
        <result property="maxInterval60" column="max_interval60"/>
        <result property="maxInterval55" column="max_interval55"/>
        <result property="maxInterval50" column="max_interval50"/>
        <result property="minInterval95" column="min_interval95"/>
        <result property="minInterval90" column="min_interval90"/>
        <result property="minInterval85" column="min_interval85"/>
        <result property="minInterval80" column="min_interval80"/>
        <result property="minInterval75" column="min_interval75"/>
        <result property="minInterval70" column="min_interval70"/>
        <result property="minInterval65" column="min_interval65"/>
        <result property="minInterval60" column="min_interval60"/>
        <result property="minInterval55" column="min_interval55"/>
        <result property="minInterval50" column="min_interval50"/>
        <result property="maxValue" column="max_value"/>
        <result property="minValue" column="min_value"/>
        <result property="avgValue" column="avg_value"/>
        <result property="mlValue" column="ml_value"/>
        <result property="dataFlag" column="data_flag"/>
    </resultMap>

    <sql id="selectWfDaPfErrIntervalVo">
        select windplant_no, model_no, data_time, max_interval95, max_interval90, max_interval85, max_interval80, max_interval75, max_interval70, max_interval65, max_interval60, max_interval55, max_interval50, min_interval95, min_interval90, min_interval85, min_interval80, min_interval75, min_interval70, min_interval65, min_interval60, min_interval55, min_interval50, max_value, min_value, avg_value, ml_value, data_flag from wf_da_pf_err_interval
    </sql>

    <select id="selectWfDaPfErrIntervalList" parameterType="WfDaPfErrInterval" resultMap="WfDaPfErrIntervalResult">
        select
        wdpei.windplant_no,
        wdpei.model_no,
        wdpei.data_time,
        wdpei.max_interval95,
        wdpei.max_interval90,
        wdpei.max_interval85,
        wdpei.max_interval80,
        wdpei.max_interval75,
        wdpei.max_interval70,
        wdpei.max_interval65,
        wdpei.max_interval60,
        wdpei.max_interval55,
        wdpei.max_interval50,
        wdpei.min_interval95,
        wdpei.min_interval90,
        wdpei.min_interval85,
        wdpei.min_interval80,
        wdpei.min_interval75,
        wdpei.min_interval70,
        wdpei.min_interval65,
        wdpei.min_interval60,
        wdpei.min_interval55,
        wdpei.min_interval50,
        wdpei.max_value,
        wdpei.min_value,
        wdpei.avg_value,
        wdpei.ml_value,
        wdpei.data_flag,
        wspd.p0,
        nwdppd.value
        from
        wf_da_pf_err_interval wdpei
        LEFT JOIN WF_STAT_PERIOD_DATA wspd ON wspd.windplant_no = wdpei.windplant_no and wspd.data_time =
        wdpei.data_time
        LEFT JOIN NOSCALE_WF_DA_PF_PERIOD_DATA nwdppd ON nwdppd.windplant_no = wdpei.windplant_no and nwdppd.model_no =
        wdpei.model_no and nwdppd.data_time = wdpei.data_time
        <where>
            <if test="windplantNo != null ">and wdpei.windplant_no = #{windplantNo}</if>
            <if test="modelNo != null ">and wdpei.model_no = #{modelNo}</if>
            <if test="maxInterval95 != null ">and wdpei.max_interval95 = #{maxInterval95}</if>
            <if test="maxInterval90 != null ">and wdpei.max_interval90 = #{maxInterval90}</if>
            <if test="maxInterval85 != null ">and wdpei.max_interval85 = #{maxInterval85}</if>
            <if test="maxInterval80 != null ">and wdpei.max_interval80 = #{maxInterval80}</if>
            <if test="maxInterval75 != null ">and wdpei.max_interval75 = #{maxInterval75}</if>
            <if test="maxInterval70 != null ">and wdpei.max_interval70 = #{maxInterval70}</if>
            <if test="maxInterval65 != null ">and wdpei.max_interval65 = #{maxInterval65}</if>
            <if test="maxInterval60 != null ">and wdpei.max_interval60 = #{maxInterval60}</if>
            <if test="maxInterval55 != null ">and wdpei.max_interval55 = #{maxInterval55}</if>
            <if test="maxInterval50 != null ">and wdpei.max_interval50 = #{maxInterval50}</if>
            <if test="minInterval95 != null ">and wdpei.min_interval95 = #{minInterval95}</if>
            <if test="minInterval90 != null ">and wdpei.min_interval90 = #{minInterval90}</if>
            <if test="minInterval85 != null ">and wdpei.min_interval85 = #{minInterval85}</if>
            <if test="minInterval80 != null ">and wdpei.min_interval80 = #{minInterval80}</if>
            <if test="minInterval75 != null ">and wdpei.min_interval75 = #{minInterval75}</if>
            <if test="minInterval70 != null ">and wdpei.min_interval70 = #{minInterval70}</if>
            <if test="minInterval65 != null ">and wdpei.min_interval65 = #{minInterval65}</if>
            <if test="minInterval60 != null ">and wdpei.min_interval60 = #{minInterval60}</if>
            <if test="minInterval55 != null ">and wdpei.min_interval55 = #{minInterval55}</if>
            <if test="minInterval50 != null ">and wdpei.min_interval50 = #{minInterval50}</if>
            <if test="maxValue != null ">and wdpei.max_value = #{maxValue}</if>
            <if test="minValue != null ">and wdpei.min_value = #{minValue}</if>
            <if test="avgValue != null ">and wdpei.avg_value = #{avgValue}</if>
            <if test="mlValue != null ">and wdpei.ml_value = #{mlValue}</if>
            <if test="dataFlag != null ">and wdpei.data_flag = #{dataFlag}</if>
            <if test="params.beginDataTime != null and params.beginDataTime != '' and params.endDataTime != null and params.endDataTime != ''">
                and wdpei.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>
        </where>
        order by wdpei.data_time asc
    </select>

    <select id="selectWfDaPfErrIntervalById" parameterType="Long" resultMap="WfDaPfErrIntervalResult">
        <include refid="selectWfDaPfErrIntervalVo"/>
        where windplant_no = #{windplantNo}
    </select>

    <select id="selectWfDaPfErrInterval" parameterType="WfDaPfErrInterval" resultMap="WfDaPfErrIntervalResult">
        select
        wdpei.windplant_no,
        wdpei.model_no,
        wdpei.data_time,
        wdpei.max_interval95,
        wdpei.max_interval90,
        wdpei.max_interval85,
        wdpei.max_interval80,
        wdpei.max_interval75,
        wdpei.max_interval70,
        wdpei.max_interval65,
        wdpei.max_interval60,
        wdpei.max_interval55,
        wdpei.max_interval50,
        wdpei.min_interval95,
        wdpei.min_interval90,
        wdpei.min_interval85,
        wdpei.min_interval80,
        wdpei.min_interval75,
        wdpei.min_interval70,
        wdpei.min_interval65,
        wdpei.min_interval60,
        wdpei.min_interval55,
        wdpei.min_interval50,
        wdpei.max_value,
        wdpei.min_value,
        wdpei.avg_value,
        wdpei.ml_value,
        wdpei.data_flag,
        wspd.p0,
        nwdppd.value
        from
        wf_da_pf_err_interval wdpei
        LEFT JOIN WF_STAT_PERIOD_DATA wspd ON wspd.windplant_no = wdpei.windplant_no and wspd.data_time = wdpei.data_time
        LEFT JOIN NOSCALE_WF_DA_PF_PERIOD_DATA nwdppd ON nwdppd.windplant_no = wdpei.windplant_no and nwdppd.model_no = wdpei.model_no and nwdppd.data_time = wdpei.data_time
        where wdpei.windplant_no = #{windplantNo} and wdpei.model_no = #{modelNo} and wdpei.data_time = #{dateTime}
    </select>

</mapper>