diff --git a/src/main/java/com/nis/util/Constants.java b/src/main/java/com/nis/util/Constants.java index 89df965d8..ffc241d13 100644 --- a/src/main/java/com/nis/util/Constants.java +++ b/src/main/java/com/nis/util/Constants.java @@ -706,6 +706,7 @@ public final class Constants { public static final String NTC_ACTION_ENTRANCE_REPORT=Configurations.getStringProperty("ntcActionEntranceReport","ntcActionEntranceReport"); public static final String TRAFFIC_WEBSITELIST_NOTIME=Configurations.getStringProperty("trafficWebsiteListNoTime","trafficWebsiteListNoTime"); public static final String TRAFFIC_TOPICLIST=Configurations.getStringProperty("trafficTopicList","trafficTopicList"); + public static final String TRAFFIC_DOMAIN_TRANS=Configurations.getStringProperty("trafficDomainTrans","trafficDomainTrans"); /** * httpclient 工具超时时间设置 */ diff --git a/src/main/java/com/nis/web/controller/dashboard/DashboardController.java b/src/main/java/com/nis/web/controller/dashboard/DashboardController.java index 2e3eed8ec..576adffb9 100644 --- a/src/main/java/com/nis/web/controller/dashboard/DashboardController.java +++ b/src/main/java/com/nis/web/controller/dashboard/DashboardController.java @@ -606,7 +606,7 @@ public class DashboardController extends BaseController{ String domain = wdt.getDomain(); Double domainId = wdt.getId().doubleValue(); Double webId = Double.parseDouble(dataMap.get("webId").toString()); - //10个域名之外的为others webId设为-1外 + //10个域名之外的为others webId设为-1外 if(dataMap.get("webId").toString().equals("-1")){ dataMap.put("domain", "Others"); break; @@ -698,92 +698,6 @@ public class DashboardController extends BaseController{ } return resultList; } - - - @RequestMapping(value="webTypeList") - public String webTypeList( HttpServletRequest request, HttpServletResponse response, Model model){ - PageLog page = new PageLog(request, response); - List list = new ArrayList(); - for (int i = 1; i < 10; i++) { - TrafficIpActiveStatistic ip = new TrafficIpActiveStatistic(); - ip.setId(i); - ip.setIpAddr(3+i+".1.1."+i); - ip.setAreaId("11"); - ip.setLinkNum(1212l); - list.add(ip); - } - page.setList(list); - model.addAttribute("page", page); - return "/dashboard/trafficWebTypeList"; - } - -////////////////////////////////////////test - @RequestMapping(value="showChart") - public String showChart(@ModelAttribute("entry") TrafficIpActiveStatistic entry, Model model){ - String ipAddr="1.1.1.1"; - TrafficIpActiveStatistic ip=new TrafficIpActiveStatistic(); - ArrayList list = new ArrayList(); -// chartMap.put("ipAddr", ip.getIpAddr()); - HashMap map1 = new HashMap(); - HashMap map2 = new HashMap(); - HashMap map3 = new HashMap(); - HashMap map4 = new HashMap(); - map1.put("name", "c2sPktNum"); - map1.put("y", ip.getC2sPktNum()); - map2.put("name", "s2cPktNum"); - map2.put("y", ip.getS2cPktNum()); - map3.put("name", "c2sByteLen"); - map3.put("y", ip.getC2sByteLen()); - map4.put("name", "s2cByteLen"); - map4.put("y", ip.getS2cByteLen()); - list.add(ip.getC2sPktNum()); - list.add(ip.getS2cPktNum()); - list.add(ip.getC2sByteLen()); - list.add(ip.getS2cByteLen()); - -// String json = new Gson().toJson(); - model.addAttribute("ipAddr",ipAddr); - model.addAttribute("chartMap",list); - return "/dashboard/trafficWebTypeList"; - } - - - public static void main(String[] args) { - Map map = new HashMap(); - map.put("a", 10); - map.put("b", "10"); - map.put("c", 10L); - map.put("d", "fsaf"); - //Gson gson = new Gson(); - Gson gson = new GsonBuilder() - /* .registerTypeAdapter( - new TypeToken>() { - }.getType(), - new JsonDeserializer>() { - @Override - public Map deserialize( - JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - - Map treeMap = new HashMap(); - JsonObject jsonObject = json.getAsJsonObject(); - Set> entrySet = jsonObject.entrySet(); - for (Map.Entry entry : entrySet) { - treeMap.put(entry.getKey(), entry.getValue()); - } - return treeMap; - } - })*/.create(); - - String json = gson.toJson(map); - System.out.println(json); - - Map map1 = gson.fromJson(json, Map.class); - Map map2 = gson.fromJson(json, new TypeToken>() { - }.getType()); - - System.out.println(map2.get("c")); - } /** * * 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 9fb9037d3..78e09f9a6 100644 --- a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java +++ b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java @@ -256,34 +256,6 @@ public class TrafficStatisticsInfoController extends BaseController { } return map; } - /** - * 间隔5分钟数据 - */ - @RequestMapping(value="bandwidthTransThree") - @ResponseBody - public Map bandwidthTransThree(String beginDate,String endDate){ - Map fromJsonList = new HashMap(); - Map map = new HashMap(); - //String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_TWO; - //String url="http://192.168.11.78:8080/galaxy/service/log/v1/"+Constants.TRAFFIC_BANDWIDTH_TRANS_THREE; - //String url="http://192.168.11.78:8080/galaxy/service/log/v1/"+Constants.TRAFFIC_BANDWIDTH_TRANS_FOUR; - String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_THREE; - //String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_FOUR; - try { - url=urlAddDate(url,beginDate,endDate); - - String string = HttpClientUtil.get(url); - Gson gson = new GsonBuilder().create(); - fromJsonList = gson.fromJson(string, new TypeToken(){}.getType()); - logger.debug("bandwidthTransThree服务查询数据成功"); - Map result = (Map)fromJsonList.get("data"); - return result; - } catch (Exception e) { - e.printStackTrace(); - logger.error("带宽详情数据获取错误"+e); - } - return map; - } /** * 协议类型详细列表 */ @@ -427,24 +399,77 @@ public class TrafficStatisticsInfoController extends BaseController { 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); + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 12); String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime()); + List domainList = appCfgService.getDomainDict(new WebsiteDomainTopic());// domain 域名 + model.addAttribute("domainList", domainList); model.addAttribute("beginDate", oneHoursAgo); model.addAttribute("endDate", now); return "/dashboard/trafficWebTypeList"; } + @RequestMapping("domainTrans") + public String domainTrans(Model model,Integer domain,Integer entranceId,String beginDate,String endDate,String domainName){ + + model.addAttribute("domainName", domainName); + model.addAttribute("domain", domain); + model.addAttribute("entranceId", entranceId); + model.addAttribute("beginDate", beginDate); + model.addAttribute("endDate", endDate); + return "/dashboard/trafficDomainTrans"; + } + @RequestMapping("ajaxDomainTrans") + @ResponseBody + public List ajaxDomainTrans(String beginDate,String endDate,Integer domain,Integer entranceId,Model model){ + Map fromJsonList = new HashMap(); + List list = new ArrayList(); + try { +// String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_IPACTIVE_ONEHOUR; + String url = "http://localhost:8088/galaxy-service/service/log/v1/trafficDomainTrans"; + url=urlAddDate(url, beginDate, endDate); + if(domain!=null){ + url=url+"&domain="+domain; + } + if(entranceId!=null){ + url=url+"&entranceId="+entranceId; + } + String string = HttpClientUtil.get(url); + Gson gson = new GsonBuilder().create(); + fromJsonList = gson.fromJson(string, new TypeToken>(){}.getType()); + logger.debug("活跃IP1小时"+fromJsonList); + list = (ArrayList) fromJsonList.get("data"); + + } catch (Exception e) { + e.printStackTrace(); + logger.error("活跃IP数据获取错误"+e); + list.add(Maps.newHashMap("error","request_service_failed")); + } + return list; + } /** * 网站统计图跟表 */ @RequestMapping(value="websiteList") @ResponseBody - public List websiteList(Model model,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){ + public List websiteList(Integer entranceId,Integer domain,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_WEBSITELIST; + String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_WEBSITELIST_NOTIME; // String url = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_WEBSITELIST; try { - url=urlAddDate(url,beginDate,endDate); + if(StringUtil.isBlank(beginDate)||StringUtil.isBlank(endDate)){ + Calendar cal = Calendar. getInstance (); + cal.setTime(new Date()); + endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间 + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 12); + beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime()); + } + url=urlAddDate(url, beginDate, endDate); + if(domain!=null){ + url=url+"&domain="+domain; + } + if(entranceId!=null){ + url=url+"&entranceId="+entranceId; + } String string = HttpClientUtil.get(url); Gson gson = new GsonBuilder().create(); fromJsonList = gson.fromJson(string, new TypeToken(){}.getType()); @@ -454,15 +479,15 @@ public class TrafficStatisticsInfoController extends BaseController { DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat dl = new DecimalFormat("0"); DecimalFormat pf = new DecimalFormat("0.00%"); - Double totalLink=0d; +// Double totalLink=0d; Double totalGbyte=0d; Double totalPackets=0d; for (Object object : list) { Map m=(Map)object; - Double count=(Double)m.get("count"); + Double count=(Double)m.get("byteCount"); totalGbyte+=count; - totalLink+=(Double)m.get("linkNum"); - totalPackets+=(Double)m.get("packets"); +// totalLink+=(Double)m.get("linkNum"); + totalPackets+=(Double)m.get("pktCount"); String format = df.format(count/1024/1024/1024); m.put("Gbyte", format); } @@ -475,14 +500,16 @@ public class TrafficStatisticsInfoController extends BaseController { } for (Object object : list) { Map m=(Map)object; - Double perLink = ((Double)m.get("linkNum"))/totalLink; - m.put("perLink",pf.format(perLink)); - Double perPackets = ((Double)m.get("packets"))/totalPackets; +// Double perLink = ((Double)m.get("linkNum"))/totalLink; +// m.put("perLink",pf.format(perLink)); + Double perPackets = ((Double)m.get("pktCount"))/totalPackets; m.put("perPackets", pf.format(perPackets)); - Double perGbyte = ((Double)m.get("count"))/totalGbyte; + Double perGbyte = ((Double)m.get("byteCount"))/totalGbyte; m.put("perGbyte", pf.format(perGbyte)); if(map.containsKey(Long.parseLong(dl.format(m.get("webId"))))){ m.put("website", map.get(Long.parseLong(dl.format(m.get("webId"))))); + }else{ + m.put("website", dl.format(m.get("webId"))); } } Collections.sort(list, new Comparator() { @@ -500,10 +527,10 @@ public class TrafficStatisticsInfoController extends BaseController { } Map m1=(Map)o1; Map m2=(Map)o2; - if((Double)m1.get("count")==(Double)m2.get("count")){ + if((Double)m1.get("byteCount")==(Double)m2.get("byteCount")){ return 0; } - int result=((Double)m1.get("count")-(Double)m2.get("count"))>0?-1:1; + int result=((Double)m1.get("byteCount")-(Double)m2.get("byteCount"))>0?-1:1; return result; } }); @@ -523,8 +550,9 @@ public class TrafficStatisticsInfoController extends BaseController { public List statisticList(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_TOPIC_AND_DOMAIN_CHART; + String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_TOPICLIST; //String url = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_TOPIC_AND_DOMAIN_CHART; + //String url = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_TOPICLIST; Map map=new HashMap(); try { url=urlAddDate(url,beginDate,endDate); @@ -557,11 +585,18 @@ public class TrafficStatisticsInfoController extends BaseController { } } } - for(Object object2 : list) { - Map m2=(Map) object2; + //将总数据赋值给每个实体 方便计算百分比 如果数据都为空 则不返回给页面展示 + for(int i=list.size()-1;i>=0;i--) { + Map m2=(Map) list.get(i); m2.put("allLink", totalLink); m2.put("allPackets",totalPackets); m2.put("allGByte", totalGByte); + long parseLong = Long.parseLong(lf.format(m2.get("linkNum"))); + long parseLong2 = Long.parseLong(lf.format(m2.get("packets"))); + double parseDouble = Double.parseDouble(lf.format(m2.get("count"))); + if(parseLong==0&&parseLong2==0&&parseDouble==0) { + list.remove(i); + } } } } catch (Exception e) { diff --git a/src/main/resources/nis.properties b/src/main/resources/nis.properties index 9f582e56b..e6e792093 100644 --- a/src/main/resources/nis.properties +++ b/src/main/resources/nis.properties @@ -596,4 +596,5 @@ ntcAsnRecord=ntcAsnRecord ntcURLReport=ntcURLReport ntcIpRangeReport=ntcIpRangeReport trafficWebsiteListNoTime=trafficWebsiteListNoTime -trafficTopicList=trafficTopicList \ No newline at end of file +trafficTopicList=trafficTopicList +trafficDomainTrans=trafficDomainTrans \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp b/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp index 1a022c099..7fdf0b54f 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp @@ -31,7 +31,7 @@
-
+
@@ -45,10 +45,7 @@ 0 bps
- - - -
+
@@ -77,18 +74,6 @@

0

-
-
- -
-
-

" - class="tooltips" data-flag="false" data-html="true" data-placement="top"> -

-

0

-
-
-
@@ -128,19 +113,6 @@
- -
-
- -
-
-

" - class="tooltips" data-flag="false" data-html="true" data-placement="top"> -

-

0

-
-
-
@@ -155,8 +127,28 @@
- - +
+
+ +
+
+

" + class="tooltips" data-flag="false" data-html="true" data-placement="top"> +

+

0

+
+
+
+
+ +
+
+

" + class="tooltips" data-flag="false" data-html="true" data-placement="top"> +

+

0

+
+
@@ -172,12 +164,6 @@
  
-
- - -
@@ -235,7 +221,7 @@
-   <%-- --%> +   
@@ -587,14 +573,11 @@ function protocolList(){ } //活跃IP统计 function ipActiveList(){ - var begin=$("#ipBeginDate").val(); - var end=$("#ipEndDate").val(); loading(); $.ajax({ url: '${ctx}/dashboard/ipActive', type : "get" , dataType:"json", - data:{"beginDate":begin,"endDate":end}, cache:false, async:true, timeout:60000,//超时时间设置,查询接口时间过长超时 diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficDomainTrans.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficDomainTrans.jsp new file mode 100644 index 000000000..a5efa5c86 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficDomainTrans.jsp @@ -0,0 +1,130 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + + <spring:message code="traffic_ip_active"></spring:message> + + + + + +
+ +<%--

+ +

--%> +
+ + + + + + + + + + +
+
+ +
+ + + + +<%-- --%> + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp index 32a6e3ac6..02c89f945 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp @@ -3,27 +3,14 @@ 网站主题服务分类 - - + + + + + + + - - - - - - - -