This commit is contained in:
renkaige
2018-12-02 17:18:53 +06:00
8 changed files with 52 additions and 70 deletions

View File

@@ -20,7 +20,7 @@
SELECT MAX(stat_time) statTime FROM traffic_app_statistic WHERE app_type != 0 SELECT MAX(stat_time) statTime FROM traffic_app_statistic WHERE app_type != 0
</select> </select>
<select id="appChart" resultType="java.util.HashMap"> <select id="appChart" resultType="java.util.HashMap">
SELECT app_type appType, SUM(link_num) count FROM traffic_app_statistic SELECT app_type appType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_app_statistic
WHERE app_type !=0 and stat_time = #{statTime} WHERE app_type !=0 and stat_time = #{statTime}
GROUP BY app_type order by count desc limit 0,10 GROUP BY app_type order by count desc limit 0,10
</select> </select>

View File

@@ -15,7 +15,7 @@ public interface TrafficHttpStatisticDao {
//获取域名分类之后属于的网站 //获取域名分类之后属于的网站
List<TrafficHttpStatistic> getDomainByWebsiteList(@Param("statTime")Date statTime); List<TrafficHttpStatistic> getDomainByWebsiteList(@Param("statTime")Date statTime);
Integer preWebsiteListCount(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime); Long preWebsiteListCount(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime);
List<Map> getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime); List<Map> getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime);
Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime); Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime);

View File

@@ -20,7 +20,7 @@
SELECT MAX(stat_time) statTime FROM traffic_http_statistic WHERE web_id != 0 SELECT MAX(stat_time) statTime FROM traffic_http_statistic WHERE web_id != 0
</select> </select>
<!-- 根据服务网站将域名分类 网站列表--> <!-- 根据服务网站将域名分类 网站列表-->
<select id="getDomainByWebsiteList" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic"> <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 SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( website_service_id, 268435455 ) websiteServiceId
FROM TRAFFIC_HTTP_STATISTIC t 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
@@ -28,7 +28,7 @@
and t.stat_time = #{statTime} and t.stat_time = #{statTime}
GROUP BY u.website_service_id ORDER BY count desc limit 0,10 GROUP BY u.website_service_id ORDER BY count desc limit 0,10
</select> </select>
<!-- 根据主题将域名分类 主题列表 最近五分钟top10--> <!-- 根据主题将域名分类 主题列表 最近五分钟top10-->
<select id="getDomainByTopicList" resultType="java.util.HashMap"> <select id="getDomainByTopicList" resultType="java.util.HashMap">
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( topic_id, 268435455 ) topicId SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( topic_id, 268435455 ) topicId
FROM TRAFFIC_HTTP_STATISTIC t FROM TRAFFIC_HTTP_STATISTIC t
@@ -37,8 +37,8 @@
and t.stat_time =#{statTime} and t.stat_time =#{statTime}
GROUP BY u.topic_id ORDER BY count desc limit 0,10 GROUP BY u.topic_id ORDER BY count desc limit 0,10
</select> </select>
<!--获取上个时间段该网站站域名流量的数据量 --> <!--获取上个时间段该网站站域名流量的数据量 -->
<select id="preWebsiteListCount" resultType="java.lang.Long"> <select id="preWebsiteListCount" resultType="java.lang.Long">
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t 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
@@ -52,7 +52,7 @@
WHERE web_id !=0 and stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM traffic_http_statistic),INTERVAL 5 MINUTE) 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 GROUP BY web_id ORDER BY count DESC limit 0,10
</select> --> </select> -->
<!-- 根据网站分组获取子域名 --> <!-- 根据网站分组获取子域名 -->
<select id="getDomainByWebsiteServiceId" resultType="java.util.HashMap"> <select id="getDomainByWebsiteServiceId" resultType="java.util.HashMap">
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
FROM traffic_http_statistic t FROM traffic_http_statistic t
@@ -61,7 +61,7 @@
and t.stat_time =#{statTime} and t.stat_time =#{statTime}
GROUP BY t.web_id ORDER BY count desc limit 0,10 GROUP BY t.web_id ORDER BY count desc limit 0,10
</select> </select>
<!-- 根据主题分组获取子域名 --> <!-- 根据主题分组获取子域名 -->
<select id="getDomainByTopicId" resultType="java.util.HashMap"> <select id="getDomainByTopicId" resultType="java.util.HashMap">
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
FROM traffic_http_statistic t FROM traffic_http_statistic t
@@ -71,7 +71,7 @@
GROUP BY t.web_id ORDER BY count desc limit 0,10 GROUP BY t.web_id ORDER BY count desc limit 0,10
</select> </select>
<!-- 指定网站下的TOP10之外为others --> <!-- 指定网站下的TOP10之外为others -->
<select id="websiteDomainOthers" resultType="java.util.HashMap"> <select id="websiteDomainOthers" resultType="java.util.HashMap">
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t 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

