<?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.ho.filecenter.mapper.PvEleAnalysisMapper">


    <sql id="Base_Column_List">
        id,group_id,`year`,
        `month`,theory_power,plan_power,
        real_power,create_time,creator
    </sql>

    <select id="selectByParam" resultType="com.ho.filecenter.entity.PvEleAnalysis">
        select
        <include refid="Base_Column_List" />
        from pv_ele_analysis
        <where>
            <if test="pvEleAnalysis.id != null">
                and id = #{pvEleAnalysis.id}
            </if>
            <if test="pvEleAnalysis.groupId != null">
                and group_id = #{pvEleAnalysis.groupId}
            </if>
            <if test="pvEleAnalysis.year != null">
                and `year` = #{pvEleAnalysis.year}
            </if>
            <if test="pvEleAnalysis.month != null">
                and `month` = #{pvEleAnalysis.month}
            </if>
        </where>
    </select>

    <insert id="insertList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
        insert into pv_ele_analysis (group_id,year,month,theory_power,plan_power,real_power,create_time,creator) values
        <foreach collection="pvEleAnalysisList" item="item" index="index" separator=",">
            (#{item.groupId},#{item.year},#{item.month},#{item.theoryPower},#{item.planPower},#{item.realPower},#{item.createTime},#{item.creator})
        </foreach>
    </insert>

    <update id="updateList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
        <foreach collection="pvEleAnalysisList" item="item" index="index" separator=";">
            update pv_ele_analysis set theory_power = #{item.theoryPower},plan_power = #{item.planPower}, real_power = #{item.realPower}
            where id = #{item.id}
        </foreach>
    </update>
</mapper>
