diff --git a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java index 96fc54b..d0fbbc8 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -1,13 +1,18 @@ package com.nis.web.dao.dashboard; +import java.util.Date; import java.util.List; import java.util.Map; +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.restful.dashboard.NtcTotalReport; import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface NtcTotalReportDao { - - List getTotalReportList(); - List getNetFlowPortInfoNew(); - List getNetFlowPortInfoOld(); + NtcTotalReport getMaxReportTime(); + Map getMaxRecvTime(); + List getTotalReportList(@Param("reportTime") Date reportTime); + List getNetFlowPortInfoNew(@Param("reportTime") Date recvTime); + List getNetFlowPortInfoOld(@Param("reportTime") Date recvTime); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml index a7ec84f..bed1fc4 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -16,18 +16,26 @@ WHERE app_type !=0 and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) GROUP BY app_type order by count desc limit 0,10 --> + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.java index 6bef086..d23a133 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.java @@ -1,11 +1,16 @@ package com.nis.web.dao.dashboard; +import java.util.Date; import java.util.List; import java.util.Map; +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.restful.dashboard.TrafficAppStatistic; import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface TrafficAppStatisticDao { - List appChart(); + TrafficAppStatistic getMaxStatTime(); + List appChart(@Param("statTime")Date statTime); } \ No newline at end of file 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 2f560df..b806287 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml @@ -15,10 +15,13 @@ stat_id, app_type, entrance_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len, 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 3c2ff0c..e7ba1f0 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java @@ -1,5 +1,6 @@ package com.nis.web.dao.dashboard; +import java.util.Date; import java.util.List; import java.util.Map; @@ -9,15 +10,16 @@ import com.nis.domain.restful.dashboard.TrafficHttpStatistic; import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface TrafficHttpStatisticDao { - List websiteList(); + TrafficHttpStatistic getMaxStatTime(); + List websiteList(@Param("statTime")Date statTime); //获取域名分类之后属于的网站 - List getDomainByWebsiteList(); - Integer preWebsiteListCount(@Param("websiteServiceId") Integer websiteServiceId); - List getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId); - Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId); + List getDomainByWebsiteList(@Param("statTime")Date statTime); + Integer preWebsiteListCount(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime); + List getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime); + Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime); - List getDomainByTopicList(); + List getDomainByTopicList(@Param("statTime") Date statTime); - List getDomainByTopicId(@Param("topicId")Object TopicId); + List getDomainByTopicId(@Param("topicId")Object TopicId,@Param("statTime")Date statTime); } \ 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 0433ebb..65d0a2c 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -15,20 +15,24 @@ stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len, stat_time + + @@ -37,37 +41,37 @@ SELECT SUM(link_num) count FROM galaxy.traffic_http_statistic t LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id = u.id WHERE u.website_service_id=#{websiteServiceId} - and stat_time = DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic WHERE web_id != 0),INTERVAL 5 MINUTE) + and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE) - + SELECT web_id webId,SUM(link_num) count FROM galaxy.traffic_http_statistic t LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id=u.id where u.website_service_id=#{websiteServiceId} - and t.stat_time =(SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic WHERE web_id != 0) + and t.stat_time =#{statTime} GROUP BY t.web_id ORDER BY count desc limit 0,10 \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.java index d1b88fd..6031f24 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.java @@ -1,10 +1,9 @@ package com.nis.web.dao.dashboard; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; - import org.apache.ibatis.annotations.Param; import com.nis.domain.restful.dashboard.TrafficIpActiveStatistic; @@ -13,11 +12,12 @@ import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface TrafficIpActiveStatisticDao { - List getIpList(TrafficIpActiveStatistic trafficIpActiveStatistic); +// List getIpList(TrafficIpActiveStatistic trafficIpActiveStatistic); + TrafficIpActiveStatistic getMaxStatTime(); - ArrayList ipActiveFiveMinute(@Param("ipAddr") String ipAddr); + ArrayList ipActiveFiveMinute(@Param("ipAddr") String ipAddr,@Param("statTime")Date statTime); - ArrayList ipActiveOneHour(@Param("ipAddr") String ipAddr); + ArrayList ipActiveOneHour(@Param("ipAddr") String ipAddr,@Param("statTime")Date statTime); - ArrayList ipActiveChart(); + ArrayList ipActiveChart(@Param("statTime")Date statTime); } \ 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 1dc4e5a..438a4f9 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml @@ -17,38 +17,41 @@ stat_time - + SELECT MAX(stat_time) statTime FROM galaxy.traffic_ip_active_statistic + + + - select IFNULL(p.maxNum,0) linkNum, date_format(a.min5,'%Y-%m-%d %H:%i') time from - (select date_sub(date_format((select MAX(stat_time) from traffic_ip_active_statistic), '%Y-%m-%d %H:%i' ),interval @mycnt :=@mycnt + 5 MINUTE) min5 + (select date_sub(#{statTime},interval @mycnt :=@mycnt + 5 MINUTE) min5 from (SELECT @mycnt:=-5) m, traffic_ip_active_statistic limit 12) a LEFT JOIN ( SELECT date_format(stat_time, '%Y-%m-%d %H:%i') timestamp, max(link_num) maxNum FROM traffic_ip_active_statistic - WHERE ip_addr=#{ipAddr} AND stat_time > DATE_SUB((select MAX(stat_time) from traffic_ip_active_statistic), INTERVAL 1 HOUR) + WHERE ip_addr=#{ipAddr} AND stat_time > DATE_SUB(#{statTime,jdbcType=TIMESTAMP}, INTERVAL 1 HOUR) 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 ip_addr ipAddr,area_id areaId, 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 galaxy.traffic_ip_active_statistic WHERE ip_addr=#{ipAddr} - and stat_time > DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_ip_active_statistic),INTERVAL 1 HOUR) + and stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR) ORDER BY linkNum DESC LIMIT 1 - - - \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java index a910246..017c21a 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java @@ -1,5 +1,6 @@ package com.nis.web.dao.dashboard; +import java.util.Date; import java.util.List; import java.util.Map; @@ -10,6 +11,7 @@ import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface TrafficPortActiveStatisticDao { - List getPortActiveList(); - TrafficPortActiveStatistic getPortActiveOld(@Param("port")Integer port); + TrafficPortActiveStatistic getMaxStatTime(); + List getPortActiveList(@Param("statTime")Date statTime); + TrafficPortActiveStatistic getPortActiveOld(@Param("port")Integer port,@Param("statTime")Date statTime); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml index 4c498ea..8891adc 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml @@ -7,16 +7,22 @@ + + + + - SELECT SUM(sum) sum from galaxy.traffic_port_active_statistic - WHERE port=#{port} and stat_time = DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_port_active_statistic),INTERVAL 5 MINUTE) + WHERE port=#{port} and stat_time = DATE_SUB(#{statTime},INTERVAL 5 MINUTE) GROUP BY port ORDER BY sum DESC limit 0,10 \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java index 474bf52..940f019 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java @@ -1,11 +1,16 @@ package com.nis.web.dao.dashboard; +import java.util.Date; import java.util.List; import java.util.Map; +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.restful.dashboard.TrafficProtocolStatistic; import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface TrafficProtocolStatisticDao { - List protocolChart(); + TrafficProtocolStatistic getMaxStatTime(); + List protocolChart(@Param("statTime")Date statTime); } \ No newline at end of file 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 e88ef1a..3b6572a 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml @@ -15,8 +15,12 @@ stat_id, proto_type, entrance_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len, 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 ee102b7..de313c1 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.java @@ -1,5 +1,6 @@ package com.nis.web.dao.dashboard; +import java.util.Date; import java.util.List; import java.util.Map; @@ -9,20 +10,22 @@ import com.nis.domain.restful.dashboard.TrafficUaStatistic; import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface TrafficUaStatisticDao { - - List systemList(); - - List getBrowserBySystem(@Param("osType") Integer osType); - - List browserList(); - - List getSystemBybrowser(@Param("bsType") Integer bsType); - Map systemOthers(@Param("bsType") List bsType,@Param("osType") Integer osType); + TrafficUaStatistic getMaxStatTime(); - Map browserOthers(@Param("osType") List osType,@Param("bsType") Integer bsType); + List systemList(@Param("statTime") Date statTime); + + List getBrowserBySystem(@Param("osType") Integer osType,@Param("statTime") Date statTime); + + List browserList(@Param("statTime") Date statTime); + + List getSystemBybrowser(@Param("bsType") Integer bsType,@Param("statTime") Date statTime); - Integer preSystemListCount(@Param("osType") Integer osType); + Map systemOthers(@Param("bsType") List bsType,@Param("osType") Integer osType,@Param("statTime") Date statTime); - Integer preBrowserListCount(@Param("bsType") Integer bsType); + Map browserOthers(@Param("osType") List osType,@Param("bsType") Integer bsType,@Param("statTime") Date statTime); + + Integer preSystemListCount(@Param("osType") Integer osType,@Param("statTime") Date statTime); + + Integer preBrowserListCount(@Param("bsType") Integer bsType,@Param("statTime") Date statTime); } \ 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 67f26e7..a922340 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml @@ -16,27 +16,31 @@ stat_id, bs_type,os_type, entrance_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len, stat_time + + \ 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 da11ceb..73a142e 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -1,6 +1,7 @@ package com.nis.web.service.restful; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -10,9 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.nis.domain.Page; +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; @@ -46,10 +50,21 @@ public class DashboardService extends BaseService{ * @return Map */ public List getTotalReportList(){ - List totalReportList = ntcTotalReportDao.getTotalReportList(); + List totalReportList =new ArrayList(); + NtcTotalReport maxReportTime = ntcTotalReportDao.getMaxReportTime(); + if(maxReportTime!=null&&maxReportTime.getReportTime()!=null) { + Date reportTime = maxReportTime.getReportTime(); + totalReportList = ntcTotalReportDao.getTotalReportList(reportTime); + } + Map maxRecvtTime = ntcTotalReportDao.getMaxRecvTime(); + List newData = new ArrayList(); + List oldData = new ArrayList(); + if(maxRecvtTime!=null&&maxRecvtTime.get("recvTime")!=null) { + Date recvTime = (Date) maxRecvtTime.get("recvTime"); + newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime); + oldData = ntcTotalReportDao.getNetFlowPortInfoOld(recvTime); + } //统计带宽的流入流出 单位 五分钟 的 byte - List newData = ntcTotalReportDao.getNetFlowPortInfoNew(); - List oldData = ntcTotalReportDao.getNetFlowPortInfoOld(); Double inoctets=0d; Double outoctets=0d; if(newData!=null&&newData.size()>0&&oldData!=null&&oldData.size()>0&&newData.get(0)!=null&&oldData.get(0)!=null){ @@ -75,27 +90,30 @@ public class DashboardService extends BaseService{ return totalReportList; } /** - * 当前时间五分钟数据 + * 最近活跃端口时间五分钟数据 * @return */ public List getPortActiveList(){ List list = new ArrayList(); - List portActiveList = trafficPortActiveStatisticDao.getPortActiveList(); - //上个时间五分钟数据 - if(portActiveList!=null&&portActiveList.size()>0) { - for (TrafficPortActiveStatistic port : portActiveList) { - if(port.getPort()!=null) { - Map map = new HashMap(); - - map.put("port", port.getPort()); - map.put("sum", port.getSum()); - TrafficPortActiveStatistic portActiveOld = trafficPortActiveStatisticDao.getPortActiveOld(port.getPort()); - if(portActiveOld!=null&&portActiveOld.getSum()!=null){ - map.put("preSum",portActiveOld.getSum()); - }else{ - map.put("preSum",0); + TrafficPortActiveStatistic maxStatTime = trafficPortActiveStatisticDao.getMaxStatTime(); + if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) { + Date statTime = maxStatTime.getStatTime(); + List portActiveList = trafficPortActiveStatisticDao.getPortActiveList(statTime); + //上个时间五分钟数据 + if(portActiveList!=null&&portActiveList.size()>0) { + for (TrafficPortActiveStatistic port : portActiveList) { + if(port.getPort()!=null) { + Map map = new HashMap(); + map.put("port", port.getPort()); + map.put("sum", port.getSum()); + TrafficPortActiveStatistic portActiveOld = trafficPortActiveStatisticDao.getPortActiveOld(port.getPort(),statTime); + if(portActiveOld!=null&&portActiveOld.getSum()!=null){ + map.put("preSum",portActiveOld.getSum()); + }else{ + map.put("preSum",0); + } + list.add(map); } - list.add(map); } } } @@ -106,37 +124,40 @@ public class DashboardService extends BaseService{ * 分页查询活跃IPtop100 * @return */ - public Page getIpList(Page page,TrafficIpActiveStatistic entry){ +/* public Page getIpList(Page page,TrafficIpActiveStatistic entry){ // 设置分页参数 entry.setPage(page); // 执行分页查询 page.setList(trafficIpActiveStatisticDao.getIpList(entry)); return page; - } + }*/ public List ipActiveFiveMinute(){ - - ArrayList list = trafficIpActiveStatisticDao.ipActiveChart(); + TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime(); ArrayList listMap=new ArrayList(); - if(list!=null&&list.size()>0) { - for (LinkedHashMap map : list) { - HashMap m = new HashMap(); - if(map.get("ipAddr")!=null) { - String ipAddr = (String) map.get("ipAddr"); - m.put("ipAddr", ipAddr); - ArrayList ipList = trafficIpActiveStatisticDao.ipActiveFiveMinute(ipAddr); - List linkList = new ArrayList(); - List timeList = new ArrayList(); - if(ipList!=null&&ipList.size()>0) { - for (TrafficIpActiveStatistic ip : ipList) { - if(ip.getLinkNum()!=null&&ip.getTime()!=null) { - linkList.add(ip.getLinkNum()); - timeList.add(ip.getTime()); + if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) { + Date statTime = maxStatTime.getStatTime(); + ArrayList list = trafficIpActiveStatisticDao.ipActiveChart(statTime); + if(list!=null&&list.size()>0) { + for (LinkedHashMap map : list) { + HashMap m = new HashMap(); + if(map.get("ipAddr")!=null) { + String ipAddr = (String) map.get("ipAddr"); + m.put("ipAddr", ipAddr); + ArrayList ipList = trafficIpActiveStatisticDao.ipActiveFiveMinute(ipAddr,statTime); + List linkList = new ArrayList(); + List timeList = new ArrayList(); + if(ipList!=null&&ipList.size()>0) { + for (TrafficIpActiveStatistic ip : ipList) { + if(ip.getLinkNum()!=null&&ip.getTime()!=null) { + linkList.add(ip.getLinkNum()); + timeList.add(ip.getTime()); + } } } + m.put("linkNum",linkList); + m.put("statTime",timeList); + listMap.add(m); } - m.put("linkNum",linkList); - m.put("statTime",timeList); - listMap.add(m); } } } @@ -144,35 +165,73 @@ public class DashboardService extends BaseService{ return listMap; } public List ipActiveOneHour(){ - - ArrayList list = trafficIpActiveStatisticDao.ipActiveChart(); + TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime(); ArrayList listMap=new ArrayList(); - if(list!=null&&list.size()>0) { - for (LinkedHashMap map : list) { - if(map.get("ipAddr")!=null) { - String ipAddr = (String) map.get("ipAddr"); - ArrayList iplList = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr); - listMap.add(iplList.get(0)); + if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) { + Date statTime = maxStatTime.getStatTime(); + ArrayList list = trafficIpActiveStatisticDao.ipActiveChart(statTime); + if(list!=null&&list.size()>0) { + for (LinkedHashMap map : list) { + if(map.get("ipAddr")!=null) { + String ipAddr = (String) map.get("ipAddr"); + ArrayList iplList = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr,statTime); + listMap.add(iplList.get(0)); + } } } } return listMap; } + @SuppressWarnings("rawtypes") public List ipActiveChart(){ - - ArrayList list = trafficIpActiveStatisticDao.ipActiveChart(); - + TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime(); + ArrayList list = new ArrayList<>(); + if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) { + Date statTime = maxStatTime.getStatTime(); + list = trafficIpActiveStatisticDao.ipActiveChart(statTime); + if(list!=null&&list.size()>0) { + for (LinkedHashMap map : list) { + if(map.get("ipAddr")!=null) { + Map m = new LinkedHashMap(); + map.put("pktNum",0); + map.put("byteLen",0); + } + } + } + } return list; } public List protocolChart() { - List list = trafficProtocolStatisticDao.protocolChart(); + TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime(); + List list=new ArrayList(); + if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) { + Date statTime = maxStatTime.getStatTime(); + list = trafficProtocolStatisticDao.protocolChart(statTime); + //当不查询包,字节时 设为0 + if(list!=null&&list.size()>0) { + Map map = new HashMap(); + map.put("pktNum",0); + map.put("byteLen",0); + } + } return list; } public List appChart() { - List list = trafficAppStatisticDao.appChart(); + List list=new ArrayList(); + TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime(); + if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) { + Date statTime = maxStatTime.getStatTime(); + list = trafficAppStatisticDao.appChart(statTime); + //当不查询包,字节时 设为0 + if(list!=null&&list.size()>0) { + Map map = new HashMap(); + map.put("pktNum",0); + map.put("byteLen",0); + } + } return list; } @@ -180,101 +239,121 @@ public class DashboardService extends BaseService{ @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); + TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + Date statTime = maxStatTime.getStatTime(); + List list = trafficUaStatisticDao.systemList(statTime); + Integer preCount=0; + for (TrafficUaStatistic ua : list) { + Map map = new HashMap(); + map.put("osType",ua.getOsType()); + map.put("count",ua.getCount()); + map.put("pktNum",0); + map.put("byteLen",0); + preCount = trafficUaStatisticDao.preSystemListCount(ua.getOsType(),statTime);//上个时段的量 用于与现在对比 + 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); - } + List list = new ArrayList(); + TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + Date statTime = maxStatTime.getStatTime(); + list = trafficUaStatisticDao.getBrowserBySystem(osType,statTime); + 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,statTime); + 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; - if(list!=null&&list.size()>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); + TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + Date statTime = maxStatTime.getStatTime(); + List list = trafficUaStatisticDao.browserList(statTime); + Integer preCount=0; + if(list!=null&&list.size()>0){ + for (TrafficUaStatistic ua : list) { + Map map = new HashMap(); + map.put("bsType",ua.getBsType()); + map.put("count",ua.getCount()); + map.put("pktNum",0); + map.put("byteLen",0); + preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType(),statTime);//上个时段的量 用于与现在对比 + if(preCount!=null){ + map.put("preCount",preCount); + }else{ + map.put("preCount",0); + } + result.add(map); + } } - 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); - } + List list = new ArrayList(); + TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + Date statTime = maxStatTime.getStatTime(); + list = trafficUaStatisticDao.getSystemBybrowser(bsType,statTime); + 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,statTime); + 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; - if(list!=null&&list.size()>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); + TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + List list = trafficHttpStatisticDao.websiteList(maxStatTime.getStatTime()); + Integer preCount=0; + if(list!=null&&list.size()>0){ + for (TrafficHttpStatistic website : list) { + Map map = new HashMap(); + map.put("webId",website.getWebId()); + map.put("count",website.getCount()); + map.put("pktNum",0); + map.put("byteLen",0); + preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId(),maxStatTime.getStatTime());//上个时段的量 用于与现在对比 + if(preCount!=null){ + map.put("preCount",preCount); + }else{ + map.put("preCount",0); + } + result.add(map); } - result.add(map); - } + } } return result; } @@ -284,19 +363,24 @@ public class DashboardService extends BaseService{ * @return list */ public List getDomainByWebsiteServiceId(Integer websiteServiceId ){ - List list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId); - List webIdList = new ArrayList(); - //查询固定网站下的域名除了TOP10以外的others域名 - if(list!=null&& list.size()>0){ - for (Map map : list) { - webIdList.add(map.get("webId")); - } - Map others = new HashMap(); - others = trafficHttpStatisticDao.websiteDomainOthers(webIdList,websiteServiceId); - if(others!=null&&others.size()>0){ - others.put("webId", "-1"); - list.add(others); - } + List list = new ArrayList(); + TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + Date statTime = maxStatTime.getStatTime(); + list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId,statTime); + List webIdList = new ArrayList(); + //查询固定网站下的域名除了TOP10以外的others域名 + if(list!=null&& list.size()>0){ + for (Map map : list) { + webIdList.add(map.get("webId")); + } + Map others = new HashMap(); + others = trafficHttpStatisticDao.websiteDomainOthers(webIdList,websiteServiceId,statTime); + if(others!=null&&others.size()>0){ + others.put("webId", "-1"); + list.add(others); + } + } } return list; } @@ -307,26 +391,29 @@ public class DashboardService extends BaseService{ */ @SuppressWarnings("unchecked") public List getDomainByWebsiteList(){ - List websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(); List result = new ArrayList(); - if(websiteList!=null&&websiteList.size()>0){ - Integer preCount=0; - for (TrafficHttpStatistic website : websiteList) { - Map map = new HashMap(); - map.put("websiteServiceId",website.getWesiteServiceId()); - map.put("count",website.getCount()); - map.put("pktNum",website.getPktNum()); - map.put("byteLen",website.getByteLen()); - preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWesiteServiceId());//上个时段的量 用于与现在对比 - if(preCount!=null){ - map.put("preCount",preCount); - }else{ - map.put("preCount",0); + TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + Date statTime = maxStatTime.getStatTime(); + List websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime); + if(websiteList!=null&&websiteList.size()>0){ + Integer preCount=0; + for (TrafficHttpStatistic website : websiteList) { + Map map = new HashMap(); + map.put("websiteServiceId",website.getWesiteServiceId()); + map.put("count",website.getCount()); + map.put("pktNum",0); + map.put("byteLen",0); + preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWesiteServiceId(),statTime);//上个时段的量 用于与现在对比 + if(preCount!=null){ + map.put("preCount",preCount); + }else{ + map.put("preCount",0); + } + result.add(map); } - result.add(map); } } - return result; } /** @@ -334,16 +421,21 @@ public class DashboardService extends BaseService{ * * **/ public List getTopicAndDomainList(){ - //按照主题分类 获得主题 - List topicList = trafficHttpStatisticDao.getDomainByTopicList(); - if(topicList!=null&&topicList.size()>0){ - for (Map m : topicList) { - List domainList= new ArrayList(); - if(m!=null&&m.get("topicId")!=null){ - domainList = trafficHttpStatisticDao.getDomainByTopicId(m.get("topicId")); - m.put("domainData", domainList); + List topicList = new ArrayList(); + TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime(); + if(maxStatTime!=null) { + Date statTime = maxStatTime.getStatTime(); + //按照主题分类 获得主题 + topicList = trafficHttpStatisticDao.getDomainByTopicList(statTime); + if(topicList!=null&&topicList.size()>0){ + for (Map m : topicList) { + List domainList= new ArrayList(); + if(m!=null&&m.get("topicId")!=null){ + domainList = trafficHttpStatisticDao.getDomainByTopicId(m.get("topicId"),statTime); + m.put("domainData", domainList); + } } - } + } } return topicList; }