From 27b18c990112e96b5582f1d5bd35be7fbe912881 Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Sat, 22 Dec 2018 23:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E9=87=8F=E7=BB=9F=E8=AE=A1app.?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E3=80=82=E5=9F=9F=E5=90=8D=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2=EF=BC=8C=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E7=BB=9F=E8=AE=A1series=E4=B8=AD=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E7=BA=A7=E6=95=B0=E6=8D=AE=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=95=B0=E6=8D=AE=E8=A7=84=E5=BE=8B=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restful/DashboardServiceController.java | 8 ++-- .../dao/dashboard/TrafficAppStatisticDao.java | 2 +- .../dao/dashboard/TrafficAppStatisticDao.xml | 11 ++--- .../dashboard/TrafficHttpStatisticDao.java | 2 +- .../dao/dashboard/TrafficHttpStatisticDao.xml | 5 ++- .../TrafficProtocolStatisticDao.java | 3 +- .../dashboard/TrafficProtocolStatisticDao.xml | 11 ++--- .../web/service/restful/DashboardService.java | 42 +++++++++++++++---- 8 files changed, 57 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java index e713ed8..50f5a8c 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -312,14 +312,14 @@ public class DashboardServiceController extends BaseRestController { */ @RequestMapping(value = "trafficProtocolList", method = RequestMethod.GET) @ApiOperation(value = "协议统计占比与报表", httpMethod = "GET", notes = "对应协议统计详情占比与报表") - public Map trafficProtocolList(String beginDate, String endDate, Model model, HttpServletRequest request, + public Map trafficProtocolList(Integer[] protoType,String beginDate, String endDate, Model model, HttpServletRequest request, HttpServletResponse response) { long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); List list = new ArrayList(); try { - List ipActiveList = dashboardService.getProtocolList(beginDate, endDate); + List ipActiveList = dashboardService.getProtocolList(beginDate, endDate,protoType); if (ipActiveList != null && ipActiveList.size() > 0) { String jsonString = JsonMapper.toJsonString(ipActiveList); list = (java.util.List) JsonMapper.fromJsonList(jsonString, HashMap.class); @@ -507,7 +507,7 @@ public class DashboardServiceController extends BaseRestController { */ @RequestMapping(value = "trafficAppList", method = RequestMethod.GET) @ApiOperation(value = "App统计占比与报表", httpMethod = "GET", notes = "对应App统计详情占比与报表") - public Map trafficAppList(Integer appType, String beginDate, String endDate, Model model, + public Map trafficAppList(Integer[] appType, String beginDate, String endDate, Model model, HttpServletRequest request, HttpServletResponse response) { long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, @@ -697,7 +697,7 @@ public class DashboardServiceController extends BaseRestController { @RequestMapping(value = "trafficWebsiteListNoTime", method = RequestMethod.GET) @ApiOperation(value = "网站流量分析详情统计", httpMethod = "GET", notes = "对应网站http分类显示") - public Map trafficWebsiteListNoTime(Integer domain,Integer entranceId , @RequestParam String beginDate, @RequestParam String endDate,Model model, HttpServletRequest request, + public Map trafficWebsiteListNoTime(Integer domain[],Integer entranceId , @RequestParam String beginDate, @RequestParam String endDate,Model model, HttpServletRequest request, HttpServletResponse response) { long start = System.currentTimeMillis(); 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 a7d9225..9d06ec2 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.java @@ -13,5 +13,5 @@ public interface TrafficAppStatisticDao { TrafficAppStatistic getMaxStatTime(); List appChart(@Param("statTime")Date statTime); - List getAppList(@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("appType")Integer appType); + List getAppList(@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("appType")Integer[] appType); } \ 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 ed55e53..e6154ec 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml @@ -32,11 +32,12 @@ SELECT app_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets, ((SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024) AS GByte FROM traffic_app_statistic WHERE - - stat_time >= #{beginTime} and stat_time <= #{endTime} - - - and app_type=#{appType} + = #{beginTime} and stat_time<= #{endTime}]]> + + and app_type in + + #{item} + GROUP BY app_type ) p LEFT JOIN ui_code_app_dic c ON p.app_type=c.view_code ORDER BY p.GByte DESC 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 694fdfe..6288a5f 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java @@ -29,7 +29,7 @@ public interface TrafficHttpStatisticDao { List getTrafficHttpStatistic(@Param("statTime") Date statTime, @Param("endTime") Date endTime); List getIdByWebSiteId(@Param("websiteId") Integer websiteId); - List getTrafficHttpDomain(@Param("beginDate")Date beginDate,@Param("endDate") Date endDate,@Param("domain")Integer domain,@Param("entranceId")Integer entranceId); + List getTrafficHttpDomain(@Param("beginDate")Date beginDate,@Param("endDate") Date endDate,@Param("domain")Integer[] domain,@Param("entranceId")Integer entranceId); List getDomainTrans(@Param("entranceId")Integer entranceId,@Param("beginDate")String beginDate,@Param("endDate")String endDate,@Param("domain")Integer domain); } \ 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 b78c764..7ced884 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -127,7 +127,10 @@ FROM sum(c2s_pkt_num + s2c_pkt_num) pktCount from traffic_http_focus_statistic t where = #{beginDate} and stat_time< #{endDate}]]> - and web_id=#{domain} + and web_id in + + #{item} + and entrance_id=#{entranceId} 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 ccafd43..f551971 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java @@ -13,5 +13,6 @@ public interface TrafficProtocolStatisticDao { TrafficProtocolStatistic getMaxStatTime(); List protocolChart(@Param("statTime")Date statTime); - List getProtocolList(@Param("statTime")Date statTime,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + List getProtocolList(@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("protoType")Integer[] protoType); + } \ 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 0387eaa..e0a79c5 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml @@ -29,11 +29,12 @@ SELECT proto_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets, ((SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024) AS GByte FROM traffic_protocol_statistic WHERE - - stat_time > DATE_SUB(#{statTime},INTERVAL 1 HOUR) - - - stat_time >= #{beginTime} and stat_time <= #{endTime} + = #{beginTime} and stat_time<= #{endTime}]]> + + and proto_type in + + #{item} + GROUP BY proto_type ) p LEFT JOIN ui_code_protocol_type_dic c ON p.proto_type=c.view_code ORDER BY p.GByte DESC 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 7499cd7..40d9540 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -592,13 +592,13 @@ public class DashboardService extends BaseService { * * @return */ - public List getProtocolList(String startTime, String endTime) { - TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime(); + public List getProtocolList(String startTime, String endTime,Integer[] protoType) { +// TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime(); List list = new ArrayList(); - if (maxStatTime != null && maxStatTime.getStatTime() != null) { - Date statTime = maxStatTime.getStatTime(); - list = trafficProtocolStatisticDao.getProtocolList(statTime, startTime, endTime); - } +// if (maxStatTime != null && maxStatTime.getStatTime() != null) { +// Date statTime = maxStatTime.getStatTime(); + list = trafficProtocolStatisticDao.getProtocolList(startTime, endTime,protoType); +// } return list; } @@ -628,7 +628,7 @@ public class DashboardService extends BaseService { * * @return */ - public List getAppList(String startTime, String endTime, Integer appType) { + public List getAppList(String startTime, String endTime, Integer[] appType) { // TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime(); List list = new ArrayList(); // if (maxStatTime != null && maxStatTime.getStatTime() != null) { @@ -830,7 +830,7 @@ public class DashboardService extends BaseService { * @param endDate * @return */ - public List getWebsiteDetails(Date beginDate, Date endDate, Integer domain, Integer entranceId) { + public List getWebsiteDetails(Date beginDate, Date endDate, Integer domain[], Integer entranceId) { List list = trafficHttpStatisticDao.getTrafficHttpDomain(beginDate, endDate, domain, entranceId); return list; } @@ -997,7 +997,10 @@ public class DashboardService extends BaseService { // String linkNumStr = String.valueOf(webIdAndCountMap.get("linkNum")); // String packetsStr = String.valueOf(webIdAndCountMap.get("pktCount")); if (countStr != null) { - count += Long.parseLong(countStr);// 将count累加 + Long pl = (Long.parseLong(countStr))/(1024*1024*1024); + if(pl>0) { + count += Long.parseLong(countStr);// 将count累加 转换单位小于0的不加 + } } // if (linkNumStr != null) { // linkNum += Long.parseLong(linkNumStr);// 将count累加 @@ -1011,6 +1014,27 @@ public class DashboardService extends BaseService { } } } + Collections.sort(list, new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if(o1==null&&o2!=null){ + return 1; + } + if(o1!=null&&o2==null){ + return -1; + } + if(o1==o2&&o1==null){ + return 0; + } + Map m1=(Map)o1; + Map m2=(Map)o2; + Object ob1 = m1.get("byteCount"); + Object ob2 = m2.get("byteCount"); + Long b1=Long.parseLong(ob1.toString()); + Long b2=Long.parseLong(ob2.toString()); + return -(b1).compareTo(b2); + } + }); if (list.size() > 0) { viewMap.put("count", count); // viewMap.put("linkNum", linkNum);