修复个别机器出省流量统计失败问题。
增加日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 + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 新增资源注册
|
||||
*
|
||||
|
||||
@@ -287,6 +287,7 @@ public class MessageHandler {
|
||||
// 查询子网卡
|
||||
RmNetworkInterfaceChild childQuery = new RmNetworkInterfaceChild();
|
||||
childQuery.setClientId(message.getClientId());
|
||||
childQuery.setIpv4Flag(true);
|
||||
List<RmNetworkInterfaceChild> existingChildren = rmNetworkInterfaceChildService.selectRmNetworkInterfaceChildList(childQuery);
|
||||
if(existingChildren != null && !existingChildren.isEmpty()){
|
||||
RmNetworkInterfaceChild networkInfoChild = existingChildren.get(0);
|
||||
@@ -349,7 +350,7 @@ public class MessageHandler {
|
||||
String stdLocalIsp = localIsp != null ? localIsp.replace("中国", "") : "";
|
||||
String stdOperator = operator.replace("中国", "");
|
||||
// 省不一样或者省一样但运营商不一样
|
||||
if (!localProvince.equals(province) || !stdLocalIsp.equals(stdOperator)) {
|
||||
if (!province.equals(localProvince) || !stdLocalIsp.equals(stdOperator)) {
|
||||
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
||||
double currentCount = v4StatMap.getOrDefault(key, 0.0);
|
||||
v4StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
||||
@@ -392,7 +393,7 @@ public class MessageHandler {
|
||||
String stdLocalIsp = localIsp != null ? localIsp.replace("中国", "") : "";
|
||||
String stdOperator = operator.replace("中国", "");
|
||||
// 省不一样或者省一样但运营商不一样
|
||||
if (!localProvince.equals(province) || !stdLocalIsp.equals(stdOperator)) {
|
||||
if (!province.equals(localProvince) || !stdLocalIsp.equals(stdOperator)) {
|
||||
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
||||
double currentCount = v6StatMap.getOrDefault(key, 0.0);
|
||||
v6StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
<if test="partNumber != null and partNumber != ''"> and part_number = #{partNumber}</if>
|
||||
<!-- 新增health_status查询条件 -->
|
||||
<if test="healthStatus != null and healthStatus != ''"> and health_status = #{healthStatus}</if>
|
||||
and `name` not like "%not%"
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user