From 59a36d63e11d69285107e77eb68849c348a2eedd Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Wed, 26 Sep 2018 16:29:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=81=E9=87=8F=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=B8=A6=E5=AE=BD=E6=B5=81=E5=87=BA=E6=B5=81=E5=85=A5?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/dao/dashboard/NtcTotalReportDao.java | 2 ++ .../web/dao/dashboard/NtcTotalReportDao.xml | 11 ++++++++- .../dao/dashboard/TrafficHttpStatisticDao.xml | 1 - .../web/service/restful/DashboardService.java | 24 +++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) 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 052222e..96fc54b 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -8,4 +8,6 @@ import com.nis.web.dao.MyBatisDao; public interface NtcTotalReportDao { List getTotalReportList(); + List getNetFlowPortInfoNew(); + List getNetFlowPortInfoOld(); } \ 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 d1db7af..c07e98d 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -19,6 +19,15 @@ + + \ 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 bb768fe..2f560bf 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -19,7 +19,6 @@ SELECT SUM(link_num) count, IFNULL( website_service_id, 268435455 ) websiteServiceId ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.TRAFFIC_HTTP_STATISTIC t LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id = u.id - and t.stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 5 MINUTE) GROUP BY u.website_service_id ORDER BY count limit 0,10 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 68ca65c..6e1faad 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -47,6 +47,30 @@ public class DashboardService extends BaseService{ */ public List getTotalReportList(){ List totalReportList = ntcTotalReportDao.getTotalReportList(); + //统计带宽的流入流出 单位 五分钟 的 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){ + Double newInoctets=Double.parseDouble(newData.get(0).get("inoctets").toString()) ; + Double newOutoctets=Double.parseDouble(newData.get(0).get("outoctets").toString()) ; + Double oldInoctets=Double.parseDouble(oldData.get(0).get("inoctets").toString()); + Double oldOutoctets=Double.parseDouble(oldData.get(0).get("outoctets").toString()); + //结果为当前五分钟减去上个五分钟 + inoctets=newInoctets-oldInoctets; + outoctets=newOutoctets-oldOutoctets; + if(inoctets<0||outoctets<0){ + inoctets=0d; + outoctets=0d; + } + } + if(totalReportList!=null&&totalReportList.size()>0){ + for (Map map : totalReportList) { + map.put("inoctets", inoctets); + map.put("outoctets", outoctets); + } + } return totalReportList; }