View File

@@ -28,7 +28,7 @@
</select> </select>
<!-- IP流量统计五分钟--> <!-- IP流量统计五分钟-->
<select id="ipActiveChart" resultType="java.util.LinkedHashMap"> <select id="ipActiveChart" resultType="java.util.LinkedHashMap">
SELECT ip_addr ipAddr, SUM(link_num) linkNum FROM traffic_ip_active_statistic SELECT ip_addr ipAddr, SUM(c2s_byte_len+s2c_byte_len) linkNum FROM traffic_ip_active_statistic
WHERE stat_time = #{statTime} WHERE stat_time = #{statTime}
GROUP BY ip_addr ORDER BY linkNum DESC limit 0,10 GROUP BY ip_addr ORDER BY linkNum DESC limit 0,10
</select> </select>

View File

@@ -20,7 +20,7 @@
SELECT MAX(stat_time) statTime FROM traffic_protocol_statistic WHERE proto_type != 0 SELECT MAX(stat_time) statTime FROM traffic_protocol_statistic WHERE proto_type != 0
</select> </select>
<select id="protocolChart" resultType="java.util.HashMap"> <select id="protocolChart" resultType="java.util.HashMap">
SELECT proto_type protoType, SUM(link_num) count FROM traffic_protocol_statistic WHERE proto_type != 0 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 AND stat_time = #{statTime} GROUP BY proto_type ORDER BY count DESC LIMIT 0, 10
</select> </select>
</mapper> </mapper>

View File

@@ -25,7 +25,7 @@ public interface TrafficUaStatisticDao {
Map browserOthers(@Param("osType") List osType,@Param("bsType") Integer bsType,@Param("statTime") Date statTime); Map browserOthers(@Param("osType") List osType,@Param("bsType") Integer bsType,@Param("statTime") Date statTime);
Integer preSystemListCount(@Param("osType") Integer osType,@Param("statTime") Date statTime); Long preSystemListCount(@Param("osType") Integer osType,@Param("statTime") Date statTime);
Integer preBrowserListCount(@Param("bsType") Integer bsType,@Param("statTime") Date statTime); Long preBrowserListCount(@Param("bsType") Integer bsType,@Param("statTime") Date statTime);
} }

View File

