流量统计增加协议详情统计图与列表,列表可分页及导出
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package com.nis.web.controller.dashboard;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -18,6 +21,12 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.beust.jcommander.internal.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
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.dashboard.TrafficIpActiveStatistic;
|
||||
@@ -29,19 +38,6 @@ import com.nis.web.controller.BaseController;
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/dashboard/traffic")
|
||||
public class TrafficStatisticsInfoController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 协议类型详细列表
|
||||
*/
|
||||
@RequestMapping(value="protocolTypeList")
|
||||
public String protocolTypeList(){
|
||||
|
||||
return "/dashboard/trafficProtocolTypeList";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rejectNum 封堵数量
|
||||
* newUniConn 新建连接数
|
||||
@@ -105,6 +101,11 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
@RequestMapping(value="bandwidthList")
|
||||
public String bandwidthList( HttpServletRequest request, HttpServletResponse response, Model model){
|
||||
return "/dashboard/trafficBandwidthList";
|
||||
}
|
||||
/**
|
||||
* 根据ip46,协议tcp,udp查询带宽 间隔5分钟数据
|
||||
*/
|
||||
@@ -136,21 +137,58 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@RequestMapping(value="bandwidthList")
|
||||
public String bandwidthList( HttpServletRequest request, HttpServletResponse response, Model model){
|
||||
PageLog<TrafficIpActiveStatistic> page = new PageLog<TrafficIpActiveStatistic>(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/trafficBandwidthList";
|
||||
/**
|
||||
* 协议类型详细列表
|
||||
*/
|
||||
@RequestMapping(value="protocolTypeList")
|
||||
public String protocolTypeList(){
|
||||
return "/dashboard/trafficProtocolTypeList";
|
||||
}
|
||||
/**
|
||||
* 协议详情统计图跟表
|
||||
*/
|
||||
@RequestMapping(value="protocolList")
|
||||
@ResponseBody
|
||||
public List protocolList(){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_LIST;
|
||||
try {
|
||||
String string = HttpClientUtil.get(url);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
logger.info("协议详情5分钟数据"+fromJsonList);
|
||||
list = (ArrayList) fromJsonList.get("data");
|
||||
Long totalLink=0l;
|
||||
Long totalPackets=0l;
|
||||
Double totalGByte=0d;
|
||||
DecimalFormat lf = new DecimalFormat("0");
|
||||
DecimalFormat df = new DecimalFormat("0.00000000");
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||||
// String linkNum = df.format(m.get("linkNum"));
|
||||
m.put("GByte", df.format(m.get("GByte")));
|
||||
m.put("packets", lf.format(m.get("packets")));
|
||||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||||
}
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
m.put("totalLink", totalLink);
|
||||
m.put("totalPackets", totalPackets);
|
||||
m.put("totalGByte", totalGByte);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("协议详情数据获取错误"+e);
|
||||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user