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 6f7d89e..e713ed8 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -212,76 +212,15 @@ public class DashboardServiceController extends BaseRestController { String[] transTypes=dashboardService.getFiledTypeByName("trans_type"); long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); - Map> resultMap=new HashMap>(); + Map resultMap=new HashMap(); try { - if(StringUtils.isEmpty(beginDate)||StringUtils.isEmpty(endDate)) { + 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) { @@ -499,7 +438,7 @@ public class DashboardServiceController extends BaseRestController { long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); - List list = new ArrayList(); + List list = new ArrayList(); try { Date begin = null; Date end = null; @@ -507,7 +446,7 @@ public class DashboardServiceController extends BaseRestController { begin = DateUtils.parseDate(beginDate); end = DateUtils.parseDate(endDate); } - List ipActiveChart = dashboardService.ipActiveFiveMinute(begin, end); + List ipActiveChart = dashboardService.ipActiveFiveMinute(begin, end); if (ipActiveChart != null && ipActiveChart.size() > 0) { list = ipActiveChart; } 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 d455699..4942c7b 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -17,6 +17,8 @@ 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); + List getBandwidthTransIPVx(@Param("beginDate") String beginDate,@Param("endDate") String endDate); + List getBandwidthTransProtocol(@Param("beginDate") String beginDate,@Param("endDate") String endDate); String getAddrType(); String getTransType(); String getEntranceId(); 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 744e4f5..88990cd 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -39,10 +39,6 @@ SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=2 ) total_traffic - - - - + + + - - - + SELECT ip_addr ipAddr,SUM(c2s_byte_len + s2c_byte_len) linkNum FROM traffic_ip_active_statistic WHERE + stat_id BETWEEN + (select stat_id from traffic_ip_active_statistic where= #{beginDate} order by stat_id limit 1)]]> + AND + (select stat_id from traffic_ip_active_statistic where + GROUP BY ip_addr ORDER BY linkNum DESC LIMIT 0,10 @@ -47,10 +55,17 @@ 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,SUM(c2s_byte_len+s2c_byte_len) count ,stat_time from traffic_ip_active_statistic + WHERE + = #{beginDate} and stat_time<#{endDate} GROUP BY stat_time,ip_addr order by stat_time asc]]>