From db33d543152a01024e78789b589e865ff3e23964 Mon Sep 17 00:00:00 2001 From: gaoguangchao <443960933@qq.com> Date: Tue, 16 Jul 2024 18:46:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E9=87=8Fdouble=E5=B0=8F=E6=95=B0?= =?UTF-8?q?=E4=BD=8D=E4=BF=9D=E7=95=992?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/zc/business/domain/OnlineSum.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/domain/OnlineSum.java b/zc-business/src/main/java/com/zc/business/domain/OnlineSum.java index 93a030d1..2146b6f2 100644 --- a/zc-business/src/main/java/com/zc/business/domain/OnlineSum.java +++ b/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 org.springframework.format.annotation.DateTimeFormat; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.Date; public class OnlineSum implements java.io.Serializable { @@ -169,7 +171,9 @@ public class OnlineSum implements java.io.Serializable { this.receiveCount += onlineLog.getReceiveCount(); this.lossCount += onlineLog.getLossCount(); 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){ this.networkQuality = OnlineLog.NetworkQuality.GOOD.getValue(); }else if(this.rttAvg >30 && this.rttAvg <= 100){