修复磁盘NPE

This commit is contained in:
gaoyutao
2026-01-30 21:21:48 +08:00
parent f75a49474a
commit 180986ba16
3 changed files with 27 additions and 13 deletions
@@ -240,11 +240,16 @@ public class MessageHandler {
String province = locationInfo.get("province");
// 过滤本地省份和空值
if (province != null && operator != null
&& (!localProvince.equals(province) || !localIsp.equals(operator))) {
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
double currentCount = v4StatMap.getOrDefault(key, 0.0);
v4StatMap.put(key, currentCount + tcpdumpVo.getCount());
if (province != null && operator != null) {
// 标准化运营商名称
String stdLocalIsp = localIsp != null ? localIsp.replace("中国", "") : "";
String stdOperator = operator.replace("中国", "");
// 省不一样或者省一样但运营商不一样
if (!localProvince.equals(province) || !stdLocalIsp.equals(stdOperator)) {
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
double currentCount = v4StatMap.getOrDefault(key, 0.0);
v4StatMap.put(key, currentCount + tcpdumpVo.getCount());
}
}
}
}
@@ -280,11 +285,16 @@ public class MessageHandler {
String province = locationInfo.get("province");
// 过滤本地省份和空值
if (province != null && operator != null
&& (!localProvince.equals(province) || !localIsp.equals(operator))) {
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
double currentCount = v6StatMap.getOrDefault(key, 0.0);
v6StatMap.put(key, currentCount + tcpdumpVo.getCount());
if (province != null && operator != null) {
// 标准化运营商名称
String stdLocalIsp = localIsp != null ? localIsp.replace("中国", "") : "";
String stdOperator = operator.replace("中国", "");
// 省不一样或者省一样但运营商不一样
if (!localProvince.equals(province) || !stdLocalIsp.equals(stdOperator)) {
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
double currentCount = v6StatMap.getOrDefault(key, 0.0);
v6StatMap.put(key, currentCount + tcpdumpVo.getCount());
}
}
}
}
@@ -279,7 +279,11 @@ public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
if(list != null && !list.isEmpty()){
Long totalUsedSpace = 0L;
for (InitialDiskInfo diskInfo : list) {
totalUsedSpace += diskInfo.getUsedSpace();
// 处理 null 值
Long usedSpace = diskInfo.getUsedSpace();
if (usedSpace != null) {
totalUsedSpace += usedSpace;
}
}
Long avgUsedSpace = totalUsedSpace/list.size();
unit = SpeedUtils.determineUnitByValue(avgUsedSpace);