修复磁盘NPE
This commit is contained in:
@@ -240,14 +240,19 @@ public class MessageHandler {
|
|||||||
String province = locationInfo.get("province");
|
String province = locationInfo.get("province");
|
||||||
|
|
||||||
// 过滤本地省份和空值
|
// 过滤本地省份和空值
|
||||||
if (province != null && operator != null
|
if (province != null && operator != null) {
|
||||||
&& (!localProvince.equals(province) || !localIsp.equals(operator))) {
|
// 标准化运营商名称
|
||||||
|
String stdLocalIsp = localIsp != null ? localIsp.replace("中国", "") : "";
|
||||||
|
String stdOperator = operator.replace("中国", "");
|
||||||
|
// 省不一样或者省一样但运营商不一样
|
||||||
|
if (!localProvince.equals(province) || !stdLocalIsp.equals(stdOperator)) {
|
||||||
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
||||||
double currentCount = v4StatMap.getOrDefault(key, 0.0);
|
double currentCount = v4StatMap.getOrDefault(key, 0.0);
|
||||||
v4StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
v4StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 计算百分比并排序
|
// 计算百分比并排序
|
||||||
List<Map.Entry<String, Double>> sortedV4List = new ArrayList<>(v4StatMap.entrySet());
|
List<Map.Entry<String, Double>> sortedV4List = new ArrayList<>(v4StatMap.entrySet());
|
||||||
@@ -280,14 +285,19 @@ public class MessageHandler {
|
|||||||
String province = locationInfo.get("province");
|
String province = locationInfo.get("province");
|
||||||
|
|
||||||
// 过滤本地省份和空值
|
// 过滤本地省份和空值
|
||||||
if (province != null && operator != null
|
if (province != null && operator != null) {
|
||||||
&& (!localProvince.equals(province) || !localIsp.equals(operator))) {
|
// 标准化运营商名称
|
||||||
|
String stdLocalIsp = localIsp != null ? localIsp.replace("中国", "") : "";
|
||||||
|
String stdOperator = operator.replace("中国", "");
|
||||||
|
// 省不一样或者省一样但运营商不一样
|
||||||
|
if (!localProvince.equals(province) || !stdLocalIsp.equals(stdOperator)) {
|
||||||
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
||||||
double currentCount = v6StatMap.getOrDefault(key, 0.0);
|
double currentCount = v6StatMap.getOrDefault(key, 0.0);
|
||||||
v6StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
v6StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 计算百分比并排序
|
// 计算百分比并排序
|
||||||
List<Map.Entry<String, Double>> sortedV6List = new ArrayList<>(v6StatMap.entrySet());
|
List<Map.Entry<String, Double>> sortedV6List = new ArrayList<>(v6StatMap.entrySet());
|
||||||
|
|||||||
+5
-1
@@ -279,7 +279,11 @@ public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
|
|||||||
if(list != null && !list.isEmpty()){
|
if(list != null && !list.isEmpty()){
|
||||||
Long totalUsedSpace = 0L;
|
Long totalUsedSpace = 0L;
|
||||||
for (InitialDiskInfo diskInfo : list) {
|
for (InitialDiskInfo diskInfo : list) {
|
||||||
totalUsedSpace += diskInfo.getUsedSpace();
|
// 处理 null 值
|
||||||
|
Long usedSpace = diskInfo.getUsedSpace();
|
||||||
|
if (usedSpace != null) {
|
||||||
|
totalUsedSpace += usedSpace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Long avgUsedSpace = totalUsedSpace/list.size();
|
Long avgUsedSpace = totalUsedSpace/list.size();
|
||||||
unit = SpeedUtils.determineUnitByValue(avgUsedSpace);
|
unit = SpeedUtils.determineUnitByValue(avgUsedSpace);
|
||||||
|
|||||||
@@ -214,7 +214,7 @@
|
|||||||
group by name
|
group by name
|
||||||
</select>
|
</select>
|
||||||
<select id="getDiskTotal" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
|
<select id="getDiskTotal" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
|
||||||
select sum(t2.total) as total
|
select sum(IFNULL(t2.total,0)) as total
|
||||||
from ${tableName} t2
|
from ${tableName} t2
|
||||||
inner join (
|
inner join (
|
||||||
select client_id, type, max(create_time) as latest_time
|
select client_id, type, max(create_time) as latest_time
|
||||||
@@ -225,7 +225,7 @@
|
|||||||
and t2.create_time = t1.latest_time
|
and t2.create_time = t1.latest_time
|
||||||
</select>
|
</select>
|
||||||
<select id="sumDistInfoByCondition" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
|
<select id="sumDistInfoByCondition" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
|
||||||
select sum(used_space) used_space,create_time
|
select SUM(IFNULL(used_space, 0)) AS used_space,create_time
|
||||||
from ${tableName}
|
from ${tableName}
|
||||||
<where>
|
<where>
|
||||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user