提交新登录界面,流量统计带宽详情增加地域区分图表显示,增加时间范围查询,协议类型码表无对应数据则取app码表
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.nis.web.controller.dashboard;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -16,6 +17,7 @@ import java.util.Set;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -34,11 +36,13 @@ import com.google.gson.LongSerializationPolicy;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.PageLog;
|
||||
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.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.dao.dashboard.codedic.CodeResult;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/dashboard/traffic")
|
||||
@@ -111,7 +115,7 @@ 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:ss" ).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("beginDate", oneHoursAgo);
|
||||
@@ -149,12 +153,25 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
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());//获取到完整的时间
|
||||
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());
|
||||
}
|
||||
URIBuilder uriBuilder = new URIBuilder(url);
|
||||
uriBuilder.addParameter("beginDate",beginDate);
|
||||
uriBuilder.addParameter("endDate",endDate);
|
||||
return uriBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* 根据ip46,协议tcp,udp查询带宽 间隔5分钟数据
|
||||
*/
|
||||
@RequestMapping(value="bandwidthTrans")
|
||||
@ResponseBody
|
||||
public Map ipActiveMinuteList(@RequestParam("addrType")String addrType,@RequestParam("transType")Integer transType){
|
||||
public Map bandwidthTrans(String beginDate,String endDate,@RequestParam("addrType")String addrType,@RequestParam("transType")Integer transType){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
Map map = new HashMap();
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS;
|
||||
@@ -165,6 +182,41 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
url=url+"?transType="+transType;
|
||||
}
|
||||
try {
|
||||
url=urlAddDate(url,beginDate,endDate);
|
||||
|
||||
String string = HttpClientUtil.get(url);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
logger.debug("带宽1小时,间隔5分钟数据"+fromJsonList);
|
||||
List list = (ArrayList) fromJsonList.get("data");
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
map=(Map) list.get(0);
|
||||
}
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("带宽详情数据获取错误"+e);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
/**
|
||||
* 根据ip46,协议tcp,udp查询带宽 间隔5分钟数据
|
||||
*/
|
||||
@RequestMapping(value="bandwidthTransTwo")
|
||||
@ResponseBody
|
||||
public Map bandwidthTransTwo(String beginDate,String endDate,@RequestParam("addrType")String addrType,@RequestParam("transType")Integer transType){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
Map map = new HashMap();
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_TWO;
|
||||
if(!StringUtil.isBlank(addrType)){
|
||||
url=url+"?addrType="+addrType;
|
||||
}
|
||||
if(transType!=null){
|
||||
url=url+"?transType="+transType;
|
||||
}
|
||||
try {
|
||||
url=urlAddDate(url,beginDate,endDate);
|
||||
|
||||
String string = HttpClientUtil.get(url);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
@@ -184,7 +236,14 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
* 协议类型详细列表
|
||||
*/
|
||||
@RequestMapping(value="protocolTypeList")
|
||||
public String protocolTypeList(){
|
||||
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());//获取到完整的时间
|
||||
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);
|
||||
return "/dashboard/trafficProtocolTypeList";
|
||||
}
|
||||
/**
|
||||
@@ -212,9 +271,11 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
Double totalGByte=0d;
|
||||
DecimalFormat lf = new DecimalFormat("0");
|
||||
DecimalFormat df = new DecimalFormat("0.00000000");
|
||||
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
Double value1 = Double.parseDouble(m.get("protocolType").toString());
|
||||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||||
// String linkNum = df.format(m.get("linkNum"));
|
||||
m.put("GByte", df.format(m.get("GByte")));
|
||||
@@ -222,6 +283,14 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||||
// 协议没匹配的匹配app码表
|
||||
for (CodeResult code : appCodeList) {
|
||||
Double value3 = Double.valueOf(code.getCode());
|
||||
if(value1.equals(value3)){
|
||||
m.put("protocolType", code.getItem());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
|
||||
Reference in New Issue
Block a user