流量统计sql去掉entrance_id 条件

This commit is contained in:
zhanghongqing
2018-12-09 19:13:47 +08:00
parent 455e4a38a9
commit 27eb0cd6f0
4 changed files with 63 additions and 180 deletions

View File

@@ -23,7 +23,7 @@
<select id="getTotalReportList" resultType="java.util.HashMap"> <select id="getTotalReportList" resultType="java.util.HashMap">
SELECT SUM(reject_num) rejectNum,SUM(monitor_num) monitorNum,SUM(c2s_pkt_num) c2sPktNum,SUM(s2c_pkt_num) s2cPktNum,SUM(c2s_byte_len) c2sByteLen,SUM(s2c_byte_len) s2cByteLen,SUM(new_uni_conn_num) newUniConnNum,SUM(live_conn_num) liveConnNum, SELECT SUM(reject_num) rejectNum,SUM(monitor_num) monitorNum,SUM(c2s_pkt_num) c2sPktNum,SUM(s2c_pkt_num) s2cPktNum,SUM(c2s_byte_len) c2sByteLen,SUM(s2c_byte_len) s2cByteLen,SUM(new_uni_conn_num) newUniConnNum,SUM(live_conn_num) liveConnNum,
SUM(drop_conn_num) dropConnNum,SUM(loop_conn_num) loopConnNum FROM ntc_total_report SUM(drop_conn_num) dropConnNum,SUM(loop_conn_num) loopConnNum FROM ntc_total_report
where report_time = #{reportTime} where report_time > DATE_SUB(#{reportTime}, INTERVAL 1 HOUR)
</select> </select>
<!-- 获取带宽最近时间 --> <!-- 获取带宽最近时间 -->
@@ -32,15 +32,8 @@
</select> </select>
<!-- 根据最近时间条获取带宽,进出口流量 --> <!-- 根据最近时间条获取带宽,进出口流量 -->
<select id="getNetFlowPortInfoNew" resultType="java.util.HashMap"> <select id="getNetFlowPortInfoNew" resultType="java.util.HashMap">
SELECT IFNULL(SUM(c2s_byte_len),0) AS inoctets ,IFNULL(SUM(s2c_byte_len),0) AS outoctets FROM traffic_trans_statistic
SELECT SUM(total_traffic.inoctets) AS inoctets ,SUM(total_traffic.outoctets) AS outoctets FROM ( WHERE stat_time > DATE_SUB(#{statTime}, INTERVAL 1 HOUR)
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
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 > 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> </select>
<!-- 获取近五分钟的带宽根据ip46协议 tcp,udp变化 --> <!-- 获取近五分钟的带宽根据ip46协议 tcp,udp变化 -->
<select id="getBandwidthTrans" resultMap="BandwidthResultMap"> <select id="getBandwidthTrans" resultMap="BandwidthResultMap">

View File

@@ -17,47 +17,28 @@
</sql> </sql>
<!-- 查询最近时间 --> <!-- 查询最近时间 -->
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficAppStatistic"> <select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficAppStatistic">
SELECT stat_time statTime FROM traffic_app_statistic WHERE app_type != 0 order by stat_time desc limit 1 SELECT stat_time statTime FROM traffic_app_statistic order by stat_time desc limit 1
</select> </select>
<select id="appChart" resultType="java.util.HashMap">
SELECT x.appType appType, SUM(x.count) count FROM <select id="appChart" resultType="java.util.HashMap">
( SELECT app_type appType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_app_statistic 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 WHERE stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
GROUP BY appType GROUP BY app_type order by count desc limit 0,10
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> </select>
<!-- 获取app统计详情 --> <!-- 获取app统计详情 -->
<select id="getAppList" resultType="java.util.HashMap"> <select id="getAppList" resultType="java.util.HashMap">
SELECT IFNULL(c.app_name,p.appType) appName,p.appType appType,p.linkNum linkNum, p.packets packets, p.GByte GByte FROM ( 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 x.appType ,SUM(x.link_num) AS linkNum,SUM(x.pkt) AS packets, SELECT app_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets,
(SUM(x.byte)/1024/1024/1024) AS GByte FROM (SUM(c2s_byte_len+s2c_byte_len)/1024/1024/1024) AS GByte
( 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 FROM traffic_app_statistic WHERE
where <if test="beginTime==null or endTime==null">
<if test="beginTime==null or endTime==null"> stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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) </if>
</if> <if test="beginTime!=null and endTime!=null">
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime} stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if> </if>
and entrance_id=1 GROUP BY app_type ) p
GROUP BY appType LEFT JOIN ui_code_app_dic c ON p.app_type=c.view_code ORDER BY p.GByte DESC
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
<if test="beginTime==null or endTime==null">
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)
</if>
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if>
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> </select>
</mapper> </mapper>

View File

@@ -19,46 +19,23 @@
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficProtocolStatistic"> <select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficProtocolStatistic">
SELECT stat_time statTime FROM traffic_protocol_statistic WHERE proto_type != 0 order by stat_time desc limit 1 SELECT stat_time statTime FROM traffic_protocol_statistic WHERE proto_type != 0 order by stat_time desc limit 1
</select> </select>
<select id="protocolChart" resultType="java.util.HashMap"> <select id="protocolChart" resultType="java.util.HashMap">
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
( SELECT proto_type protoType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_protocol_statistic stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour) GROUP BY proto_type ORDER BY count DESC LIMIT 0, 10
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>
<select id="getProtocolList" resultType="java.util.HashMap"> <select id="getProtocolList" resultType="java.util.HashMap">
SELECT IFNULL(c.protocol_type,p.protoType) protocolType,p.protoType protoType,p.linkNum linkNum, p.packets packets, p.GByte GByte FROM ( 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 x.protoType ,SUM(x.link_num) AS linkNum,SUM(x.pkt) AS packets, SELECT proto_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets,
(SUM(x.byte)/1024/1024/1024) AS GByte FROM (SUM(c2s_byte_len+s2c_byte_len)/1024/1024/1024) AS GByte
( 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 FROM traffic_protocol_statistic WHERE
where <if test="beginTime==null or endTime==null">
<if test="beginTime==null or endTime==null"> stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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) </if>
</if> <if test="beginTime!=null and endTime!=null">
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime} stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if> </if>
and entrance_id=1 GROUP BY proto_type ) p
GROUP BY protoType LEFT JOIN ui_code_protocol_type_dic c ON p.proto_type=c.view_code ORDER BY p.GByte DESC
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
<if test="beginTime==null or endTime==null">
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)
</if>
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if>
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> </select>
</mapper> </mapper>

