<?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.report.mapper.EmsReportPointSteamMapper">

    <resultMap type="EmsReportPointSteam" id="EmsReportPointSteamResult">
        <result property="objId" column="obj_id"/>
        <result property="monitorCode" column="monitor_code"/>
        <result property="instrumentValue" column="instrument_value"/>
        <result property="expend" column="expend"/>
        <result property="recordTime" column="record_time"/>
        <result property="beginTime" column="begin_time"/>
        <result property="endTime" column="end_time"/>
        <result property="updateFlag" column="update_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"/>
    </resultMap>

    <sql id="selectEmsReportPointSteamVo">
        select obj_id,
               monitor_code,
               instrument_value,
               expend,
               record_time,
               begin_time,
               end_time,
               update_flag,
               create_by,
               create_time,
               update_by,
               update_time
        from ems_report_point_steam
    </sql>

    <select id="selectEmsReportPointSteamList" parameterType="EmsReportPointSteam"
            resultMap="EmsReportPointSteamResult">
        <include refid="selectEmsReportPointSteamVo"/>
        <where>
            <if test="monitorCode != null  and monitorCode != ''">and monitor_code = #{monitorCode}</if>
            <if test="instrumentValue != null ">and instrument_value = #{instrumentValue}</if>
            <if test="expend != null ">and expend = #{expend}</if>
            <if test="params.beginRecordTime != null and params.beginRecordTime != '' and params.endRecordTime != null and params.endRecordTime != ''">
                and record_time between #{params.beginRecordTime} and #{params.endRecordTime}
            </if>
            <if test="params.beginBeginTime != null and params.beginBeginTime != '' and params.endBeginTime != null and params.endBeginTime != ''">
                and begin_time between #{params.beginBeginTime} and #{params.endBeginTime}
            </if>
            <if test="params.beginEndTime != null and params.beginEndTime != '' and params.endEndTime != null and params.endEndTime != ''">
                and end_time between #{params.beginEndTime} and #{params.endEndTime}
            </if>
            <if test="updateFlag != null  and updateFlag != ''">and update_flag = #{updateFlag}</if>
        </where>
    </select>

    <select id="selectEmsReportPointSteamByObjId" parameterType="Long" resultMap="EmsReportPointSteamResult">
        <include refid="selectEmsReportPointSteamVo"/>
        where obj_id = #{objId}
    </select>

    <insert id="insertEmsReportPointSteam" parameterType="EmsReportPointSteam" useGeneratedKeys="true"
            keyProperty="objId">
        insert into ems_report_point_steam
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="monitorCode != null">monitor_code,</if>
            <if test="instrumentValue != null">instrument_value,</if>
            <if test="expend != null">expend,</if>
            <if test="recordTime != null">record_time,</if>
            <if test="beginTime != null">begin_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="updateFlag != null">update_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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="monitorCode != null">#{monitorCode},</if>
            <if test="instrumentValue != null">#{instrumentValue},</if>
            <if test="expend != null">#{expend},</if>
            <if test="recordTime != null">#{recordTime},</if>
            <if test="beginTime != null">#{beginTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="updateFlag != null">#{updateFlag},</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>
        </trim>
    </insert>

    <update id="updateEmsReportPointSteam" parameterType="EmsReportPointSteam">
        update ems_report_point_steam
        <trim prefix="SET" suffixOverrides=",">
            <if test="monitorCode != null">monitor_code = #{monitorCode},</if>
            <if test="instrumentValue != null">instrument_value = #{instrumentValue},</if>
            <if test="expend != null">expend = #{expend},</if>
            <if test="recordTime != null">record_time = #{recordTime},</if>
            <if test="beginTime != null">begin_time = #{beginTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="updateFlag != null">update_flag = #{updateFlag},</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>
        </trim>
        where obj_id = #{objId}
    </update>

    <delete id="deleteEmsReportPointSteamByObjId" parameterType="Long">
        delete
        from ems_report_point_steam
        where obj_id = #{objId}
    </delete>

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