<?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.inspect.metadata.statis.mapper.BasedataStatisNvrMapper">

    <resultMap type="BasedataStatisNvr" id="BasedataStatisNvrResult">
        <result property="statisNvrId" column="statis_nvr_id"/>
        <result property="statisDay" column="statis_day"/>
        <result property="eqpBookId" column="eqp_book_id"/>
        <result property="patrolDeviceCode" column="patrol_device_code"/>
        <result property="patrolDeviceName" column="patrol_device_name"/>
        <result property="duration" column="duration"/>
        <result property="cycle" column="cycle"/>
        <result property="complete" column="complete"/>
        <result property="allCapacity" column="all_capacity"/>
        <result property="useCapacity" column="use_capacity"/>
        <result property="usePercentage" column="use_percentage"/>
        <result property="hvmAbn" column="hvm_abn"/>
        <result property="hvmFault" column="hvm_fault"/>
        <result property="hvmHighTempAlm" column="hvm_high_temp_alm"/>
        <result property="hvmLowTempAlm" column="hvm_low_temp_alm"/>
        <result property="hvmFanFault" column="hvm_fan_fault"/>
        <result property="hvmDiskReadErr" column="hvm_disk_read_err"/>
        <result property="hvmDskFul" column="hvm_disk_full"/>
        <result property="hvmVideoSigAbn" column="hvm_video_sig_abn"/>
        <result property="hvmDiskUnformat" column="hvm_disk_unformat"/>
        <result property="hvmIllegalAccess" column="hvm_illegal_access"/>
        <result property="hvmFmtUnmatched" column="hvm_fmt_unmatched"/>
        <result property="hvmPicRecAbn" column="hvm_pic_rec_abn"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="deleteFlag" column="delete_flag"/>
    </resultMap>

    <sql id="selectBasedataStatisNvrVo">
        select statis_nvr_id,
               statis_day,
               eqp_book_id,
               patrol_device_code,
               patrol_device_name,
               duration,
               cycle,
               complete,
               all_capacity,
               use_capacity,
               use_percentage,
               hvm_abn,
               hvm_fault,
               hvm_high_temp_alm,
               hvm_low_temp_alm,
               hvm_fan_fault,
               hvm_disk_read_err,
               hvm_disk_full,
               hvm_video_sig_abn,
               hvm_disk_unformat,
               hvm_illegal_access,
               hvm_fmt_unmatched,
               hvm_pic_rec_abn,
               create_time,
               update_by,
               update_time,
               delete_flag
        from basedata_statis_nvr
    </sql>

    <select id="selectBasedataStatisNvrList" parameterType="BasedataStatisNvr" resultMap="BasedataStatisNvrResult">
        <include refid="selectBasedataStatisNvrVo"/>
        <where>
            <if test="statisDay != null ">and statis_day = #{statisDay}</if>
            <if test="eqpBookId != null ">and eqp_book_id = #{eqpBookId}</if>
            <if test="patrolDeviceCode != null  and patrolDeviceCode != ''">and patrol_device_code =
                #{patrolDeviceCode}
            </if>
            <if test="patrolDeviceName != null  and patrolDeviceName != ''">and patrol_device_name like concat('%',
                #{patrolDeviceName}, '%')
            </if>
            <if test="duration != null  and duration != ''">and duration = #{duration}</if>
            <if test="cycle != null ">and cycle = #{cycle}</if>
            <if test="complete != null  and complete != ''">and complete = #{complete}</if>
            <if test="allCapacity != null  and allCapacity != ''">and all_capacity = #{allCapacity}</if>
            <if test="useCapacity != null  and useCapacity != ''">and use_capacity = #{useCapacity}</if>
            <if test="usePercentage != null  and usePercentage != ''">and use_percentage = #{usePercentage}</if>
            <if test="hvmAbn != null  and hvmAbn != ''">and hvm_abn = #{hvmAbn}</if>
            <if test="hvmFault != null  and hvmFault != ''">and hvm_fault = #{hvmFault}</if>
            <if test="hvmHighTempAlm != null  and hvmHighTempAlm != ''">and hvm_high_temp_alm = #{hvmHighTempAlm}</if>
            <if test="hvmLowTempAlm != null  and hvmLowTempAlm != ''">and hvm_low_temp_alm = #{hvmLowTempAlm}</if>
            <if test="hvmFanFault != null  and hvmFanFault != ''">and hvm_fan_fault = #{hvmFanFault}</if>
            <if test="hvmDiskReadErr != null  and hvmDiskReadErr != ''">and hvm_disk_read_err = #{hvmDiskReadErr}</if>
            <if test="hvmDskFul != null  and hvmDskFul != ''">and hvm_disk_full = #{hvmDskFul}</if>
            <if test="hvmVideoSigAbn != null  and hvmVideoSigAbn != ''">and hvm_video_sig_abn = #{hvmVideoSigAbn}</if>
            <if test="hvmDiskUnformat != null  and hvmDiskUnformat != ''">and hvm_disk_unformat = #{hvmDiskUnformat}</if>
            <if test="hvmIllegalAccess != null  and hvmIllegalAccess != ''">and hvm_illegal_access = #{hvmIllegalAccess}</if>
            <if test="hvmFmtUnmatched != null  and hvmFmtUnmatched != ''">and hvm_fmt_unmatched = #{hvmFmtUnmatched}
            </if>
            <if test="hvmPicRecAbn != null  and hvmPicRecAbn != ''">and hvm_pic_rec_abn = #{hvmPicRecAbn}</if>
            <if test="deleteFlag != null  and deleteFlag != ''">and delete_flag = #{deleteFlag}</if>
        </where>
    </select>

    <select id="selectBasedataStatisNvrByStatisNvrId" parameterType="Long" resultMap="BasedataStatisNvrResult">
        <include refid="selectBasedataStatisNvrVo"/>
        where statis_nvr_id = #{statisNvrId}
    </select>

    <insert id="insertBasedataStatisNvr" parameterType="BasedataStatisNvr" useGeneratedKeys="true"
            keyProperty="statisNvrId">
        insert into basedata_statis_nvr
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="statisDay != null">statis_day,</if>
            <if test="eqpBookId != null">eqp_book_id,</if>
            <if test="patrolDeviceCode != null">patrol_device_code,</if>
            <if test="patrolDeviceName != null">patrol_device_name,</if>
            <if test="duration != null">duration,</if>
            <if test="cycle != null">cycle,</if>
            <if test="complete != null">complete,</if>
            <if test="allCapacity != null">all_capacity,</if>
            <if test="useCapacity != null">use_capacity,</if>
            <if test="usePercentage != null">use_percentage,</if>
            <if test="hvmAbn != null">hvm_abn,</if>
            <if test="hvmFault != null">hvm_fault,</if>
            <if test="hvmHighTempAlm != null">hvm_high_temp_alm,</if>
            <if test="hvmLowTempAlm != null">hvm_low_temp_alm,</if>
            <if test="hvmFanFault != null">hvm_fan_fault,</if>
            <if test="hvmDiskReadErr != null">hvm_disk_read_err,</if>
            <if test="hvmDskFul != null">hvm_disk_full,</if>
            <if test="hvmVideoSigAbn != null">hvm_video_sig_abn,</if>
            <if test="hvmDiskUnformat != null">hvm_disk_unformat,</if>
            <if test="hvmIllegalAccess != null">hvm_illegal_access,</if>
            <if test="hvmFmtUnmatched != null">hvm_fmt_unmatched,</if>
            <if test="hvmPicRecAbn != null">hvm_pic_rec_abn,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deleteFlag != null">delete_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="statisDay != null">#{statisDay},</if>
            <if test="eqpBookId != null">#{eqpBookId},</if>
            <if test="patrolDeviceCode != null">#{patrolDeviceCode},</if>
            <if test="patrolDeviceName != null">#{patrolDeviceName},</if>
            <if test="duration != null">#{duration},</if>
            <if test="cycle != null">#{cycle},</if>
            <if test="complete != null">#{complete},</if>
            <if test="allCapacity != null">#{allCapacity},</if>
            <if test="useCapacity != null">#{useCapacity},</if>
            <if test="usePercentage != null">#{usePercentage},</if>
            <if test="hvmAbn != null">#{hvmAbn},</if>
            <if test="hvmFault != null">#{hvmFault},</if>
            <if test="hvmHighTempAlm != null">#{hvmHighTempAlm},</if>
            <if test="hvmLowTempAlm != null">#{hvmLowTempAlm},</if>
            <if test="hvmFanFault != null">#{hvmFanFault},</if>
            <if test="hvmDiskReadErr != null">#{hvmDiskReadErr},</if>
            <if test="hvmDskFul != null">#{hvmDskFul},</if>
            <if test="hvmVideoSigAbn != null">#{hvmVideoSigAbn},</if>
            <if test="hvmDiskUnformat != null">#{hvmDiskUnformat},</if>
            <if test="hvmIllegalAccess != null">#{hvmIllegalAccess},</if>
            <if test="hvmFmtUnmatched != null">#{hvmFmtUnmatched},</if>
            <if test="hvmPicRecAbn != null">#{hvmPicRecAbn},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deleteFlag != null">#{deleteFlag},</if>
        </trim>
    </insert>

    <update id="updateBasedataStatisNvr" parameterType="BasedataStatisNvr">
        update basedata_statis_nvr
        <trim prefix="SET" suffixOverrides=",">
            <if test="statisDay != null">statis_day = #{statisDay},</if>
            <if test="eqpBookId != null">eqp_book_id = #{eqpBookId},</if>
            <if test="patrolDeviceCode != null">patrol_device_code = #{patrolDeviceCode},</if>
            <if test="patrolDeviceName != null">patrol_device_name = #{patrolDeviceName},</if>
            <if test="duration != null">duration = #{duration},</if>
            <if test="cycle != null">cycle = #{cycle},</if>
            <if test="complete != null">complete = #{complete},</if>
            <if test="allCapacity != null">all_capacity = #{allCapacity},</if>
            <if test="useCapacity != null">use_capacity = #{useCapacity},</if>
            <if test="usePercentage != null">use_percentage = #{usePercentage},</if>
            <if test="hvmAbn != null">hvm_abn = #{hvmAbn},</if>
            <if test="hvmFault != null">hvm_fault = #{hvmFault},</if>
            <if test="hvmHighTempAlm != null">hvm_high_temp_alm = #{hvmHighTempAlm},</if>
            <if test="hvmLowTempAlm != null">hvm_low_temp_alm = #{hvmLowTempAlm},</if>
            <if test="hvmFanFault != null">hvm_fan_fault = #{hvmFanFault},</if>
            <if test="hvmDiskReadErr != null">hvm_disk_read_err = #{hvmDiskReadErr},</if>
            <if test="hvmDskFul != null">hvm_disk_full = #{hvmDskFul},</if>
            <if test="hvmVideoSigAbn != null">hvm_video_sig_abn = #{hvmVideoSigAbn},</if>
            <if test="hvmDiskUnformat != null">hvm_disk_unformat = #{hvmDiskUnformat},</if>
            <if test="hvmIllegalAccess != null">hvm_illegal_access = #{hvmIllegalAccess},</if>
            <if test="hvmFmtUnmatched != null">hvm_fmt_unmatched = #{hvmFmtUnmatched},</if>
            <if test="hvmPicRecAbn != null">hvm_pic_rec_abn = #{hvmPicRecAbn},</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="deleteFlag != null">delete_flag = #{deleteFlag},</if>
        </trim>
        where statis_nvr_id = #{statisNvrId}
    </update>

    <delete id="deleteBasedataStatisNvrByStatisNvrId" parameterType="Long">
        delete
        from basedata_statis_nvr
        where statis_nvr_id = #{statisNvrId}
    </delete>

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