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

    <resultMap type="WfDaEfPara" id="WfDaEfParaResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="modelNo" column="model_no"/>
        <result property="efProcTimeAm" column="ef_proc_time_am"/>
        <result property="efProcTimePm" column="ef_proc_time_pm"/>
        <result property="efDayProcTime" column="ef_day_proc_time"/>
        <result property="efMonthProcTime" column="ef_month_proc_time"/>
        <result property="efType" column="ef_type"/>
        <result property="para" column="para"/>
        <result property="mem" column="mem"/>
        <result property="ifModelValid" column="if_model_valid"/>
    </resultMap>

    <sql id="selectWfDaEfParaVo">
        select windplant_no, model_no, ef_proc_time_am, ef_proc_time_pm, ef_day_proc_time, ef_month_proc_time, ef_type, para, mem, if_model_valid from wf_da_ef_para
    </sql>

    <select id="selectWfDaEfParaList" parameterType="WfDaEfPara" resultMap="WfDaEfParaResult">
        select
        wdep.*,
        win.name as "windplantName",
        wmi.item_name as "itemName"
        from
        wf_da_ef_para wdep
        left join windplant win on win.windplant_no = wdep.windplant_no
        left join enum_menu_item wmi on wmi.item_no = wdep.model_no and wmi.menu_no = 120
        <where>
            <if test="windplantNo != null ">and wdep.windplant_no = #{windplantNo}</if>
            <if test="modelNo != null ">and wdep.model_no = #{modelNo}</if>
            <if test="efProcTimeAm != null ">and wdep.ef_proc_time_am = #{efProcTimeAm}</if>
            <if test="efProcTimePm != null ">and wdep.ef_proc_time_pm = #{efProcTimePm}</if>
            <if test="efDayProcTime != null ">and wdep.ef_day_proc_time = #{efDayProcTime}</if>
            <if test="efMonthProcTime != null ">and wdep.ef_month_proc_time = #{efMonthProcTime}</if>
            <if test="efType != null ">and wdep.ef_type = #{efType}</if>
            <if test="para != null  and para != ''">and wdep.para = #{para}</if>
            <if test="mem != null  and mem != ''">and wdep.mem = #{mem}</if>
            <if test="ifModelValid != null ">and wdep.if_model_valid = #{ifModelValid}</if>
        </where>
        order by wdep.windplant_no asc
    </select>

    <select id="selectWfDaEfParaById" parameterType="Long" resultMap="WfDaEfParaResult">
        <include refid="selectWfDaEfParaVo"/>
        where windplant_no = #{windplantNo} and model_no = #{modelNo}
    </select>

    <insert id="insertWfDaEfPara" parameterType="WfDaEfPara">
        insert into wf_da_ef_para
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">windplant_no,</if>
            <if test="modelNo != null">model_no,</if>
            <if test="efProcTimeAm != null">ef_proc_time_am,</if>
            <if test="efProcTimePm != null">ef_proc_time_pm,</if>
            <if test="efDayProcTime != null">ef_day_proc_time,</if>
            <if test="efMonthProcTime != null">ef_month_proc_time,</if>
            <if test="efType != null">ef_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="efProcTimeAm != null">#{efProcTimeAm},</if>
            <if test="efProcTimePm != null">#{efProcTimePm},</if>
            <if test="efDayProcTime != null">#{efDayProcTime},</if>
            <if test="efMonthProcTime != null">#{efMonthProcTime},</if>
            <if test="efType != null">#{efType},</if>
            <if test="para != null">#{para},</if>
            <if test="mem != null">#{mem},</if>
            <if test="ifModelValid != null">#{ifModelValid},</if>
        </trim>
    </insert>

    <update id="updateWfDaEfPara" parameterType="WfDaEfPara">
        update wf_da_ef_para
        <trim prefix="SET" suffixOverrides=",">
            <if test="efProcTimeAm != null">ef_proc_time_am = #{efProcTimeAm},</if>
            <if test="efProcTimePm != null">ef_proc_time_pm = #{efProcTimePm},</if>
            <if test="efDayProcTime != null">ef_day_proc_time = #{efDayProcTime},</if>
            <if test="efMonthProcTime != null">ef_month_proc_time = #{efMonthProcTime},</if>
            <if test="efType != null">ef_type = #{efType},</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="deleteWfDaEfParaById" parameterType="Long">
        delete from wf_da_ef_para where windplant_no = #{windplantNo} and model_no = #{modelNo}
    </delete>

</mapper>