流量统计菜单下所有菜单包含包总量和字节总量的列表:
增加两列pps 与 bps
This commit is contained in:
@@ -3,6 +3,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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -248,7 +249,7 @@ public class DashboardController extends BaseController{
|
||||
@ResponseBody
|
||||
public List ajaxIpActiveList(String beginDate,String endDate,Integer entranceId){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
List<TrafficIpActiveStatistic> list = new ArrayList<TrafficIpActiveStatistic>();
|
||||
try {
|
||||
String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_IPACTIVE_ONEHOUR;
|
||||
url=urlAddDate(url, beginDate, endDate);
|
||||
@@ -260,6 +261,16 @@ public class DashboardController extends BaseController{
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map<String, Object>>(){}.getType());
|
||||
logger.debug("活跃IP1小时"+fromJsonList);
|
||||
list = gson.fromJson(fromJsonList.get("data").toString(), new TypeToken<List<TrafficIpActiveStatistic>>() {}.getType()) ;
|
||||
if(list.size()>0) {
|
||||
DecimalFormat lf = new DecimalFormat("0");
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
//两个时间段之间的秒数
|
||||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||||
for(TrafficIpActiveStatistic data:list) {
|
||||
data.setAvgByte(lf.format(Integer.parseInt(data.get_byte())*8/allSeconds));
|
||||
data.setAvgPacket(lf.format(Integer.parseInt(data.get_packet())/allSeconds));
|
||||
}
|
||||
}
|
||||
Collections.sort(list, new Comparator<TrafficIpActiveStatistic>() {
|
||||
|
||||
@Override
|
||||
@@ -282,7 +293,7 @@ public class DashboardController extends BaseController{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("活跃IP数据获取错误"+e);
|
||||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||||
//list.add(Maps.newHashMap("error","request_service_failed"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ 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.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
@@ -301,6 +302,7 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
@RequestMapping(value="protocolList")
|
||||
@ResponseBody
|
||||
public List protocolList(Model model,Integer entranceId,Integer[] protoType,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_LIST;
|
||||
@@ -327,6 +329,8 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
DecimalFormat lf = new DecimalFormat("0");
|
||||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||||
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
|
||||
//两个时间段之间的秒数
|
||||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
@@ -336,6 +340,10 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
m.put("GByte", df.format(m.get("GByte")));
|
||||
m.put("packets", lf.format(m.get("packets")));
|
||||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||||
m.put("pps",lf.format(avgPacket));
|
||||
double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds;
|
||||
m.put("bps",lf.format(avgByte));
|
||||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||||
// 协议没匹配的匹配app码表
|
||||
@@ -407,6 +415,9 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
Double totalGByte=0d;
|
||||
DecimalFormat lf = new DecimalFormat("0");
|
||||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||||
//两个时间段之间的秒数
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
@@ -417,6 +428,11 @@ 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());
|
||||
|
||||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||||
m.put("pps",lf.format(avgPacket));
|
||||
double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds;
|
||||
m.put("bps",lf.format(avgByte));
|
||||
}
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
@@ -485,7 +501,7 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
@ResponseBody
|
||||
public List ajaxAppTopList(String beginDate,String endDate,Integer appType,Integer entranceId,Integer searchQuota,Model model){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
try {
|
||||
String url=Constants.DASHBOARD_URL+Constants.APPCONN_RECORD_TOP100;
|
||||
URIBuilder uriBuilder = new URIBuilder(url);
|
||||
@@ -508,7 +524,18 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map<String, Object>>(){}.getType());
|
||||
logger.debug("app列表Top100"+fromJsonList);
|
||||
list = (ArrayList) fromJsonList.get("data");
|
||||
|
||||
if(list.size()>0) {
|
||||
//两个时间段之间的秒数
|
||||
DecimalFormat dl = new DecimalFormat("0");
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||||
for(Map m:list) {
|
||||
double avgPacket=Double.parseDouble(m.get("pktNum").toString())/allSeconds;
|
||||
m.put("pps",dl.format(avgPacket));
|
||||
double avgByte=Double.parseDouble(m.get("byteNum").toString())*8/allSeconds;
|
||||
m.put("bps",dl.format(avgByte));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("app列表Top100"+e);
|
||||
@@ -610,6 +637,9 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
// Double totalLink=0d;
|
||||
Double totalGbyte=0d;
|
||||
Double totalPackets=0d;
|
||||
//两个时间段之间的秒数
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||||
for (Object object : list) {
|
||||
Map m=(Map)object;
|
||||
Double count=(Double)m.get("byteCount");
|
||||
@@ -618,6 +648,11 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
totalPackets+=(Double)m.get("pktCount");
|
||||
String format = df.format(count/1024/1024/1024);
|
||||
m.put("Gbyte", format);
|
||||
|
||||
double avgPacket=Double.parseDouble(m.get("pktCount").toString())/allSeconds;
|
||||
m.put("pps",dl.format(avgPacket));
|
||||
double avgByte=Double.parseDouble(m.get("byteCount").toString())*8/allSeconds;
|
||||
m.put("bps",dl.format(avgByte));
|
||||
}
|
||||
List<WebsiteDomainTopic> codeList = appCfgService.getDomainDict(new WebsiteDomainTopic());
|
||||
Map<Long, String> map = new HashMap<Long,String>();
|
||||
@@ -687,12 +722,19 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
Long totalPackets=0l;
|
||||
Double totalGByte=0d;
|
||||
DecimalFormat lf = new DecimalFormat("0");
|
||||
//两个时间段之间的秒数
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
for (Object object : list) {
|
||||
Map m=(Map) object;
|
||||
totalLink+=Long.parseLong(lf.format(m.get("linkNum")));
|
||||
totalPackets+=Long.parseLong(lf.format(m.get("packets")));
|
||||
totalGByte+=Double.parseDouble(lf.format(m.get("count")));
|
||||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||||
m.put("pps",lf.format(avgPacket));
|
||||
double avgByte=Double.parseDouble(m.get("count").toString())*8/allSeconds;
|
||||
m.put("bps",lf.format(avgByte));
|
||||
m.remove("domainData");
|
||||
Double value1=0d;
|
||||
if(StringUtil.isBlank(m.get("topicId").toString())){
|
||||
|
||||
Reference in New Issue
Block a user