feat(face): 添加人工调整标记字段并优化匹配逻辑

- 在 FaceEntity 中新增 isManual 字段,用于标识是否经过人工调整
- 优化人脸识别匹配流程,若已人工调整则跳过自动匹配
- 更新 FaceMapper.xml,支持 isManual 字段的更新操作
- 在处理自定义人脸匹配时,设置人工调整标记并清除缓存
This commit is contained in:
2025-10-30 00:18:03 +08:00
parent 745943fc23
commit 73825cd1d6
3 changed files with 26 additions and 7 deletions

View File

@@ -41,6 +41,10 @@ public class FaceEntity {
* 匹配的结果,JSON字符串
*/
private String matchResult;
/**
* 是否人工调整过,0-否,1-是
*/
private Integer isManual;
private Date createAt;
private Date updateAt;
private int isDelete;

View File

@@ -290,13 +290,6 @@ public class FaceServiceImpl implements FaceService {
if (faceId == null) {
throw new IllegalArgumentException("faceId 不能为空");
}
log.debug("开始人脸匹配:faceId={}, isNew={}", faceId, isNew);
// 记录识别次数到Redis,设置2天过期时间
recordFaceRecognitionCount(faceId);
try {
// 1. 数据准备:获取人脸信息、景区配置、适配器等
FaceEntity face = faceRepository.getFace(faceId);
if (face == null) {
@@ -304,6 +297,17 @@ public class FaceServiceImpl implements FaceService {
return null;
}
if (!isNew && Integer.valueOf(1).equals(face.getIsManual())) {
log.info("人工选择的,无需匹配,faceId: {}", faceId);
return null;
}
log.debug("开始人脸匹配:faceId={}, isNew={}", faceId, isNew);
// 记录识别次数到Redis,设置2天过期时间
recordFaceRecognitionCount(faceId);
try {
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(face.getScenicId());
IFaceBodyAdapter faceBodyAdapter = scenicService.getScenicFaceBodyAdapter(face.getScenicId());
@@ -1293,6 +1297,14 @@ public class FaceServiceImpl implements FaceService {
if (finalSampleList.isEmpty()) {
throw new BaseException("至少需要保留一个样本");
}
// 设置人工调整标记
FaceEntity updateEntity = new FaceEntity();
updateEntity.setId(faceId);
updateEntity.setIsManual(1);
faceMapper.update(updateEntity);
faceRepository.clearFaceCache(faceId);
handleCustomFaceMatching(faceId, finalSampleList);
}

View File

@@ -20,6 +20,9 @@
<if test="faceUrl!= null and faceUrl!= ''">
face_url = #{faceUrl},
</if>
<if test="isManual!= null ">
is_manual = #{isManual},
</if>
match_sample_ids = #{matchSampleIds},
first_match_rate = #{firstMatchRate},
match_result = #{matchResult},