refactor(pc): 优化人脸服务中的模式匹配逻辑

- 在获取 re_match_mode 配置时,添加默认值 0,避免潜在的 NullPointerException
- 优化了 switch 表达式中的条件判断,提高代码可读性
This commit is contained in:
2025-09-18 18:31:30 +08:00
parent 864fc2c127
commit 7820a282d9

View File

@@ -963,7 +963,7 @@ public class FaceServiceImpl implements FaceService {
// 查询是否触发过低阈值检测 // 查询是否触发过低阈值检测
String lowThresholdKey = FACE_LOW_THRESHOLD_PFX + faceId; String lowThresholdKey = FACE_LOW_THRESHOLD_PFX + faceId;
boolean hasLowThreshold = redisTemplate.hasKey(lowThresholdKey); boolean hasLowThreshold = redisTemplate.hasKey(lowThresholdKey);
Integer mode = scenicConfig.getInteger("re_match_mode"); Integer mode = scenicConfig.getInteger("re_match_mode", 0);
return switch (mode) { return switch (mode) {
case 1 -> tourMatch || recognitionCount > 1 || hasLowThreshold; case 1 -> tourMatch || recognitionCount > 1 || hasLowThreshold;
case 5 -> hasLowThreshold || (ruleMatched >= 2); case 5 -> hasLowThreshold || (ruleMatched >= 2);