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

    <resultMap type="WindplantPoint" id="WindplantPointResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="statTime1" column="stat_time1"/>
        <result property="statTime2" column="stat_time2"/>
        <result property="statTime3" column="stat_time3"/>
        <result property="statDayTime1" column="stat_day_time1"/>
        <result property="statDayTime2" column="stat_day_time2"/>
        <result property="statDayTime3" column="stat_day_time3"/>
        <result property="statMonthTime1" column="stat_month_time1"/>
        <result property="statMonthTime2" column="stat_month_time2"/>
        <result property="statMonthTime3" column="stat_month_time3"/>
        <result property="exportTime1" column="export_time1"/>
        <result property="exportTime2" column="export_time2"/>
    </resultMap>

    <sql id="selectWindplantPointVo">
        select windplant_no, stat_time1, stat_time2, stat_time3, stat_day_time1, stat_day_time2, stat_day_time3, stat_month_time1, stat_month_time2, stat_month_time3, export_time1, export_time2 from windplant_point
    </sql>

    <select id="selectWindplantPointList" parameterType="WindplantPoint" resultMap="WindplantPointResult">
        select
        wp.*,
        w.name as "windplantName"
        from
        windplant_point wp
        left join windplant w on w.windplant_no = wp.windplant_no
        <where>
            <if test="windplantNo != null ">and wp.windplant_no = #{windplantNo}</if>
            <if test="statTime1 != null ">and wp.stat_time1 = #{statTime1}</if>
            <if test="statTime2 != null ">and wp.stat_time2 = #{statTime2}</if>
            <if test="statTime3 != null ">and wp.stat_time3 = #{statTime3}</if>
            <if test="statDayTime1 != null ">and wp.stat_day_time1 = #{statDayTime1}</if>
            <if test="statDayTime2 != null ">and wp.stat_day_time2 = #{statDayTime2}</if>
            <if test="statDayTime3 != null ">and wp.stat_day_time3 = #{statDayTime3}</if>
            <if test="statMonthTime1 != null ">and wp.stat_month_time1 = #{statMonthTime1}</if>
            <if test="statMonthTime2 != null ">and wp.stat_month_time2 = #{statMonthTime2}</if>
            <if test="statMonthTime3 != null ">and wp.stat_month_time3 = #{statMonthTime3}</if>
            <if test="exportTime1 != null ">and wp.export_time1 = #{exportTime1}</if>
            <if test="exportTime2 != null ">and wp.export_time2 = #{exportTime2}</if>
        </where>
        order by wp.windplant_no asc
    </select>

    <select id="selectWindplantPointById" parameterType="Long" resultMap="WindplantPointResult">
        <include refid="selectWindplantPointVo"/>
        where windplant_no = #{windplantNo}
    </select>

    <select id="checkWindplantNoUnique" parameterType="Long" resultType="int">
        select count(1) from windplant_point where windplant_no = #{windplantNo} and rownum <![CDATA[ <= ]]> 1
    </select>

    <insert id="insertWindplantPoint" parameterType="WindplantPoint">
        insert into windplant_point
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">windplant_no,</if>
            <if test="statTime1 != null">stat_time1,</if>
            <if test="statTime2 != null">stat_time2,</if>
            <if test="statTime3 != null">stat_time3,</if>
            <if test="statDayTime1 != null">stat_day_time1,</if>
            <if test="statDayTime2 != null">stat_day_time2,</if>
            <if test="statDayTime3 != null">stat_day_time3,</if>
            <if test="statMonthTime1 != null">stat_month_time1,</if>
            <if test="statMonthTime2 != null">stat_month_time2,</if>
            <if test="statMonthTime3 != null">stat_month_time3,</if>
            <if test="exportTime1 != null">export_time1,</if>
            <if test="exportTime2 != null">export_time2,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">#{windplantNo},</if>
            <if test="statTime1 != null">#{statTime1},</if>
            <if test="statTime2 != null">#{statTime2},</if>
            <if test="statTime3 != null">#{statTime3},</if>
            <if test="statDayTime1 != null">#{statDayTime1},</if>
            <if test="statDayTime2 != null">#{statDayTime2},</if>
            <if test="statDayTime3 != null">#{statDayTime3},</if>
            <if test="statMonthTime1 != null">#{statMonthTime1},</if>
            <if test="statMonthTime2 != null">#{statMonthTime2},</if>
            <if test="statMonthTime3 != null">#{statMonthTime3},</if>
            <if test="exportTime1 != null">#{exportTime1},</if>
            <if test="exportTime2 != null">#{exportTime2},</if>
        </trim>
    </insert>

    <update id="updateWindplantPoint" parameterType="WindplantPoint">
        update windplant_point
        <trim prefix="SET" suffixOverrides=",">
            <if test="statTime1 != null">stat_time1 = #{statTime1},</if>
            <if test="statTime2 != null">stat_time2 = #{statTime2},</if>
            <if test="statTime3 != null">stat_time3 = #{statTime3},</if>
            <if test="statDayTime1 != null">stat_day_time1 = #{statDayTime1},</if>
            <if test="statDayTime2 != null">stat_day_time2 = #{statDayTime2},</if>
            <if test="statDayTime3 != null">stat_day_time3 = #{statDayTime3},</if>
            <if test="statMonthTime1 != null">stat_month_time1 = #{statMonthTime1},</if>
            <if test="statMonthTime2 != null">stat_month_time2 = #{statMonthTime2},</if>
            <if test="statMonthTime3 != null">stat_month_time3 = #{statMonthTime3},</if>
            <if test="exportTime1 != null">export_time1 = #{exportTime1},</if>
            <if test="exportTime2 != null">export_time2 = #{exportTime2},</if>
        </trim>
        where windplant_no = #{windplantNo}
    </update>

    <delete id="deleteWindplantPointById" parameterType="Long">
        delete from windplant_point where windplant_no = #{windplantNo}
    </delete>

    <delete id="deleteWindplantPointByIds" parameterType="String">
        delete from windplant_point where windplant_no in
        <foreach item="windplantNo" collection="array" open="(" separator="," close=")">
            #{windplantNo}
        </foreach>
    </delete>

</mapper>