diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml index 159769b..5b9b810 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml @@ -16,8 +16,8 @@ stat_time \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java index 7689564..7fca504 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java @@ -12,4 +12,8 @@ public interface TrafficHttpStatisticDao { List websiteList(); List getTypeBywebsite(@Param("webId") Integer webId); + + Map websiteTypeOthers(@Param("webType") List webType,@Param("webId") Integer webId); + + Integer preWebsiteListCount(@Param("webId") Integer webId); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml index 5de9b5c..a2db696 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -17,14 +17,32 @@ - + 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 + + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml index c38598f..3c6e416 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml @@ -26,7 +26,7 @@ diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml index 23d3880..f12e4ab 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml @@ -16,8 +16,6 @@ stat_time \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.java index 16d6f59..ee102b7 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.java @@ -17,4 +17,12 @@ public interface TrafficUaStatisticDao { List browserList(); List 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); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml index cd19594..ac8713b 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml @@ -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 - + - - + 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 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 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 + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/restful/DashboardService.java b/src/main/java/com/nis/web/service/restful/DashboardService.java index c5cba8c..a84fe70 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -62,57 +62,120 @@ public class DashboardService extends BaseService{ List list = trafficAppStatisticDao.appChart(); return list; } + +// 操作系统列表 排名TOP10 @SuppressWarnings({ "unchecked", "rawtypes" }) public List systemList(){ List result = new ArrayList(); List 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 getBrowserBySystem(Integer osType ){ List 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 browserList() { List result = new ArrayList(); List 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 getSystemBybrowser(Integer bsType ){ List 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 websiteList() { List result = new ArrayList(); List 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 getTypeBywebsite(Integer webId ){ List 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; } }