feat(face): 添加打印机大屏人脸识别试点功能

- 在PrinterTvController中添加tv场景参数,用于触发打印机大屏识别试点逻辑
- 在FaceMatchingScene枚举中新增PRINTER_TV_RECOGNIZE场景,支持仅执行识别补救落库建关系
- 在FaceMatchingPipelineFactory中创建打印机大屏识别试点Pipeline,包含识别补救落库建关系等阶段
- 在FaceServiceImpl中添加打印机大屏人脸识别的专门处理方法matchFaceIdForPrinterTv
- 通过scene参数区分普通人脸识别和打印机大屏识别试点流程
This commit is contained in:
2025-12-29 11:34:10 +08:00
parent 58e8189b13
commit d6780ccb7a
4 changed files with 79 additions and 3 deletions

View File

@@ -7,6 +7,9 @@ import com.ycwl.basic.biz.OrderBiz;
import com.ycwl.basic.biz.TemplateBiz;
import com.ycwl.basic.constant.BaseContextHandler;
import com.ycwl.basic.exception.BaseException;
import com.ycwl.basic.face.pipeline.core.FaceMatchingContext;
import com.ycwl.basic.face.pipeline.enums.FaceMatchingScene;
import com.ycwl.basic.face.pipeline.factory.FaceMatchingPipelineFactory;
import com.ycwl.basic.facebody.adapter.IFaceBodyAdapter;
import com.ycwl.basic.facebody.entity.SearchFaceResultItem;
import com.ycwl.basic.mapper.FaceSampleMapper;
@@ -85,6 +88,8 @@ import com.ycwl.basic.storage.adapters.IStorageAdapter;
import com.ycwl.basic.storage.enums.StorageAcl;
import com.ycwl.basic.storage.utils.StorageUtil;
import com.ycwl.basic.utils.*;
import com.ycwl.basic.pipeline.core.Pipeline;
import com.ycwl.basic.pipeline.exception.PipelineException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
@@ -119,6 +124,8 @@ import static com.ycwl.basic.constant.StorageConstant.USER_FACE;
@Slf4j
@Service
public class FaceServiceImpl implements FaceService {
private static final String FACE_UPLOAD_SCENE_PRINTER_TV = "tv";
@Autowired
private FaceMapper faceMapper;
@Autowired
@@ -176,6 +183,8 @@ public class FaceServiceImpl implements FaceService {
// 编排器
@Autowired
private FaceMatchingOrchestrator faceMatchingOrchestrator;
@Autowired
private FaceMatchingPipelineFactory faceMatchingPipelineFactory;
// 防重复服务
@Autowired
@@ -311,7 +320,7 @@ public class FaceServiceImpl implements FaceService {
resp.setUrl(faceUrl);
resp.setFaceId(newFaceId);
resp.setScenicId(scenicId);
matchFaceId(newFaceId, oldFaceId == null);
matchFaceId(newFaceId, oldFaceId == null, scene);
// 异步执行自动添加打印
Long finalFaceId = newFaceId;
@@ -368,9 +377,35 @@ public class FaceServiceImpl implements FaceService {
}
@Override
public SearchFaceRespVo matchFaceId(Long faceId, boolean isNew, String scene) {
if (Strings.CI.equals(FACE_UPLOAD_SCENE_PRINTER_TV, scene)) {
return matchFaceIdForPrinterTv(faceId, isNew);
}
return faceMatchingOrchestrator.orchestrateMatching(faceId, isNew, scene);
}
private SearchFaceRespVo matchFaceIdForPrinterTv(Long faceId, boolean isNew) {
FaceMatchingContext context = FaceMatchingContext.builder()
.faceId(faceId)
.isNew(isNew)
.scene(FaceMatchingScene.PRINTER_TV_RECOGNIZE)
.build();
Pipeline<FaceMatchingContext> pipeline = faceMatchingPipelineFactory.createPrinterTvRecognizePipeline();
try {
boolean success = pipeline.execute(context);
if (!success) {
throw new BaseException("打印机大屏人脸识别失败");
}
return context.getSearchResult();
} catch (PipelineException e) {
Throwable rootCause = e.getCause();
if (rootCause instanceof BaseException baseException) {
throw baseException;
}
throw new BaseException("打印机大屏人脸识别失败");
}
}
/**
* 更新人脸实体结果信息
* 仅用于 handleCustomFaceMatching 方法