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

    <resultMap type="EmsXfData" id="EmsXfDataResult">
        <result property="id"    column="id"    />
        <result property="dataTimestamp"    column="data_timestamp"    />
        <result property="dczt"    column="dczt"    />
        <result property="yszt"    column="yszt"    />
        <result property="pszt"    column="pszt"    />
        <result property="dcfzt"    column="dcfzt"    />
        <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="remark"    column="remark"    />
        <result property="siteId"    column="site_id"    />
        <result property="deviceId"    column="device_id"    />
    </resultMap>

    <sql id="selectEmsXfDataVo">
        select id, data_timestamp, dczt, yszt, pszt, dcfzt, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_xf_data
    </sql>

    <select id="selectEmsXfDataList" parameterType="EmsXfData" resultMap="EmsXfDataResult">
        <include refid="selectEmsXfDataVo"/>
        <where>
            <if test="dataTimestamp != null "> and data_timestamp = #{dataTimestamp}</if>
            <if test="dczt != null "> and dczt = #{dczt}</if>
            <if test="yszt != null "> and yszt = #{yszt}</if>
            <if test="pszt != null "> and pszt = #{pszt}</if>
            <if test="dcfzt != null "> and dcfzt = #{dcfzt}</if>
            <if test="siteId != null  and siteId != ''"> and site_id = #{siteId}</if>
            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
        </where>
    </select>

    <select id="selectEmsXfDataById" parameterType="Long" resultMap="EmsXfDataResult">
        <include refid="selectEmsXfDataVo"/>
        where id = #{id}
    </select>

    <insert id="insertEmsXfData" parameterType="EmsXfData" useGeneratedKeys="true" keyProperty="id">
        insert into ems_xf_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dataTimestamp != null">data_timestamp,</if>
            <if test="dczt != null">dczt,</if>
            <if test="yszt != null">yszt,</if>
            <if test="pszt != null">pszt,</if>
            <if test="dcfzt != null">dcfzt,</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="remark != null">remark,</if>
            <if test="siteId != null">site_id,</if>
            <if test="deviceId != null and deviceId != ''">device_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dataTimestamp != null">#{dataTimestamp},</if>
            <if test="dczt != null">#{dczt},</if>
            <if test="yszt != null">#{yszt},</if>
            <if test="pszt != null">#{pszt},</if>
            <if test="dcfzt != null">#{dcfzt},</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="remark != null">#{remark},</if>
            <if test="siteId != null">#{siteId},</if>
            <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
        </trim>
    </insert>

    <update id="updateEmsXfData" parameterType="EmsXfData">
        update ems_xf_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="dataTimestamp != null">data_timestamp = #{dataTimestamp},</if>
            <if test="dczt != null">dczt = #{dczt},</if>
            <if test="yszt != null">yszt = #{yszt},</if>
            <if test="pszt != null">pszt = #{pszt},</if>
            <if test="dcfzt != null">dcfzt = #{dcfzt},</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="remark != null">remark = #{remark},</if>
            <if test="siteId != null">site_id = #{siteId},</if>
            <if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEmsXfDataById" parameterType="Long">
        delete from ems_xf_data where id = #{id}
    </delete>

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