bps计算保留两位小数展示

(cherry picked from commit 79de7b51df)
This commit is contained in:
tanghao
2019-01-22 08:54:11 +00:00
committed by 王鑫
parent 372232d206
commit 86365ad7b1
8 changed files with 18 additions and 12 deletions

View File

@@ -263,11 +263,12 @@ public class DashboardController extends BaseController{
list = gson.fromJson(fromJsonList.get("data").toString(), new TypeToken<List<TrafficIpActiveStatistic>>() {}.getType()) ;
if(list.size()>0) {
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
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(Long.parseLong(data.get_byte())/1024/1024/1024/allSeconds));
data.setAvgByte(f.format(Long.parseLong(data.get_byte())/1024/1024/1024/allSeconds));
data.setAvgPacket(lf.format(Long.parseLong(data.get_packet())/allSeconds));
}
}

View File

@@ -331,6 +331,7 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
DecimalFormat df = new DecimalFormat("0.0000000000");
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
//两个时间段之间的秒数
@@ -347,7 +348,7 @@ public class TrafficStatisticsInfoController extends BaseController {
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("GByte").toString())/allSeconds;
m.put("bps",lf.format(avgByte));
m.put("bps",f.format(avgByte));
totalLink+=Long.parseLong( m.get("linkNum").toString());
totalPackets+=Long.parseLong(m.get("packets").toString());
// 协议没匹配的匹配app码表
@@ -418,6 +419,7 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
DecimalFormat df = new DecimalFormat("0.0000000000");
//两个时间段之间的秒数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -436,7 +438,7 @@ public class TrafficStatisticsInfoController extends BaseController {
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("GByte").toString())/allSeconds;
m.put("bps",lf.format(avgByte));
m.put("bps",f.format(avgByte));
}
for (Object object : list) {
Map m=(Map) object;
@@ -540,13 +542,14 @@ public class TrafficStatisticsInfoController extends BaseController {
if(list.size()>0) {
//两个时间段之间的秒数
DecimalFormat dl = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
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())/1024/1024/1024/allSeconds;
m.put("bps",dl.format(avgByte));
m.put("bps",f.format(avgByte));
}
}
} catch (Exception e) {
@@ -647,6 +650,7 @@ public class TrafficStatisticsInfoController extends BaseController {
DecimalFormat df = new DecimalFormat("0.000000000");
DecimalFormat dl = new DecimalFormat("0");
DecimalFormat pf = new DecimalFormat("0.000000000");
DecimalFormat f = new DecimalFormat("0.00");
// Double totalLink=0d;
Double totalGbyte=0d;
Double totalPackets=0d;
@@ -665,7 +669,7 @@ public class TrafficStatisticsInfoController extends BaseController {
double avgPacket=Double.parseDouble(m.get("pktCount").toString())/allSeconds;
m.put("pps",dl.format(avgPacket));
double avgByte=Double.parseDouble(m.get("byteCount").toString())/1024/1024/1024/allSeconds;
m.put("bps",dl.format(avgByte));
m.put("bps",f.format(avgByte));
}
List<WebsiteDomainTopic> codeList = appCfgService.getDomainDict(new WebsiteDomainTopic());
Map<Long, String> map = new HashMap<Long,String>();
@@ -735,6 +739,7 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
//两个时间段之间的秒数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
@@ -747,7 +752,7 @@ public class TrafficStatisticsInfoController extends BaseController {
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("count").toString())/1024/1024/1024/allSeconds;
m.put("bps",lf.format(avgByte));
m.put("bps",f.format(avgByte));
m.remove("domainData");
Double value1=0d;
if(StringUtil.isBlank(m.get("topicId").toString())){