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

    <resultMap type="MvPoint" id="MvPointResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="mvNo" column="mv_no"/>
        <result property="saveTime" column="save_time"/>
        <result property="statSaveTime1" column="stat_save_time1"/>
        <result property="statSaveTime2" column="stat_save_time2"/>
        <result property="statSaveTime3" column="stat_save_time3"/>
        <result property="dayStatSaveTime1" column="day_stat_save_time1"/>
        <result property="dayStatSaveTime2" column="day_stat_save_time2"/>
        <result property="dayStatSaveTime3" column="day_stat_save_time3"/>
        <result property="monthStatSaveTime1" column="month_stat_save_time1"/>
        <result property="monthStatSaveTime2" column="month_stat_save_time2"/>
        <result property="monthStatSaveTime3" column="month_stat_save_time3"/>
        <result property="period" column="period"/>
    </resultMap>

    <sql id="selectMvPointVo">
        select windplant_no, mv_no, save_time, stat_save_time1, stat_save_time2, stat_save_time3, day_stat_save_time1, day_stat_save_time2, day_stat_save_time3, month_stat_save_time1, month_stat_save_time2, month_stat_save_time3, period from mv_point
    </sql>

    <select id="selectMvPointList" parameterType="MvPoint" resultMap="MvPointResult">
        select
        mp.*,
        w.name as "windplantName",
        m.name as "mvName"
        from
        mv_point mp
        left join windplant w on w.windplant_no = mp.windplant_no
        left join mv m on m.mv_no = mp.mv_no
        <where>
            <if test="windplantNo != null ">and mp.windplant_no = #{windplantNo}</if>
            <if test="mvNo != null ">and mp.mv_no = #{mvNo}</if>
            <if test="saveTime != null ">and mp.save_time = #{saveTime}</if>
            <if test="statSaveTime1 != null ">and mp.stat_save_time1 = #{statSaveTime1}</if>
            <if test="statSaveTime2 != null ">and mp.stat_save_time2 = #{statSaveTime2}</if>
            <if test="statSaveTime3 != null ">and mp.stat_save_time3 = #{statSaveTime3}</if>
            <if test="dayStatSaveTime1 != null ">and mp.day_stat_save_time1 = #{dayStatSaveTime1}</if>
            <if test="dayStatSaveTime2 != null ">and mp.day_stat_save_time2 = #{dayStatSaveTime2}</if>
            <if test="dayStatSaveTime3 != null ">and mp.day_stat_save_time3 = #{dayStatSaveTime3}</if>
            <if test="monthStatSaveTime1 != null ">and mp.month_stat_save_time1 = #{monthStatSaveTime1}</if>
            <if test="monthStatSaveTime2 != null ">and mp.month_stat_save_time2 = #{monthStatSaveTime2}</if>
            <if test="monthStatSaveTime3 != null ">and mp.month_stat_save_time3 = #{monthStatSaveTime3}</if>
            <if test="period != null ">and mp.period = #{period}</if>
            <if test="mvName != null  and mvName != ''">and m.name like concat(concat('%', #{mvName}), '%')</if>
        </where>
        order by mp.windplant_no asc
    </select>

    <select id="selectMvPointById" parameterType="Long" resultMap="MvPointResult">
        <include refid="selectMvPointVo"/>
        where windplant_no = #{windplantNo} and mv_no = #{mvNo}
    </select>

</mapper>