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

    <resultMap type="WfUspPfPara" id="WfUspPfParaResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="modelNo" column="model_no"/>
        <result property="pfProcTime" column="pf_proc_time"/>
        <result property="pfDayProcTime" column="pf_day_proc_time"/>
        <result property="pfMonthProcTime" column="pf_month_proc_time"/>
        <result property="pfType" column="pf_type"/>
        <result property="para" column="para"/>
        <result property="mem" column="mem"/>
        <result property="ifModelValid" column="if_model_valid"/>
    </resultMap>

    <sql id="selectWfUspPfParaVo">
        select windplant_no, model_no, pf_proc_time, pf_day_proc_time, pf_month_proc_time, pf_type, para, mem, if_model_valid from wf_usp_pf_para
    </sql>

    <select id="selectWfUspPfParaList" parameterType="WfUspPfPara" resultMap="WfUspPfParaResult">
        select
        wupp.*,
        win.name as "windplantName",
        wmi.item_name as "itemName"
        from
        wf_usp_pf_para wupp
        left join windplant win on win.windplant_no = wupp.windplant_no
        left join enum_menu_item wmi on wmi.item_no = wupp.model_no and wmi.menu_no = 123
        <where>
            <if test="windplantNo != null ">and wupp.windplant_no = #{windplantNo}</if>
            <if test="modelNo != null ">and wupp.model_no = #{modelNo}</if>
            <if test="pfProcTime != null ">and wupp.pf_proc_time = #{pfProcTime}</if>
            <if test="pfDayProcTime != null ">and wupp.pf_day_proc_time = #{pfDayProcTime}</if>
            <if test="pfMonthProcTime != null ">and wupp.pf_month_proc_time = #{pfMonthProcTime}</if>
            <if test="pfType != null ">and wupp.pf_type = #{pfType}</if>
            <if test="para != null  and para != ''">and wupp.para = #{para}</if>
            <if test="mem != null  and mem != ''">and wupp.mem = #{mem}</if>
            <if test="ifModelValid != null ">and wupp.if_model_valid = #{ifModelValid}</if>
        </where>
        order by wupp.windplant_no asc
    </select>

    <select id="selectWfUspPfParaById" parameterType="Long" resultMap="WfUspPfParaResult">
        <include refid="selectWfUspPfParaVo"/>
        where windplant_no = #{windplantNo} and model_no = #{modelNo}
    </select>

    <insert id="insertWfUspPfPara" parameterType="WfUspPfPara">
        insert into wf_usp_pf_para
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">windplant_no,</if>
            <if test="modelNo != null">model_no,</if>
            <if test="pfProcTime != null">pf_proc_time,</if>
            <if test="pfDayProcTime != null">pf_day_proc_time,</if>
            <if test="pfMonthProcTime != null">pf_month_proc_time,</if>
            <if test="pfType != null">pf_type,</if>
            <if test="para != null">para,</if>
            <if test="mem != null">mem,</if>
            <if test="ifModelValid != null">if_model_valid,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">#{windplantNo},</if>
            <if test="modelNo != null">#{modelNo},</if>
            <if test="pfProcTime != null">#{pfProcTime},</if>
            <if test="pfDayProcTime != null">#{pfDayProcTime},</if>
            <if test="pfMonthProcTime != null">#{pfMonthProcTime},</if>
            <if test="pfType != null">#{pfType},</if>
            <if test="para != null">#{para},</if>
            <if test="mem != null">#{mem},</if>
            <if test="ifModelValid != null">#{ifModelValid},</if>
        </trim>
    </insert>

    <update id="updateWfUspPfPara" parameterType="WfUspPfPara">
        update wf_usp_pf_para
        <trim prefix="SET" suffixOverrides=",">
            <if test="pfProcTime != null">pf_proc_time = #{pfProcTime},</if>
            <if test="pfDayProcTime != null">pf_day_proc_time = #{pfDayProcTime},</if>
            <if test="pfMonthProcTime != null">pf_month_proc_time = #{pfMonthProcTime},</if>
            <if test="pfType != null">pf_type = #{pfType},</if>
            <if test="para != null">para = #{para},</if>
            <if test="mem != null">mem = #{mem},</if>
            <if test="ifModelValid != null">if_model_valid = #{ifModelValid},</if>
        </trim>
        where windplant_no = #{windplantNo} and model_no = #{modelNo}
    </update>

    <delete id="deleteWfUspPfParaById" parameterType="Long">
        delete from wf_usp_pf_para where windplant_no = #{windplantNo} and model_no = #{modelNo}
    </delete>

</mapper>