<?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.zksy.base.mapper.AlarmAssignListMapper">
    
    <resultMap type="com.zksy.base.domain.AlarmAssignList" id="AlarmAssignListResult">
        <result property="alarmAssignId"    column="alarm_assign_id"    />
        <result property="deviceCode"    column="device_code"    />
        <result property="deviceName"    column="device_name"    />
        <result property="manufacturer"    column="manufacturer"    />
        <result property="alarmStatus"    column="alarm_status"    />
        <result property="hiddenDangerType"    column="hidden_danger_type"    />
        <result property="hiddenDangerRemark"    column="hidden_danger_remark"    />
        <result property="alarmTime"    column="alarm_time"    />
        <result property="assignStatus"    column="assign_status"    />
        <result property="assignTime"    column="assign_time"    />
        <result property="assignUserId"    column="assign_user_id"    />
        <result property="assignRemark"    column="assign_remark"    />
    </resultMap>

    <sql id="selectAlarmAssignListVo">
        select alarm_assign_id, device_code, device_name, manufacturer, alarm_status, hidden_danger_type, hidden_danger_remark, alarm_time, assign_status, assign_time, assign_user_id, assign_remark from alarm_assign_list
    </sql>

    <select id="selectAlarmAssignListList" parameterType="com.zksy.base.domain.AlarmAssignList" resultMap="AlarmAssignListResult">
        <include refid="selectAlarmAssignListVo"/>
        <where>  
            <if test="alarmAssignId != null "> and alarm_assign_id = #{alarmAssignId}</if>
            <if test="deviceCode != null  and deviceCode != ''"> and device_code = #{deviceCode}</if>
            <if test="manufacturer != null  and manufacturer != ''"> and manufacturer like concat('%', #{manufacturer}, '%')</if>
            <if test="alarmStatus != null "> and alarm_status = #{alarmStatus}</if>
            <!-- <if test="params.beginAlarmTime != null and params.beginAlarmTime != '' and params.endAlarmTime != null and params.endAlarmTime != ''"> and alarm_time between #{params.beginAlarmTime} and #{params.endAlarmTime}</if> -->
            <if test="assignStatus != null "> and assign_status = #{assignStatus}</if>
        </where>
    </select>
    
    <select id="selectAlarmAssignListByAlarmAssignId" parameterType="Long" resultMap="AlarmAssignListResult">
        <include refid="selectAlarmAssignListVo"/>
        where alarm_assign_id = #{alarmAssignId}
    </select>

    <insert id="insertAlarmAssignList" parameterType="com.zksy.base.domain.AlarmAssignList">
        insert into alarm_assign_list
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="alarmAssignId != null">alarm_assign_id,</if>
            <if test="deviceCode != null and deviceCode != ''">device_code,</if>
            <if test="deviceName != null and deviceName != ''">device_name,</if>
            <if test="manufacturer != null">manufacturer,</if>
            <if test="alarmStatus != null">alarm_status,</if>
            <if test="hiddenDangerType != null">hidden_danger_type,</if>
            <if test="hiddenDangerRemark != null">hidden_danger_remark,</if>
            <if test="alarmTime != null">alarm_time,</if>
            <if test="assignStatus != null">assign_status,</if>
            <if test="assignTime != null">assign_time,</if>
            <if test="assignUserId != null">assign_user_id,</if>
            <if test="assignRemark != null">assign_remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="alarmAssignId != null">#{alarmAssignId},</if>
            <if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
            <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
            <if test="manufacturer != null">#{manufacturer},</if>
            <if test="alarmStatus != null">#{alarmStatus},</if>
            <if test="hiddenDangerType != null">#{hiddenDangerType},</if>
            <if test="hiddenDangerRemark != null">#{hiddenDangerRemark},</if>
            <if test="alarmTime != null">#{alarmTime},</if>
            <if test="assignStatus != null">#{assignStatus},</if>
            <if test="assignTime != null">#{assignTime},</if>
            <if test="assignUserId != null">#{assignUserId},</if>
            <if test="assignRemark != null">#{assignRemark},</if>
         </trim>
    </insert>

    <update id="updateAlarmAssignList" parameterType="com.zksy.base.domain.AlarmAssignList">
        update alarm_assign_list
        <trim prefix="SET" suffixOverrides=",">
            <if test="deviceCode != null and deviceCode != ''">device_code = #{deviceCode},</if>
            <if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
            <if test="manufacturer != null">manufacturer = #{manufacturer},</if>
            <if test="alarmStatus != null">alarm_status = #{alarmStatus},</if>
            <if test="hiddenDangerType != null">hidden_danger_type = #{hiddenDangerType},</if>
            <if test="hiddenDangerRemark != null">hidden_danger_remark = #{hiddenDangerRemark},</if>
            <if test="alarmTime != null">alarm_time = #{alarmTime},</if>
            <if test="assignStatus != null">assign_status = #{assignStatus},</if>
            <if test="assignTime != null">assign_time = #{assignTime},</if>
            <if test="assignUserId != null">assign_user_id = #{assignUserId},</if>
            <if test="assignRemark != null">assign_remark = #{assignRemark},</if>
        </trim>
        where alarm_assign_id = #{alarmAssignId}
    </update>

    <delete id="deleteAlarmAssignListByAlarmAssignId" parameterType="Long">
        delete from alarm_assign_list where alarm_assign_id = #{alarmAssignId}
    </delete>

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