<?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.citygis.web.mapper.LookMonitorMapper">

    <select id="getLookMonitorByUrl" resultType="com.citygis.web.domain.LookMonitor">
        SELECT
        COUNT(DISTINCT (url)) num,
        COUNT(url) business
        FROM
        tab_log2
        where time = #{dateTime}
    </select>

    <select id="getLookMonitorByKb" resultType="com.citygis.web.domain.LookMonitor">
        SELECT
        COUNT(DISTINCT (操作表)) num,
        COUNT(sqlstr) business
        FROM
        数据同步日志_2025_4
        WHERE
        操作 = 'insert'
        AND 操作时间 = #{dateTime}
    </select>

    <select id="getLookMonitorByKafka" resultType="com.citygis.web.domain.LookMonitor">
        SELECT
        COUNT(DISTINCT (tabName)) num,
        SUM(CAST (receiveCount AS INT)) business
        FROM
        tab_kafkaLog
        WHERE time = #{dateTime}
    </select>

    <select id="getUrlMsg" resultType="com.citygis.web.domain.TabLinkTitle">
        SELECT
        COALESCE(SUM(CASE WHEN status != 'HTTP/1.1 200' THEN 1 ELSE 0 END), 0) error,
        COALESCE(MAX(CAST(responseTime AS INT)), 0) big,
        COALESCE(AVG(CAST(responseTime AS INT)), 0) average,
        COALESCE(MIN(CAST(responseTime AS INT)), 0) small
        FROM tab_log2
        WHERE time = #{dateTime}
    </select>

    <select id="getLookMonitorByUrlAndStatus" resultType="com.citygis.web.domain.LookMonitor">
        SELECT url,
        CASE WHEN status = 'HTTP/1.1 200' THEN 1 ELSE 0 END status
        FROM tab_log2 AS t1
        WHERE time = (
        SELECT MAX(time)
        FROM tab_log2 AS t2
        WHERE t1.url = t2.url
        AND t2.time = #{dateTime}
        )
    </select>

    <select id="getDataMap" resultType="com.citygis.web.domain.LookMonitor" parameterType="integer">
        select COUNT(1) num,"SYSTEM" systemName FROM LIU_TONG_YI.TAB_ACCESS_AND_READY WHERE ACCESS_TYPE = #{type}
        GROUP BY "SYSTEM"
    </select>

</mapper>
