<?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.lutao.cloud.oil.mapper.VideoEquipmentInfoMapper">


    <select id="queryVideoEquipmentInfoTree" resultType="com.lutao.cloud.oil.pojo.vo.VideoEquipmentInfoBaseVO">
        SELECT
            vei.id,
            IFNULL(pi.platform_name, vei.platform_code) AS platform_name,
            vei.camera_name,
            vei.camera_index,
            ai.app_name,
            vei.online_status
        FROM
            video_equipment_info vei
                LEFT JOIN platform_info pi ON vei.platform_code = pi.platform_code
                LEFT JOIN app_info ai ON vei.app_id = ai.id
        WHERE pi.delete_flag = '0';

    </select>
    <select id="queryVideoNumberChart" resultType="com.lutao.cloud.oil.pojo.vo.ScreenVideoNumberVO">
        SELECT
            ai.app_name,
            COUNT( 1 ) AS videoTotalNumber
        FROM
            video_equipment_info vei

                LEFT JOIN app_info ai ON vei.app_id = ai.id
        GROUP BY
            vei.app_id
    </select>

    <!-- 三家视频总数 在线数   -->
    <select id="queryVideoNumberOnlineChart"
            resultType="com.lutao.cloud.oil.pojo.param.ScreenVideoNumberOnlineVO">

        SELECT
            app_id AS appName,
            COUNT(*) AS totalNumber,
            COUNT( CASE WHEN online_status = '1' THEN 1 END ) AS onlineNumber
        FROM
            video_equipment_info
        GROUP BY
            app_id;

    </select>


</mapper>