<?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.WfTheorypowerDataMapper">
    
    <resultMap type="WfTheorypowerData" id="WfTheorypowerDataResult">
        <result property="windplantNo"    column="windplant_no"    />
        <result property="dataTime"    column="data_time"    />
        <result property="theorypower"    column="theorypower"    />
        <result property="availablepower"    column="availablepower"    />
        <result property="isLimit"    column="is_limit"    />
        <result property="dataFlag"    column="data_flag"    />
    </resultMap>

    <sql id="selectWfTheorypowerDataVo">
        select windplant_no, data_time, theorypower, availablepower, is_limit, data_flag from wf_theorypower_data
    </sql>

    <select id="selectWfTheorypowerDataList" parameterType="WfTheorypowerData" resultMap="WfTheorypowerDataResult">
        <include refid="selectWfTheorypowerDataVo"/>
        <where>
            <if test="windplantNo != null ">and windplant_no = #{windplantNo}</if>
            <if test="theorypower != null "> and theorypower = #{theorypower}</if>
            <if test="availablepower != null "> and availablepower = #{availablepower}</if>
            <if test="isLimit != null "> and is_limit = #{isLimit}</if>
            <if test="dataFlag != null "> and data_flag = #{dataFlag}</if>
            <if test="params.beginDataTime != null and params.beginDataTime != '' and params.endDataTime != null and params.endDataTime != ''">
                and data_time between to_date(#{params.beginDataTime},'yyyy-MM-dd HH24:MI:SS') and
                to_date(#{params.endDataTime},'yyyy-MM-dd HH24:MI:SS')
            </if>
            <if test="dataTime != null ">and data_time = #{dataTime}</if>
        </where>
    </select>
    
    <select id="selectWfTheorypowerDataById" parameterType="Long" resultMap="WfTheorypowerDataResult">
        <include refid="selectWfTheorypowerDataVo"/>
        where windplant_no = #{windplantNo}
    </select>

    <select id="selectWfTheorypowerData" parameterType="WfTheorypowerData" resultMap="WfTheorypowerDataResult">
        <include refid="selectWfTheorypowerDataVo"/>
        where windplant_no = #{windplantNo} and data_time > #{dataTime}
    </select>

    <insert id="insertWfTheorypowerData" parameterType="WfTheorypowerData">
        insert into wf_theorypower_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">windplant_no,</if>
            <if test="dataTime != null">data_time,</if>
            <if test="theorypower != null">theorypower,</if>
            <if test="availablepower != null">availablepower,</if>
            <if test="isLimit != null">is_limit,</if>
            <if test="dataFlag != null">data_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">#{windplantNo},</if>
            <if test="dataTime != null">#{dataTime},</if>
            <if test="theorypower != null">#{theorypower},</if>
            <if test="availablepower != null">#{availablepower},</if>
            <if test="isLimit != null">#{isLimit},</if>
            <if test="dataFlag != null">#{dataFlag},</if>
         </trim>
    </insert>

    <update id="updateWfTheorypowerData" parameterType="WfTheorypowerData">
        update wf_theorypower_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="dataTime != null">data_time = #{dataTime},</if>
            <if test="theorypower != null">theorypower = #{theorypower},</if>
            <if test="availablepower != null">availablepower = #{availablepower},</if>
            <if test="isLimit != null">is_limit = #{isLimit},</if>
            <if test="dataFlag != null">data_flag = #{dataFlag},</if>
        </trim>
        where windplant_no = #{windplantNo}
    </update>

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

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