大屏统计图表接口返回值增加上一段时间参数preCount,其它类型others

This commit is contained in:
zhanghongqing
2018-07-23 17:44:18 +08:00
parent d5aff2e139
commit 5079032c09
8 changed files with 157 additions and 29 deletions

View File

@@ -16,8 +16,8 @@
stat_time
</sql>
<select id="appChart" resultType="java.util.HashMap">
SELECT app_type appType, count(app_type) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_app_statistic
WHERE app_type !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
GROUP BY app_type limit 0,10
SELECT app_type appType, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_app_statistic
WHERE app_type !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY app_type order by count desc limit 0,10
</select>
</mapper>

View File

@@ -12,4 +12,8 @@ public interface TrafficHttpStatisticDao {
List<TrafficHttpStatistic> websiteList();
List<Map> getTypeBywebsite(@Param("webId") Integer webId);
Map websiteTypeOthers(@Param("webType") List webType,@Param("webId") Integer webId);
Integer preWebsiteListCount(@Param("webId") Integer webId);
}

View File

@@ -17,14 +17,32 @@
</sql>
<!--获取网站列表列表 -->
<select id="websiteList" resultMap="BaseResultMap">
SELECT web_id webId, count(web_id) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_http_statistic
WHERE web_id !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
SELECT web_id webId, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_http_statistic
WHERE web_id !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY web_id ORDER BY count DESC limit 0,10
</select>
<!-- 根据网站分类 -->
<select id="getTypeBywebsite" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT web_type webType, count(web_type) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_http_statistic
WHERE web_type !=0 and web_id=#{webId} and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
GROUP BY web_type limit 0,10
<select id="getTypeBywebsite" parameterType="java.lang.Integer" resultType="java.util.HashMap">
SELECT web_type webType, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_http_statistic
WHERE web_type !=0 and web_id=#{webId} and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY web_type ORDER BY count limit 0,10
</select>
<!--获取上个时间段网站流量的数据量 -->
<select id="preWebsiteListCount" resultType="java.lang.Integer">
SELECT (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count FROM galaxy.traffic_http_statistic
WHERE web_type !=0 and web_id=#{webId}
and stat_time between DATE_SUB(NOW(),INTERVAL 10 MINUTE) and DATE_SUB(NOW(),INTERVAL 5 MINUTE)
</select>
<!-- 指定网站下的TOP10之外为others -->
<select id="websiteTypeOthers" resultType="java.util.HashMap">
SELECT (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_http_statistic
WHERE web_type !=0 and web_id=#{webId}
<if test="webType!=null and webType.size()>0">
and bs_type not in
<foreach collection="webType" item="singleType" index="index" open="(" close=")" separator=",">
#{singleType}
</foreach>
</if>
and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
</select>
</mapper>

View File

@@ -26,7 +26,7 @@
<!-- IP流量统计-->
<select id="ipActiveChart" resultType="java.util.LinkedHashMap">
SELECT ip_addr ipAddr, SUM(link_num) linkNum ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ip_active_statistic
WHERE stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
WHERE stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY ip_addr ORDER BY link_num DESC limit 0,10
</select>

View File

@@ -16,8 +16,6 @@
stat_time
</sql>
<select id="protocolChart" resultType="java.util.HashMap">
SELECT proto_type protoType, count(proto_type) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_protocol_statistic
WHERE proto_type!=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
GROUP BY proto_type limit 0,10
SELECT proto_type protoType, ( SUM(c2s_pkt_num) + SUM(s2c_pkt_num) + SUM(c2s_byte_len) + SUM(s2c_byte_len)) count, ( SUM(c2s_pkt_num) + SUM(s2c_pkt_num)) pktNum, ( SUM(c2s_byte_len) + SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_protocol_statistic WHERE proto_type != 0 AND stat_time >= DATE_SUB(NOW(), INTERVAL 5 MINUTE) GROUP BY proto_type ORDER BY count DESC LIMIT 0, 10
</select>
</mapper>

View File

@@ -17,4 +17,12 @@ public interface TrafficUaStatisticDao {
List<TrafficUaStatistic> browserList();
List<Map> getSystemBybrowser(@Param("bsType") Integer bsType);
Map systemOthers(@Param("bsType") List bsType,@Param("osType") Integer osType);
Map browserOthers(@Param("osType") List osType,@Param("bsType") Integer bsType);
Integer preSystemListCount(@Param("osType") Integer osType);
Integer preBrowserListCount(@Param("bsType") Integer bsType);
}

View File

@@ -16,28 +16,65 @@
stat_id, bs_type,os_type, entrance_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len,
stat_time
</sql>
<!--获取操作系统列表 -->
<!--获取操作系统列表TOP10 -->
<select id="systemList" resultMap="BaseResultMap">
SELECT os_type osType, count(os_type) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE os_type !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
SELECT os_type osType, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE os_type !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY os_type ORDER BY count DESC limit 0,10
</select>
<!-- 根据操作系统获取浏览器分类 -->
<select id="getBrowserBySystem" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT bs_type bsType, count(bs_type) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE bs_type !=0 and os_type=#{osType} and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
GROUP BY bs_type limit 0,10
<!--获取上个时间段操作系统的数据量 -->
<select id="preSystemListCount" resultType="java.lang.Integer">
SELECT (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count FROM galaxy.traffic_ua_statistic
WHERE os_type !=0 and os_type=#{osType}
and stat_time between DATE_SUB(NOW(),INTERVAL 10 MINUTE) and DATE_SUB(NOW(),INTERVAL 5 MINUTE)
</select>
<!--获取浏览器列表 -->
<select id="browserList" resultMap="BaseResultMap">
SELECT bs_type bsType, count(bs_type) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE bs_type !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
<!-- 根据操作系统获取浏览器分类 -->
<select id="getBrowserBySystem" parameterType="java.lang.Integer" resultType="java.util.HashMap">
SELECT bs_type bsType, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE bs_type !=0 and os_type=#{osType} and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY bs_type ORDER BY count DESC limit 0,10
</select>
<!--浏览器TOP10后所有为others -->
<select id="systemOthers" resultType="java.util.HashMap">
SELECT (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE bs_type !=0 and os_type=#{osType}
<if test="bsType!=null and bsType.size()>0">
and os_type not in
<foreach collection="bsType" item="singleType" index="index" open="(" close=")" separator=",">
#{singleType}
</foreach>
</if>
and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
</select>
<!--获取浏览器列表TOP10 -->
<select id="browserList" resultMap="BaseResultMap">
SELECT bs_type bsType, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE bs_type !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY bs_type ORDER BY count DESC limit 0,10
</select>
<!--获取上个时间段浏览器的数据量 -->
<select id="preBrowserListCount" resultType="java.lang.Integer">
SELECT (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count FROM galaxy.traffic_ua_statistic
WHERE bs_type !=0 and bs_type=#{bsType}
and stat_time between DATE_SUB(NOW(),INTERVAL 10 MINUTE) and DATE_SUB(NOW(),INTERVAL 5 MINUTE)
</select>
<!-- 根据浏览器获取操作系统分类 -->
<select id="getSystemBybrowser" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT os_type osType, count(os_type) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE os_type !=0 and bs_type=#{bsType} and stat_time >= DATE_SUB(NOW(),INTERVAL 555 HOUR)
GROUP BY os_type limit 0,10
<select id="getSystemBybrowser" parameterType="java.lang.Integer" resultType="java.util.HashMap">
SELECT os_type osType, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE os_type !=0 and bs_type=#{bsType} and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
GROUP BY os_type ORDER BY count DESC limit 0,10
</select>
<!--操作系统TOP10后所有为others -->
<select id="browserOthers" parameterType="java.util.List" resultType="java.util.HashMap">
SELECT (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_ua_statistic
WHERE os_type !=0 and bs_type=#{bsType}
<if test="osType!=null and osType.size()>0">
and bs_type not in
<foreach collection="osType" item="singleType" index="index" open="(" close=")" separator=",">
#{singleType}
</foreach>
</if>
and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
</select>
</mapper>

View File

@@ -62,57 +62,120 @@ public class DashboardService extends BaseService{
List<Map> list = trafficAppStatisticDao.appChart();
return list;
}
// 操作系统列表 排名TOP10
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Map> systemList(){
List<Map> result = new ArrayList<Map>();
List<TrafficUaStatistic> list = trafficUaStatisticDao.systemList();
Integer preCount=0;
for (TrafficUaStatistic ua : list) {
Map map = new HashMap();
map.put("osType",ua.getOsType());
map.put("count",ua.getCount());
map.put("pktNum",ua.getPktNum());
map.put("byteLen",ua.getByteLen());
preCount = trafficUaStatisticDao.preSystemListCount(ua.getOsType());//上个时段的量 用于与现在对比
if(preCount!=null){
map.put("preCount",preCount);
}else{
map.put("preCount",0);
}
result.add(map);
}
return result;
}
public List<Map> getBrowserBySystem(Integer osType ){
List<Map> list = trafficUaStatisticDao.getBrowserBySystem(osType);
List bsType = new ArrayList();
//查新固定操系统下的除了TOP10以外的others
if(list!=null&& list.size()>0){
for (Map map : list) {
bsType.add(map.get("bsType"));
}
Map others = new HashMap();
others = trafficUaStatisticDao.systemOthers(bsType,osType);
if(others!=null&&others.size()>0){
others.put("bsType", "-1");
list.add(others);
}
}
return list;
}
public List<Map> browserList() {
List<Map> result = new ArrayList<Map>();
List<TrafficUaStatistic> list = trafficUaStatisticDao.browserList();
Integer preCount=0;
for (TrafficUaStatistic ua : list) {
Map map = new HashMap();
map.put("bsType",ua.getBsType());
map.put("count",ua.getCount());
map.put("pktNum",ua.getPktNum());
map.put("byteLen",ua.getByteLen());
preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType());//上个时段的量 用于与现在对比
if(preCount!=null){
map.put("preCount",preCount);
}else{
map.put("preCount",0);
}
result.add(map);
}
return result;
}
public List<Map> getSystemBybrowser(Integer bsType ){
List<Map> list = trafficUaStatisticDao.getSystemBybrowser(bsType);
List osType = new ArrayList();
//查询固定操系统下的除了TOP10以外的others
if(list!=null&& list.size()>0){
for (Map map : list) {
osType.add(map.get("osType"));
}
Map others = new HashMap();
others = trafficUaStatisticDao.browserOthers(osType,bsType);
if(others!=null&&others.size()>0){
others.put("osType", "-1");
list.add(others);
}
}
return list;
}
public List<Map> websiteList() {
List<Map> result = new ArrayList<Map>();
List<TrafficHttpStatistic> list = trafficHttpStatisticDao.websiteList();
Integer preCount=0;
for (TrafficHttpStatistic website : list) {
Map map = new HashMap();
map.put("webId",website.getWebId());
map.put("count",website.getCount());
map.put("pktNum",website.getPktNum());
map.put("byteLen",website.getByteLen());
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId());//上个时段的量 用于与现在对比
if(preCount!=null){
map.put("preCount",preCount);
}else{
map.put("preCount",0);
}
result.add(map);
}
return result;
}
public List<Map> getTypeBywebsite(Integer webId ){
List<Map> list = trafficHttpStatisticDao.getTypeBywebsite(webId);
List webType = new ArrayList();
//查询固定网站下的除了TOP10以外的others分类
if(list!=null&& list.size()>0){
for (Map map : list) {
webType.add(map.get("webType"));
}
Map others = new HashMap();
others = trafficHttpStatisticDao.websiteTypeOthers(webType,webId);
if(others!=null&&others.size()>0){
others.put("webType", "-1");
list.add(others);
}
}
return list;
}
}