<?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.TabDatalogMapper">

    <select id="getDataLogList" resultType="com.citygis.web.domain.TabDatalog"
            parameterType="com.citygis.web.domain.TabDatalog">
        SELECT
        count(1) num,
        d.操作表 tableEnglishName,
        tsm.table_name,
        tsm.system_name
        FROM
        数据同步日志_2025_4 d
        left join tab_system_msg tsm
        on
        tsm.table_english_name = d.操作表
        <where>
            d.操作 = 'insert'
            <if test="tableName != null">
                and tsm.table_name like concat('%',#{tableName},'%')
            </if>
        </where>

        group by
        d.操作表,
        tsm.table_name,
        tsm.system_name

    </select>

    <select id="getDatalogDetailByTableEnglishName" resultType="com.citygis.web.domain.TabDatalog"
            parameterType="com.citygis.web.domain.TabDatalog">
        SELECT
        count(1) num,
        d.操作表 tableEnglishName,
        tsm.table_name,
        tsm.system_name
        FROM
        数据同步日志_2025_4 d
        left join tab_system_msg tsm
        on
        tsm.table_english_name = d.操作表
        <where>
            d.操作 = 'insert'
            <if test="tableEnglishName != null">
                and d.操作表 like concat('%',#{tableEnglishName},'%')
            </if>
        </where>
        <if test="startTime != null">
            and 操作时间 >= #{startTime}
            and 操作时间 &lt;= #{endTime}
        </if>
        group by
        d.操作表,
        tsm.table_name,
        tsm.system_name
    </select>

    <select id="getLinkTitle" resultType="com.citygis.web.domain.TabLinkTitle"
            parameterType="com.citygis.web.domain.TabDatalog">
        SELECT
        MAX(cnt) big,
        AVG(cnt) average,
        MIN(cnt) small
        FROM
        (SELECT COUNT(1) AS cnt FROM 数据同步日志_2025_4 WHERE 操作表 = #{tableEnglishName} GROUP BY 操作时间) AS
        subquery
    </select>

</mapper>
