1:更改首页流量统计的sql
2:更改topic数据的获取方式 3:修改sql中where错误 4:修改表结构sql
This commit is contained in:
@@ -1,87 +1,106 @@
|
||||
<?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.nis.web.dao.dashboard.TrafficHttpStatisticDao">
|
||||
<resultMap id="BaseResultMap" type="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||
<id column="stat_id" jdbcType="INTEGER" property="statId" />
|
||||
<result column="link_num" jdbcType="INTEGER" property="linkNum" />
|
||||
<result column="web_id" jdbcType="INTEGER" property="webId" />
|
||||
<result column="c2s_pkt_num" jdbcType="BIGINT" property="c2sPktNum" />
|
||||
<result column="s2c_pkt_num" jdbcType="BIGINT" property="s2cPktNum" />
|
||||
<result column="c2s_byte_len" jdbcType="BIGINT" property="c2sByteLen" />
|
||||
<result column="s2c_byte_len" jdbcType="BIGINT" property="s2cByteLen" />
|
||||
<result column="stat_time" jdbcType="TIMESTAMP" property="statTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len,
|
||||
stat_time
|
||||
</sql>
|
||||
<!-- 获取最近时间并且有效 -->
|
||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||
SELECT stat_time statTime FROM traffic_http_statistic order by stat_time desc limit 1
|
||||
</select>
|
||||
<!-- 根据服务网站将域名分类 网站列表-->
|
||||
<select id="getDomainByWebsiteList" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( website_service_id, 268435455 ) websiteServiceId
|
||||
FROM TRAFFIC_HTTP_STATISTIC t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
||||
where t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY u.website_service_id ORDER BY count desc limit 0,10
|
||||
</select>
|
||||
<!-- 根据主题将域名分类 主题列表 最近五分钟top10-->
|
||||
<select id="getDomainByTopicList" resultType="java.util.HashMap">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( topic_id, 268435455 ) topicId
|
||||
FROM TRAFFIC_HTTP_STATISTIC t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
||||
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY u.topic_id ORDER BY count desc limit 0,10
|
||||
|
||||
</select>
|
||||
<!--获取上个时间段该网站站域名流量的数据量 -->
|
||||
<select id="preWebsiteListCount" resultType="java.lang.Long">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
||||
WHERE u.website_service_id=#{websiteServiceId}
|
||||
and stat_time < DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 2 hour)
|
||||
</select>
|
||||
|
||||
<!--获取网站列表列表 -->
|
||||
<!-- <select id="websiteList" resultMap="BaseResultMap">
|
||||
SELECT web_id webId, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count FROM traffic_http_statistic
|
||||
WHERE web_id !=0 and stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM traffic_http_statistic),INTERVAL 5 MINUTE)
|
||||
GROUP BY web_id ORDER BY count DESC limit 0,10
|
||||
</select> -->
|
||||
<!-- 根据网站分组获取子域名 -->
|
||||
<select id="getDomainByWebsiteServiceId" resultType="java.util.HashMap">
|
||||
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
|
||||
FROM traffic_http_statistic t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
||||
where u.website_service_id=#{websiteServiceId}
|
||||
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY t.web_id ORDER BY count desc limit 0,10
|
||||
</select>
|
||||
<!-- 根据主题分组获取子域名 -->
|
||||
<select id="getDomainByTopicId" resultType="java.util.HashMap">
|
||||
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
|
||||
FROM traffic_http_statistic t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
||||
where u.topic_id=#{topicId}
|
||||
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY t.web_id ORDER BY count desc limit 0,10
|
||||
</select>
|
||||
|
||||
<!-- 指定网站下的TOP10之外为others -->
|
||||
<select id="websiteDomainOthers" resultType="java.util.HashMap">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
||||
where u.website_service_id=#{websiteServiceId}
|
||||
|
||||
<mapper
|
||||
namespace="com.nis.web.dao.dashboard.TrafficHttpStatisticDao">
|
||||
<resultMap id="BaseResultMap"
|
||||
type="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||
<id column="stat_id" jdbcType="INTEGER" property="statId" />
|
||||
<result column="link_num" jdbcType="INTEGER" property="linkNum" />
|
||||
<result column="web_id" jdbcType="INTEGER" property="webId" />
|
||||
<result column="c2s_pkt_num" jdbcType="BIGINT"
|
||||
property="c2sPktNum" />
|
||||
<result column="s2c_pkt_num" jdbcType="BIGINT"
|
||||
property="s2cPktNum" />
|
||||
<result column="c2s_byte_len" jdbcType="BIGINT"
|
||||
property="c2sByteLen" />
|
||||
<result column="s2c_byte_len" jdbcType="BIGINT"
|
||||
property="s2cByteLen" />
|
||||
<result column="stat_time" jdbcType="TIMESTAMP"
|
||||
property="statTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len,
|
||||
s2c_byte_len,
|
||||
stat_time
|
||||
</sql>
|
||||
<!-- 获取最近时间并且有效 -->
|
||||
<select id="getMaxStatTime"
|
||||
resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||
SELECT stat_time statTime FROM traffic_http_statistic order by stat_time
|
||||
desc limit 1
|
||||
</select>
|
||||
<!-- 根据服务网站将域名分类 网站列表 -->
|
||||
<select id="getDomainByWebsiteList"
|
||||
resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( website_service_id,
|
||||
268435455 ) websiteServiceId
|
||||
FROM TRAFFIC_HTTP_STATISTIC t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
||||
where t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY u.website_service_id ORDER BY count desc limit 0,10
|
||||
</select>
|
||||
|
||||
<!-- 根据主题将域名分类 主题列表 最近五分钟top10 -->
|
||||
<select id="getDomainByTopicList" resultType="java.util.HashMap">
|
||||
SELECT
|
||||
IFNULL(topic_id, 268435455) topicId,
|
||||
id
|
||||
FROM
|
||||
ui_website_domain_topic u
|
||||
GROUP BY
|
||||
u.topic_id,
|
||||
id
|
||||
</select>
|
||||
|
||||
<!--获取上个时间段该网站站域名流量的数据量 -->
|
||||
<select id="preWebsiteListCount" resultType="java.lang.Long">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
||||
WHERE u.website_service_id=#{websiteServiceId}
|
||||
and stat_time < DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 2 hour)
|
||||
</select>
|
||||
|
||||
<!--获取网站列表列表 -->
|
||||
<!-- <select id="websiteList" resultMap="BaseResultMap"> SELECT web_id webId,
|
||||
(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count
|
||||
FROM traffic_http_statistic WHERE web_id !=0 and stat_time >= DATE_SUB((SELECT
|
||||
MAX(stat_time) FROM traffic_http_statistic),INTERVAL 5 MINUTE) GROUP BY web_id
|
||||
ORDER BY count DESC limit 0,10 </select> -->
|
||||
<!-- 根据网站分组获取子域名 -->
|
||||
<select id="getDomainByWebsiteServiceId"
|
||||
resultType="java.util.HashMap">
|
||||
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
|
||||
FROM traffic_http_statistic t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
||||
where u.website_service_id=#{websiteServiceId}
|
||||
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY t.web_id ORDER BY count desc limit 0,10
|
||||
</select>
|
||||
<!-- 根据主题分组获取子域名 -->
|
||||
<select id="getDomainByTopicId" resultType="java.util.HashMap">
|
||||
select web_id webId,sum(c2s_byte_len + s2c_byte_len) count from
|
||||
traffic_http_statistic t where
|
||||
<![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} group by t.web_id ]]>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 指定网站下的TOP10之外为others -->
|
||||
<select id="websiteDomainOthers" resultType="java.util.HashMap">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM
|
||||
traffic_http_statistic t
|
||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
||||
where u.website_service_id=#{websiteServiceId}
|
||||
|
||||
<if test="webIdList!=null and webIdList.size()>0">
|
||||
and t.web_id not in
|
||||
<foreach collection="webIdList" item="singleType" index="index" open="(" close=")" separator=",">
|
||||
#{singleType}
|
||||
</foreach>
|
||||
and t.web_id not in
|
||||
<foreach collection="webIdList" item="singleType"
|
||||
index="index" open="(" close=")" separator=",">
|
||||
#{singleType}
|
||||
</foreach>
|
||||
</if>
|
||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
</select>
|
||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user