无识别结果时返回

This commit is contained in:
2024-12-26 13:51:33 +08:00
parent 43ae10916c
commit 30314ecd48
4 changed files with 27 additions and 12 deletions

View File

@@ -19,6 +19,7 @@ import com.ycwl.basic.service.task.TaskService;
import com.ycwl.basic.task.FaceCleaner;
import com.ycwl.basic.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -121,6 +122,10 @@ public class FaceServiceImpl implements FaceService {
//1、上传人脸照片
String faceUrl = uploadFileALiOss(file, userId);
SearchFaceRespVo searchFaceRespVo = faceService.searchFace(scenicId, faceUrl);
if (searchFaceRespVo == null) {
ossUtil.deleteFileByUrl(faceUrl);
throw new BaseException("人脸照片校验失败,请重新上传");
}
float score = searchFaceRespVo.getScore();
if (score<faceScore) {
//校验失败,删除,提示重新上传
@@ -134,8 +139,12 @@ public class FaceServiceImpl implements FaceService {
FaceEntity faceEntity = new FaceEntity();
faceEntity.setScore(searchFaceRespVo.getScore());
faceEntity.setMatchResult(searchFaceRespVo.getSearchResultJson());
faceEntity.setFirstMatchRate(BigDecimal.valueOf(searchFaceRespVo.getFirstMatchRate()));
faceEntity.setMatchSampleIds(searchFaceRespVo.getSampleListIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
if (searchFaceRespVo.getFirstMatchRate() != null) {
faceEntity.setFirstMatchRate(BigDecimal.valueOf(searchFaceRespVo.getFirstMatchRate()));
}
if (searchFaceRespVo.getSampleListIds() != null) {
faceEntity.setMatchSampleIds(searchFaceRespVo.getSampleListIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
}
faceEntity.setCreateAt(new Date());
faceEntity.setScenicId(scenicId);
faceEntity.setMemberId(userId);
@@ -145,7 +154,13 @@ public class FaceServiceImpl implements FaceService {
faceEntity.setId(SnowFlakeUtil.getLongId());
faceMapper.add(faceEntity);
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
}else {
} else if (StringUtils.isBlank(faceRespVO.getMatchSampleIds())) {
// 如果之前的是没有匹配到的
// 也去新增
faceEntity.setId(faceRespVO.getId());
faceMapper.update(faceEntity);
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
} else {
//2、更新人脸
faceEntity.setId(faceRespVO.getId());
faceMapper.update(faceEntity);