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 51d1f6e68..198e86e75 100644 --- a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java +++ b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java @@ -1,12 +1,15 @@ package com.nis.web.controller.dashboard; import java.lang.reflect.Type; +import java.math.BigDecimal; import java.net.URISyntaxException; import java.net.URLEncoder; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -35,10 +38,13 @@ import com.google.gson.JsonParseException; import com.google.gson.LongSerializationPolicy; import com.google.gson.reflect.TypeToken; import com.nis.domain.PageLog; +import com.nis.domain.SysDataDictionaryItem; +import com.nis.domain.configuration.WebsiteDomainTopic; import com.nis.domain.dashboard.TrafficIpActiveStatistic; import com.nis.util.CodeDicUtils; import com.nis.util.Constants; import com.nis.util.DateUtil; +import com.nis.util.DictUtils; import com.nis.util.StringUtil; import com.nis.util.httpclient.HttpClientUtil; import com.nis.web.controller.BaseController; @@ -382,4 +388,100 @@ public class TrafficStatisticsInfoController extends BaseController { } return list; } + /** + * 网址类型列表 + */ + @RequestMapping("webTypeList") + public String webTypeList(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/trafficWebTypeList"; + } + /** + * 网站统计图跟表 + */ + @RequestMapping(value="websiteList") + @ResponseBody + public List websiteList(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 = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_WEBSITELIST; + 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("website接口数据"+fromJsonList); + list = (ArrayList) fromJsonList.get("data"); + BigDecimal divisor=new BigDecimal(1024*1024*1024); + DecimalFormat df = new DecimalFormat("0.00"); + DecimalFormat dl = new DecimalFormat("0"); + DecimalFormat pf = new DecimalFormat("0.00%"); + Double totalLink=0d; + Double totalGbyte=0d; + Double totalPackets=0d; + for (Object object : list) { + Map m=(Map)object; + Double count=(Double)m.get("count"); + totalGbyte+=count; + totalLink+=(Double)m.get("linkNum"); + totalPackets+=(Double)m.get("packets"); + String format = df.format(count/1024/1024/1024); + m.put("Gbyte", format); + } + List codeList = appCfgService.getDomainDict(new WebsiteDomainTopic()); + Map map = new HashMap(); + for (WebsiteDomainTopic websiteDomainTopic : codeList) { + if(!map.containsKey(websiteDomainTopic.getWebsiteServiceId())){ + map.put(websiteDomainTopic.getId(),websiteDomainTopic.getDomain()); + } + } + 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; + m.put("perPackets", pf.format(perPackets)); + Double perGbyte = ((Double)m.get("count"))/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"))))); + } + } + Collections.sort(list, new Comparator() { + + @Override + public int compare(Object o1, Object o2) { + if(o1==null&&o2!=null){ + return 1; + } + if(o1!=null&&o2==null){ + return -1; + } + if(o1==null&&o2==null){ + return 0; + } + Map m1=(Map)o1; + Map m2=(Map)o2; + if((Double)m1.get("count")==(Double)m2.get("count")){ + return 0; + } + int result=((Double)m1.get("count")-(Double)m2.get("count"))>0?-1:1; + return result; + } + }); + } catch (Exception e) { + e.printStackTrace(); + logger.error("网站域名数据获取错误"+e); + list.add(Maps.newHashMap("error","request_service_failed")); + } + return list; + } + } diff --git a/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp b/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp index c60ba36cc..21858d0ec 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/dashBoardIndex.jsp @@ -196,7 +196,7 @@
-   <%-- --%> +   
diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp index 2c46ff8b1..32a6e3ac6 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp @@ -3,118 +3,185 @@ 网站主题服务分类 - + + + + + + + + + + + - + -
- -

- -

