<?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.ems.mapper.AdmEmsPgSupplyHMapper">

    <resultMap type="com.ruoyi.ems.domain.AdmEmsPgSupplyH" id="AdmEmsPgSupplyHResult">
        <result property="id"    column="id"    />
        <result property="areaCode"    column="area_code"    />
        <result property="facsCode"    column="facs_code"    />
        <result property="date"    column="date"    />
        <result property="time"    column="time"    />
        <result property="timeIndex"    column="time_index"    />
        <result property="meterType"    column="meter_type"    />
        <result property="meterUnitPrice"    column="meter_unit_price"    />
        <result property="useElecReading"    column="use_elec_reading"    />
        <result property="useElecQuantity"    column="use_elec_quantity"    />
        <result property="useElecCost"    column="use_elec_cost"    />
        <result property="upElecReading"    column="up_elec_reading"    />
        <result property="upElecQuantity"    column="up_elec_quantity"    />
        <result property="upElecEarn"    column="up_elec_earn"    />
    </resultMap>

    <sql id="selectAdmEmsPgSupplyHVo">
        select id, area_code, facs_code, date, time, time_index, meter_type, meter_unit_price, use_elec_reading, use_elec_quantity, use_elec_cost, up_elec_reading, up_elec_quantity, up_elec_earn from adm_ems_pg_supply_h
    </sql>

    <select id="selectAdmEmsPgSupplyHList" parameterType="com.ruoyi.ems.domain.AdmEmsPgSupplyH" resultMap="AdmEmsPgSupplyHResult">
        <include refid="selectAdmEmsPgSupplyHVo"/>
        <where>
            <if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
            <if test="facsCode != null  and facsCode != ''"> and facs_code = #{facsCode}</if>
            <if test="date != null "> and date = #{date}</if>
            <if test="time != null "> and time = #{time}</if>
            <if test="timeIndex != null "> and time_index = #{timeIndex}</if>
            <if test="meterType != null "> and meter_type = #{meterType}</if>
            <if test="meterUnitPrice != null "> and meter_unit_price = #{meterUnitPrice}</if>
            <if test="useElecReading != null "> and use_elec_reading = #{useElecReading}</if>
            <if test="useElecQuantity != null "> and use_elec_quantity = #{useElecQuantity}</if>
            <if test="useElecCost != null "> and use_elec_cost = #{useElecCost}</if>
            <if test="upElecReading != null "> and up_elec_reading = #{upElecReading}</if>
            <if test="upElecQuantity != null "> and up_elec_quantity = #{upElecQuantity}</if>
            <if test="upElecEarn != null "> and up_elec_earn = #{upElecEarn}</if>
        </where>
    </select>

    <select id="selectAdmEmsPgSupplyHById" parameterType="Long" resultMap="AdmEmsPgSupplyHResult">
        <include refid="selectAdmEmsPgSupplyHVo"/>
        where id = #{id}
    </select>

    <insert id="insertAdmEmsPgSupplyH" parameterType="com.ruoyi.ems.domain.AdmEmsPgSupplyH" useGeneratedKeys="true" keyProperty="id">
        insert into adm_ems_pg_supply_h
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaCode != null and areaCode != ''">area_code,</if>
            <if test="facsCode != null and facsCode != ''">facs_code,</if>
            <if test="date != null">date,</if>
            <if test="time != null">time,</if>
            <if test="timeIndex != null">time_index,</if>
            <if test="meterType != null">meter_type,</if>
            <if test="meterUnitPrice != null">meter_unit_price,</if>
            <if test="useElecReading != null">use_elec_reading,</if>
            <if test="useElecQuantity != null">use_elec_quantity,</if>
            <if test="useElecCost != null">use_elec_cost,</if>
            <if test="upElecReading != null">up_elec_reading,</if>
            <if test="upElecQuantity != null">up_elec_quantity,</if>
            <if test="upElecEarn != null">up_elec_earn,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaCode != null and areaCode != ''">#{areaCode},</if>
            <if test="facsCode != null and facsCode != ''">#{facsCode},</if>
            <if test="date != null">#{date},</if>
            <if test="time != null">#{time},</if>
            <if test="timeIndex != null">#{timeIndex},</if>
            <if test="meterType != null">#{meterType},</if>
            <if test="meterUnitPrice != null">#{meterUnitPrice},</if>
            <if test="useElecReading != null">#{useElecReading},</if>
            <if test="useElecQuantity != null">#{useElecQuantity},</if>
            <if test="useElecCost != null">#{useElecCost},</if>
            <if test="upElecReading != null">#{upElecReading},</if>
            <if test="upElecQuantity != null">#{upElecQuantity},</if>
            <if test="upElecEarn != null">#{upElecEarn},</if>
         </trim>
    </insert>

    <update id="updateAdmEmsPgSupplyH" parameterType="com.ruoyi.ems.domain.AdmEmsPgSupplyH">
        update adm_ems_pg_supply_h
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
            <if test="facsCode != null and facsCode != ''">facs_code = #{facsCode},</if>
            <if test="date != null">date = #{date},</if>
            <if test="time != null">time = #{time},</if>
            <if test="timeIndex != null">time_index = #{timeIndex},</if>
            <if test="meterType != null">meter_type = #{meterType},</if>
            <if test="meterUnitPrice != null">meter_unit_price = #{meterUnitPrice},</if>
            <if test="useElecReading != null">use_elec_reading = #{useElecReading},</if>
            <if test="useElecQuantity != null">use_elec_quantity = #{useElecQuantity},</if>
            <if test="useElecCost != null">use_elec_cost = #{useElecCost},</if>
            <if test="upElecReading != null">up_elec_reading = #{upElecReading},</if>
            <if test="upElecQuantity != null">up_elec_quantity = #{upElecQuantity},</if>
            <if test="upElecEarn != null">up_elec_earn = #{upElecEarn},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdmEmsPgSupplyHById" parameterType="Long">
        delete from adm_ems_pg_supply_h where id = #{id}
    </delete>

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