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 2f261a5..8564b63 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -1,6 +1,9 @@ package com.nis.web.controller.restful; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -20,6 +23,7 @@ import com.nis.restful.ServiceRuntimeException; import com.nis.util.Constants; import com.nis.util.ExceptionUtil; import com.nis.util.JsonMapper; +import com.nis.util.StringUtils; import com.nis.web.controller.BaseRestController; import com.nis.web.service.AuditLogThread; import com.nis.web.service.ServicesRequestLogService; @@ -90,13 +94,49 @@ public class DashboardServiceController extends BaseRestController { */ @RequestMapping(value = "trafficBandwidthTrans", method = RequestMethod.GET) @ApiOperation(value = "带宽根据ip46,协议tcp,udp查询详情", httpMethod = "GET", notes = "对应带宽根据IPv4,6,协议tcp,udp统计数据显示") - public Map trafficBandwidthTrans(String addrType,Integer transType,Model model, HttpServletRequest request, HttpServletResponse response) { - + public Map trafficBandwidthTrans(String beginDate,String endDate,String addrType,Integer transType,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 resultList = dashboardService.getBandwidthTrans(addrType, transType); + 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()); + } + List resultList = dashboardService.getBandwidthTrans(addrType, transType,beginDate,endDate); + if (resultList!=null&&resultList.size() > 0) { + list = resultList; + } + } catch (Exception e) { + e.printStackTrace(); + auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause()); + logger.error("带宽实时统计数据检索失败"+ExceptionUtil.getExceptionMsg(e)); + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "带宽实时统计数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue()); + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "带宽实时统计数据检索成功",list, 0); + } + /** + * 根据ip46,协议tcp,udp查询带宽 + */ + @RequestMapping(value = "trafficBandwidthTransTwo", method = RequestMethod.GET) + @ApiOperation(value = "带宽根据ip46,协议tcp,udp查询详情", httpMethod = "GET", notes = "对应带宽根据IPv4,6,协议tcp,udp统计数据显示") + public Map trafficBandwidthTransTow(String beginDate,String endDate,String addrType,Integer transType,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 { + 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()); + } + List resultList = dashboardService.getBandwidthTrans2(addrType, transType,beginDate,endDate); if (resultList!=null&&resultList.size() > 0) { list = resultList; } 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 f3d3e33..adecd45 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -16,7 +16,7 @@ public interface NtcTotalReportDao { Map getMaxStatTime(); List getTotalReportList(@Param("reportTime") Date reportTime); List getNetFlowPortInfoNew(@Param("statTime") Date statTime); - List getBandwidthTrans(@Param("statTime") Date statTime,@Param("addrType") String addrType,@Param("transType") Integer transType); + List getBandwidthTrans(@Param("entranceId") Integer entranceId,@Param("beginDate") String beginDate,@Param("endDate") String endDate,@Param("addrType") String addrType,@Param("transType") Integer transType); Map getEntranceMaxReportTime(); List getActionTrans(@Param("reportTime") Date reportTime,@Param("entranceId") Integer entranceId,@Param("serviceSql") String serviceSql); 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 fce095e..4e409f1 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -23,7 +23,7 @@ @@ -45,7 +45,7 @@ - + select IFNULL(SUM(c2s_byte_len+s2c_byte_len),0) gbps,IFNULL(SUM(c2s_pkt_num+s2c_pkt_num),0) pps,IFNULL(SUM(link_num),0) linkNum, stat_time time from traffic_trans_statistic + where =#{beginDate}]]> + + and addr_type=#{addrType} + + + and trans_type=${transType} + + and entrance_id=#{entranceId} + group by stat_time order by stat_time + +