912 lines
33 KiB
Plaintext
912 lines
33 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8"%>
|
||
<%@ include file="/WEB-INF/include/taglib.jsp"%>
|
||
<html>
|
||
<head>
|
||
<title><spring:message code="app"></spring:message>
|
||
</title>
|
||
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/pages/css/dashboard.css">
|
||
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/pages/css/pagination.css">
|
||
|
||
<script src="${pageContext.request.contextPath}/static/pages/scripts/jquery.pagination.js"></script>
|
||
<script src="${ctxStatic }/global/plugins/tableExport-3.3.13/xlsx.core.js"></script>
|
||
<script src="${ctxStatic }/global/plugins/tableExport-3.3.13/FileSaver.js"></script>
|
||
<script src="${ctxStatic }/global/plugins/tableExport-3.3.13/tableexport.js"></script>
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<div class="page-content">
|
||
<div class="theme-panel hidden-xs hidden-sm">
|
||
<button type="button" class="btn btn-default"
|
||
onClick="javascript:window.location.reload()">
|
||
<i class="fa fa-refresh"></i>
|
||
</button>
|
||
<button type="button" class="btn btn-default" onClick="javascript:window.location='${ctx}/dashboard/traffic/appTypeList'">
|
||
<i class="fa fa-history"></i>
|
||
</button>
|
||
</div>
|
||
<h3 class="page-title">
|
||
<spring:message code="${appName}"></spring:message>
|
||
</h3>
|
||
<h5 class="page-header"></h5>
|
||
<ul class="nav nav-tabs">
|
||
<li class="changeData active" value="1"><a href="javascript:void(0);"><spring:message code="real_time"/></a></li>
|
||
<li class="changeData" value="2"><a href="javascript:void(0);"><spring:message code="history"/></a></li>
|
||
</ul>
|
||
<br>
|
||
<div class="row">
|
||
<form:form id="searchForm" method="get" class="form-search">
|
||
<!-- 搜索内容与操作按钮栏 -->
|
||
<div class="col-md-12">
|
||
<div class="pull-left chart-history">
|
||
<div class="input-group">
|
||
<div class="input-group-btn">
|
||
<span class="selectpicker form-control"><spring:message
|
||
code="begin_date" /></span>
|
||
</div>
|
||
<input name="beginDate" id="beginDate" type="text" readonly="readonly" maxlength="20" class="form-control Wdate input-medium"
|
||
value="" onclick="WdatePicker({onpicked:function(){this.onchange()},dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,maxDate:'#F{\'new Date()\'}'});" onchange="setStartTime('#beginDate','#endDate',7,'d','yyyy-MM-dd hh:mm:ss',false)"/>
|
||
</div>
|
||
</div>
|
||
<div class="pull-left chart-history">
|
||
<div class="input-group">
|
||
<div class="input-group-btn">
|
||
<span class="selectpicker form-control"><spring:message
|
||
code="end_date" /></span>
|
||
</div>
|
||
<input name="endDate" id="endDate" type="text" readonly="readonly" maxlength="20" class="form-control Wdate input-medium"
|
||
value="" onclick="WdatePicker({onpicked:function(){this.onchange()},dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,maxDate:'#F{\'new Date()\'}'});" onchange="setEndTime('#beginDate','#endDate',7,'d','yyyy-MM-dd hh:mm:ss',false)"/>
|
||
</div>
|
||
</div>
|
||
<div class="pull-left">
|
||
<div class="input-group">
|
||
<div class="input-group-btn">
|
||
<span class="selectpicker form-control" ><spring:message code="entrance_id"/></span>
|
||
</div>
|
||
<select id="entranceId" name="entranceId" class="selectpicker form-control" width="100px" data-live-search="true" data-live-search-placeholder="search">
|
||
<option value=""><spring:message code="select"/></option>
|
||
<c:forEach items="${fns:getDictList('ENTRANCE')}" var="dict" >
|
||
<option value="${dict.itemCode}"><spring:message code="${dict.itemValue}"></spring:message></option>
|
||
</c:forEach>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="pull-left">
|
||
<button type="button" class="btn blue"
|
||
onClick="return searchList()">
|
||
<i class="fa fa-search"></i>
|
||
<spring:message code="search" />
|
||
</button>
|
||
<%-- <button type="button" class="btn btn-default" id="resetBtn">
|
||
<i class="fa fa-refresh"></i>
|
||
<spring:message code="reset" />
|
||
</button> --%>
|
||
</div>
|
||
</div>
|
||
<!-- 搜索内容与操作按钮栏 -->
|
||
</form:form>
|
||
</div>
|
||
<div class="row chart-realTime">
|
||
<div id="chart-realTime" style="width: 97%; height: 430px; margin-top: 20px"></div>
|
||
<input id="total" type="hidden" />
|
||
<input id="sipData" type="hidden" />
|
||
<input id="dipData" type="hidden" />
|
||
<input id="timeData" type="hidden" />
|
||
<input id="appType" name="appType" type="hidden" value="${appType}" />
|
||
<input id="beginDateh" type="hidden" value="${beginDate}" />
|
||
<input id="endDateh" type="hidden" value="${endDate}" />
|
||
</div>
|
||
<div class="row chart-history hidden">
|
||
<div id="chart-history" style="width: 97%; height: 430px; margin-top: 20px"></div>
|
||
</div>
|
||
<ul class="nav nav-tabs">
|
||
<li class="searchQuota active" value="1" onclick="changeOrderby(1)"><a href="javascript:void(0);"><spring:message code="link_num"/></a></li>
|
||
<li class="searchQuota" value="2" onclick="changeOrderby(2)"><a href="javascript:void(0);"><spring:message code="packet"/></a></li>
|
||
<li class="searchQuota" value="3" onclick="changeOrderby(3)"><a href="javascript:void(0);"><spring:message code="byte"/></a></li>
|
||
</ul>
|
||
<div class="btn-group pull-right" style="padding-top: 5px">
|
||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> <spring:message code="export"/>
|
||
<span class="caret"></span>
|
||
</button>
|
||
<ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -12px;">
|
||
<li><a class="btn export-btn" data-type="xlsx" id="export-btn"><i class="fa fa-download"> </i> excel </a><li>
|
||
<li><a class="btn export-btn" data-type="csv" id="export-btn"><i class="fa fa-download"> </i> csv </a><li>
|
||
</ul>
|
||
<div class="btn-group">
|
||
<button type="button" class="btn btn-default css-print" onClick="doPrint()"><i class="fa glyphicon glyphicon-print" style="top:3px;margin-right: 3px;"></i><spring:message code="print"/></button>
|
||
</div>
|
||
</div>
|
||
<br>
|
||
<div class="row" style="padding-top: 5px">
|
||
<div class="table-responsive">
|
||
<table id="contentTable" style="width: 100%;"
|
||
class="table table-striped table-bordered table-condensed text-nowrap">
|
||
<thead>
|
||
<tr>
|
||
<th><spring:message code="client_ip"/></th>
|
||
<th><spring:message code="link_num"/></th>
|
||
<th><spring:message code="percentage"/> (<spring:message code="link_num"/>)</th>
|
||
<th><spring:message code="packets"/></th>
|
||
<th><spring:message code="percentage"/> (<spring:message code="packets"/>)</th>
|
||
<th><spring:message code="bytes"/></th>
|
||
<th><spring:message code="percentage"/> (<spring:message code="bytes"/>)</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="tableData"></tbody>
|
||
</table>
|
||
|
||
<div id="page" class="pageView"><div class="M-box"></div><div class="pageMessage"> <spring:message code="current"/> <input type="text" class="pageCurrent" readonly="readonly"/> / <span class="pageNum"></span> <spring:message code="page"/> , <spring:message code="total"/> <span class="pageTotal"></span> <spring:message code="count"/></div></div>
|
||
<div class="none-data"><i class="fa fa-warning font-red-flamingo"></i> <spring:message code="noneData"/></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/highcharts.js"></script>
|
||
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/exporting.js"></script>
|
||
<%-- <script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/series-label.js"></script> --%>
|
||
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/offline-exporting.js"></script>
|
||
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/exporting-data.js"></script>
|
||
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/standalone.js"></script>
|
||
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/no-data-to-display.js"></script>
|
||
|
||
<script type="text/javascript">
|
||
$(document).ready(function() {
|
||
var starth = $("#beginDateh").val();
|
||
var endh = $("#endDateh").val();
|
||
$("#beginDate").val(starth);
|
||
$("#endDate").val(endh);
|
||
var appType=$("#appType").val();
|
||
var entranceId=$("#entranceId").val();
|
||
var searchQuota=$(".searchQuota[class~='active']").val();
|
||
appTransAjax(starth,endh,appType,entranceId);
|
||
showRealTimeTransChart(appType,entranceId);// 实时折线
|
||
appTop100List(starth,endh,appType,entranceId,searchQuota);
|
||
//筛选功能初始化
|
||
$("#resetBtn").on("click",function() {
|
||
$("select.selectpicker").each(function() {
|
||
$(this).selectpicker('val',$(this).find('option:first').val());
|
||
$(this).find("option").attr("selected",false);
|
||
$(this).find("option:first").attr("selected",true);
|
||
});
|
||
$(".Wdate").attr("value", '');
|
||
$("#searchForm")[0].reset();
|
||
});
|
||
$(".searchQuota").on("click",function(){
|
||
$(".searchQuota").removeClass("active");
|
||
$(this).addClass("active");
|
||
})
|
||
$(".chart-realTime").removeClass("hidden");
|
||
$(".chart-history").addClass("hidden");
|
||
$(".changeData").on("click",function(){
|
||
$(".changeData").removeClass("active");
|
||
$(this).addClass("active");
|
||
if($(this).val()==1){
|
||
$(".chart-realTime").removeClass("hidden");
|
||
$(".chart-history").addClass("hidden");
|
||
}else{
|
||
$(".chart-realTime").addClass("hidden");
|
||
$(".chart-history").removeClass("hidden");
|
||
}
|
||
})
|
||
$('.pageView').hide();
|
||
});
|
||
// 改变排序字段
|
||
function changeOrderby(searchQuota) {
|
||
appTop100List($("#beginDate").val(),$("#endDate").val(),$("#appType").val(),$("#entranceId").val(),searchQuota);
|
||
}
|
||
function searchList() {
|
||
var start = $("#beginDate").val();
|
||
var end = $("#endDate").val();
|
||
$("#beginDateh").val(start);
|
||
$("#endDateh").val(end);
|
||
if (start == '' || end == '' || end == null || start == null) {
|
||
window.location.reload();
|
||
} else {
|
||
var appType=$("#appType").val();
|
||
var entranceId=$("#entranceId").val();
|
||
var searchQuota=$(".searchQuota[class~='active']").val();
|
||
appTransAjax(start,end,appType,entranceId);// 折线
|
||
showRealTimeTransChart(appType,entranceId);// 折线
|
||
appTop100List(start,end,appType,entranceId,searchQuota);// 列表
|
||
}
|
||
}
|
||
// 列表
|
||
function appTop100List(start,end,appType,entranceId,searchQuota){
|
||
$.ajax({
|
||
url : "${ctx}/dashboard/traffic/ajaxAppTopList",
|
||
type : 'get',
|
||
dataType : "json",
|
||
data : {
|
||
"beginDate" : start,
|
||
"endDate" : end,
|
||
"appType" : appType,
|
||
"entranceId" : entranceId,
|
||
"searchQuota":searchQuota
|
||
},
|
||
async : true,
|
||
timeout : 50000,
|
||
traditional:true,
|
||
success : function(data) {
|
||
if (data != null && data.length > 0 && data[0].error != null) {
|
||
top.$.jBox.tip( "<spring:message code='request_service_failed'/>", "<spring:message code='info'/>");
|
||
return;
|
||
}
|
||
fileData = data;
|
||
getPageData(1, 10);//初始化第一页的数据
|
||
pageJuan(10);//初始化分页
|
||
closeTip();
|
||
if (data != null && data.length < 1) {
|
||
$(".none-data").show();
|
||
$('.pageView').hide();
|
||
} else {
|
||
$('.none-data').hide();
|
||
$('.pageView').show();
|
||
}
|
||
},
|
||
error : function(data, textStatus, errorThrown) {
|
||
closeTip();
|
||
},
|
||
complete : function(XMLHttpRequest, status) {//超时设置
|
||
closeTip();
|
||
}
|
||
});
|
||
}
|
||
// 处理接口数据
|
||
function htmlData(fileDataS) {
|
||
$("#tableData").html("");
|
||
if (fileDataS == null || fileData == '') {
|
||
$(".none-data").show();
|
||
$('.pageView').hide();
|
||
} else {
|
||
$('.none-data').hide();
|
||
$('.pageView').show();
|
||
var start=$("#beginDateh").val();
|
||
var end=$("#endDateh").val();
|
||
var totalunique=0;
|
||
var totalpkt=0;
|
||
var totalbyte=0;
|
||
$.each(fileDataS, function(index, data) {
|
||
totalunique=totalunique+(Number(data.logNum));
|
||
totalpkt=totalpkt+(Number(data.pktNum));
|
||
totalbyte=totalbyte+(Number(data.byteNum));
|
||
})
|
||
$.each(fileDataS, function(index, data) {
|
||
if (data != null) {
|
||
var html ="<tr>";
|
||
html += "<td class='tc'>" + data.ipAddr + "</td>";
|
||
html += "<td class='tc'>" + data.logNum + "</td>";
|
||
html += "<td class='tc'>" + data.logPercent + " %</td>";
|
||
// html += "<td class='tc'>" + (((data.entranceId)==1) ? "Astana":"Alamty") + "</td>";
|
||
html += "<td class='tc'>" + Math.round(data.pktNum*100)/100 + "</td>";
|
||
html += "<td class='tc'>" + data.pktPercent + " %</td>";
|
||
html += "<td class='tc'>" + Math.round(data.byteNum*100)/100 + "</td>";
|
||
html += "<td class='tc'>" + data.bytePercent + " %</td>";
|
||
html += "</tr>"
|
||
if(index==fileDataS.length-1){
|
||
html+="<tr class='tr-total hidden'>"
|
||
html+= "<td class='tc'>"+"<spring:message code='report_total'/>"+"</td>";
|
||
html+= "<td class='tc'>"+totalunique+"</td>";
|
||
html+= "<td class='tc'>" +"--"+"</td>";
|
||
html+= "<td class='tc'>"+totalpkt+"</td>";
|
||
html+= "<td class='tc'>"+"--"+"</td>";
|
||
html+= "<td class='tc'>"+totalbyte+"</td>";
|
||
html+= "<td class='tc'>"+"--"+"</td>";
|
||
html+="</tr>"
|
||
}
|
||
}
|
||
$("#tableData").append(html);
|
||
});
|
||
}
|
||
}
|
||
|
||
// app曲线图
|
||
function appTransAjax(beginDate, endDate,appType,entranceId) {
|
||
loading();
|
||
$.ajax({ url : "${ctx}/dashboard/traffic/ajaxAppTrend?appType="+appType+"&beginDate="+beginDate+"&endDate="+endDate+"&entranceId="+entranceId,
|
||
type : "get",
|
||
dataType : "json",
|
||
async : true,
|
||
success : function(rs) {
|
||
var series=new Array();
|
||
var sipResult=new Array();
|
||
var dipResult=new Array();
|
||
var sipData=new Array();
|
||
var dipData=new Array();
|
||
var timeData=new Array();
|
||
var total=[];
|
||
if(rs!=null&&Object.keys(rs).length>0){
|
||
sipResult=rs.sipResult;
|
||
dipResult=rs.dipResult
|
||
total.push(rs.sipSum,rs.dipSum);
|
||
// 图表导出用列
|
||
$(sipResult).each(function(i,d){
|
||
sipData.push(d[1])
|
||
timeData.push(d[0])
|
||
})
|
||
$(dipResult).each(function(i,d){
|
||
dipData.push(d[1])
|
||
})
|
||
|
||
}else{
|
||
total.push(0,0);
|
||
}
|
||
showActionHistoryChart(sipResult,dipResult);
|
||
$("#total").val(JSON.stringify(total));
|
||
$("#sipData").val(JSON.stringify(sipData));
|
||
$("#dipData").val(JSON.stringify(dipData));
|
||
$("#timeData").val(JSON.stringify(timeData));
|
||
closeTip();
|
||
},
|
||
error : function(data, textStatus, errorThrown) {
|
||
closeTip();
|
||
},
|
||
complete : function(XMLHttpRequest, status) {//超时设置
|
||
closeTip();
|
||
}
|
||
});
|
||
|
||
}
|
||
/**
|
||
* 获取本页数据
|
||
* @param currentPage 当前页数 【初次查数据,默认第1页】
|
||
*/
|
||
var fileData;
|
||
function getPageData(currentPage, pageNumber) {
|
||
if (typeof (fileData) != "undefined" && fileData != null ) {
|
||
//计算每页数据起始和终止数据编号
|
||
// var pageNumber = 10;
|
||
var maxLength = currentPage * pageNumber - 1;
|
||
var minLength = currentPage * pageNumber - pageNumber;
|
||
var pageData = [];
|
||
for (var i = minLength; i < fileData.length; i++) {
|
||
if (maxLength < i) {
|
||
break;
|
||
} else {
|
||
pageData.push(fileData[i]);
|
||
}
|
||
}
|
||
htmlData(pageData);
|
||
} else {
|
||
//把空数据传到页面中去
|
||
htmlData(fileData);
|
||
}
|
||
}
|
||
// 导出列表
|
||
$(".export-btn").click(function(){
|
||
var nowDate=new Date();
|
||
var dataType = $(this).attr("data-type");
|
||
getPageData(1,999999);// 设置导出页条数
|
||
var start=$("#beginDate").val();
|
||
var end=$("#endDate").val();
|
||
var htmlTitle="";
|
||
htmlTitle+="<tr class='tr-title'>";
|
||
htmlTitle+= "<th class='tc' colspan='1'>"+"<spring:message code='${appName}'/>"+"</th>";
|
||
htmlTitle+= "<th class='tc' colspan='2'>"+start+"--"+ end +"</th>";
|
||
htmlTitle+="</tr>"
|
||
$("#contentTable thead").prepend(htmlTitle);
|
||
if(dataType=="xlsx"){
|
||
getTableContent("contentTable");
|
||
}else{
|
||
var te = $("#contentTable").tableExport({
|
||
headings:true,
|
||
footers:true,
|
||
formats:[dataType],
|
||
fileName:"<spring:message code='${appName}'></spring:message>"+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds(),
|
||
bootstrap:false
|
||
});
|
||
$("#myexport").click();
|
||
$("caption").remove();
|
||
}
|
||
$(".tr-title").remove();
|
||
getPageData(1,10);
|
||
pageJuan(10);//初始化分页
|
||
});
|
||
/**
|
||
* 调用后台接口
|
||
* @param Int id 表格id
|
||
* @return Array
|
||
*/
|
||
function getTableContent(id){
|
||
var mytable = document.getElementById(id);
|
||
var nowDate=new Date();
|
||
var data = [];
|
||
for(var i=0,rows=mytable.rows.length; i<rows; i++){
|
||
for(var j=0,cells=mytable.rows[i].cells.length; j<cells; j++){
|
||
if(!data[i]){
|
||
data[i] = new Array();
|
||
}
|
||
data[i][j] = mytable.rows[i].cells[j].innerHTML;
|
||
}
|
||
}
|
||
var title= data.shift();
|
||
var heard= data.shift();
|
||
var map ={};
|
||
map["titleTime"]=title;
|
||
map["heard"]=heard;
|
||
map["book"]=data;
|
||
map["titleCode"]="<spring:message code='${appName}'/>"+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds();
|
||
var exports = JSON.stringify(map);
|
||
aJaxImportPost("${ctx}/export/ajaxExport",{"exports":exports});
|
||
}
|
||
$("#print-btn").click(function() {
|
||
window.print();
|
||
});
|
||
/**
|
||
* 分页控件处理
|
||
*/
|
||
function pageJuan(showData) {
|
||
if (typeof (fileData) != "undefined" && fileData != null) {
|
||
var totalData = fileData.length;
|
||
// var showData = 10;
|
||
if (showData > totalData) {
|
||
showData = totalData;
|
||
}
|
||
var current=1;
|
||
$('.M-box').pagination({
|
||
totalData : totalData,
|
||
showData : showData,
|
||
coping : true,
|
||
callback : function(index) {
|
||
//改变显示开始和结束数据编号
|
||
getPageData(index.getCurrent(), showData);
|
||
current=index.getCurrent();
|
||
$(".pageCurrent").val(current);
|
||
}
|
||
});
|
||
if(totalData<10){
|
||
$(".pageCurrent").val(1);
|
||
}
|
||
$(".pageTotal").text(totalData);
|
||
$(".pageNum").text(Math.ceil(totalData/10));
|
||
}
|
||
}
|
||
function realTimeTrendAjax(beginDate, endDate,appType,entranceId){
|
||
var result={};
|
||
$.ajax({
|
||
url : "${ctx}/dashboard/traffic/ajaxAppTrend?appType="+appType+"&beginDate="+beginDate+"&endDate="+endDate+"&entranceId="+entranceId,
|
||
type : "get",
|
||
dataType : "json",
|
||
async : false,
|
||
success : function(rs) {
|
||
result=rs;
|
||
closeTip();
|
||
},
|
||
error : function(data, textStatus, errorThrown) {
|
||
closeTip();
|
||
},
|
||
complete : function(XMLHttpRequest, status) {//超时设置
|
||
closeTip();
|
||
}
|
||
});
|
||
return result;
|
||
}
|
||
var timer=null;
|
||
// 局点信息
|
||
function showRealTimeTransChart(appType,entranceId) {
|
||
var time1=(new Date().getTime())-(1000 * 60 * 10+1000 * 60 * 5);
|
||
var time2=(new Date().getTime())-(1000 * 60 * 5);//推迟五分钟
|
||
var beginDate=dateFtt("yyyy-MM-dd hh:mm:ss",new Date(time1)); //获取十个点
|
||
var endDate=dateFtt("yyyy-MM-dd hh:mm:ss",new Date(time2)); // 少算一分钟
|
||
var sipResult=new Array();
|
||
var dipResult=new Array();
|
||
var intData = realTimeTrendAjax(beginDate, endDate,appType,entranceId); //初始化数据 为10个点
|
||
sipResult=intData.sipResult;
|
||
dipResult=intData.dipResult;
|
||
var nowDate=new Date();
|
||
Highcharts.setOptions({ global: { useUTC: false } });
|
||
var num=0;
|
||
var chart = Highcharts.chart('chart-realTime',
|
||
{
|
||
chart: {
|
||
// type: 'spline',
|
||
type: 'area',
|
||
marginRight: 10,
|
||
// events: {
|
||
// events: {
|
||
// load: function() {}
|
||
// }
|
||
// }
|
||
},
|
||
noData:{
|
||
style: {//设置字体颜色
|
||
color: '#413333',
|
||
fontFamily:'Microsoft YaHei',
|
||
fontWeight:"unset",
|
||
},
|
||
},
|
||
exporting : {
|
||
filename : '<spring:message code="${appName}"></spring:message>'+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds(),
|
||
scale : 1,
|
||
sourceWidth : 1280,
|
||
sourceHeight : 500,
|
||
buttons : {
|
||
contextButton : {
|
||
menuItems : [
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[0],// 打印
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[1],// jpeg
|
||
'downloadPNG','downloadPDF',
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[4],// excel
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[3],// cvs
|
||
]
|
||
}
|
||
}
|
||
},
|
||
colors:['#a9d4cf','#eecf8d'],
|
||
title : {
|
||
text : null
|
||
},
|
||
xAxis: {
|
||
type:'datetime',
|
||
dateTimeLabelFormats: {
|
||
second: '%H:%M:%S',
|
||
minute: '%H:%M',
|
||
hour: '%H:%M',
|
||
day: '%m-%d',
|
||
week: '%m-%d',
|
||
month: '%Y-%m',
|
||
year: '%Y'
|
||
},
|
||
title: {
|
||
text: 'time',
|
||
align:'high',
|
||
},
|
||
labels: {
|
||
// rotation: -45, //倾斜的角度
|
||
},
|
||
},
|
||
yAxis : {
|
||
title : {
|
||
text : null
|
||
},
|
||
min:0,
|
||
allowDecimals:false
|
||
},
|
||
tooltip: {
|
||
dateTimeLabelFormats: {
|
||
millisecond: '%Y-%m-%d %H:%M:%S',
|
||
second: '%Y-%m-%d %H:%M:%S',
|
||
minute: '%Y-%m-%d %H:%M:%S',
|
||
hour: '%Y-%m-%d %H:%M:%S',
|
||
day: '%Y-%m-%d %H:%M:%S',
|
||
week: '%Y-%m-%d %H:%M:%S',
|
||
month: '%Y-%m-%d %H:%M:%S',
|
||
year: '%Y-%m-%d %H:%M:%S'
|
||
}
|
||
},
|
||
credits : {//是否有水印
|
||
enabled : false
|
||
},
|
||
plotOptions : {
|
||
series : {
|
||
marker : {
|
||
radius : 2,
|
||
hover : {
|
||
enabled : true,
|
||
radius : 7,
|
||
radiusPlus : 5
|
||
}
|
||
}
|
||
}
|
||
},
|
||
series: [{
|
||
name: '<spring:message code="client_ip"/>',
|
||
lineColor:'#a9d4cf',
|
||
lineWidth:1,
|
||
marker: {
|
||
enabled: false
|
||
},
|
||
data: (function () {
|
||
var data = [];
|
||
if(sipResult!=null&&sipResult.length>0){
|
||
var count=10;
|
||
if(sipResult.length<10){
|
||
count=sipResult.length;
|
||
}
|
||
for (var i = 0; i < count; i++) {
|
||
var d =sipResult[i];
|
||
var x = d[0], // 时间
|
||
y = d[1];
|
||
data.push({
|
||
x: x,
|
||
y: y
|
||
});
|
||
}
|
||
} else{
|
||
var time = (new Date()).getTime()-(1000 * 60 * 10+1000 * 60 * 5);
|
||
for (var i = 0; i <10; i++) {
|
||
data.push({
|
||
x: time + i * 1000*60,
|
||
y: 0
|
||
});
|
||
}
|
||
}
|
||
return data;
|
||
}())
|
||
},
|
||
{
|
||
name: '<spring:message code="server_ip"/>',
|
||
lineColor:'#a9d4cf',
|
||
lineWidth:1,
|
||
marker: {
|
||
enabled: false
|
||
},
|
||
data: (function () {
|
||
var data = [];
|
||
if(dipResult!=null&&dipResult.length>0){
|
||
var count=10;
|
||
if(dipResult.length<10){
|
||
count=dipResult.length;
|
||
}
|
||
for (var i = 0; i < count; i++) {
|
||
var d =dipResult[i];
|
||
var x = d[0], // 当前时间
|
||
y = d[1];
|
||
data.push({
|
||
x: x,
|
||
y: y
|
||
});
|
||
}
|
||
}else{
|
||
var time = (new Date()).getTime()-(1000 * 60 * 10+1000 * 60 * 5);
|
||
for (var i = 0; i <10; i++) {
|
||
data.push({
|
||
x: time + i * 1000*60,
|
||
y: 0
|
||
});
|
||
}
|
||
}
|
||
return data;
|
||
}())
|
||
}]
|
||
});
|
||
|
||
var series = chart.series[0];
|
||
var series1 = chart.series[1];
|
||
window.clearInterval(timer);
|
||
// if(sipResult!=null&&sipResult.length>0){
|
||
timer=setInterval(function() {
|
||
var time3=(new Date().getTime())-(1000 * 60 * 5);
|
||
var time4=(new Date().getTime())-(1000 * 60 * 4);
|
||
var begin=dateFtt("yyyy-MM-dd hh:mm:ss",new Date(time3)); //获取1个点少算一分钟
|
||
var end=dateFtt("yyyy-MM-dd hh:mm:ss",new Date(time4));
|
||
$.ajax({
|
||
url : "${ctx}/dashboard/traffic/ajaxAppTrend?appType="+appType+"&beginDate="+begin+"&endDate="+end+"&entranceId="+entranceId,
|
||
type : "post",
|
||
dataType : "json",
|
||
cache:false,
|
||
async : true,
|
||
success : function(rs) {
|
||
var realTimeData=rs;
|
||
if(realTimeData!=null&&Object.keys(realTimeData).length>0){
|
||
var sipReal=realTimeData.sipResult;
|
||
var dipReal=realTimeData.dipResult;
|
||
var d =sipReal[0];
|
||
series.addPoint([d[0], d[1]], true, true);
|
||
var t =dipReal[0];
|
||
series1.addPoint([t[0], t[1]], true, true);
|
||
}else{
|
||
var x=(new Date()).getTime()-(1000 * 60 * 5);
|
||
var y=0;
|
||
series.addPoint([x, y], true, true);
|
||
series1.addPoint([x, y], true, true);
|
||
}
|
||
|
||
closeTip();
|
||
},
|
||
error : function(data, textStatus, errorThrown) {
|
||
closeTip();
|
||
},
|
||
complete : function(XMLHttpRequest, status) {//超时设置
|
||
closeTip();
|
||
}
|
||
});
|
||
},1000*60);
|
||
// }else{
|
||
// window.clearInterval(timer);
|
||
// }
|
||
}
|
||
// 历史信息
|
||
function showActionHistoryChart(sipResult,dipResult) {
|
||
var nowDate=new Date();
|
||
Highcharts.setOptions({ global: { useUTC: false } });
|
||
var num=0;
|
||
var chart = Highcharts.chart('chart-history',
|
||
{
|
||
chart: {
|
||
type: 'area',
|
||
zoomType: 'x'
|
||
},
|
||
noData:{
|
||
style: {//设置字体颜色
|
||
color: '#413333',
|
||
fontFamily:'Microsoft YaHei',
|
||
fontWeight:"unset",
|
||
},
|
||
},
|
||
exporting : {
|
||
filename : '<spring:message code="${appName}"></spring:message>'+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds(),
|
||
scale : 1,
|
||
sourceWidth : 1280,
|
||
sourceHeight : 500,
|
||
buttons : {
|
||
contextButton : {
|
||
menuItems : [
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[0],// 打印
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[1],// jpeg
|
||
'downloadPNG','downloadPDF',
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[4],// excel
|
||
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[3],// cvs
|
||
]
|
||
}
|
||
}
|
||
},
|
||
colors:['#a9d4cf','#eecf8d'],
|
||
title : {
|
||
text : null
|
||
},
|
||
xAxis: {
|
||
type:'datetime',
|
||
dateTimeLabelFormats: {
|
||
second: '%H:%M:%S',
|
||
minute: '%H:%M',
|
||
hour: '%H:%M',
|
||
day: '%m-%d',
|
||
week: '%m-%d',
|
||
month: '%Y-%m',
|
||
year: '%Y'
|
||
},
|
||
title: {
|
||
text: 'time',
|
||
align:'high',
|
||
},
|
||
labels: {
|
||
// rotation: -45, //倾斜的角度
|
||
},
|
||
},
|
||
yAxis : {
|
||
title : {
|
||
text : null
|
||
},
|
||
min:0,
|
||
allowDecimals:false
|
||
},
|
||
tooltip: {
|
||
dateTimeLabelFormats: {
|
||
millisecond: '%Y-%m-%d %H:%M:%S',
|
||
second: '%Y-%m-%d %H:%M:%S',
|
||
minute: '%Y-%m-%d %H:%M:%S',
|
||
hour: '%Y-%m-%d %H:%M:%S',
|
||
day: '%Y-%m-%d %H:%M:%S',
|
||
week: '%Y-%m-%d %H:%M:%S',
|
||
month: '%Y-%m-%d %H:%M:%S',
|
||
year: '%Y-%m-%d %H:%M:%S'
|
||
}
|
||
},
|
||
credits : {//是否有水印
|
||
enabled : false
|
||
},
|
||
plotOptions : {
|
||
series : {
|
||
marker : {
|
||
radius : 2,
|
||
hover : {
|
||
enabled : true,
|
||
radius : 7,
|
||
radiusPlus : 5
|
||
}
|
||
}
|
||
}
|
||
},
|
||
series: [{
|
||
name: '<spring:message code="client_ip"/>',
|
||
data: sipResult,
|
||
lineColor:'#a9d4cf',
|
||
lineWidth:1,
|
||
marker: {
|
||
enabled: false
|
||
}
|
||
},
|
||
{
|
||
name: '<spring:message code="server_ip"/>',
|
||
data: dipResult,
|
||
lineColor:'#eecf8d',
|
||
lineWidth:1,
|
||
marker: {
|
||
enabled: false
|
||
}
|
||
}]
|
||
});
|
||
}
|
||
(function(H) {
|
||
H.Chart.prototype.downloadXLS = function() {
|
||
var nowDate=new Date();
|
||
var start=$("#beginDateh").val();
|
||
var end=$("#endDateh").val();
|
||
var rows = [];
|
||
var heard = [];
|
||
/* 调用后台接口导出 */
|
||
var total = JSON.parse($("#total").val());
|
||
var timeData = JSON.parse($("#timeData").val());
|
||
var sipData = JSON.parse($("#sipData").val());
|
||
var dipData = JSON.parse($("#dipData").val());
|
||
var map={};
|
||
heard.push("time","server","client");
|
||
for(var i=0;i<sipData.length;i++){
|
||
var colData=[];
|
||
var time=new Date(timeData[i]); //
|
||
var ftime=dateFtt("yyyy-MM-dd hh:mm:ss",time);
|
||
colData.push(ftime,sipData[i],dipData[i])
|
||
rows.push(colData)
|
||
}
|
||
total.unshift('<spring:message code="report_total"/>');
|
||
rows.push(total)
|
||
map["titleTime"]='<spring:message code="${appName}"></spring:message>'+","+start+"--"+end;
|
||
map["heard"]=heard;
|
||
map["book"]=rows;
|
||
map["titleCode"]='<spring:message code="${appName}"></spring:message>'+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds();
|
||
var exports = JSON.stringify(map);
|
||
aJaxImportPost("${ctx}/export/ajaxExport",{"exports":exports});
|
||
};
|
||
}(Highcharts));
|
||
|
||
(function(H) {
|
||
H.Chart.prototype.downloadCSV = function() {
|
||
var total = JSON.parse($("#total").val());
|
||
var timeData = JSON.parse($("#timeData").val());
|
||
var sipData = JSON.parse($("#sipData").val());
|
||
var dipData = JSON.parse($("#dipData").val());
|
||
var data=[];
|
||
for(var i=0;i<sipData.length;i++){
|
||
var colData=[];
|
||
var time=new Date(timeData[i]); //
|
||
var ftime=dateFtt("yyyy-MM-dd hh:mm:ss",time);
|
||
colData.push(ftime,sipData[i],dipData[i])
|
||
data.push({
|
||
num1:ftime,
|
||
num2:sipData[i],
|
||
num3:dipData[i],
|
||
})
|
||
}
|
||
data.push({
|
||
num1:"<spring:message code='report_total'/>",
|
||
num2:total
|
||
})
|
||
var start = $("#beginDateh").val();
|
||
var end = $("#endDateh").val();
|
||
exportCsv({
|
||
title:["<spring:message code='${appName}'/>",start+"--"+end],
|
||
titleForKey:["num1","num2","num3"],
|
||
data:data
|
||
});
|
||
};
|
||
}(Highcharts));
|
||
|
||
function exportCsv(obj){
|
||
var nowDate=new Date();
|
||
//title ["","",""]
|
||
var title = obj.title;
|
||
//titleForKey ["","",""]
|
||
var titleForKey = obj.titleForKey;
|
||
var data = obj.data;
|
||
var str = [];
|
||
str.push(obj.title.join(",")+"\n");
|
||
for(var i=0;i<data.length;i++){
|
||
var temp = [];
|
||
for(var j=0;j<titleForKey.length;j++){
|
||
temp.push(data[i][titleForKey[j]]);
|
||
}
|
||
str.push(temp.join(",")+"\n");
|
||
}
|
||
str = "\uFEFF"+str.join(""); //
|
||
var blob = new Blob([str], {type: 'text/plain'});
|
||
var uri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(blob);
|
||
var downloadLink = document.createElement("a");
|
||
downloadLink.href = window.URL.createObjectURL(blob);
|
||
downloadLink.download = "<spring:message code='${appName}'/>"+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds()+".csv";
|
||
downloadLink.style.display = 'none';
|
||
document.body.appendChild(downloadLink);
|
||
downloadLink.click();
|
||
document.body.removeChild(downloadLink);
|
||
}
|
||
</script>
|
||
</body>
|
||
</html> |