View File

@@ -21,132 +21,64 @@
SELECT stat_time statTime FROM traffic_ua_statistic order by stat_time desc limit 1 SELECT stat_time statTime FROM traffic_ua_statistic order by stat_time desc limit 1
</select> </select>
<!--获取操作系统列表TOP10 --> <!--获取操作系统列表TOP10 -->
<select id="systemList" resultMap="BaseResultMap"> <select id="systemList" resultMap="BaseResultMap">
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
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE stat_time > DATE_SUB(#{statTime}, INTERVAL 1 HOUR)
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 os_type ORDER BY count DESC limit 0,10
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>
<!--获取上个时间段操作系统的数据量 --> <!--获取上个时间段操作系统的数据量 -->
<select id="preSystemListCount" resultType="java.lang.Long"> <select id="preSystemListCount" resultType="java.lang.Long">
SELECT SUM(x.count) count FROM SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE os_type=#{osType}
where stat_time &lt; 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 &lt; DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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 and stat_time > DATE_SUB(#{statTime},INTERVAL 2 HOUR)
GROUP BY osType
UNION ALL
SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
where stat_time &lt; 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>
<!-- 根据操作系统获取浏览器分类 --> <!-- 根据操作系统获取浏览器分类 -->
<select id="getBrowserBySystem" resultType="java.util.HashMap"> <select id="getBrowserBySystem" resultType="java.util.HashMap">
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
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE os_type=#{osType} and stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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 bs_type ORDER BY count DESC limit 0,10
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> </select>
<!--浏览器TOP10后所有为others --> <!--浏览器TOP10后所有为others -->
<select id="systemOthers" resultType="java.util.HashMap"> <select id="systemOthers" resultType="java.util.HashMap">
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE bs_type !=0 and os_type=#{osType}
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"> <if test="bsType!=null and bsType.size()>0">
and x.bsType not in and bs_type not in
<foreach collection="bsType" item="singleType" index="index" open="(" close=")" separator=","> <foreach collection="bsType" item="singleType" index="index" open="(" close=")" separator=",">
#{singleType} #{singleType}
</foreach> </foreach>
</if> </if>
ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and os_type=#{osType} and entrance_id=1 and stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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> </select>
<!--获取浏览器列表TOP10 --> <!--获取浏览器列表TOP10 -->
<select id="browserList" resultMap="BaseResultMap"> <select id="browserList" resultMap="BaseResultMap">
SELECT x.bsType, SUM(x.count) count FROM SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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 bs_type ORDER BY count DESC limit 0,10
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>
<!--获取上个时间段浏览器的数据量 --> <!--获取上个时间段浏览器的数据量 -->
<select id="preBrowserListCount" resultType="java.lang.Long"> <select id="preBrowserListCount" resultType="java.lang.Long">
SELECT SUM(x.count) count FROM SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
( SELECT bs_type bsType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE bs_type=#{bsType}
where stat_time &lt; 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 &lt; DATE_SUB(#{statTime},INTERVAL 1 HOUR) and stat_time > DATE_SUB(#{statTime},INTERVAL 2 HOUR)
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 &lt; 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>
<!-- 根据浏览器获取操作系统分类 --> <!-- 根据浏览器获取操作系统分类 -->
<select id="getSystemBybrowser" resultType="java.util.HashMap"> <select id="getSystemBybrowser" resultType="java.util.HashMap">
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
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE bs_type=#{bsType} and stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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 os_type ORDER BY count DESC limit 0,10
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> </select>
<!--操作系统TOP10后所有为others --> <!--操作系统TOP10后所有为others -->
<select id="browserOthers" parameterType="java.util.List" resultType="java.util.HashMap"> <select id="browserOthers" parameterType="java.util.List" resultType="java.util.HashMap">
SELECT SUM(x.count) count FROM SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
( SELECT os_type osType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic WHERE os_type !=0 and bs_type=#{bsType}
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"> <if test="osType!=null and osType.size()>0">
and os_type not in and os_type not in
<foreach collection="osType" item="singleType" index="index" open="(" close=")" separator=","> <foreach collection="osType" item="singleType" index="index" open="(" close=")" separator=",">
#{singleType} #{singleType}
</foreach> </foreach>
</if> </if>
ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and bs_type=#{bsType} and entrance_id=1 and stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR)
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> </select>
</mapper> </mapper>