- - --%> + <%-- --%> - - - - - - - - - -
- -
-
-
- -
- - - - -
- - - -
- - - - - -<%-- --%> - - - - - - - - - - + + + +
+
+
+ +
+ + + + +
+ + + + +
+
+ - - -<%-- --%> - - - - - - + + + + + + + - - -
${entry.id }${entry.ipAddr }${entry.areaId }${entry.linkNum }${entry.c2sPktNum }${entry.s2cPktNum }${entry.c2sByteLen }${entry.s2cByteLen }
-
${page}
-
-
+ + + + +
+
+
+
+    + +
+
+ <%--

 1 @@ -132,70 +199,361 @@ 33456 +
+
  
+

--%>
-
- - + + function chartData(websiteId) { + loading(); + $ + .ajax({ + url : '${ctx}/dashboard/traffic/websiteChart', + type : 'get', + dataType : "json", + data : { + "websiteId" : websiteId + }, + async : false, + timeout : 10000, + success : function(data) { + if (data != null && data.length > 0 + && data[0].error != null) { + top.$.jBox + .tip( + "", + ""); + return; + } + webTypeChart(data); + }, + error : function(data, textStatus, errorThrown) { + closeTip(); + }, + complete : function(XMLHttpRequest, status) {//超时设置 + closeTip(); + } + }); + } + /** + * 分页控件处理 + */ + function pageJuan(showData) { + if (typeof (fileData) != "undefined" && fileData != null) { + var totalData = fileData.length; + // var showData = 10; + if (showData > totalData) { + showData = totalData; + } + $('.M-box').pagination({ + totalData : totalData, + showData : showData, + coping : true, + callback : function(index) { + //改变显示开始和结束数据编号 + getPageData(index.getCurrent(), showData); + } + }); + } + } + // 比例协议统计图 + /* function webTypeChart(rs){ + //终端用户 分操作系统与浏览器 + var data=new Array(); + $(rs).each(function(i, d) { + data.push({ + name: d.website, + y: d.count, + }); + }); + // 创建图例 + var chart = Highcharts.chart('chart',{ + chart: { + plotBackgroundColor:null, + plotBorderWidth:null, + plotShadow:false, + type: 'pie' + }, + navigation: { + buttonOptions: { + x:-25, + } + }, + exporting: { + allowHTML:true, + filename:"Website", + scale:1, + sourceWidth: 1280, + sourceHeight: 500, + }, + noData:{ + style: {//设置字体颜色 + color: '#000', + }, + }, + // legend:{// 底部平鋪图例 + // width:1280, + // x:40, + // itemWidth:100, + // itemDistance:2, + // itemHoverStyle:{ + // color:'#61D2F7', + // }, + // }, + legend: { + // layout: 'vertical', + align: 'right', + verticalAlign: 'middle', + width:380, + itemWidth:100, + itemDistance:2, + itemHoverStyle:{ + color:'#61D2F7', + }, + }, + // colors:['#f36f8a', '#44A9A8', '#ffff43','#25f3e6','#964CEC','#32B0ED','#2b6ed7','#7278DD','#2DA9D8','#C66FE6'], + title: { + text: null, + }, + plotOptions: { + series: { + dataLabels: { + enabled: true, + softConnector: true, // 是否使用曲线 + formatter: function () { + // 通过函数判断是否显示数据标签,为了防止数据标签过于密集 + return this.percentage > 1 ? '' + this.point.name + ' : ' +this.percentage.toFixed(2)+' %' : null; + }, + style: { + color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' + } + }, + }, + pie:{ + allowPointSelect: true, + showInLegend: true, + point: { + events: { + mouseOver: function(e) { + this.slice(); + }, + // 鼠标移出时,收回突出显示 + mouseOut: function() { + this.slice(); + }, + // 默认是点击突出,这里屏蔽掉 + click: function() { + return false; + } + }, + }, + } + }, + credits:{//是否有highcharts水印 + enabled:false + }, + tooltip: { + headerFormat: '{series.name}
', + pointFormat: '{point.name}: {point.percentage:.2f}%' + }, + series: [{ + name: "Website", + colorByPoint: true, + data: data + }], + }); + } */ + \ No newline at end of file