@@ -22,25 +22,25 @@
</select> </select>
<!--获取操作系统列表TOP10 --> <!--获取操作系统列表TOP10 -->
<select id="systemList" resultMap="BaseResultMap"> <select id="systemList" resultMap="BaseResultMap">
SELECT os_type osType, SUM(link_num) 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 stat_time = #{statTime} WHERE os_type !=0 and stat_time = #{statTime}
GROUP BY os_type ORDER BY count DESC limit 0,10 GROUP BY os_type ORDER BY count DESC limit 0,10
</select> </select>
<!--获取上个时间段操作系统的数据量 --> <!--获取上个时间段操作系统的数据量 -->
<select id="preSystemListCount" resultType="java.lang.Integer"> <select id="preSystemListCount" resultType="java.lang.Long">
SELECT SUM(link_num) count FROM traffic_ua_statistic SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
WHERE os_type !=0 and os_type=#{osType} WHERE os_type !=0 and os_type=#{osType}
and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE) and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE)
</select> </select>
<!-- 根据操作系统获取浏览器分类 --> <!-- 根据操作系统获取浏览器分类 -->
<select id="getBrowserBySystem" resultType="java.util.HashMap"> <select id="getBrowserBySystem" resultType="java.util.HashMap">
SELECT bs_type bsType, SUM(link_num) 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} and stat_time = #{statTime} WHERE bs_type !=0 and os_type=#{osType} and stat_time = #{statTime}
GROUP BY bs_type ORDER BY count DESC limit 0,10 GROUP BY bs_type 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(link_num) count FROM traffic_ua_statistic SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
WHERE bs_type !=0 and os_type=#{osType} WHERE bs_type !=0 and os_type=#{osType}
<if test="bsType!=null and bsType.size()>0"> <if test="bsType!=null and bsType.size()>0">
and bs_type not in and bs_type not in
@@ -53,25 +53,25 @@
<!--获取浏览器列表TOP10 --> <!--获取浏览器列表TOP10 -->
<select id="browserList" resultMap="BaseResultMap"> <select id="browserList" resultMap="BaseResultMap">
SELECT bs_type bsType, SUM(link_num) 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 stat_time = #{statTime} WHERE bs_type !=0 and stat_time = #{statTime}
GROUP BY bs_type ORDER BY count DESC limit 0,10 GROUP BY bs_type ORDER BY count DESC limit 0,10
</select> </select>
<!--获取上个时间段浏览器的数据量 --> <!--获取上个时间段浏览器的数据量 -->
<select id="preBrowserListCount" resultType="java.lang.Integer"> <select id="preBrowserListCount" resultType="java.lang.Long">
SELECT SUM(link_num) count FROM traffic_ua_statistic SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
WHERE bs_type !=0 and bs_type=#{bsType} WHERE bs_type !=0 and bs_type=#{bsType}
and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE) and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE)
</select> </select>
<!-- 根据浏览器获取操作系统分类 --> <!-- 根据浏览器获取操作系统分类 -->
<select id="getSystemBybrowser" resultType="java.util.HashMap"> <select id="getSystemBybrowser" resultType="java.util.HashMap">
SELECT os_type osType, SUM(link_num) 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} and stat_time = #{statTime} WHERE os_type !=0 and bs_type=#{bsType} and stat_time = #{statTime}
GROUP BY os_type ORDER BY count DESC limit 0,10 GROUP BY os_type 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(link_num) count FROM traffic_ua_statistic SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_ua_statistic
WHERE os_type !=0 and bs_type=#{bsType} WHERE os_type !=0 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

View File

