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

    <resultMap type="PvUspPfPara" id="PvUspPfParaResult">
        <result property="pvNo" column="pv_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="selectPvUspPfParaVo">
        select pv_no, model_no, pf_proc_time, pf_day_proc_time, pf_month_proc_time, pf_type, para, mem, if_model_valid from pv_usp_pf_para
    </sql>

    <select id="selectPvUspPfParaList" parameterType="PvUspPfPara" resultMap="PvUspPfParaResult">
        select
        pupp.*,
        pps.name as "pvName",
        wmi.item_name as "itemName"
        from
        pv_usp_pf_para pupp
        left join pv_power_station pps on pps.pv_station_no = pupp.pv_no
        left join enum_menu_item wmi on wmi.item_no = pupp.model_no and wmi.menu_no = 123
        <where>
            <if test="pvNo != null ">and pupp.pv_no = #{pvNo}</if>
            <if test="modelNo != null ">and pupp.model_no = #{modelNo}</if>
            <if test="pfProcTime != null ">and pupp.pf_proc_time = #{pfProcTime}</if>
            <if test="pfDayProcTime != null ">and pupp.pf_day_proc_time = #{pfDayProcTime}</if>
            <if test="pfMonthProcTime != null ">and pupp.pf_month_proc_time = #{pfMonthProcTime}</if>
            <if test="pfType != null ">and pupp.pf_type = #{pfType}</if>
            <if test="para != null  and para != ''">and pupp.para = #{para}</if>
            <if test="mem != null  and mem != ''">and pupp.mem = #{mem}</if>
            <if test="ifModelValid != null ">and pupp.if_model_valid = #{ifModelValid}</if>
        </where>
        order by pupp.pv_no asc
    </select>

    <select id="selectPvUspPfParaById" parameterType="Long" resultMap="PvUspPfParaResult">
        <include refid="selectPvUspPfParaVo"/>
        where pv_no = #{pvNo} and model_no = #{modelNo}
    </select>

    <insert id="insertPvUspPfPara" parameterType="PvUspPfPara">
        insert into pv_usp_pf_para
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pvNo != null">pv_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="pvNo != null">#{pvNo},</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="updatePvUspPfPara" parameterType="PvUspPfPara">
        update pv_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 pv_no = #{pvNo} and model_no = #{modelNo}
    </update>

    <delete id="deletePvUspPfParaById" parameterType="Long">
        delete from pv_usp_pf_para where pv_no = #{pvNo} and model_no = #{modelNo}
    </delete>
</mapper>