You've already forked FrameTour-BE
调整
This commit is contained in:
@@ -37,6 +37,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -56,9 +57,6 @@ public class FaceServiceImpl implements FaceService {
|
||||
@Autowired
|
||||
private StatisticsMapper statisticsMapper;
|
||||
|
||||
@Value("${face.score}")
|
||||
private float faceScore;
|
||||
private final float strictScore = 0.75F;
|
||||
@Autowired
|
||||
private TaskService taskTaskService;
|
||||
@Autowired
|
||||
@@ -136,18 +134,13 @@ public class FaceServiceImpl implements FaceService {
|
||||
adapter.deleteFile(filePath, fileName);
|
||||
throw new BaseException("人脸照片校验失败,请重新上传");
|
||||
}
|
||||
float score = scenicDbSearchResult.getScore();
|
||||
if (score<faceScore) {
|
||||
//校验失败,删除,提示重新上传
|
||||
adapter.deleteFile(filePath, fileName);
|
||||
throw new BaseException("人脸照片校验失败,请重新上传");
|
||||
}
|
||||
// 2、通过人脸查找用户库
|
||||
Long newFaceId = SnowFlakeUtil.getLongId();
|
||||
FaceEntity faceEntity = new FaceEntity();
|
||||
faceEntity.setScore(scenicDbSearchResult.getScore());
|
||||
faceEntity.setMatchResult(scenicDbSearchResult.getSearchResultJson());
|
||||
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME, faceUrl);
|
||||
float strictScore = 0.6F;
|
||||
if (userDbSearchResult == null) {
|
||||
// 都是null了,那得是新的
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
@@ -159,12 +152,21 @@ public class FaceServiceImpl implements FaceService {
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
} else {
|
||||
// 有匹配结果,且能匹配旧的数据
|
||||
Long oldFaceId = userDbSearchResult.getSampleListIds().get(0);
|
||||
FaceRespVO oldFace = faceMapper.getById(oldFaceId);
|
||||
if (oldFace == null) {
|
||||
faceService.deleteFaceSample(USER_FACE_DB_NAME, oldFaceId.toString());
|
||||
} else {
|
||||
faceEntity.setId(oldFaceId);
|
||||
Optional<Long> faceAny = userDbSearchResult.getSampleListIds().stream().filter(oldFaceId -> {
|
||||
FaceEntity face = faceRepository.getFace(oldFaceId);
|
||||
if (face == null) {
|
||||
return false;
|
||||
}
|
||||
return face.getScenicId().equals(scenicId);
|
||||
}).findAny();
|
||||
if (faceAny.isPresent()) {
|
||||
Long oldFaceId = faceAny.get();
|
||||
FaceRespVO oldFace = faceMapper.getById(oldFaceId);
|
||||
if (oldFace == null) {
|
||||
faceService.deleteFaceSample(USER_FACE_DB_NAME, oldFaceId.toString());
|
||||
} else {
|
||||
faceEntity.setId(oldFaceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scenicDbSearchResult.getFirstMatchRate() != null) {
|
||||
@@ -215,13 +217,15 @@ public class FaceServiceImpl implements FaceService {
|
||||
}
|
||||
return memberSourceEntity;
|
||||
}).collect(Collectors.toList());
|
||||
sourceMapper.addRelations(memberSourceEntityList);
|
||||
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
|
||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||
task.faceId = faceEntity.getId();
|
||||
task.faceSampleIds = sampleListIds;
|
||||
task.memberId = userId;
|
||||
VideoPieceGetter.addTask(task);
|
||||
if (!memberSourceEntityList.isEmpty()) {
|
||||
sourceMapper.addRelations(memberSourceEntityList);
|
||||
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
|
||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||
task.faceId = faceEntity.getId();
|
||||
task.faceSampleIds = sampleListIds;
|
||||
task.memberId = userId;
|
||||
VideoPieceGetter.addTask(task);
|
||||
}
|
||||
}
|
||||
return ApiResponse.success(resp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user