From 13b279de13fe37dfe606df6d9fb829fdd2435833 Mon Sep 17 00:00:00 2001 From: wangwenrui Date: Mon, 17 Dec 2018 23:41:00 +0800 Subject: [PATCH] =?UTF-8?q?traffic=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restful/DashboardServiceController.java | 98 ++++++++++++++ .../web/dao/dashboard/NtcTotalReportDao.java | 5 +- .../web/dao/dashboard/NtcTotalReportDao.xml | 18 ++- .../web/service/restful/DashboardService.java | 122 ++++++++++++++++++ 4 files changed, 241 insertions(+), 2 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 06ad51e..a71553e 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -187,6 +187,104 @@ public class DashboardServiceController extends BaseRestController { } return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "带宽实时统计数据检索成功",list, 0); } + /** + * 根据ip46,协议tcp,udp查询带宽 + */ + @RequestMapping(value = "trafficBandwidthTransThree", method = RequestMethod.GET) + @ApiOperation(value = "带宽根据ip46,协议tcp,udp查询详情", httpMethod = "GET", notes = "对应带宽根据IPv4,6,协议tcp,udp统计数据显示") + public Map trafficBandwidthTransThree(String beginDate,String endDate,Model model, HttpServletRequest request, HttpServletResponse response) { + String[] addrTypes=dashboardService.getFiledTypeByName("addr_type"); + String[] transTypes=dashboardService.getFiledTypeByName("trans_type"); + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); + Map> resultMap=new HashMap>(); + try { + if(StringUtils.isEmpty(beginDate)||StringUtils.isEmpty(endDate)) { + Calendar cal = Calendar. getInstance (); + cal.setTime(new Date()); + endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间 + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); + beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime()); + } + String addrType=null; + Integer transType=null; + if(addrTypes!=null){ + for(int i=0;i resultList = dashboardService.getBandwidthTrans(addrType, transType,beginDate,endDate); + if (resultList!=null&&resultList.size() > 0) { + resultMap.put("ipv"+addrType+"Type1", resultList); + } + + resultList = dashboardService.getBandwidthTrans2(addrType, transType,beginDate,endDate); + if (resultList!=null&&resultList.size() > 0) { + resultMap.put("ipv"+addrType+"Type2", resultList); + } + addrType=null; + } + } + if(transTypes!=null){ + for(int i=0;i resultList = dashboardService.getBandwidthTrans(addrType, transType,beginDate,endDate); + if (resultList!=null&&resultList.size() > 0) { + resultMap.put("trans"+transType+"Type1", resultList); + } + resultList = dashboardService.getBandwidthTrans2(addrType, transType,beginDate,endDate); + if (resultList!=null&&resultList.size() > 0) { + resultMap.put("trans"+transType+"Type2", resultList); + } + transType=null; + } + } + + + } catch (Exception e) { + auditLogThread.setExceptionInfo("带宽实时统计数据检索失败:"+e.getMessage()); + logger.error("带宽实时统计数据检索失败:"+ExceptionUtil.getExceptionMsg(e)); + if (e instanceof RestServiceException) { + throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start, + "带宽实时统计数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode()); + } else if (e instanceof ServiceRuntimeException) { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "带宽实时统计数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode()); + } else { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "带宽实时统计数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue()); + } + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "带宽实时统计数据检索成功",resultMap, 0); + } + /** + * 根据ip46,协议tcp,udp查询带宽 + */ + @RequestMapping(value = "trafficBandwidthTransFour", method = RequestMethod.GET) + @ApiOperation(value = "带宽根据ip46,协议tcp,udp查询详情", httpMethod = "GET", notes = "对应带宽根据IPv4,6,协议tcp,udp统计数据显示") + public Map trafficBandwidthTransFour(String beginDate,String endDate,Model model, HttpServletRequest request, HttpServletResponse response) { + String[] addrTypes=dashboardService.getFiledTypeByName("addr_type"); + String[] transTypes=dashboardService.getFiledTypeByName("trans_type"); + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); + Map> resultMap=new HashMap>(); + try { + resultMap = dashboardService.getBandwidthTransEntrance(beginDate, endDate); + + } catch (Exception e) { + auditLogThread.setExceptionInfo("带宽实时统计数据检索失败:"+e.getMessage()); + logger.error("带宽实时统计数据检索失败:"+ExceptionUtil.getExceptionMsg(e)); + if (e instanceof RestServiceException) { + throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start, + "带宽实时统计数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode()); + } else if (e instanceof ServiceRuntimeException) { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "带宽实时统计数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode()); + } else { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "带宽实时统计数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue()); + } + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "带宽实时统计数据检索成功",resultMap, 0); + } /** * 流量统计活跃端口统计 */ 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 a69287c..d455699 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -17,7 +17,10 @@ public interface NtcTotalReportDao { List getTotalReportList(@Param("reportTime") Date reportTime); List getNetFlowPortInfoNew(@Param("statTime") Date statTime); List getBandwidthTrans(@Param("entranceId") Integer entranceId,@Param("beginDate") String beginDate,@Param("endDate") String endDate,@Param("addrType") String addrType,@Param("transType") Integer transType); - + String getAddrType(); + String getTransType(); + String getEntranceId(); + List getBandwidthTrans2(@Param("beginDate") String beginDate,@Param("endDate") String endDate); Map getEntranceMaxReportTime(); List getActionTrans(@Param("beginDate") String beginDate,@Param("endDate") String endDate ,@Param("entranceId") Integer entranceId,@Param("serviceSql") String serviceSql); } \ 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 f6c39cd..05e952b 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -82,8 +82,24 @@ and entrance_id=#{entranceId} group by stat_time order by stat_time + + - + + +