Просмотр исходного кода

fix(person): 画像统计 groupingBy 空 key 兜底,修复切换人员报系统异常

- DataProfileService.callInfoStat:号码运营商 personNoCn 为空时归入「未知运营商」,
  空值直接进 Collectors.groupingBy 会抛 NPE(元素不可映射为 null key),
  远程环境李如云存在运营商为空的号码记录,切换人员时 /dp/callStat 必现 500。
- IntimacyService.resolveOtherName:对方姓名与对方卡号同时为空时兜底「未知」。
- IntimacyService.buildNightCallRecords:夜间通话按 otherName 分组前先过滤空值
  (coalesce(otherName, otherPhone) 双空仍可能产出 null,正则 filter 拦不住 null)。

排查过 person/call 模块全部 groupingBy 调用点,其余均有前置 filter 保护
或 key 来自 COUNT(*) 聚合/list.size(),不可能为 null。
cc 2 недель назад
Родитель
Сommit
727b0d2e85

+ 1 - 1
ai-server/src/main/java/com/zsjz/ai/module/person/service/DataProfileService.java

@@ -70,7 +70,7 @@ public class DataProfileService {
                 .eq(PersonLibNo::getLibType, 2));
 
         Map<String, List<String>> operCountMap = personLibNos.stream()
-                .collect(Collectors.groupingBy(PersonLibNo::getPersonNoCn,
+                .collect(Collectors.groupingBy(p -> StrUtil.emptyToDefault(p.getPersonNoCn(), "未知运营商"),
                         Collectors.mapping(PersonLibNo::getPersonNo, Collectors.toList())));
         log.info("{}的号码统计结果为:{}", personName, operCountMap);
         callDataProfileStatDTO.setOperCountMap(operCountMap);

+ 3 - 1
ai-server/src/main/java/com/zsjz/ai/module/person/service/IntimacyService.java

@@ -656,7 +656,8 @@ public class IntimacyService extends ServiceImpl<IntimacyMapper, Intimacy> {
     }
 
     private String resolveOtherName(String otherName, String fallback) {
-        return StrUtil.emptyToDefault(otherName, fallback);
+        // otherName 与 fallback(otherCardNo)可能同时为空,groupingBy 不允许 null key,兜底为「未知」
+        return StrUtil.emptyToDefault(StrUtil.emptyToDefault(otherName, fallback), "未知");
     }
 
     private String buildBehaviorLabel(String behavior, int weight) {
@@ -696,6 +697,7 @@ public class IntimacyService extends ServiceImpl<IntimacyMapper, Intimacy> {
         List<NightVoiceTempDTO> rawRecords = intimacyMapper.selectAllDataByName(personName, callTableName);
 
         Map<String, List<NightVoiceTempDTO>> groupedByName = rawRecords.stream()
+                .filter(a -> StrUtil.isNotBlank(a.getOtherName()))
                 .filter(a -> !ReUtil.isMatch("^(12|95|96|106)", a.getOtherName()))
                 .collect(Collectors.groupingBy(NightVoiceTempDTO::getOtherName));
         for (Map.Entry<String, List<NightVoiceTempDTO>> nameEntry : groupedByName.entrySet()) {