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 @@ <%-- --%>