<?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.BaseCollectDeviceInfoMapper">

    <resultMap type="BaseCollectDeviceInfo" id="BaseCollectDeviceInfoResult">
        <result property="objid"    column="objid"    />
        <result property="collectDeviceId"    column="collect_device_id"    />
        <result property="collectDeviceName"    column="collect_device_name"    />
        <result property="manufacturer"    column="manufacturer"    />
        <result property="factoryNumber"    column="factory_number"    />
        <result property="produceDate"    column="produce_date"    />
        <result property="address"    column="address"    />
        <result property="energyType"    column="energy_type"    />
        <result property="model"    column="model"    />
        <result property="ip"    column="ip"    />
        <result property="remark"    column="remark"    />
        <result property="onlineState"    column="online_state"    />
        <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="selectBaseCollectDeviceInfoVo">
        select objid, collect_device_id, collect_device_name, manufacturer, factory_number, produce_date, address, energy_type, model, ip, remark, online_state, dept_id, user_id, create_by, create_time, update_by, update_time from base_collect_device_info
    </sql>

    <select id="selectBaseCollectDeviceInfoList" parameterType="BaseCollectDeviceInfo" resultMap="BaseCollectDeviceInfoResult">
        <include refid="selectBaseCollectDeviceInfoVo"/>
        <where>
            <if test="collectDeviceName != null  and collectDeviceName != ''"> and collect_device_name like concat('%', #{collectDeviceName}, '%')</if>
            <if test="manufacturer != null  and manufacturer != ''"> and manufacturer = #{manufacturer}</if>
            <if test="factoryNumber != null  and factoryNumber != ''"> and factory_number = #{factoryNumber}</if>
            <if test="produceDate != null "> and produce_date = #{produceDate}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="energyType != null "> and energy_type = #{energyType}</if>
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="ip != null  and ip != ''"> and ip = #{ip}</if>
            <if test="onlineState != null "> and online_state = #{onlineState}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>

    <select id="selectBaseCollectDeviceInfoByObjid" parameterType="Long" resultMap="BaseCollectDeviceInfoResult">
        <include refid="selectBaseCollectDeviceInfoVo"/>
        where objid = #{objid}
    </select>

    <insert id="insertBaseCollectDeviceInfo" parameterType="BaseCollectDeviceInfo" useGeneratedKeys="true" keyProperty="objid">
        insert into base_collect_device_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="collectDeviceId != null">collect_device_id,</if>
            <if test="collectDeviceName != null">collect_device_name,</if>
            <if test="manufacturer != null">manufacturer,</if>
            <if test="factoryNumber != null">factory_number,</if>
            <if test="produceDate != null">produce_date,</if>
            <if test="address != null">address,</if>
            <if test="energyType != null">energy_type,</if>
            <if test="model != null">model,</if>
            <if test="ip != null">ip,</if>
            <if test="remark != null">remark,</if>
            <if test="onlineState != null">online_state,</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="collectDeviceName != null">#{collectDeviceName},</if>
            <if test="manufacturer != null">#{manufacturer},</if>
            <if test="factoryNumber != null">#{factoryNumber},</if>
            <if test="produceDate != null">#{produceDate},</if>
            <if test="address != null">#{address},</if>
            <if test="energyType != null">#{energyType},</if>
            <if test="model != null">#{model},</if>
            <if test="ip != null">#{ip},</if>
            <if test="remark != null">#{remark},</if>
            <if test="onlineState != null">#{onlineState},</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="updateBaseCollectDeviceInfo" parameterType="BaseCollectDeviceInfo">
        update base_collect_device_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="collectDeviceId != null">collect_device_id = #{collectDeviceId},</if>
            <if test="collectDeviceName != null">collect_device_name = #{collectDeviceName},</if>
            <if test="manufacturer != null">manufacturer = #{manufacturer},</if>
            <if test="factoryNumber != null">factory_number = #{factoryNumber},</if>
            <if test="produceDate != null">produce_date = #{produceDate},</if>
            <if test="address != null">address = #{address},</if>
            <if test="energyType != null">energy_type = #{energyType},</if>
            <if test="model != null">model = #{model},</if>
            <if test="ip != null">ip = #{ip},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="onlineState != null">online_state = #{onlineState},</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="deleteBaseCollectDeviceInfoByObjid" parameterType="Long">
        delete from base_collect_device_info where objid = #{objid}
    </delete>

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