修复个别机器出省流量统计失败问题。
增加日95利用率排序
This commit is contained in:
+41
-3
@@ -133,7 +133,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
childData = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||
}
|
||||
batchSetNetWorkMsg(allData);
|
||||
|
||||
setBandwidthYestoday(allData);
|
||||
// 1. 过滤
|
||||
List<RmResourceRegistration> filteredList = allData;
|
||||
if (hasQueryParam) {
|
||||
@@ -168,7 +168,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
List<RmResourceRegistration> currentPageData = new ArrayList<>(pageList);
|
||||
|
||||
// 4. 只处理当前页数据
|
||||
processCurrentPageData(currentPageData);
|
||||
// processCurrentPageData(currentPageData);
|
||||
|
||||
resultMap.put("list", currentPageData);
|
||||
resultMap.put("total", total);
|
||||
@@ -326,7 +326,18 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
RmResourceRegistration::getBandwidthResult,
|
||||
Comparator.nullsLast(Comparator.reverseOrder())
|
||||
);
|
||||
} else if (sortType == 4) { // 告警优先排序
|
||||
} else if (sortType == 5) { // 升序:按数值从小到大(如 10.1% < 110.1%)
|
||||
comparator = Comparator.comparing(
|
||||
r -> parsePercentage(r.getBandwidthRate()), // 转换为数值
|
||||
Comparator.nullsFirst(Comparator.naturalOrder())
|
||||
);
|
||||
} else if (sortType == 6) { // 降序:按数值从大到小
|
||||
comparator = Comparator.comparing(
|
||||
r -> parsePercentage(r.getBandwidthRate()), // 转换为数值
|
||||
Comparator.nullsLast(Comparator.reverseOrder())
|
||||
);
|
||||
}
|
||||
else if (sortType == 4) { // 告警优先排序
|
||||
comparator = (a, b) -> {
|
||||
// 设置告警标志
|
||||
boolean aAlarm = isAlarm(a);
|
||||
@@ -356,6 +367,17 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
list.sort(comparator);
|
||||
}
|
||||
}
|
||||
private BigDecimal parsePercentage(String rate) {
|
||||
if (rate == null || rate.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String numericStr = rate.trim().replace("%", "");
|
||||
return new BigDecimal(numericStr);
|
||||
} catch (NumberFormatException e) {
|
||||
return null; // 转换失败返回 null,后续会被 nullsLast 处理
|
||||
}
|
||||
}
|
||||
private boolean isAlarm(RmResourceRegistration item) {
|
||||
Date delAlarmTime = item.getDelAlarmTime();
|
||||
boolean alarmFlag = true;
|
||||
@@ -811,6 +833,22 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setBandwidthYestoday(List<RmResourceRegistration> registrationList){
|
||||
for (RmResourceRegistration registration : registrationList) {
|
||||
// 查询昨日95值
|
||||
BigDecimal bandwidthResult = registration.getBandwidthResult();
|
||||
BigDecimal reportedBandwidth = registration.getReportedBandwidth();
|
||||
if(reportedBandwidth != null && bandwidthResult != null){
|
||||
if(reportedBandwidth.compareTo(BigDecimal.ZERO) == 0){
|
||||
registration.setBandwidthRate(null);
|
||||
}else{
|
||||
// 计算日95带宽值利用率
|
||||
BigDecimal bandwidthRate = bandwidthResult.multiply(new BigDecimal(100)).divide(reportedBandwidth, 1, RoundingMode.HALF_UP);
|
||||
registration.setBandwidthRate(bandwidthRate + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 新增资源注册
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user