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

    <resultMap id="BaseResultMap" type="com.ho.filecenter.entity.Power">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <id property="groupId" column="group_id" jdbcType="INTEGER"/>
        <result property="projectName" column="project_name" jdbcType="VARCHAR"/>
        <result property="settleMonth" column="settle_month" jdbcType="VARCHAR"/>
        <result property="meterMan" column="meter_man" jdbcType="VARCHAR"/>
        <result property="biCycle" column="bi_cycle" jdbcType="VARCHAR"/>
        <result property="checker" column="checker" jdbcType="VARCHAR"/>
        <result property="powerAll" column="power_all" jdbcType="DECIMAL"/>
        <result property="powerSelf" column="power_self" jdbcType="DECIMAL"/>
        <result property="powerUp" column="power_up" jdbcType="DECIMAL"/>
        <result property="consumeRatio" column="consume_ratio" jdbcType="VARCHAR"/>
        <result property="powerJ" column="power_j" jdbcType="DECIMAL"/>
        <result property="powerF" column="power_f" jdbcType="DECIMAL"/>
        <result property="powerP" column="power_p" jdbcType="DECIMAL"/>
        <result property="powerG" column="power_g" jdbcType="DECIMAL"/>
        <result property="powerSigle" column="power_sigle" jdbcType="DECIMAL"/>
        <result property="origPriceJ" column="orig_price_j" jdbcType="DECIMAL"/>
        <result property="origPriceF" column="orig_price_f" jdbcType="DECIMAL"/>
        <result property="origPriceP" column="orig_price_p" jdbcType="DECIMAL"/>
        <result property="origPriceG" column="orig_price_g" jdbcType="DECIMAL"/>
        <result property="origPriceSigle" column="orig_price_sigle" jdbcType="DECIMAL"/>
        <result property="discountPriceJ" column="discount_price_j" jdbcType="DECIMAL"/>
        <result property="discountPriceF" column="discount_price_f" jdbcType="DECIMAL"/>
        <result property="discountPriceP" column="discount_price_p" jdbcType="DECIMAL"/>
        <result property="discountPriceG" column="discount_price_g" jdbcType="DECIMAL"/>
        <result property="discountPriceSigle" column="discount_price_sigle" jdbcType="DECIMAL"/>
        <result property="feeJ" column="fee_j" jdbcType="DECIMAL"/>
        <result property="feeF" column="fee_f" jdbcType="DECIMAL"/>
        <result property="feeP" column="fee_p" jdbcType="DECIMAL"/>
        <result property="feeG" column="fee_g" jdbcType="DECIMAL"/>
        <result property="feeSigle" column="fee_sigle" jdbcType="DECIMAL"/>
        <result property="receivableFee" column="receivable_fee" jdbcType="DECIMAL"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="creator" column="creator" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,group_id
        ,project_name,settle_month,
        meter_man,bi_cycle,checker,
        power_all,power_self,power_up,
        consume_ratio,power_j,power_f,
        power_p,power_g,power_sigle,
        orig_price_j,orig_price_f,orig_price_p,
        orig_price_g,orig_price_sigle,discount_price_j,
        discount_price_f,discount_price_p,discount_price_g,
        discount_price_sigle,fee_j,fee_f,
        fee_p,fee_g,fee_sigle,
        receivable_fee,create_time,creator
    </sql>


    <insert id="insertSelective" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
        insert into power
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="groupId != null">group_id,</if>
            <if test="projectName != null">project_name,</if>
            <if test="settleMonth != null">settle_month,</if>
            <if test="meterMan != null">meter_man,</if>
            <if test="biCycle != null">bi_cycle,</if>
            <if test="checker != null">checker,</if>
            <if test="powerAll != null">power_all,</if>
            <if test="powerSelf != null">power_self,</if>
            <if test="powerUp != null">power_up,</if>
            <if test="consumeRatio != null">consume_ratio,</if>
            <if test="powerJ != null">power_j,</if>
            <if test="powerF != null">power_f,</if>
            <if test="powerP != null">power_p,</if>
            <if test="powerG != null">power_g,</if>
            <if test="powerSigle != null">power_sigle,</if>
            <if test="origPriceJ != null">orig_price_j,</if>
            <if test="origPriceF != null">orig_price_f,</if>
            <if test="origPriceP != null">orig_price_p,</if>
            <if test="origPriceG != null">orig_price_g,</if>
            <if test="origPriceSigle != null">orig_price_sigle,</if>
            <if test="discountPriceJ != null">discount_price_j,</if>
            <if test="discountPriceF != null">discount_price_f,</if>
            <if test="discountPriceP != null">discount_price_p,</if>
            <if test="discountPriceG != null">discount_price_g,</if>
            <if test="discountPriceSigle != null">discount_price_sigle,</if>
            <if test="feeJ != null">fee_j,</if>
            <if test="feeF != null">fee_f,</if>
            <if test="feeP != null">fee_p,</if>
            <if test="feeG != null">fee_g,</if>
            <if test="feeSigle != null">fee_sigle,</if>
            <if test="receivableFee != null">receivable_fee,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator</if>

        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="groupId != null">#{groupId},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="settleMonth != null">#{settleMonth},</if>
            <if test="meterMan != null">#{meterMan},</if>
            <if test="biCycle != null">#{biCycle},</if>
            <if test="checker != null">#{checker},</if>
            <if test="powerAll != null">#{powerAll},</if>
            <if test="powerSelf != null">#{powerSelf},</if>
            <if test="powerUp != null">#{powerUp},</if>
            <if test="consumeRatio != null">#{consumeRatio},</if>
            <if test="powerJ != null">#{powerJ},</if>
            <if test="powerF != null">#{powerF},</if>
            <if test="powerP != null">#{powerP},</if>
            <if test="powerG != null">#{powerG},</if>
            <if test="powerSigle != null">#{powerSigle},</if>
            <if test="origPriceJ != null">#{origPriceJ},</if>
            <if test="origPriceF != null">#{origPriceF},</if>
            <if test="origPriceP != null">#{origPriceP},</if>
            <if test="origPriceG != null">#{origPriceG},</if>
            <if test="origPriceSigle != null">#{origPriceSigle},</if>
            <if test="discountPriceJ != null">#{discountPriceJ},</if>
            <if test="discountPriceF != null">#{discountPriceF},</if>
            <if test="discountPriceP != null">#{discountPriceP},</if>
            <if test="discountPriceG != null">#{discountPriceG},</if>
            <if test="discountPriceSigle != null">#{discountPriceSigle},</if>
            <if test="feeJ != null">#{feeJ},</if>
            <if test="feeF != null">#{feeF},</if>
            <if test="feeP != null">#{feeP},</if>
            <if test="feeG != null">#{feeG},</if>
            <if test="feeSigle != null">#{feeSigle},</if>
            <if test="receivableFee != null">#{receivableFee},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator}</if>

        </trim>
    </insert>

    <update id="updateByPrimaryKey">
        update power
        set group_id             = #{groupId},
            project_name         = #{projectName},
            settle_month         = #{settleMonth},
            meter_man            = #{meterMan},
            bi_cycle             = #{biCycle},
            checker              = #{checker},
            power_all            = #{powerAll},
            power_self           = #{powerSelf},
            power_up             = #{powerUp},
            consume_ratio        = #{consumeRatio},
            power_j              = #{powerJ},
            power_f              = #{powerF},
            power_p              = #{powerP},
            power_g              = #{powerG},
            power_sigle          = #{powerSigle},
            orig_price_j         = #{origPriceJ},
            orig_price_f         = #{origPriceF},
            orig_price_p         = #{origPriceP},
            orig_price_g         = #{origPriceG},
            orig_price_sigle     = #{origPriceSigle},
            discount_price_j     = #{discountPriceJ},
            discount_price_f     = #{discountPriceF},
            discount_price_p     = #{discountPriceP},
            discount_price_g     = #{discountPriceG},
            discount_price_sigle = #{discountPriceSigle},
            fee_j                = #{feeJ},
            fee_f                = #{feeF},
            fee_p                = #{feeP},
            fee_g                = #{feeG},
            fee_sigle            = #{feeSigle},
            receivable_fee       = #{receivableFee},
            create_time= #{createTime},
            creator= #{creator}
        where id = #{id,jdbcType=BIGINT}
    </update>

    <update id="updateByPrimaryKeySelective">
        update power
        <set>
            <if test="groupId != null">
                group_id = #{groupId},
            </if>
            <if test="projectName != null">
                project_name = #{projectName},
            </if>
            <if test="settleMonth != null">
                settle_month = #{settleMonth},
            </if>
            <if test="settleMonth != null">
                meter_man = #{meterMan},
            </if>
            <if test="settleMonth != null">
                bi_cycle = #{biCycle},
            </if>
            <if test="checker != null">
                checker = #{checker},
            </if>
            <if test="powerAll != null">
                power_all = #{powerAll},
            </if>
            <if test="powerSelf != null">
                power_self = #{powerSelf},
            </if>
            <if test="powerUp != null">
                power_up = #{powerUp},
            </if>

            <if test="consumeRatio != null">
                consume_ratio = #{consumeRatio},
            </if>
            <if test="powerJ != null">
                power_j = #{powerJ},
            </if>
            <if test="powerF != null">
                power_f = #{powerF},
            </if>
            <if test="powerP != null">
                power_p = #{powerP},
            </if>
            <if test="powerG != null">
                power_g = #{powerG},
            </if>
            <if test="powerSigle != null">
                power_sigle = #{powerSigle},
            </if>
            <if test="consumeRatio != null">
                orig_price_j = #{origPriceJ},
            </if>
            <if test="consumeRatio != null">
                orig_price_f = #{origPriceF},
            </if>
            <if test="consumeRatio != null">
                orig_price_p = #{origPriceP},
            </if>
            <if test="consumeRatio != null">
                orig_price_g = #{origPriceG},
            </if>

            <if test="origPriceSigle != null">
                orig_price_sigle = #{origPriceSigle},
            </if>
            <if test="discountPriceJ != null">
                discount_price_j = #{discountPriceJ},
            </if>
            <if test="discountPriceF != null">
                discount_price_f = #{discountPriceF},
            </if>
            <if test="discountPriceP != null">
                discount_price_p = #{discountPriceP},
            </if>
            <if test="discountPriceG != null">
                discount_price_g = #{discountPriceG},
            </if>
            <if test="discountPriceSigle != null">
                discount_price_sigle = #{discountPriceSigle},
            </if>
            <if test="feeJ != null">
                fee_j = #{feeJ},
            </if>
            <if test="feeF != null">
                fee_f = #{feeF},
            </if>
            <if test="feeP != null">
                fee_p = #{feeP},
            </if>
            <if test="feeG != null">
                fee_g = #{feeG},
            </if>
            <if test="feeSigle != null">
                fee_sigle = #{feeSigle},
            </if>
            <if test="receivableFee != null">
                receivable_fee = #{receivableFee},
            </if>
            <if test="createTime!= null">
                create_time= #{createTime},
            </if>
            <if test="creator!= null">
                creator= #{creator}
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <delete id="batchDeletes">
        <!--循环删除 -->
        delete
        from power
        <where>
            <if test="list != null and list.size !=0">
                and id in
                <foreach collection="list" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>
        </where>
    </delete>

    <delete id="deleteByPrimaryKey">
        delete
        from power
        where id = #{id,jdbcType=INTEGER}
    </delete>

    <select id="selectAll" resultType="com.ho.filecenter.entity.Power">
        select
        <include refid="Base_Column_List"/>
        from power
        <where>
            <if test="groupId != null">
                and group_id = #{groupId}
            </if>
            <if test="settleMonth != null">
                and settle_month = #{settleMonth}
            </if>
            <if test="projectName != null">
                and project_name = #{projectName}
            </if>
            order by create_time desc
        </where>
    </select>

    <select id="selectById" resultType="com.ho.filecenter.entity.Power">
        select
        <include refid="Base_Column_List"/>
        from power
        <where>
            <if test="id != null">
                and id= #{id}
            </if>
            <if test="settleMonth != null">
                and settle_month = #{settleMonth}
            </if>
            <if test="projectName != null">
                and project_name = #{projectName}
            </if>
        </where>
    </select>

    <select id="selectByMonthAndName" resultType="com.ho.filecenter.entity.Power">
        select
        <include refid="Base_Column_List"/>
        from power
        where
        settle_month = #{settleMonth}
        and project_name = #{projectName}
    </select>


</mapper>
