From 73825cd1d62f86032b2b72ff891ddaadd1fbaaa1 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 30 Oct 2025 00:18:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(face):=20=E6=B7=BB=E5=8A=A0=E4=BA=BA?= =?UTF-8?q?=E5=B7=A5=E8=B0=83=E6=95=B4=E6=A0=87=E8=AE=B0=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E5=8C=B9=E9=85=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 FaceEntity 中新增 isManual 字段,用于标识是否经过人工调整 - 优化人脸识别匹配流程,若已人工调整则跳过自动匹配 - 更新 FaceMapper.xml,支持 isManual 字段的更新操作 - 在处理自定义人脸匹配时,设置人工调整标记并清除缓存 --- .../model/pc/face/entity/FaceEntity.java | 4 +++ .../service/pc/impl/FaceServiceImpl.java | 26 ++++++++++++++----- src/main/resources/mapper/FaceMapper.xml | 3 +++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ycwl/basic/model/pc/face/entity/FaceEntity.java b/src/main/java/com/ycwl/basic/model/pc/face/entity/FaceEntity.java index 0d9151c7..377249f6 100644 --- a/src/main/java/com/ycwl/basic/model/pc/face/entity/FaceEntity.java +++ b/src/main/java/com/ycwl/basic/model/pc/face/entity/FaceEntity.java @@ -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; diff --git a/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java b/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java index 38cb83c7..77c65b8f 100644 --- a/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java @@ -290,19 +290,23 @@ public class FaceServiceImpl implements FaceService { if (faceId == null) { throw new IllegalArgumentException("faceId 不能为空"); } - + // 1. 数据准备:获取人脸信息、景区配置、适配器等 + FaceEntity face = faceRepository.getFace(faceId); + if (face == null) { + log.warn("人脸不存在,faceId: {}", faceId); + 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 { - // 1. 数据准备:获取人脸信息、景区配置、适配器等 - FaceEntity face = faceRepository.getFace(faceId); - if (face == null) { - log.warn("人脸不存在,faceId: {}", faceId); - return null; - } 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); } diff --git a/src/main/resources/mapper/FaceMapper.xml b/src/main/resources/mapper/FaceMapper.xml index f6c37c50..3053eb77 100644 --- a/src/main/resources/mapper/FaceMapper.xml +++ b/src/main/resources/mapper/FaceMapper.xml @@ -20,6 +20,9 @@ face_url = #{faceUrl}, + + is_manual = #{isManual}, + match_sample_ids = #{matchSampleIds}, first_match_rate = #{firstMatchRate}, match_result = #{matchResult},