<?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.project.zcustom.mapper.smart.PlatGreenSmartEnergyMapper">
    
    <resultMap type="PlatGreenSmartEnergy" id="PlatGreenSmartEnergyResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="appOrg"    column="app_org"    />
        <result property="canteenName"    column="canteen_name"    />
        <result property="waterConsumptionNum"    column="water_consumption_num"    />
        <result property="quantityHeatNum"    column="quantity_heat_num"    />
        <result property="gasVolumeNum"    column="gas_volume_num"    />
    </resultMap>

    <sql id="selectPlatGreenSmartEnergyVo">
        select id, del_flag, create_by, create_time, update_by, update_time, app_org, canteen_name, water_consumption_num, quantity_heat_num, gas_volume_num from large_plat_green_smart_energy
    </sql>

    <select id="selectPlatGreenSmartEnergyList" parameterType="PlatGreenSmartEnergy" resultMap="PlatGreenSmartEnergyResult">
        <include refid="selectPlatGreenSmartEnergyVo"/>
        <where>  
            <if test="appOrg != null  and appOrg != ''"> and app_org = #{appOrg}</if>
            <if test="canteenName != null  and canteenName != ''"> and canteen_name like concat('%', #{canteenName}, '%')</if>
            <if test="waterConsumptionNum != null "> and water_consumption_num = #{waterConsumptionNum}</if>
            <if test="quantityHeatNum != null "> and quantity_heat_num = #{quantityHeatNum}</if>
            <if test="gasVolumeNum != null "> and gas_volume_num = #{gasVolumeNum}</if>
        </where>
    </select>
    
    <select id="selectPlatGreenSmartEnergyById" parameterType="Long" resultMap="PlatGreenSmartEnergyResult">
        <include refid="selectPlatGreenSmartEnergyVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlatGreenSmartEnergy" parameterType="PlatGreenSmartEnergy" useGeneratedKeys="true" keyProperty="id">
        insert into large_plat_green_smart_energy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="appOrg != null">app_org,</if>
            <if test="canteenName != null">canteen_name,</if>
            <if test="waterConsumptionNum != null">water_consumption_num,</if>
            <if test="quantityHeatNum != null">quantity_heat_num,</if>
            <if test="gasVolumeNum != null">gas_volume_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="appOrg != null">#{appOrg},</if>
            <if test="canteenName != null">#{canteenName},</if>
            <if test="waterConsumptionNum != null">#{waterConsumptionNum},</if>
            <if test="quantityHeatNum != null">#{quantityHeatNum},</if>
            <if test="gasVolumeNum != null">#{gasVolumeNum},</if>
         </trim>
    </insert>

    <update id="updatePlatGreenSmartEnergy" parameterType="PlatGreenSmartEnergy">
        update large_plat_green_smart_energy
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="appOrg != null">app_org = #{appOrg},</if>
            <if test="canteenName != null">canteen_name = #{canteenName},</if>
            <if test="waterConsumptionNum != null">water_consumption_num = #{waterConsumptionNum},</if>
            <if test="quantityHeatNum != null">quantity_heat_num = #{quantityHeatNum},</if>
            <if test="gasVolumeNum != null">gas_volume_num = #{gasVolumeNum},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlatGreenSmartEnergyById" parameterType="Long">
        delete from large_plat_green_smart_energy where id = #{id}
    </delete>

    <delete id="deletePlatGreenSmartEnergyByIds" parameterType="String">
        delete from large_plat_green_smart_energy where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="reallyDeleteByWrapper">
        DELETE FROM large_plat_green_smart_energy ${ew.customSqlSegment}
    </delete>
</mapper>