Browse Source

增量double小数位保留2

develop
gaoguangchao 4 months ago
parent
commit
db33d54315
  1. 6
      zc-business/src/main/java/com/zc/business/domain/OnlineSum.java

6
zc-business/src/main/java/com/zc/business/domain/OnlineSum.java

@ -3,6 +3,8 @@ package com.zc.business.domain;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date; import java.util.Date;
public class OnlineSum implements java.io.Serializable { public class OnlineSum implements java.io.Serializable {
@ -169,7 +171,9 @@ public class OnlineSum implements java.io.Serializable {
this.receiveCount += onlineLog.getReceiveCount(); this.receiveCount += onlineLog.getReceiveCount();
this.lossCount += onlineLog.getLossCount(); this.lossCount += onlineLog.getLossCount();
this.lossRate = String.format("%.2f%%", (this.sendCount==0?0:(double)this.lossCount/this.sendCount)*100); this.lossRate = String.format("%.2f%%", (this.sendCount==0?0:(double)this.lossCount/this.sendCount)*100);
this.rttAvg = this.sendCount==0?0:rtt/this.sendCount; BigDecimal bd = new BigDecimal(Double.toString(this.sendCount==0?0:rtt/this.sendCount));
bd = bd.setScale(2, RoundingMode.HALF_UP);
this.rttAvg =bd.doubleValue();
if(this.rttAvg > 0 && this.rttAvg <= 30){ if(this.rttAvg > 0 && this.rttAvg <= 30){
this.networkQuality = OnlineLog.NetworkQuality.GOOD.getValue(); this.networkQuality = OnlineLog.NetworkQuality.GOOD.getValue();
}else if(this.rttAvg >30 && this.rttAvg <= 100){ }else if(this.rttAvg >30 && this.rttAvg <= 100){

Loading…
Cancel
Save