<?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.testor.module.video.dao.VideoAlarmDao">

    <select id="selectVideoInfoBySpaceType" resultType="com.testor.module.video.model.domain.VideoEquipmentInfo">
        SELECT
        *
        FROM
        t_video_equipment_info
        WHERE
        status = 0
        <if test="param.markList!= null ">
            AND is_eye in
            <foreach item="item" collection="param.markList" open="(" separator="," close=")" >
               #{item}
            </foreach>
        </if>
        <if test="param.orgId !=null and param.orgId !=''">
            AND org_id=#{param.orgId}
        </if>
        <if test="param.enterpiseId!=null and param.enterpiseId.size>0 ">
            and
            <foreach item="item" collection="param.enterpiseId" open="(" close=")" separator="or">
                find_in_set(#{item},space_type_id)
            </foreach>
        </if>
    </select>
    <select id="selectVideoInfoBySpace" resultType="com.testor.module.video.model.domain.VideoEquipmentInfo">
        SELECT
        *
        FROM
        t_video_equipment_info
        WHERE
        status = 0
        <if test="param.markList!=null">
            AND is_eye in
            <foreach item="item" collection="param.markList" open="(" separator="," close=")" >
                #{item}
            </foreach>
        </if>
        <if test="param.orgId !=null and param.orgId !=''">
            AND org_id=#{param.orgId}
        </if>
        <if test="param.enterpiseId!=null and param.enterpiseId.size>0 ">
            and
            <foreach item="item" collection="param.enterpiseId" open="(" close=")" separator="or">
                find_in_set(#{item},space_id)
            </foreach>
        </if>
    </select>

    <select id="selectVideoInfoByMonitor" resultType="com.testor.module.video.model.domain.VideoEquipmentInfo">
        SELECT
            *
        FROM
        t_video_equipment_info
        WHERE
        status = 0
        <if test="param.markList!=null ">
            AND is_eye in
            <foreach item="item" collection="param.markList" open="(" separator="," close=")" >
                #{item}
            </foreach>
        </if>
        <if test="param.orgId !=null and param.orgId !=''">
            AND org_id=#{param.orgId}
        </if>
        <if test="param.enterpiseId!=null and param.enterpiseId.size>0 ">
            and
            <foreach item="item" collection="param.enterpiseId" open="(" close=")" separator="or">
                find_in_set(#{item},monitor_location)
            </foreach>
        </if>
    </select>


    <select id="selectBySpaceList" resultType="com.testor.module.video.model.domain.VideoEquipmentInfo">
        SELECT
        *
        FROM
        t_video_equipment_info
        WHERE
        status = 0

            AND is_eye in
            <foreach item="item" collection="markList" open="(" separator="," close=")" >
                #{item}
            </foreach>
        <if test="param.orgId !=null and param.orgId !=''">
            AND org_id=#{param.orgId}
        </if>
        <if test="param.enterpiseId!=null and param.enterpiseId.size>0 ">
            and device_id in
            <foreach item="item" collection="param.enterpiseId" open="(" separator="," close=")" >
                #{item}
            </foreach>
        </if>
    </select>
    <select id="selectListSpace" resultType="com.testor.module.video.model.domain.VideoEquipmentInfo">
        SELECT
        *
        FROM
        t_video_equipment_info
        WHERE
        status = 0
        AND is_eye = #{mark}
        AND org_id=#{orgId}
        limit 24
    </select>
</mapper>
