bps计算保留两位小数展示

This commit is contained in:
tanghao
2019-01-22 16:54:11 +08:00
parent 0ed34ac938
commit 79de7b51df
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())){

View File

@@ -379,7 +379,7 @@
html += "<td class='tc'>" + data.pps + "</td>";
html += "<td class='tc'>" + data.pktPercent + " %</td>";
html += "<td class='tc'>" + Math.round(data.byteNum*100)/100 + "</td>";
html += "<td class='tc'>" + data.bps + "</td>";
html += "<td class='tc'>" + Math.round(data.bps*100)/100 + "</td>";
html += "<td class='tc'>" + data.bytePercent + " %</td>";
html += "</tr>"
if(index==fileDataS.length-1){

View File

@@ -355,7 +355,7 @@ function htmlData(fileDataS){
html+= "<td class='tc'>"+data.pps+"</td>";
html+= "<td class='tc'>"+packper+"%"+"</td>";
html+= "<td class='tc'>"+Math.round(data.GByte*100)/100+"</td>";
html+= "<td class='tc'>"+data.bps+"</td>";
html+= "<td class='tc'>"+Math.round(data.bps*100)/100+"</td>";
html+= "<td class='tc'>"+gbytper+"%"+"</td>";
html+="</tr>"
if(index==fileDataS.length-1){

View File

@@ -300,7 +300,7 @@ function htmlData(fileDataS){
html+= "<td class='tc'>"+data.pps+"</td>";
html+= "<td class='tc'>"+(data.packets/data.allPackets*100).toFixed(2)+"%"+"</td>";
html+= "<td class='tc'>"+(data.count/1073741824).toFixed(2)+"</td>";
html+= "<td class='tc'>"+data.bps+"</td>";
html+= "<td class='tc'>"+Math.round(data.bps*100)/100+"</td>";
html+= "<td class='tc'>"+(data.count/data.allGByte*100).toFixed(2)+"%"+"</td>";
html+="</tr>"
if(index==fileDataS.length-1){

View File

@@ -419,7 +419,7 @@ function showIpActiveChart(xData,series){
html+= "<td class='tc'>"+rs.c2sByteLen+"</td>";
html+= "<td class='tc'>"+rs.s2cByteLen+"</td>";
html+= "<td class='tc'>"+byteNum+"</td>";
html+= "<td class='tc'>"+rs.avgByte+"</td>";
html+= "<td class='tc'>"+Math.round(rs.avgByte*100)/100+"</td>";
html+= "<td class='tc'>"+rs.linkNum+"</td>";
html+= "<td class='tc'>"+rs.c2sPktNum+"</td>";
html+= "<td class='tc'>"+rs.s2cPktNum+"</td>";

View File

@@ -368,7 +368,7 @@ function htmlData(fileDataS){
html+= "<td class='tc'>"+data.pps+"</td>";
html+= "<td class='tc'>"+packper+"%"+"</td>";
html+= "<td class='tc'>"+Math.round(data.GByte*100)/100+"</td>";
html+= "<td class='tc'>"+data.bps+"</td>";
html+= "<td class='tc'>"+Math.round(data.bps*100)/100+"</td>";
html+= "<td class='tc'>"+gbytper+"%"+"</td>";
html+="</tr>"
if(index==fileDataS.length-1){

View File

@@ -400,7 +400,7 @@
html += "<td class='tc'>" + data.pps + "</td>";
html += "<td class='tc'>" + packper + " %</td>";
html += "<td class='tc'>" + Math.round(data.Gbyte*100)/100 + "</td>";
html += "<td class='tc'>" + data.bps + "</td>";
html += "<td class='tc'>" + Math.round(data.bps*100)/100 + "</td>";
html += "<td class='tc'>" + gbytper + " %</td>";
html += "</tr>"
if(index==fileDataS.length-1){