85 lines
4.3 KiB
XML
85 lines
4.3 KiB
XML
<?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.TrafficIpActiveStatisticDao">
|
|
<resultMap id="BaseResultMap" type="com.nis.domain.restful.dashboard.TrafficIpActiveStatistic">
|
|
<id column="stat_id" jdbcType="INTEGER" property="statId" />
|
|
<result column="ip_addr" jdbcType="VARCHAR" property="ipAddr" />
|
|
<result column="area_id" jdbcType="INTEGER" property="areaId" />
|
|
<result column="link_num" jdbcType="BIGINT" property="linkNum" />
|
|
<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, ip_addr, area_id, link_num, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len,
|
|
stat_time
|
|
</sql>
|
|
<!-- 活跃IPTOP列表 -->
|
|
<!-- <select id="getIpList" resultMap="BaseResultMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
from traffic_ip_active_statistic
|
|
</select> -->
|
|
<!-- IP流量统计五分钟-->
|
|
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficIpActiveStatistic">
|
|
SELECT stat_time statTime FROM traffic_ip_active_statistic order by stat_time desc limit 1
|
|
</select>
|
|
<!-- IP流量统计五分钟TOp10-->
|
|
<!-- <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
|
|
<![CDATA[ stat_time> #{beginDate} and stat_time<=#{endDate}]]>
|
|
GROUP BY ip_addr ORDER BY linkNum DESC limit 0,10
|
|
</select>-->
|
|
<select id="ipActiveChart" resultType="java.util.LinkedHashMap">
|
|
SELECT ip_addr ipAddr,SUM(link_num) linkNum FROM traffic_ip_active_statistic WHERE
|
|
<![CDATA[stat_time >= #{beginDate} AND stat_time < #{endDate}]]>
|
|
<if test="entranceId !=null">
|
|
and area_id=#{entranceId}
|
|
</if>
|
|
GROUP BY ip_addr ORDER BY linkNum DESC LIMIT 0,10
|
|
</select>
|
|
|
|
<!-- IP流量统计一小时内每隔五分钟数据-->
|
|
<!-- <select id="ipActiveFiveMinute" resultMap="BaseResultMap">
|
|
select IFNULL(p.sumNum,0) linkNum, date_format(a.min5,'%Y-%m-%d %H:%i') time from
|
|
(select date_sub(#{endDate},interval @mycnt :=@mycnt + 5 MINUTE) min5
|
|
from (SELECT @mycnt:=-5) m, traffic_ip_active_statistic limit #{inter}) a
|
|
LEFT JOIN (
|
|
SELECT date_format(stat_time, '%Y-%m-%d %H:%i') timestamp, SUM(c2s_byte_len+s2c_byte_len) sumNum FROM traffic_ip_active_statistic
|
|
WHERE ip_addr=#{ipAddr} AND <![CDATA[ stat_time> #{beginDate} and stat_time<=#{endDate}]]>
|
|
GROUP by timestamp
|
|
) p
|
|
on date_format(p.timestamp,'%Y-%m-%d %H:%i')=date_format(a.min5,'%Y-%m-%d %H:%i')
|
|
ORDER by time
|
|
</select> -->
|
|
<!--<select id="ipActiveFiveMinute" resultMap="BaseResultMap">
|
|
select SUM(c2s_byte_len+s2c_byte_len) count ,stat_time time from traffic_ip_active_statistic
|
|
WHERE ip_addr=#{ipAddr} and
|
|
<![CDATA[ stat_time> #{beginDate} and stat_time<=#{endDate} GROUP BY stat_time]]>
|
|
</select> -->
|
|
|
|
<select id="ipActiveFiveMinute" resultMap="BaseResultMap">
|
|
select ip_addr,SUM(link_num) count ,stat_time from traffic_ip_active_statistic
|
|
WHERE
|
|
<![CDATA[ip_addr in (${ipAddr}) and stat_time>= #{beginDate} and stat_time<#{endDate}]]>
|
|
<if test="entranceId !=null">
|
|
and area_id=#{entranceId}
|
|
</if>
|
|
GROUP BY stat_time,ip_addr order by stat_time asc
|
|
</select>
|
|
<!-- IP流量统计一小时-->
|
|
<select id="ipActiveOneHour" resultType="java.util.HashMap">
|
|
SELECT ip_addr ipAddr,area_id areaId,SUM(c2s_byte_len+s2c_byte_len) count, link_num linkNum ,c2s_pkt_num c2sPktNum,s2c_pkt_num s2cPktNum,c2s_byte_len c2sByteLen,s2c_byte_len s2cByteLen,date_format(stat_time, '%Y-%m-%d %H:%i:%s') statTime FROM traffic_ip_active_statistic
|
|
WHERE ip_addr=#{ipAddr}
|
|
and <![CDATA[ stat_time>= #{beginDate} and stat_time<#{endDate}]]>
|
|
<if test="entranceId !=null">
|
|
and area_id=#{entranceId}
|
|
</if>
|
|
GROUP BY statTime
|
|
ORDER BY count DESC LIMIT 1
|
|
</select>
|
|
|
|
</mapper> |