sql优化流量统计
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
<!-- 获取取阻断,监测等流量信息最近时间 -->
|
||||
<select id="getMaxReportTime" resultType="com.nis.domain.restful.dashboard.NtcTotalReport">
|
||||
SELECT MAX(report_time) reportTime FROM ntc_total_report
|
||||
SELECT report_time reportTime FROM ntc_total_report order by report_time desc limit 1
|
||||
</select>
|
||||
|
||||
<!-- 根据最近的时间获取阻断,监测等流量信息 -->
|
||||
@@ -28,17 +28,17 @@
|
||||
|
||||
<!-- 获取带宽最近时间 -->
|
||||
<select id="getMaxStatTime" resultType="java.util.HashMap">
|
||||
SELECT MAX(stat_time) statTime FROM traffic_trans_statistic
|
||||
SELECT stat_time statTime FROM traffic_trans_statistic order by stat_time desc limit 1
|
||||
</select>
|
||||
<!-- 根据最近时间条获取带宽,进出口流量 -->
|
||||
<select id="getNetFlowPortInfoNew" resultType="java.util.HashMap">
|
||||
|
||||
SELECT SUM(total_traffic.inoctets) AS inoctets ,SUM(total_traffic.outoctets) AS outoctets FROM (
|
||||
SELECT SUM(total_traffic.inoctets) AS inoctets ,SUM(total_traffic.outoctets) AS outoctets FROM (
|
||||
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
|
||||
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=1
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
|
||||
UNION ALL
|
||||
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
|
||||
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=2
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
|
||||
) total_traffic
|
||||
|
||||
</select>
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
<!-- 获取报表最近时间 -->
|
||||
<select id="getEntranceMaxReportTime" resultType="java.util.HashMap">
|
||||
SELECT MAX(report_time) reportTime FROM ntc_entrance_report
|
||||
SELECT report_time reportTime FROM ntc_entrance_report order by report_time desc limit 1
|
||||
</select>
|
||||
<!-- entrance 1,2 ,动作为阻断,近五分钟数据 -->
|
||||
<select id="getActionTrans" resultType="com.nis.domain.restful.NtcEntranceReport">
|
||||
|
||||
@@ -17,19 +17,33 @@
|
||||
</sql>
|
||||
<!-- 查询最近时间 -->
|
||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficAppStatistic">
|
||||
SELECT MAX(stat_time) statTime FROM traffic_app_statistic WHERE app_type != 0
|
||||
SELECT stat_time statTime FROM traffic_app_statistic WHERE app_type != 0 order by stat_time desc limit 1
|
||||
</select>
|
||||
<select id="appChart" resultType="java.util.HashMap">
|
||||
SELECT app_type appType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_app_statistic
|
||||
WHERE app_type !=0 and stat_time = #{statTime}
|
||||
GROUP BY app_type order by count desc limit 0,10
|
||||
SELECT x.appType appType, SUM(x.count) count FROM
|
||||
( SELECT app_type appType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_app_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
|
||||
GROUP BY appType
|
||||
UNION ALL
|
||||
SELECT app_type appType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_app_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
|
||||
GROUP BY appType
|
||||
) x GROUP BY x.appType order by count desc limit 0,10
|
||||
</select>
|
||||
<!-- 获取app统计详情 -->
|
||||
<select id="getAppList" resultType="java.util.HashMap">
|
||||
SELECT IFNULL(c.app_name,p.app_type) appName,p.app_type appType,p.link_num linkNum, p.packets packets, p.GByte GByte FROM (
|
||||
SELECT app_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets,
|
||||
(SUM(c2s_byte_len+s2c_byte_len)/1024/1024/1024) AS GByte
|
||||
FROM traffic_app_statistic WHERE stat_time=#{statTime} GROUP BY app_type ) p
|
||||
LEFT JOIN ui_code_app_dic c ON p.app_type=c.view_code ORDER BY p.GByte DESC
|
||||
SELECT IFNULL(c.app_name,p.appType) appName,p.appType appType,p.linkNum linkNum, p.packets packets, p.GByte GByte FROM (
|
||||
SELECT x.appType ,SUM(x.link_num) AS linkNum,SUM(x.pkt) AS packets,
|
||||
(SUM(x.byte)/1024/1024/1024) AS GByte FROM
|
||||
( SELECT app_type appType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_app_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
|
||||
GROUP BY appType
|
||||
UNION ALL
|
||||
SELECT app_type appType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_app_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
|
||||
GROUP BY appType
|
||||
) x
|
||||
GROUP BY x.appType ) p
|
||||
LEFT JOIN ui_code_app_dic c ON p.appType=c.view_code ORDER BY p.GByte DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -17,22 +17,20 @@
|
||||
</sql>
|
||||
<!-- 获取最近时间并且有效 -->
|
||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||
SELECT MAX(stat_time) statTime FROM traffic_http_statistic WHERE web_id != 0
|
||||
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.web_id!=0
|
||||
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
|
||||
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
|
||||
@@ -41,7 +39,8 @@
|
||||
<!--获取上个时间段该网站站域名流量的数据量 -->
|
||||
<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
|
||||
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>
|
||||
@@ -56,7 +55,7 @@
|
||||
<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
|
||||
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
|
||||
@@ -65,7 +64,7 @@
|
||||
<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
|
||||
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
|
||||
@@ -74,13 +73,13 @@
|
||||
<!-- 指定网站下的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
|
||||
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>
|
||||
</foreach>
|
||||
</if>
|
||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
@@ -24,12 +24,12 @@
|
||||
</select> -->
|
||||
<!-- IP流量统计五分钟-->
|
||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficIpActiveStatistic">
|
||||
SELECT MAX(stat_time) statTime FROM traffic_ip_active_statistic
|
||||
SELECT stat_time statTime FROM traffic_ip_active_statistic order by stat_time desc limit 1
|
||||
</select>
|
||||
<!-- IP流量统计五分钟-->
|
||||
<select id="ipActiveChart" resultType="java.util.LinkedHashMap">
|
||||
SELECT ip_addr ipAddr, SUM(c2s_byte_len+s2c_byte_len) linkNum FROM traffic_ip_active_statistic
|
||||
WHERE stat_time = #{statTime}
|
||||
WHERE stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY ip_addr ORDER BY linkNum DESC limit 0,10
|
||||
</select>
|
||||
|
||||
|
||||
@@ -11,18 +11,19 @@
|
||||
|
||||
<!-- 获取最大时间 -->
|
||||
<select id="getMaxStatTime" resultMap="BaseResultMap">
|
||||
SELECT MAX(stat_time) statTime FROM traffic_port_active_statistic
|
||||
SELECT stat_time statTime FROM traffic_port_active_statistic order by stat_time desc limit 1
|
||||
</select>
|
||||
<!-- 获取当前时间五分钟数据 -->
|
||||
<select id="getPortActiveList" resultMap="BaseResultMap">
|
||||
SELECT port ,SUM(sum) sum from traffic_port_active_statistic
|
||||
WHERE stat_time = #{statTime}
|
||||
WHERE stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
GROUP BY port order by sum desc limit 0,10
|
||||
</select>
|
||||
<!-- 获取上个时间段的数据 -->
|
||||
<select id="getPortActiveOld" resultMap="BaseResultMap">
|
||||
SELECT SUM(sum) sum from traffic_port_active_statistic
|
||||
WHERE port=#{port} and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE)
|
||||
WHERE port=#{port} and stat_time < DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 2 hour)
|
||||
GROUP BY port ORDER BY sum DESC limit 0,10
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -17,18 +17,34 @@
|
||||
</sql>
|
||||
<!-- 获取最近时间 -->
|
||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficProtocolStatistic">
|
||||
SELECT MAX(stat_time) statTime FROM traffic_protocol_statistic WHERE proto_type != 0
|
||||
SELECT stat_time statTime FROM traffic_protocol_statistic WHERE proto_type != 0 order by stat_time desc limit 1
|
||||
</select>
|
||||
<select id="protocolChart" resultType="java.util.HashMap">
|
||||
SELECT proto_type protoType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_protocol_statistic WHERE proto_type != 0
|
||||
AND stat_time = #{statTime} GROUP BY proto_type ORDER BY count DESC LIMIT 0, 10
|
||||
SELECT x.protoType protoType, SUM(x.count) count FROM
|
||||
( SELECT proto_type protoType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_protocol_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
|
||||
GROUP BY protoType
|
||||
UNION ALL
|
||||
SELECT proto_type protoType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_protocol_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
|
||||
GROUP BY protoType
|
||||
) x
|
||||
GROUP BY x.protoType ORDER BY count DESC LIMIT 0, 10
|
||||
</select>
|
||||
|
||||
<select id="getProtocolList" resultType="java.util.HashMap">
|
||||
SELECT IFNULL(c.protocol_type,p.proto_type) protocolType,p.proto_type protoType,p.link_num linkNum, p.packets packets, p.GByte GByte FROM (
|
||||
SELECT proto_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets,
|
||||
(SUM(c2s_byte_len+s2c_byte_len)/1024/1024/1024) AS GByte
|
||||
FROM traffic_protocol_statistic WHERE stat_time=#{statTime} GROUP BY proto_type ) p
|
||||
LEFT JOIN ui_code_protocol_type_dic c ON p.proto_type=c.view_code ORDER BY p.GByte DESC
|
||||
SELECT IFNULL(c.protocol_type,p.protoType) protocolType,p.protoType protoType,p.linkNum linkNum, p.packets packets, p.GByte GByte FROM (
|
||||
SELECT x.protoType ,SUM(x.link_num) AS linkNum,SUM(x.pkt) AS packets,
|
||||
(SUM(x.byte)/1024/1024/1024) AS GByte FROM
|
||||
( SELECT proto_type protoType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_protocol_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
|
||||
GROUP BY protoType
|
||||
UNION ALL
|
||||
SELECT proto_type protoType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_protocol_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
|
||||
GROUP BY protoType
|
||||
) x
|
||||
GROUP BY x.protoType ) p
|
||||
LEFT JOIN ui_code_protocol_type_dic c ON p.protoType=c.view_code ORDER BY p.GByte DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -18,67 +18,135 @@
|
||||
</sql>
|
||||
<!-- 获取最近时间并且有效 -->
|
||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficUaStatistic">
|
||||
SELECT MAX(stat_time) statTime FROM traffic_ua_statistic WHERE os_type !=0 and bs_type!=0
|
||||
SELECT stat_time statTime FROM traffic_ua_statistic order by stat_time desc limit 1
|
||||
</select>
|
||||
<!--获取操作系统列表TOP10 -->
|
||||
<select id="systemList" resultMap="BaseResultMap">
|
||||
SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE os_type !=0 and stat_time = #{statTime}
|
||||
GROUP BY os_type ORDER BY count DESC limit 0,10
|
||||
SELECT x.osType osType, SUM(x.count) count FROM
|
||||
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
|
||||
GROUP BY osType
|
||||
UNION ALL
|
||||
SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
|
||||
GROUP BY osType
|
||||
) x
|
||||
GROUP BY x.osType ORDER BY count DESC limit 0,10
|
||||
</select>
|
||||
<!--获取上个时间段操作系统的数据量 -->
|
||||
<select id="preSystemListCount" resultType="java.lang.Long">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE os_type !=0 and os_type=#{osType}
|
||||
and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE)
|
||||
SELECT SUM(x.count) count FROM
|
||||
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time < DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and os_type=#{osType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and os_type=#{osType} and entrance_id=1
|
||||
and stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and os_type=#{osType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 2 HOUR) and os_type=#{osType} and entrance_id=1
|
||||
GROUP BY osType
|
||||
UNION ALL
|
||||
SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time < DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and os_type=#{osType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and os_type=#{osType} and entrance_id=2
|
||||
and stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and os_type=#{osType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 2 HOUR) and os_type=#{osType} and entrance_id=2
|
||||
GROUP BY osType
|
||||
) x
|
||||
</select>
|
||||
<!-- 根据操作系统获取浏览器分类 -->
|
||||
<select id="getBrowserBySystem" resultType="java.util.HashMap">
|
||||
SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE bs_type !=0 and os_type=#{osType} and stat_time = #{statTime}
|
||||
GROUP BY bs_type ORDER BY count DESC limit 0,10
|
||||
SELECT x.bsType bsType, SUM(x.count) count FROM
|
||||
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and os_type=#{osType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and os_type=#{osType} and entrance_id=1
|
||||
GROUP BY bsType
|
||||
UNION ALL
|
||||
SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and os_type=#{osType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and os_type=#{osType} and entrance_id=2
|
||||
GROUP BY bsType
|
||||
) x
|
||||
GROUP BY x.bsType ORDER BY count DESC limit 0,10
|
||||
</select>
|
||||
<!--浏览器TOP10后所有为others -->
|
||||
<select id="systemOthers" resultType="java.util.HashMap">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE bs_type !=0 and os_type=#{osType}
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM
|
||||
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and os_type=#{osType}
|
||||
<if test="bsType!=null and bsType.size()>0">
|
||||
and bs_type not in
|
||||
and x.bsType not in
|
||||
<foreach collection="bsType" item="singleType" index="index" open="(" close=")" separator=",">
|
||||
#{singleType}
|
||||
</foreach>
|
||||
</if>
|
||||
and stat_time = #{statTime}
|
||||
ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and os_type=#{osType} and entrance_id=1
|
||||
UNION ALL
|
||||
SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
<if test="bsType!=null and bsType.size()>0">
|
||||
and x.bsType not in
|
||||
<foreach collection="bsType" item="singleType" index="index" open="(" close=")" separator=",">
|
||||
#{singleType}
|
||||
</foreach>
|
||||
</if>
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and os_type=#{osType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and os_type=#{osType} and entrance_id=2
|
||||
) x
|
||||
|
||||
</select>
|
||||
|
||||
<!--获取浏览器列表TOP10 -->
|
||||
<select id="browserList" resultMap="BaseResultMap">
|
||||
SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE bs_type !=0 and stat_time = #{statTime}
|
||||
GROUP BY bs_type ORDER BY count DESC limit 0,10
|
||||
SELECT x.bsType, SUM(x.count) count FROM
|
||||
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
|
||||
GROUP BY bsType
|
||||
UNION ALL
|
||||
SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
|
||||
GROUP BY bsType
|
||||
) x
|
||||
GROUP BY x.bsType ORDER BY count DESC limit 0,10
|
||||
</select>
|
||||
<!--获取上个时间段浏览器的数据量 -->
|
||||
<select id="preBrowserListCount" resultType="java.lang.Long">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE bs_type !=0 and bs_type=#{bsType}
|
||||
and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE)
|
||||
SELECT SUM(x.count) count FROM
|
||||
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time < DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and bs_type=#{bsType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and bs_type=#{bsType} and entrance_id=1
|
||||
and stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and bs_type=#{bsType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 2 HOUR) and bs_type=#{bsType} and entrance_id=1
|
||||
GROUP BY bsType
|
||||
UNION ALL
|
||||
SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time < DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and bs_type=#{bsType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and bs_type=#{bsType} and entrance_id=2
|
||||
and stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and bs_type=#{bsType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 2 HOUR) and bs_type=#{bsType} and entrance_id=2
|
||||
GROUP BY bsType
|
||||
) x
|
||||
</select>
|
||||
<!-- 根据浏览器获取操作系统分类 -->
|
||||
<select id="getSystemBybrowser" resultType="java.util.HashMap">
|
||||
SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE os_type !=0 and bs_type=#{bsType} and stat_time = #{statTime}
|
||||
GROUP BY os_type ORDER BY count DESC limit 0,10
|
||||
SELECT x.osType osType, SUM(x.count) count FROM
|
||||
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and bs_type=#{bsType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and bs_type=#{bsType} and entrance_id=1
|
||||
GROUP BY osType
|
||||
UNION ALL
|
||||
SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and bs_type=#{bsType} ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and bs_type=#{bsType} and entrance_id=2
|
||||
GROUP BY osType
|
||||
) x
|
||||
GROUP BY x.osType ORDER BY count DESC limit 0,10
|
||||
</select>
|
||||
<!--操作系统TOP10后所有为others -->
|
||||
<select id="browserOthers" parameterType="java.util.List" resultType="java.util.HashMap">
|
||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
WHERE os_type !=0 and bs_type=#{bsType}
|
||||
SELECT SUM(x.count) count FROM
|
||||
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=1 and bs_type=#{bsType}
|
||||
<if test="osType!=null and osType.size()>0">
|
||||
and os_type not in
|
||||
<foreach collection="osType" item="singleType" index="index" open="(" close=")" separator=",">
|
||||
#{singleType}
|
||||
</foreach>
|
||||
</if>
|
||||
and stat_time = #{statTime}
|
||||
ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and bs_type=#{bsType} and entrance_id=1
|
||||
UNION ALL
|
||||
SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
|
||||
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_ua_statistic WHERE entrance_id=2 and bs_type=#{bsType}
|
||||
<if test="osType!=null and osType.size()>0">
|
||||
and os_type not in
|
||||
<foreach collection="osType" item="singleType" index="index" open="(" close=")" separator=",">
|
||||
#{singleType}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and bs_type=#{bsType} and entrance_id=2
|
||||
) x
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user