From 4c18346d87030c48803f1ba3eb50ac639a7547e7 Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Thu, 13 Dec 2018 20:37:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E9=87=8F=E7=BB=9F=E8=AE=A1-=E8=A7=A3?= =?UTF-8?q?=E5=86=B3traffic=E8=AF=A6=E6=83=85=E6=97=B6=E6=8A=98=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E6=9C=80=E5=90=8E=E6=97=B6=E9=97=B4=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=BA0=E9=97=AE=E9=A2=98=E3=80=82=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E7=94=A8=E6=88=B7=E8=A1=8C=E4=B8=BA=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=B8=AD=E7=94=A8=E6=88=B7=E5=90=8D=E8=B7=9Fip=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=B8=BA=E7=A9=BA=E6=97=A0=E7=94=A8=E6=88=B7=E5=90=8D?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=B6=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82app,=E5=8D=8F=E8=AE=AE=EF=BC=8Ctraffic=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96,=E9=BB=98=E8=AE=A4=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=98=BE=E7=A4=BA=E4=B8=BA=E6=9C=80=E8=BF=91=E4=B8=80?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=EF=BC=8C=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=B8=A4=E4=BD=8D=E5=B0=8F=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrafficStatisticsInfoController.java | 63 ++++++++------ .../TrafficStatisticsReportController.java | 32 +++++--- .../dashboard/trafficActionTransList.jsp | 82 +++++++++++++++++-- .../views/dashboard/trafficAppTypeList.jsp | 39 +++++---- .../views/dashboard/trafficBandwidthList.jsp | 27 +++--- .../dashboard/trafficProtocolTypeList.jsp | 40 +++++---- .../webapp/static/pages/scripts/pageLogs.js | 21 +++++ 7 files changed, 218 insertions(+), 86 deletions(-) diff --git a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java index 361870dbc..51d1f6e68 100644 --- a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java +++ b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java @@ -115,9 +115,9 @@ public class TrafficStatisticsInfoController extends BaseController { public String bandwidthList(Model model){ Calendar cal = Calendar. getInstance (); cal.setTime(new Date()); - String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间 + String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间 cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); - String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime()); + String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime()); model.addAttribute("beginDate", oneHoursAgo); model.addAttribute("endDate", now); return "/dashboard/trafficBandwidthList"; @@ -126,7 +126,14 @@ public class TrafficStatisticsInfoController extends BaseController { * 流量统计滚动动作查看详情页面 */ @RequestMapping(value={"trafficBlockList","trafficMonitorList"}) - public String serviceBlockList(@RequestParam("searchAction")String searchAction,HttpServletRequest request, HttpServletResponse response, Model model){ + public String serviceBlockList(@RequestParam("searchAction")String searchAction,Model model){ + Calendar cal = Calendar. getInstance (); + cal.setTime(new Date()); + String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间 + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); + String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime()); + model.addAttribute("beginDate", oneHoursAgo); + model.addAttribute("endDate", now); model.addAttribute("searchAction", searchAction); return "/dashboard/trafficActionTransList"; } @@ -135,12 +142,13 @@ public class TrafficStatisticsInfoController extends BaseController { */ @RequestMapping(value="actionEntranceTrans") @ResponseBody - public List actionTrans(@RequestParam("searchAction")String searchAction){ + public List actionTrans(String beginDate,String endDate,@RequestParam("searchAction")String searchAction){ Map fromJsonList = new HashMap(); List resultList = new ArrayList(); String url = Constants.DASHBOARD_URL+Constants.NTC_ACTION_ENTRANCE_REPORT; url=url+"?searchAction="+searchAction; try { + url = urlAddDate(url,beginDate,endDate); String string = HttpClientUtil.get(url); Gson gson = new GsonBuilder().create(); fromJsonList = gson.fromJson(string, new TypeToken(){}.getType()); @@ -153,13 +161,23 @@ public class TrafficStatisticsInfoController extends BaseController { } return resultList; } + /** + * + * + * url路径时间参数格式化 + * @param url + * @param beginDate + * @param endDate + * @return + * @throws URISyntaxException + */ public String urlAddDate(String url,String beginDate,String endDate) throws URISyntaxException{ if(StringUtil.isBlank(beginDate)||StringUtil.isBlank(endDate)){ Calendar cal = Calendar. getInstance (); cal.setTime(new Date()); - endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间 + endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).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()); + beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime()); } URIBuilder uriBuilder = new URIBuilder(url); uriBuilder.addParameter("beginDate",beginDate); @@ -239,11 +257,11 @@ public class TrafficStatisticsInfoController extends BaseController { public String protocolTypeList(Model model){ Calendar cal = Calendar. getInstance (); cal.setTime(new Date()); - String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间 + String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间 cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); - String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime()); - model.addAttribute("searchFoundStartTime", oneHoursAgo); - model.addAttribute("searchFoundEndTime", now); + String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime()); + model.addAttribute("beginDate", oneHoursAgo); + model.addAttribute("endDate", now); return "/dashboard/trafficProtocolTypeList"; } /** @@ -251,16 +269,12 @@ public class TrafficStatisticsInfoController extends BaseController { */ @RequestMapping(value="protocolList") @ResponseBody - public List protocolList(Model model,@RequestParam(required=false)String searchFoundStartTime,@RequestParam(required=false)String searchFoundEndTime){ + public List protocolList(Model model,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){ Map fromJsonList = new HashMap(); List list = new ArrayList(); String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_LIST; try { - if(!StringUtil.isBlank(searchFoundStartTime)&&!StringUtil.isBlank(searchFoundEndTime)){ - searchFoundStartTime=URLEncoder.encode(searchFoundStartTime, "UTF-8"); - searchFoundEndTime=URLEncoder.encode(searchFoundEndTime, "UTF-8"); - url+="?searchFoundStartTime="+searchFoundStartTime+"&searchFoundEndTime="+searchFoundEndTime; - } + url=urlAddDate(url,beginDate,endDate); String string = HttpClientUtil.get(url); Gson gson = new GsonBuilder().create(); fromJsonList = gson.fromJson(string, new TypeToken(){}.getType()); @@ -311,7 +325,14 @@ public class TrafficStatisticsInfoController extends BaseController { * App类型详细列表 */ @RequestMapping(value="appTypeList") - public String appTypeList(){ + public String appTypeList(Model model){ + Calendar cal = Calendar. getInstance (); + cal.setTime(new Date()); + String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间 + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); + String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime()); + model.addAttribute("beginDate", oneHoursAgo); + model.addAttribute("endDate", now); return "/dashboard/trafficAppTypeList"; } /** @@ -319,16 +340,12 @@ public class TrafficStatisticsInfoController extends BaseController { */ @RequestMapping(value="appList") @ResponseBody - public List appList(@RequestParam(value="searchFoundStartTime",required=false)String searchFoundStartTime,@RequestParam(value="searchFoundEndTime",required=false)String searchFoundEndTime){ + public List appList(@RequestParam(value="beginDate",required=false)String beginDate,@RequestParam(value="endDate",required=false)String endDate){ Map fromJsonList = new HashMap(); List list = new ArrayList(); String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_APP_LIST; try { - if(!StringUtil.isBlank(searchFoundStartTime)&&!StringUtil.isBlank(searchFoundEndTime)){ - searchFoundStartTime=URLEncoder.encode(searchFoundStartTime, "UTF-8"); - searchFoundEndTime=URLEncoder.encode(searchFoundEndTime, "UTF-8"); - url+="?searchFoundStartTime="+searchFoundStartTime+"&searchFoundEndTime="+searchFoundEndTime; - } + url=urlAddDate(url,beginDate,endDate); String string = HttpClientUtil.get(url); Gson gson = new GsonBuilder().create(); fromJsonList = gson.fromJson(string, new TypeToken(){}.getType()); diff --git a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java index af5177678..e4645b2e8 100644 --- a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java +++ b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java @@ -94,23 +94,29 @@ public class TrafficStatisticsReportController extends BaseController { model.addAttribute("accountList", accountList); if(StringUtil.isBlank(account)&&accountList!=null&&accountList.size()>0&&!"3".equals(searchBusinessType)) { Map accountMap = (Map) accountList.get(0); - String firstAccount=(String) accountMap.get("account"); - String userString = HttpClientUtil.get(userUrl+"&searchAccount="+firstAccount); - // 指定用户 查询 - Gson usergson = new GsonBuilder().create(); - userJsonList = usergson.fromJson(userString, new TypeToken(){}.getType()); - userList = (ArrayList) userJsonList.get("data"); + String firstAccount=""; + if(accountMap!=null&&accountMap.get("account")!=null){ + firstAccount=(String) accountMap.get("account"); + String userString = HttpClientUtil.get(userUrl+"&searchAccount="+firstAccount); + // 指定用户 查询 + Gson usergson = new GsonBuilder().create(); + userJsonList = usergson.fromJson(userString, new TypeToken(){}.getType()); + userList = (ArrayList) userJsonList.get("data"); + } model.addAttribute("userList", userList); model.addAttribute("searchAccount", firstAccount); } if(StringUtil.isBlank(nasIp)&&nasIpList!=null&&nasIpList.size()>0&&!"2".equals(searchBusinessType)) { - Map IpMap = (Map) nasIpList.get(0); - String firstIp=(String) IpMap.get("nasIp"); - String ipString = HttpClientUtil.get(ipUrl+"&searchNasIp="+firstIp); - // 指定IP查询 - Gson ipgson = new GsonBuilder().create(); - ipJsonList = ipgson.fromJson(ipString, new TypeToken(){}.getType()); - ipList = (ArrayList) ipJsonList.get("data"); + Map ipMap = (Map) nasIpList.get(0); + String firstIp=""; + if(ipMap!=null&&ipMap.get("nasIp")!=null){ + firstIp=(String) ipMap.get("nasIp"); + String ipString = HttpClientUtil.get(ipUrl+"&searchNasIp="+firstIp); + // 指定IP查询 + Gson ipgson = new GsonBuilder().create(); + ipJsonList = ipgson.fromJson(ipString, new TypeToken(){}.getType()); + ipList = (ArrayList) ipJsonList.get("data"); + } model.addAttribute("ipList", ipList); model.addAttribute("searchNasIp", firstIp); diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficActionTransList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficActionTransList.jsp index 96c7dce94..3776ae899 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficActionTransList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficActionTransList.jsp @@ -17,10 +17,42 @@

- +
+ + +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+ +
+ + +
+
+ +
+
+ + @@ -30,8 +62,36 @@ <%-- --%>