You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
5.4 KiB
186 lines
5.4 KiB
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 {
|
|
private static final long serialVersionUID = 1L;
|
|
private long id;
|
|
private long deviceId;
|
|
private String deviceName;
|
|
private String deviceIp;
|
|
private String stakeMark;
|
|
private String deviceStatus;
|
|
private int sendCount;//发送数
|
|
private int receiveCount;//返回数
|
|
private int lossCount;//丢包数
|
|
private String lossRate;//丢包率
|
|
private double rttAvg;//平均往返时延
|
|
private String networkQuality;//网络质量
|
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
private Date statisticalDate;//统计日期
|
|
|
|
public long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public Long getDeviceId() {
|
|
return deviceId;
|
|
}
|
|
|
|
public void setDeviceId(Long deviceId) {
|
|
this.deviceId = deviceId;
|
|
}
|
|
|
|
public String getDeviceName() {
|
|
return deviceName;
|
|
}
|
|
|
|
public void setDeviceName(String deviceName) {
|
|
this.deviceName = deviceName;
|
|
}
|
|
|
|
public String getDeviceIp() {
|
|
return deviceIp;
|
|
}
|
|
|
|
public void setDeviceIp(String deviceIp) {
|
|
this.deviceIp = deviceIp;
|
|
}
|
|
|
|
public String getStakeMark() {
|
|
return stakeMark;
|
|
}
|
|
|
|
public void setStakeMark(String stakeMark) {
|
|
this.stakeMark = stakeMark;
|
|
}
|
|
|
|
public String getDeviceStatus() {
|
|
return deviceStatus;
|
|
}
|
|
|
|
public void setDeviceStatus(String deviceStatus) {
|
|
this.deviceStatus = deviceStatus;
|
|
}
|
|
|
|
public int getSendCount() {
|
|
return sendCount;
|
|
}
|
|
|
|
public void setSendCount(int sendCount) {
|
|
this.sendCount = sendCount;
|
|
}
|
|
|
|
public int getReceiveCount() {
|
|
return receiveCount;
|
|
}
|
|
|
|
public void setReceiveCount(int receiveCount) {
|
|
this.receiveCount = receiveCount;
|
|
}
|
|
|
|
public int getLossCount() {
|
|
return lossCount;
|
|
}
|
|
|
|
public void setLossCount(int lossCount) {
|
|
this.lossCount = lossCount;
|
|
}
|
|
|
|
public String getLossRate() {
|
|
return lossRate;
|
|
}
|
|
|
|
public void setLossRate(String lossRate) {
|
|
this.lossRate = lossRate;
|
|
}
|
|
|
|
public double getRttAvg() {
|
|
return rttAvg;
|
|
}
|
|
|
|
public void setRttAvg(double rttAvg) {
|
|
this.rttAvg = rttAvg;
|
|
}
|
|
|
|
public String getNetworkQuality() {
|
|
return networkQuality;
|
|
}
|
|
|
|
public void setNetworkQuality(String networkQuality) {
|
|
this.networkQuality = networkQuality;
|
|
}
|
|
|
|
public Date getStatisticalDate() {
|
|
return statisticalDate;
|
|
}
|
|
|
|
public void setStatisticalDate(Date statisticalDate) {
|
|
this.statisticalDate = statisticalDate;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "OnlineSum{" +
|
|
"id=" + id +
|
|
", deviceId='" + deviceId + '\'' +
|
|
", deviceName='" + deviceName + '\'' +
|
|
", deviceIp='" + deviceIp + '\'' +
|
|
", stakeMark='" + stakeMark + '\'' +
|
|
", deviceStatus='" + deviceStatus + '\'' +
|
|
", sendCount=" + sendCount +
|
|
", receiveCount=" + receiveCount +
|
|
", lossCount=" + lossCount +
|
|
", lossRate='" + lossRate + '\'' +
|
|
", rttAvg=" + rttAvg +
|
|
", networkQuality='" + networkQuality + '\'' +
|
|
", statisticalDate=" + statisticalDate +
|
|
'}';
|
|
}
|
|
|
|
public OnlineSum copyFromLog(OnlineLog onlineLog) {
|
|
this.deviceId = onlineLog.getDeviceId();
|
|
this.deviceName = onlineLog.getDeviceName();
|
|
this.deviceIp = onlineLog.getDeviceIp();
|
|
this.stakeMark = onlineLog.getStakeMark();
|
|
this.deviceStatus = onlineLog.getDeviceStatus();
|
|
this.sendCount = onlineLog.getSendCount();
|
|
this.receiveCount = onlineLog.getReceiveCount();
|
|
this.lossCount = onlineLog.getLossCount();
|
|
this.lossRate = onlineLog.getLossRate();
|
|
this.rttAvg = onlineLog.getRttAvg();
|
|
this.networkQuality = onlineLog.getNetworkQuality();
|
|
this.statisticalDate = new Date();
|
|
return this;
|
|
}
|
|
|
|
public OnlineSum incrementSummary(OnlineLog onlineLog) {
|
|
double rtt = this.rttAvg*this.sendCount+onlineLog.getRttAvg()*onlineLog.getSendCount();
|
|
this.deviceStatus = onlineLog.getDeviceStatus();
|
|
this.sendCount += onlineLog.getSendCount();
|
|
this.receiveCount += onlineLog.getReceiveCount();
|
|
this.lossCount += onlineLog.getLossCount();
|
|
this.lossRate = String.format("%.2f%%", (this.sendCount==0?0:(double)this.lossCount/this.sendCount)*100);
|
|
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){
|
|
this.networkQuality = OnlineLog.NetworkQuality.NORMAL.getValue();
|
|
}else {
|
|
this.networkQuality = OnlineLog.NetworkQuality.BAD.getValue();
|
|
}
|
|
return this;
|
|
}
|
|
}
|
|
|