From 53c8f2279b266d177edf205235ecb9cd2ef792e7 Mon Sep 17 00:00:00 2001 From: shangguanyanfei Date: Mon, 21 Jan 2019 14:49:55 +0800 Subject: [PATCH] =?UTF-8?q?1.Traffic=20Statistic=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=92=8CProtocol=20Statistic=E9=A1=B5=E9=9D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0direction=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=202.?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E9=82=AE=E4=BB=B6=E6=97=A5=E5=BF=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=89=80=E6=9C=89=E5=8A=A8=E4=BD=9C=E6=97=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=9A=E4=B8=AAservice=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restful/DashboardServiceController.java | 13 +++++----- .../restful/NtcLogSearchController.java | 6 ++--- .../web/dao/dashboard/NtcTotalReportDao.java | 4 +-- .../web/dao/dashboard/NtcTotalReportDao.xml | 2 ++ .../TrafficProtocolStatisticDao.java | 2 +- .../dashboard/TrafficProtocolStatisticDao.xml | 5 +++- .../com/nis/web/service/BaseLogService.java | 25 +++++++++++++------ .../com/nis/web/service/LogDataService.java | 10 ++------ .../web/service/restful/DashboardService.java | 10 ++++---- 9 files changed, 44 insertions(+), 33 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 837d7fb..56ad55c 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -218,19 +218,20 @@ public class DashboardServiceController extends BaseRestController { */ @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,String searchQuotaType,Model model, HttpServletRequest request, HttpServletResponse response) { + public Map trafficBandwidthTransThree(String beginDate,String endDate,String searchQuotaType,Model model,Integer searchDirection, + HttpServletRequest request, HttpServletResponse response) { 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 (); + 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()); } - resultMap = dashboardService.getBandwidthTransEntrance(beginDate, endDate,searchQuotaType); + resultMap = dashboardService.getBandwidthTransEntrance(beginDate, endDate,searchQuotaType,searchDirection); } catch (Exception e) { auditLogThread.setExceptionInfo("带宽实时统计数据检索失败:"+e.getMessage()); @@ -321,14 +322,14 @@ public class DashboardServiceController extends BaseRestController { */ @RequestMapping(value = "trafficProtocolList", method = RequestMethod.GET) @ApiOperation(value = "协议统计占比与报表", httpMethod = "GET", notes = "对应协议统计详情占比与报表") - public Map trafficProtocolList(Integer[] protoType,String beginDate, String endDate,Integer entranceId, Model model, HttpServletRequest request, - HttpServletResponse response) { + public Map trafficProtocolList(Integer[] protoType,String beginDate, String endDate,Integer entranceId, Model model, + Integer searchDirection,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,protoType,entranceId); + List ipActiveList = dashboardService.getProtocolList(beginDate, endDate,protoType,entranceId,searchDirection); if (ipActiveList != null && ipActiveList.size() > 0) { String jsonString = JsonMapper.toJsonString(ipActiveList); list = (java.util.List) JsonMapper.fromJsonList(jsonString, HashMap.class); diff --git a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java index 22a9960..a69129d 100644 --- a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java +++ b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java @@ -180,9 +180,9 @@ public class NtcLogSearchController extends BaseRestController { AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); //判断searchCfgId是否为null - if(ntcMailLog.getSearchCfgId() ==null){ - ntcMailLog.setSearchCfgId("-1"); - } +// if(ntcMailLog.getSearchCfgId() ==null){ +// ntcMailLog.setSearchCfgId("-1"); +// } try { resetTime(ntcMailLog); ntcLogService.queryConditionCheck(auditLogThread, start, ntcMailLog, NtcMailLog.class, page); 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 87f21d0..9fb8a38 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -19,8 +19,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); + List getBandwidthTransIPVx(@Param("beginDate") String beginDate,@Param("endDate") String endDate,@Param("searchDirection") Integer searchDirection); + List getBandwidthTransProtocol(@Param("beginDate") String beginDate,@Param("endDate") String endDate,@Param("searchDirection") Integer searchDirection); 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 3fd068b..cd75f4b 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -73,11 +73,13 @@ WHERE = #{beginDate} and stat_time < #{endDate} ]]> and addr_type in (4,6) + and direction =#{searchDirection} group by addr_type,stat_time ,entrance_id order by stat_time 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 839c05c..091090c 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.java @@ -13,6 +13,6 @@ public interface TrafficProtocolStatisticDao { TrafficProtocolStatistic getMaxStatTime(); List protocolChart(@Param("statTime")Date statTime); - List getProtocolList(@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("protoType")Integer[] protoType,@Param("entranceId")Integer entranceId); + List getProtocolList(@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("protoType")Integer[] protoType,@Param("entranceId")Integer entranceId,@Param("searchDirection")Integer searchDirection); } \ 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 17e989e..4b006e9 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml @@ -37,7 +37,10 @@ - and entrance_id=#{entranceId} + and entrance_id = #{entranceId} + + + and direction = #{searchDirection} 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/BaseLogService.java b/src/main/java/com/nis/web/service/BaseLogService.java index ac04d3f..410ee38 100644 --- a/src/main/java/com/nis/web/service/BaseLogService.java +++ b/src/main/java/com/nis/web/service/BaseLogService.java @@ -195,16 +195,27 @@ public abstract class BaseLogService { } catch (Exception e) { throw new RestServiceException("searchFoundStartTime参数错误", RestBusinessCode.param_formate_error.getValue()); } + //service参数改为可以传多个 + if (!StringUtil.isBlank(entity.getSearchService())) { + String[] splits = org.apache.commons.lang.StringUtils.split(entity.getSearchService(), ","); + for (String service : splits) { + try { + Integer.parseInt(service); + } catch (Exception e) { + throw new RestServiceException("searchService参数错误", RestBusinessCode.param_formate_error.getValue()); + } - try { - if (!StringUtil.isBlank(entity.getSearchService())) { - Integer.parseInt(entity.getSearchService()); } - } catch (NumberFormatException e) { - throw new RestServiceException("searchService参数格式错误", RestBusinessCode.param_formate_error.getValue()); - } catch (Exception e) { - throw new RestServiceException("searchService参数错误", RestBusinessCode.param_formate_error.getValue()); } +// try { +// if (!StringUtil.isBlank(entity.getSearchService())) { +// Integer.parseInt(entity.getSearchService()); +// } +// } catch (NumberFormatException e) { +// throw new RestServiceException("searchService参数格式错误", RestBusinessCode.param_formate_error.getValue()); +// } catch (Exception e) { +// throw new RestServiceException("searchService参数错误", RestBusinessCode.param_formate_error.getValue()); +// } try { checkCloumnIsExist(thread, start, clazz, page); } catch (RestServiceException e) { diff --git a/src/main/java/com/nis/web/service/LogDataService.java b/src/main/java/com/nis/web/service/LogDataService.java index 7cc6a13..2126b36 100644 --- a/src/main/java/com/nis/web/service/LogDataService.java +++ b/src/main/java/com/nis/web/service/LogDataService.java @@ -1004,7 +1004,8 @@ public class LogDataService { if (field.equals("cfg_id") || field.equals("web_id") || field.equals("app_id") - || field.equals("proto_id")) { + || field.equals("proto_id") + || field.equals("service")) { if (field.equals("cfg_id")) { if (value.toString().trim() .equals("0")) { @@ -1015,13 +1016,6 @@ public class LogDataService { + " =" + value.toString() .trim()); - } else if (value.toString() - .trim().equals("-1")) { - whereSB.append(" and " - + filedAndColumnMap - .get(key) - .toLowerCase() - + " >0"); } else { whereSB.append(" and " + filedAndColumnMap 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 983b771..cb51619 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -733,12 +733,12 @@ public class DashboardService extends BaseService { * * @return */ - public List getProtocolList(String startTime, String endTime, Integer[] protoType,Integer entranceId) { + public List getProtocolList(String startTime, String endTime, Integer[] protoType,Integer entranceId,Integer searchDirection) { // TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime(); List list = new ArrayList(); // if (maxStatTime != null && maxStatTime.getStatTime() != null) { // Date statTime = maxStatTime.getStatTime(); - list = trafficProtocolStatisticDao.getProtocolList(startTime, endTime, protoType,entranceId); + list = trafficProtocolStatisticDao.getProtocolList(startTime, endTime, protoType,entranceId,searchDirection); // } return list; } @@ -1290,13 +1290,13 @@ public class DashboardService extends BaseService { return fieldType == null ? null : fieldType.split(","); } - public Map getBandwidthTransEntrance(String beginDate, String endDate,String searchQuotaType) throws ParseException { + public Map getBandwidthTransEntrance(String beginDate, String endDate,String searchQuotaType,Integer searchDirection) throws ParseException { Map resultMap = new HashMap(); Map> listMap = new HashMap>(); List bandwidthListIPvx = new ArrayList(); List bandwidthListProtocol = new ArrayList(); - bandwidthListIPvx = ntcTotalReportDao.getBandwidthTransIPVx(beginDate, endDate); - bandwidthListProtocol = ntcTotalReportDao.getBandwidthTransProtocol(beginDate, endDate); + bandwidthListIPvx = ntcTotalReportDao.getBandwidthTransIPVx(beginDate, endDate,searchDirection); + bandwidthListProtocol = ntcTotalReportDao.getBandwidthTransProtocol(beginDate, endDate,searchDirection); Map trafficMap = new HashMap(); if ((!StringUtil.isEmpty(bandwidthListIPvx) && bandwidthListIPvx.size() > 0) || (!StringUtil.isEmpty(bandwidthListProtocol) && bandwidthListProtocol.size() > 0)) {