<?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.agri.system.mapper.SysDevOperLogMapper">
    
    <resultMap type="SysDevOperLog" id="SysDevOperLogResult">
        <result property="id"    column="id"    />
        <result property="agriName"    column="agri_name"    />
        <result property="imei"    column="imei"    />
        <result property="funcCode"    column="func_code"    />
        <result property="opType"    column="op_type"    />
        <result property="opSource"    column="op_source"    />
        <result property="payload"    column="payload"    />
        <result property="lockAcquired"    column="lock_acquired"    />
        <result property="lockHolder"    column="lock_holder"    />
        <result property="taskStatus"    column="task_status"    />
        <result property="ackReceived"    column="ack_received"    />
        <result property="ackSuc"    column="ack_suc"    />
        <result property="isLockSuc"    column="is_lock_suc"    />
        <result property="isTask"    column="is_task"    />
        <result property="runTime"    column="run_time"    />
        <result property="noTaskReason"    column="no_task_reason"    />
        <result property="ack"    column="ack"    />
        <result property="execResult"    column="exec_result"    />
        <result property="skipReason"    column="skip_reason"    />
        <result property="latestState"    column="latest_state"    />
        <result property="remark"    column="remark"    />
        <result property="version"    column="version"    />
        <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="selectSysDevOperLogVo">
        select id, agri_name, imei, func_code, op_type, op_source, payload, lock_acquired, lock_holder, task_status, ack_received, ack_suc, is_lock_suc, is_task, run_time, no_task_reason, ack, exec_result, skip_reason, latest_state, remark, version, create_by, create_time, update_by, update_time from sys_dev_oper_log
    </sql>

    <select id="selectSysDevOperLogList" parameterType="SysDevOperLog" resultMap="SysDevOperLogResult">
        <include refid="selectSysDevOperLogVo"/>
        <where>
            <if test="agriName != null  and agriName != ''"> and agri_name like concat('%', #{agriName}, '%')</if>
            <if test="imei != null  and imei != ''"> and imei like concat('%', #{imei}, '%')</if>
            <if test="funcCode != null  and funcCode != ''"> and func_code = #{funcCode}</if>
            <if test="opType != null "> and op_type = #{opType}</if>
            <if test="opSource != null "> and op_source = #{opSource}</if>
            <if test="lockAcquired != null "> and lock_acquired = #{lockAcquired}</if>
            <if test="ackReceived != null "> and ack_received = #{ackReceived}</if>
            <if test="ackSuc != null "> and ack_suc = #{ackSuc}</if>
            <if test="isLockSuc != null "> and is_lock_suc = #{isLockSuc}</if>
            <if test="isTask != null "> and is_task = #{isTask}</if>
            <if test="execResult != null "> and exec_result = #{execResult}</if>
        </where>
    </select>


    <select id="selectSysDevOperLogById" parameterType="Long" resultMap="SysDevOperLogResult">
        <include refid="selectSysDevOperLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysDevOperLog" parameterType="SysDevOperLog" useGeneratedKeys="true" keyProperty="id">
        insert into sys_dev_oper_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="agriName != null">agri_name,</if>
            <if test="imei != null">imei,</if>
            <if test="funcCode != null">func_code,</if>
            <if test="opType != null">op_type,</if>
            <if test="opSource != null">op_source,</if>
            <if test="payload != null">payload,</if>
            <if test="lockAcquired != null">lock_acquired,</if>
            <if test="lockHolder != null">lock_holder,</if>
            <if test="taskStatus != null">task_status,</if>
            <if test="ackReceived != null">ack_received,</if>
            <if test="ackSuc != null">ack_suc,</if>
            <if test="isLockSuc != null">is_lock_suc,</if>
            <if test="isTask != null">is_task,</if>
            <if test="runTime != null">run_time,</if>
            <if test="noTaskReason != null">no_task_reason,</if>
            <if test="ack != null">ack,</if>
            <if test="execResult != null">exec_result,</if>
            <if test="skipReason != null">skip_reason,</if>
            <if test="latestState != null">latest_state,</if>
            <if test="remark != null">remark,</if>
            <if test="version != null">version,</if>
            create_by,
            create_time,
            update_by,
            update_time,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="agriName != null">#{agriName},</if>
            <if test="imei != null">#{imei},</if>
            <if test="funcCode != null">#{funcCode},</if>
            <if test="opType != null">#{opType},</if>
            <if test="opSource != null">#{opSource},</if>
            <if test="payload != null">#{payload},</if>
            <if test="lockAcquired != null">#{lockAcquired},</if>
            <if test="lockHolder != null">#{lockHolder},</if>
            <if test="taskStatus != null">#{taskStatus},</if>
            <if test="ackReceived != null">#{ackReceived},</if>
            <if test="ackSuc != null">#{ackSuc},</if>
            <if test="isLockSuc != null">#{isLockSuc},</if>
            <if test="isTask != null">#{isTask},</if>
            <if test="runTime != null">#{runTime},</if>
            <if test="noTaskReason != null">#{noTaskReason},</if>
            <if test="ack != null">#{ack},</if>
            <if test="execResult != null">#{execResult},</if>
            <if test="skipReason != null">#{skipReason},</if>
            <if test="latestState != null">#{latestState},</if>
            <if test="remark != null">#{remark},</if>
            <if test="version != null">#{version},</if>
            #{createBy},
            #{createTime},
            #{updateBy},
            #{updateTime},
        </trim>
    </insert>

    <update id="updateSysDevOperLog" parameterType="SysDevOperLog">
        update sys_dev_oper_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="agriName != null">agri_name = #{agriName},</if>
            <if test="imei != null">imei = #{imei},</if>
            <if test="funcCode != null">func_code = #{funcCode},</if>
            <if test="opType != null">op_type = #{opType},</if>
            <if test="opSource != null">op_source = #{opSource},</if>
            <if test="payload != null">payload = #{payload},</if>
            <if test="lockAcquired != null">lock_acquired = #{lockAcquired},</if>
            <if test="lockHolder != null">lock_holder = #{lockHolder},</if>
            <if test="taskStatus != null">task_status = #{taskStatus},</if>
            <if test="ackReceived != null">ack_received = #{ackReceived},</if>
            <if test="ackSuc != null">ack_suc = #{ackSuc},</if>
            <if test="isLockSuc != null">is_lock_suc = #{isLockSuc},</if>
            <if test="isTask != null">is_task = #{isTask},</if>
            <if test="runTime != null">run_time = #{runTime},</if>
            <if test="noTaskReason != null">no_task_reason = #{noTaskReason},</if>
            <if test="ack != null">ack = #{ack},</if>
            <if test="execResult != null">exec_result = #{execResult},</if>
            <if test="skipReason != null">skip_reason = #{skipReason},</if>
            <if test="latestState != null">latest_state = #{latestState},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="version != null">version = #{version},</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 id = #{id}
    </update>

    <delete id="deleteSysDevOperLogById" parameterType="Long">
        delete from sys_dev_oper_log where id = #{id}
    </delete>

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