<?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.manage.mapper.DialIndicatorLogMapper">
    
    <resultMap type="DialIndicatorLog" id="DialIndicatorLogResult">
        <result property="logId"    column="log_id"    />
        <result property="ipAddress"    column="ip_address"    />
        <result property="portNo"    column="port_no"    />
        <result property="protocol"    column="protocol"    />
        <result property="channelId"    column="channel_id"    />
        <result property="channelName"    column="channel_name"    />
        <result property="eventType"    column="event_type"    />
        <result property="deviceId"    column="device_id"    />
        <result property="deviceUuid"    column="device_uuid"    />
        <result property="sceneId"    column="scene_id"    />
        <result property="ruleId"    column="rule_id"    />
        <result property="tagsetId"    column="tagset_id"    />
        <result property="photo"    column="photo"    />
        <result property="readingType"    column="reading_type"    />
        <result property="readingResult"    column="reading_result"    />
        <result property="statusResult"    column="status_result"    />
        <result property="pilotLampstate"    column="pilot_lampState"    />
        <result property="eightPositionSelectorKnobTate"    column="eight_position_selector_knob_tate"    />
        <result property="airSwitchCircuitBreakerState"    column="air_switch_circuit_breaker_state"    />
        <result property="relayProtectionControllerState"    column="relay_protection_controller_state"    />
        <result property="silicaGelBreatherState"    column="silica_gel_breather_state"    />
        <result property="charactersState"    column="characters_state"    />
        <result property="circuitBreakerState"    column="circuit_breaker_state"    />
        <result property="knifeSwitchState"    column="knife_switch_state"    />
        <result property="openSetTypeState"    column="open_set_type_state"    />
        <result property="delFlag"    column="del_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"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectDialIndicatorLogVo">
        select log_id, ip_address, port_no, protocol, channel_id, channel_name, event_type, device_id, device_uuid, scene_id, rule_id, tagset_id, photo, reading_type, reading_result, status_result, pilot_lampState, eight_position_selector_knob_tate, air_switch_circuit_breaker_state, relay_protection_controller_state, silica_gel_breather_state, characters_state, circuit_breaker_state, knife_switch_state, open_set_type_state, del_flag, create_by, create_time, update_by, update_time, remark from dial_indicator_log
    </sql>

    <select id="selectDialIndicatorLogList" parameterType="DialIndicatorLog" resultMap="DialIndicatorLogResult">
        <include refid="selectDialIndicatorLogVo"/>
        <where>  
            <if test="ipAddress != null  and ipAddress != ''"> and ip_address = #{ipAddress}</if>
            <if test="portNo != null  and portNo != ''"> and port_no = #{portNo}</if>
            <if test="protocol != null  and protocol != ''"> and protocol = #{protocol}</if>
            <if test="channelId != null  and channelId != ''"> and channel_id = #{channelId}</if>
            <if test="channelName != null  and channelName != ''"> and channel_name like concat('%', #{channelName}, '%')</if>
            <if test="eventType != null  and eventType != ''"> and event_type = #{eventType}</if>
            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
            <if test="deviceUuid != null  and deviceUuid != ''"> and device_uuid = #{deviceUuid}</if>
            <if test="sceneId != null  and sceneId != ''"> and scene_id = #{sceneId}</if>
            <if test="ruleId != null  and ruleId != ''"> and rule_id = #{ruleId}</if>
            <if test="tagsetId != null  and tagsetId != ''"> and tagset_id = #{tagsetId}</if>
            <if test="photo != null  and photo != ''"> and photo = #{photo}</if>
            <if test="readingType != null  and readingType != ''"> and reading_type = #{readingType}</if>
            <if test="readingResult != null  and readingResult != ''"> and reading_result = #{readingResult}</if>
            <if test="statusResult != null  and statusResult != ''"> and status_result = #{statusResult}</if>
            <if test="pilotLampstate != null  and pilotLampstate != ''"> and pilot_lampState = #{pilotLampstate}</if>
            <if test="eightPositionSelectorKnobTate != null  and eightPositionSelectorKnobTate != ''"> and eight_position_selector_knob_tate = #{eightPositionSelectorKnobTate}</if>
            <if test="airSwitchCircuitBreakerState != null  and airSwitchCircuitBreakerState != ''"> and air_switch_circuit_breaker_state = #{airSwitchCircuitBreakerState}</if>
            <if test="relayProtectionControllerState != null  and relayProtectionControllerState != ''"> and relay_protection_controller_state = #{relayProtectionControllerState}</if>
            <if test="silicaGelBreatherState != null  and silicaGelBreatherState != ''"> and silica_gel_breather_state = #{silicaGelBreatherState}</if>
            <if test="charactersState != null  and charactersState != ''"> and characters_state = #{charactersState}</if>
            <if test="circuitBreakerState != null  and circuitBreakerState != ''"> and circuit_breaker_state = #{circuitBreakerState}</if>
            <if test="knifeSwitchState != null  and knifeSwitchState != ''"> and knife_switch_state = #{knifeSwitchState}</if>
            <if test="openSetTypeState != null  and openSetTypeState != ''"> and open_set_type_state = #{openSetTypeState}</if>
        </where>
    </select>
    
    <select id="selectDialIndicatorLogByLogId" parameterType="Long" resultMap="DialIndicatorLogResult">
        <include refid="selectDialIndicatorLogVo"/>
        where log_id = #{logId}
    </select>

    <insert id="insertDialIndicatorLog" parameterType="DialIndicatorLog" useGeneratedKeys="true" keyProperty="logId">
        insert into dial_indicator_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ipAddress != null">ip_address,</if>
            <if test="portNo != null">port_no,</if>
            <if test="protocol != null">protocol,</if>
            <if test="channelId != null">channel_id,</if>
            <if test="channelName != null">channel_name,</if>
            <if test="eventType != null">event_type,</if>
            <if test="deviceId != null">device_id,</if>
            <if test="deviceUuid != null">device_uuid,</if>
            <if test="sceneId != null">scene_id,</if>
            <if test="ruleId != null">rule_id,</if>
            <if test="tagsetId != null">tagset_id,</if>
            <if test="photo != null">photo,</if>
            <if test="readingType != null">reading_type,</if>
            <if test="readingResult != null">reading_result,</if>
            <if test="statusResult != null">status_result,</if>
            <if test="pilotLampstate != null">pilot_lampState,</if>
            <if test="eightPositionSelectorKnobTate != null">eight_position_selector_knob_tate,</if>
            <if test="airSwitchCircuitBreakerState != null">air_switch_circuit_breaker_state,</if>
            <if test="relayProtectionControllerState != null">relay_protection_controller_state,</if>
            <if test="silicaGelBreatherState != null">silica_gel_breather_state,</if>
            <if test="charactersState != null">characters_state,</if>
            <if test="circuitBreakerState != null">circuit_breaker_state,</if>
            <if test="knifeSwitchState != null">knife_switch_state,</if>
            <if test="openSetTypeState != null">open_set_type_state,</if>
            <if test="delFlag != null">del_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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ipAddress != null">#{ipAddress},</if>
            <if test="portNo != null">#{portNo},</if>
            <if test="protocol != null">#{protocol},</if>
            <if test="channelId != null">#{channelId},</if>
            <if test="channelName != null">#{channelName},</if>
            <if test="eventType != null">#{eventType},</if>
            <if test="deviceId != null">#{deviceId},</if>
            <if test="deviceUuid != null">#{deviceUuid},</if>
            <if test="sceneId != null">#{sceneId},</if>
            <if test="ruleId != null">#{ruleId},</if>
            <if test="tagsetId != null">#{tagsetId},</if>
            <if test="photo != null">#{photo},</if>
            <if test="readingType != null">#{readingType},</if>
            <if test="readingResult != null">#{readingResult},</if>
            <if test="statusResult != null">#{statusResult},</if>
            <if test="pilotLampstate != null">#{pilotLampstate},</if>
            <if test="eightPositionSelectorKnobTate != null">#{eightPositionSelectorKnobTate},</if>
            <if test="airSwitchCircuitBreakerState != null">#{airSwitchCircuitBreakerState},</if>
            <if test="relayProtectionControllerState != null">#{relayProtectionControllerState},</if>
            <if test="silicaGelBreatherState != null">#{silicaGelBreatherState},</if>
            <if test="charactersState != null">#{charactersState},</if>
            <if test="circuitBreakerState != null">#{circuitBreakerState},</if>
            <if test="knifeSwitchState != null">#{knifeSwitchState},</if>
            <if test="openSetTypeState != null">#{openSetTypeState},</if>
            <if test="delFlag != null">#{delFlag},</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>
         </trim>
    </insert>

    <update id="updateDialIndicatorLog" parameterType="DialIndicatorLog">
        update dial_indicator_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="ipAddress != null">ip_address = #{ipAddress},</if>
            <if test="portNo != null">port_no = #{portNo},</if>
            <if test="protocol != null">protocol = #{protocol},</if>
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="channelName != null">channel_name = #{channelName},</if>
            <if test="eventType != null">event_type = #{eventType},</if>
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="deviceUuid != null">device_uuid = #{deviceUuid},</if>
            <if test="sceneId != null">scene_id = #{sceneId},</if>
            <if test="ruleId != null">rule_id = #{ruleId},</if>
            <if test="tagsetId != null">tagset_id = #{tagsetId},</if>
            <if test="photo != null">photo = #{photo},</if>
            <if test="readingType != null">reading_type = #{readingType},</if>
            <if test="readingResult != null">reading_result = #{readingResult},</if>
            <if test="statusResult != null">status_result = #{statusResult},</if>
            <if test="pilotLampstate != null">pilot_lampState = #{pilotLampstate},</if>
            <if test="eightPositionSelectorKnobTate != null">eight_position_selector_knob_tate = #{eightPositionSelectorKnobTate},</if>
            <if test="airSwitchCircuitBreakerState != null">air_switch_circuit_breaker_state = #{airSwitchCircuitBreakerState},</if>
            <if test="relayProtectionControllerState != null">relay_protection_controller_state = #{relayProtectionControllerState},</if>
            <if test="silicaGelBreatherState != null">silica_gel_breather_state = #{silicaGelBreatherState},</if>
            <if test="charactersState != null">characters_state = #{charactersState},</if>
            <if test="circuitBreakerState != null">circuit_breaker_state = #{circuitBreakerState},</if>
            <if test="knifeSwitchState != null">knife_switch_state = #{knifeSwitchState},</if>
            <if test="openSetTypeState != null">open_set_type_state = #{openSetTypeState},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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>
        </trim>
        where log_id = #{logId}
    </update>

    <delete id="deleteDialIndicatorLogByLogId" parameterType="Long">
        delete from dial_indicator_log where log_id = #{logId}
    </delete>

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