<?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.unis.equipmentOnlineRateAssessment.modular.monitorCamera.mapper.MonitorCameraMapper">

    <select id="findcamera"
            resultType="com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.CameraAndNvrVO">
        select * from monitor_camera
        <where>
            <if test="name != null and name != ''">
                name like concat('%',#{name},'%')
            </if>
        </where>
    </select>


    <select id="onlineInspectionPage"
            resultType="com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.OnlineInspectionPageVO">

        SELECT DISTINCT
        oi.org_id,
        oi.org_name,
        bui.zcdz_city zcdzCityId,
        dd.DICT_LABEL zcdzCityName,
        mc.id,
        mc.`name`,
        mc.`status`,
        mc.warn_time,
        mc.`type`
        FROM
        depot_qh.org_info oi
        LEFT JOIN province_all.biz_unit_info bui ON oi.unit_info_id = bui.id
        LEFT JOIN province_all.dev_dict dd ON bui.zcdz_city = dd.ID
        left join depot_qh.monitor_camera mc on oi.org_id=mc.org_id

        <where>
            mc.`status`!='1'

            <if test="zcdzCityName!=null and zcdzCityName!=''">
                and dd.DICT_LABEL=#{zcdzCityName}
            </if>
            <if test="warnTime!=null and maxDate!=null and minDate!=null">
                and mc.warn_time between #{minDate} and #{maxDate}
            </if>
        </where>

    </select>

    <select id="selectAll" resultType="java.lang.Integer">
        select count(id) mcAll from monitor_camera
        <where>
            <if test="orgId!=null and orgId!=''">
                and org_id=#{orgId}
            </if>
        </where>
    </select>

    <select id="selectCameraOnlineNum" resultType="java.lang.Integer">
        select count(id) mcOn from monitor_camera
        <where>
            `status`='1'
            <if test="orgId!=null and orgId!=''">
                and org_id=#{orgId}
            </if>
        </where>
    </select>

    <select id="selectCameraOfflineNum" resultType="java.lang.Integer">
        select count(id) mcOff from monitor_camera
        <where>
            `status`!='1'
            <if test="orgId!=null and orgId!=''">
                and org_id=#{orgId}
            </if>
        </where>
    </select>

</mapper>