<?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.hw.ems.base.mapper.BaseCollectCommunicateMapper">

    <resultMap type="BaseCollectCommunicate" id="BaseCollectCommunicateResult">
        <result property="objid"    column="objid"    />
        <result property="collectDeviceId"    column="collect_device_id"    />
        <result property="terminalTime"    column="terminal_time"    />
        <result property="timeInterval"    column="time_interval"    />
        <result property="meterAgreement"    column="meter_agreement"    />
        <result property="meterType"    column="meter_type"    />
        <result property="meterStatus"    column="meter_status"    />
        <result property="meterIp"    column="meter_ip"    />
        <result property="heartInterval"    column="heart_interval"    />
        <result property="baudRateOne"    column="baud_rate_one"    />
        <result property="baudRateTwo"    column="baud_rate_two"    />
        <result property="baudRateThree"    column="baud_rate_three"    />
        <result property="baudRateFour"    column="baud_rate_four"    />
        <result property="remark"    column="remark"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <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="selectBaseCollectCommunicateVo">
        select objid, collect_device_id, terminal_time, time_interval, meter_agreement, meter_type, meter_status, meter_ip, heart_interval, baud_rate_one, baud_rate_two, baud_rate_three, baud_rate_four, remark, dept_id, user_id, create_by, create_time, update_by, update_time from base_collect_communicate
    </sql>

    <select id="selectBaseCollectCommunicateList" parameterType="BaseCollectCommunicate" resultMap="BaseCollectCommunicateResult">
        <include refid="selectBaseCollectCommunicateVo"/>
        <where>
            <if test="collectDeviceId != null  and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
            <if test="terminalTime != null "> and terminal_time = #{terminalTime}</if>
            <if test="timeInterval != null "> and time_interval = #{timeInterval}</if>
            <if test="meterAgreement != null  and meterAgreement != ''"> and meter_agreement = #{meterAgreement}</if>
            <if test="meterType != null "> and meter_type = #{meterType}</if>
            <if test="meterStatus != null "> and meter_status = #{meterStatus}</if>
            <if test="meterIp != null  and meterIp != ''"> and meter_ip = #{meterIp}</if>
            <if test="heartInterval != null "> and heart_interval = #{heartInterval}</if>
            <if test="baudRateOne != null "> and baud_rate_one = #{baudRateOne}</if>
            <if test="baudRateTwo != null "> and baud_rate_two = #{baudRateTwo}</if>
            <if test="baudRateThree != null "> and baud_rate_three = #{baudRateThree}</if>
            <if test="baudRateFour != null "> and baud_rate_four = #{baudRateFour}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>

    <select id="selectBaseCollectCommunicateByObjid" parameterType="Long" resultMap="BaseCollectCommunicateResult">
        <include refid="selectBaseCollectCommunicateVo"/>
        where objid = #{objid}
    </select>

    <insert id="insertBaseCollectCommunicate" parameterType="BaseCollectCommunicate" useGeneratedKeys="true" keyProperty="objid">
        insert into base_collect_communicate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="collectDeviceId != null">collect_device_id,</if>
            <if test="terminalTime != null">terminal_time,</if>
            <if test="timeInterval != null">time_interval,</if>
            <if test="meterAgreement != null">meter_agreement,</if>
            <if test="meterType != null">meter_type,</if>
            <if test="meterStatus != null">meter_status,</if>
            <if test="meterIp != null">meter_ip,</if>
            <if test="heartInterval != null">heart_interval,</if>
            <if test="baudRateOne != null">baud_rate_one,</if>
            <if test="baudRateTwo != null">baud_rate_two,</if>
            <if test="baudRateThree != null">baud_rate_three,</if>
            <if test="baudRateFour != null">baud_rate_four,</if>
            <if test="remark != null">remark,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</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="collectDeviceId != null">#{collectDeviceId},</if>
            <if test="terminalTime != null">#{terminalTime},</if>
            <if test="timeInterval != null">#{timeInterval},</if>
            <if test="meterAgreement != null">#{meterAgreement},</if>
            <if test="meterType != null">#{meterType},</if>
            <if test="meterStatus != null">#{meterStatus},</if>
            <if test="meterIp != null">#{meterIp},</if>
            <if test="heartInterval != null">#{heartInterval},</if>
            <if test="baudRateOne != null">#{baudRateOne},</if>
            <if test="baudRateTwo != null">#{baudRateTwo},</if>
            <if test="baudRateThree != null">#{baudRateThree},</if>
            <if test="baudRateFour != null">#{baudRateFour},</if>
            <if test="remark != null">#{remark},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</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="updateBaseCollectCommunicate" parameterType="BaseCollectCommunicate">
        update base_collect_communicate
        <trim prefix="SET" suffixOverrides=",">
            <if test="collectDeviceId != null">collect_device_id = #{collectDeviceId},</if>
            <if test="terminalTime != null">terminal_time = #{terminalTime},</if>
            <if test="timeInterval != null">time_interval = #{timeInterval},</if>
            <if test="meterAgreement != null">meter_agreement = #{meterAgreement},</if>
            <if test="meterType != null">meter_type = #{meterType},</if>
            <if test="meterStatus != null">meter_status = #{meterStatus},</if>
            <if test="meterIp != null">meter_ip = #{meterIp},</if>
            <if test="heartInterval != null">heart_interval = #{heartInterval},</if>
            <if test="baudRateOne != null">baud_rate_one = #{baudRateOne},</if>
            <if test="baudRateTwo != null">baud_rate_two = #{baudRateTwo},</if>
            <if test="baudRateThree != null">baud_rate_three = #{baudRateThree},</if>
            <if test="baudRateFour != null">baud_rate_four = #{baudRateFour},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</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 objid = #{objid}
    </update>

    <delete id="deleteBaseCollectCommunicateByObjid" parameterType="Long">
        delete from base_collect_communicate where objid = #{objid}
    </delete>

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