<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzjt.mapper.TraffAlarmRecordMapper">
    <update id="updateTraffAlarmRecordUrl" parameterType="com.hzjt.domain.Traffalarmrecord">
        UPDATE traffalarmrecord
        set retrytime= sysdate,
        retrycount= retrycount+1
        <trim prefix="," suffixOverrides=",">
            <if test="img1path!=null">img1path=#{img1path},</if>
            <if test="img2path!=null">img2path=#{img2path},</if>
            <if test="img3path!=null">img3path=#{img3path},</if>
            <if test="img4path!=null">img4path=#{img4path},</if>
            <if test="img5path!=null">img5path=#{img5path},</if>
            <if test="videopath!=null">videopath=#{videopath},</if>
        </trim>
        WHERE recordid=#{recordid}
    </update>

    <update id="updatePushEvent" parameterType="com.hzjt.domain.Traffalarmrecord">
        UPDATE traffalarmrecord
        set PUSHSTATUS = #{pushstatus},
            PUSHDESC = #{pushdesc},
            PUSHCOUNT= CASE WHEN PUSHCOUNT IS NULL THEN 1 ELSE PUSHCOUNT + 1 END,
            PUSHDATE= sysdate
        WHERE RECORDID = #{recordid}
    </update>

    <insert id="inserTraffAlarmRecord">
        insert into traffalarmrecord
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="recordid != null" >recordid,</if>
            <if test="algotype != null" >algotype,</if>
            <if test="areaid != null" >areaid,</if>
            <if test="fdid != null" >fdid,</if>
            <if test="channelid != null" > channelid,</if>
            <if test="channeletype != null" >channeletype,</if>
            <if test="channelname != null" > channelname ,</if>
            <if test="recordtime != null" > recordtime,</if>
            <if test="recordtype != null" > recordtype,</if>
            <if test="location != null" > location,</if>
            <if test="img1urlfrom != null" >img1urlfrom,</if>
            <if test="img1path != null" > img1path,</if>
            <if test="img2urlfrom != null" >img2urlfrom,</if>
            <if test="img2path != null" > img2path,</if>
            <if test="img3urlfrom != null" >img3urlfrom,</if>
            <if test="img3path != null" > img3path,</if>
            <if test="img4urlfrom != null" >img4urlfrom,</if>
            <if test="img4path != null" > img4path,</if>
            <if test="img5urlfrom != null" >img5urlfrom,</if>
            <if test="img5path != null" > img5path,</if>
            <if test="videourlfrom != null" >videourlfrom,</if>
            <if test="videopath != null" >videopath,</if>
            <if test="retrytime != null" > retrytime,</if>
            <if test="retrycount != null" > retrycount,</if>
            <if test="recordlevel != null" > recordlevel,</if>
            <if test="checkstatus != null" >checkstatus,</if>
            <if test="creator != null" > creator,</if>
            <if test="createtime != null" > createtime,</if>
            <if test="updator != null" > updator,</if>
            <if test="updatetime != null" >updatetime,</if>
            <if test="remark != null" >remark,</if>
            <if test="pushstatus != null" >pushstatus,</if>
            <if test="pushdesc != null" > pushdesc,</if>
            <if test="processstatus != null" > processstatus,</if>
            <if test="objlable != null" > objlable,</if>
        </trim>
        <trim prefix="select" suffix="from  dual" suffixOverrides="," >

            <if test="recordid != null" >#{recordid},</if>
            <if test="algotype != null" >#{algotype},</if>
            <if test="areaid != null" >#{areaid},</if>
            <if test="fdid != null" >#{fdid},</if>
            <if test="channelid != null" >#{ channelid},</if>
            <if test="channeletype != null" >#{channeletype},</if>
            <if test="channelname != null" >#{ channelname },</if>
            <if test="recordtime != null" >#{ recordtime},</if>
            <if test="recordtype != null" >#{ recordtype},</if>
            <if test="location != null" >#{ location},</if>
            <if test="img1urlfrom != null" >#{img1urlfrom},</if>
            <if test="img1path != null" >#{ img1path},</if>
            <if test="img2urlfrom != null" >#{img2urlfrom},</if>
            <if test="img2path != null" >#{ img2path},</if>
            <if test="img3urlfrom != null" >#{img3urlfrom},</if>
            <if test="img3path != null" >#{ img3path},</if>
            <if test="img4urlfrom != null" >#{img4urlfrom},</if>
            <if test="img4path != null" >#{ img4path},</if>
            <if test="img5urlfrom != null" >#{img5urlfrom},</if>
            <if test="img5path != null" >#{img5path},</if>
            <if test="videourlfrom != null" >#{videourlfrom},</if>
            <if test="videopath != null" >#{videopath},</if>
            <if test="retrytime != null" >#{retrytime},</if>
            <if test="retrycount != null" >#{retrycount},</if>
            <if test="recordlevel != null" >#{recordlevel,jdbcType=INTEGER},</if>
            <if test="checkstatus != null" >#{checkstatus,jdbcType=INTEGER},</if>
            <if test="creator != null" >#{creator},</if>
            <if test="createtime != null" >#{createtime},</if>
            <if test="updator != null" >#{updator},</if>
            <if test="updatetime != null" >#{updatetime},</if>
            <if test="remark != null" >#{remark},</if>
            <if test="pushstatus != null" >#{pushstatus},</if>
            <if test="pushdesc != null" >#{pushdesc},</if>
            <if test="processstatus != null" > #{processstatus},</if>
            <if test="objlable != null" > #{objlable},</if>

        </trim>

    </insert>

    <select id="selectmax" resultType="java.lang.Integer">

        select nvl(max(recordid),0)+1 from   traffalarmrecord

    </select>

</mapper>