@@ -1,31 +1,14 @@
package com.nis.web.service.restful; package com.nis.web.service.restful;
import java.util.ArrayList; import com.beust.jcommander.internal.Maps;
import java.util.Date; import com.nis.domain.restful.dashboard.*;
import java.util.HashMap; import com.nis.web.dao.dashboard.*;
import java.util.LinkedHashMap; import com.nis.web.service.BaseService;
import java.util.List; import com.zdjizhi.utils.StringUtil;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nis.domain.Page; import java.util.*;
import com.nis.domain.restful.dashboard.NtcTotalReport;
import com.nis.domain.restful.dashboard.TrafficAppStatistic;
import com.nis.domain.restful.dashboard.TrafficHttpStatistic;
import com.nis.domain.restful.dashboard.TrafficIpActiveStatistic;
import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic;
import com.nis.domain.restful.dashboard.TrafficProtocolStatistic;
import com.nis.domain.restful.dashboard.TrafficUaStatistic;
import com.nis.web.dao.dashboard.NtcTotalReportDao;
import com.nis.web.dao.dashboard.TrafficAppStatisticDao;
import com.nis.web.dao.dashboard.TrafficHttpStatisticDao;
import com.nis.web.dao.dashboard.TrafficIpActiveStatisticDao;
import com.nis.web.dao.dashboard.TrafficPortActiveStatisticDao;
import com.nis.web.dao.dashboard.TrafficProtocolStatisticDao;
import com.nis.web.dao.dashboard.TrafficUaStatisticDao;
import com.nis.web.service.BaseService;
@Service @Service
public class DashboardService extends BaseService{ public class DashboardService extends BaseService{
@@ -57,34 +40,33 @@ public class DashboardService extends BaseService{
totalReportList = ntcTotalReportDao.getTotalReportList(reportTime); totalReportList = ntcTotalReportDao.getTotalReportList(reportTime);
} }
Map maxRecvtTime = ntcTotalReportDao.getMaxRecvTime(); Map maxRecvtTime = ntcTotalReportDao.getMaxRecvTime();
List<Map> newData = new ArrayList<Map>(); List<Map> newData = new ArrayList<Map>();
// List<Map> oldData = new ArrayList<Map>();
if(maxRecvtTime!=null&&maxRecvtTime.get("statTime")!=null) { if(maxRecvtTime!=null && maxRecvtTime.get("statTime")!=null) {
Date recvTime = (Date) maxRecvtTime.get("statTime"); Date recvTime = (Date) maxRecvtTime.get("statTime");
newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime); newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime);
// oldData = ntcTotalReportDao.getNetFlowPortInfoOld(recvTime);
} }
//统计带宽的流入流出 单位 五分钟 的 byte //统计带宽的流入流出 单位 五分钟 的 byte
Double inoctets=0d; if(StringUtil.isNotEmpty(newData)){
Double outoctets=0d; Double inoctets = Double.parseDouble(newData.get(0).get("inoctets").toString()) ;
if(newData!=null&&newData.size()>0&&newData.get(0)!=null){ Double outoctets = Double.parseDouble(newData.get(0).get("outoctets").toString()) ;
Double newInoctets=Double.parseDouble(newData.get(0).get("inoctets").toString()) ;
Double newOutoctets=Double.parseDouble(newData.get(0).get("outoctets").toString()) ; if (StringUtil.isEmpty(totalReportList)) {
//结果为当前五分钟减去上个五分钟 Map valueMap = Maps.newHashMap();
inoctets=newInoctets; valueMap.put("inoctets", inoctets);
outoctets=newOutoctets; valueMap.put("outoctets", outoctets);
if(inoctets<0||outoctets<0){ totalReportList.add(valueMap);
inoctets=0d; } else {
outoctets=0d; totalReportList.get(0).put("inoctets", inoctets);
} totalReportList.get(0).put("outoctets", outoctets);
}
if(totalReportList!=null&&totalReportList.size()>0){
for (Map map : totalReportList) {
map.put("inoctets", inoctets);
map.put("outoctets", outoctets);
} }
} }
return totalReportList; return totalReportList;
} }
/** /**
@@ -241,7 +223,7 @@ public class DashboardService extends BaseService{
if(maxStatTime!=null) { if(maxStatTime!=null) {
Date statTime = maxStatTime.getStatTime(); Date statTime = maxStatTime.getStatTime();
List<TrafficUaStatistic> list = trafficUaStatisticDao.systemList(statTime); List<TrafficUaStatistic> list = trafficUaStatisticDao.systemList(statTime);
Integer preCount=0; Long preCount=0l;
for (TrafficUaStatistic ua : list) { for (TrafficUaStatistic ua : list) {
Map map = new HashMap(); Map map = new HashMap();
map.put("osType",ua.getOsType()); map.put("osType",ua.getOsType());
@@ -290,7 +272,7 @@ public class DashboardService extends BaseService{
if(maxStatTime!=null) { if(maxStatTime!=null) {
Date statTime = maxStatTime.getStatTime(); Date statTime = maxStatTime.getStatTime();
List<TrafficUaStatistic> list = trafficUaStatisticDao.browserList(statTime); List<TrafficUaStatistic> list = trafficUaStatisticDao.browserList(statTime);
Integer preCount=0; Long preCount=0l;
if(list!=null&&list.size()>0){ if(list!=null&&list.size()>0){
for (TrafficUaStatistic ua : list) { for (TrafficUaStatistic ua : list) {
Map map = new HashMap(); Map map = new HashMap();
@@ -339,7 +321,7 @@ public class DashboardService extends BaseService{
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime(); TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
if(maxStatTime!=null) { if(maxStatTime!=null) {
List<TrafficHttpStatistic> list = trafficHttpStatisticDao.websiteList(maxStatTime.getStatTime()); List<TrafficHttpStatistic> list = trafficHttpStatisticDao.websiteList(maxStatTime.getStatTime());
Integer preCount=0; Long preCount=0l;
if(list!=null&&list.size()>0){ if(list!=null&&list.size()>0){
for (TrafficHttpStatistic website : list) { for (TrafficHttpStatistic website : list) {
Map map = new HashMap(); Map map = new HashMap();
@@ -401,7 +383,7 @@ public class DashboardService extends BaseService{
Date statTime = maxStatTime.getStatTime(); Date statTime = maxStatTime.getStatTime();
List<TrafficHttpStatistic> websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime); List<TrafficHttpStatistic> websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime);
if(websiteList!=null&&websiteList.size()>0){ if(websiteList!=null&&websiteList.size()>0){
Integer preCount=0; Long preCount=0l;
for (TrafficHttpStatistic website : websiteList) { for (TrafficHttpStatistic website : websiteList) {
Map map = new HashMap(); Map map = new HashMap();
map.put("websiteServiceId",website.getWesiteServiceId()); map.put("websiteServiceId",website.getWesiteServiceId());