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

    <resultMap type="UploadPfValueConfig" id="UploadPfValueConfigResult">
        <result property="pfNo" column="pf_no"/>
        <result property="windplantNo" column="windplant_no"/>
        <result property="projectNo" column="project_no"/>
        <result property="timeScale" column="time_scale"/>
        <result property="name" column="name"/>
        <result property="nameDesc" column="name_desc"/>
        <result property="statTime" column="stat_time"/>
    </resultMap>

    <sql id="selectUploadPfValueConfigVo">
        select pf_no, windplant_no, project_no, time_scale, name, name_desc, stat_time from upload_pf_value_config
    </sql>

    <select id="selectUploadPfValueConfigList" parameterType="UploadPfValueConfig"
            resultMap="UploadPfValueConfigResult">
        select
        upvc.*,
        win.name as "windplantName"
        from
        upload_pf_value_config upvc
        left join windplant win on win.windplant_no = upvc.windplant_no
        <where>
            <if test="pfNo != null ">and upvc.pf_no = #{pfNo}</if>
            <if test="windplantNo != null ">and upvc.windplant_no = #{windplantNo}</if>
            <if test="projectNo != null ">and upvc.project_no = #{projectNo}</if>
            <if test="timeScale != null ">and upvc.time_scale = #{timeScale}</if>
            <if test="name != null  and name != ''">and upvc.name like concat(concat('%', #{name}), '%')</if>
            <if test="nameDesc != null  and nameDesc != ''">and upvc.name_desc = #{nameDesc}</if>
            <if test="statTime != null ">and upvc.stat_time = #{statTime}</if>
        </where>
        order by upvc.windplant_no asc
    </select>

    <select id="selectUploadPfValueConfigById" parameterType="Long" resultMap="UploadPfValueConfigResult">
        <include refid="selectUploadPfValueConfigVo"/>
        where pf_no = #{pfNo}
    </select>

</mapper>