流量统计菜单下所有菜单包含包总量和字节总量的列表:

增加两列pps 与 bps
This commit is contained in:
tanghao
2019-01-17 12:43:04 +08:00
parent 3e79c2a0fd
commit c16f9b16bb
13 changed files with 149 additions and 30 deletions

View File

@@ -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;
}