无识别结果时返回
This commit is contained in:
parent
43ae10916c
commit
30314ecd48
@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SearchFaceRespVo {
|
public class SearchFaceRespVo {
|
||||||
private Float score;
|
private float score;
|
||||||
private List<Long> sampleListIds;
|
private List<Long> sampleListIds;
|
||||||
private String searchResultJson;
|
private String searchResultJson;
|
||||||
private Float firstMatchRate;
|
private Float firstMatchRate;
|
||||||
|
@ -19,6 +19,7 @@ import com.ycwl.basic.service.task.TaskService;
|
|||||||
import com.ycwl.basic.task.FaceCleaner;
|
import com.ycwl.basic.task.FaceCleaner;
|
||||||
import com.ycwl.basic.utils.*;
|
import com.ycwl.basic.utils.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -121,6 +122,10 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
//1、上传人脸照片
|
//1、上传人脸照片
|
||||||
String faceUrl = uploadFileALiOss(file, userId);
|
String faceUrl = uploadFileALiOss(file, userId);
|
||||||
SearchFaceRespVo searchFaceRespVo = faceService.searchFace(scenicId, faceUrl);
|
SearchFaceRespVo searchFaceRespVo = faceService.searchFace(scenicId, faceUrl);
|
||||||
|
if (searchFaceRespVo == null) {
|
||||||
|
ossUtil.deleteFileByUrl(faceUrl);
|
||||||
|
throw new BaseException("人脸照片校验失败,请重新上传");
|
||||||
|
}
|
||||||
float score = searchFaceRespVo.getScore();
|
float score = searchFaceRespVo.getScore();
|
||||||
if (score<faceScore) {
|
if (score<faceScore) {
|
||||||
//校验失败,删除,提示重新上传
|
//校验失败,删除,提示重新上传
|
||||||
@ -134,8 +139,12 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
FaceEntity faceEntity = new FaceEntity();
|
FaceEntity faceEntity = new FaceEntity();
|
||||||
faceEntity.setScore(searchFaceRespVo.getScore());
|
faceEntity.setScore(searchFaceRespVo.getScore());
|
||||||
faceEntity.setMatchResult(searchFaceRespVo.getSearchResultJson());
|
faceEntity.setMatchResult(searchFaceRespVo.getSearchResultJson());
|
||||||
|
if (searchFaceRespVo.getFirstMatchRate() != null) {
|
||||||
faceEntity.setFirstMatchRate(BigDecimal.valueOf(searchFaceRespVo.getFirstMatchRate()));
|
faceEntity.setFirstMatchRate(BigDecimal.valueOf(searchFaceRespVo.getFirstMatchRate()));
|
||||||
|
}
|
||||||
|
if (searchFaceRespVo.getSampleListIds() != null) {
|
||||||
faceEntity.setMatchSampleIds(searchFaceRespVo.getSampleListIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
faceEntity.setMatchSampleIds(searchFaceRespVo.getSampleListIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||||
|
}
|
||||||
faceEntity.setCreateAt(new Date());
|
faceEntity.setCreateAt(new Date());
|
||||||
faceEntity.setScenicId(scenicId);
|
faceEntity.setScenicId(scenicId);
|
||||||
faceEntity.setMemberId(userId);
|
faceEntity.setMemberId(userId);
|
||||||
@ -145,7 +154,13 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
faceEntity.setId(SnowFlakeUtil.getLongId());
|
faceEntity.setId(SnowFlakeUtil.getLongId());
|
||||||
faceMapper.add(faceEntity);
|
faceMapper.add(faceEntity);
|
||||||
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
|
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
|
||||||
}else {
|
} else if (StringUtils.isBlank(faceRespVO.getMatchSampleIds())) {
|
||||||
|
// 如果之前的是没有匹配到的
|
||||||
|
// 也去新增
|
||||||
|
faceEntity.setId(faceRespVO.getId());
|
||||||
|
faceMapper.update(faceEntity);
|
||||||
|
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
|
||||||
|
} else {
|
||||||
//2、更新人脸
|
//2、更新人脸
|
||||||
faceEntity.setId(faceRespVO.getId());
|
faceEntity.setId(faceRespVO.getId());
|
||||||
faceMapper.update(faceEntity);
|
faceMapper.update(faceEntity);
|
||||||
|
@ -89,20 +89,20 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
if (matchList.isEmpty()) {
|
if (matchList.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (matchList.get(0).getFaceItems().isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
SearchFaceRespVo respVo = new SearchFaceRespVo();
|
SearchFaceRespVo respVo = new SearchFaceRespVo();
|
||||||
|
respVo.setScore(matchList.get(0).getQualitieScore());
|
||||||
|
respVo.setSearchResultJson(JSON.toJSONString(matchList.get(0)));
|
||||||
|
if (matchList.get(0).getFaceItems().isEmpty()) {
|
||||||
|
return respVo;
|
||||||
|
}
|
||||||
List<SearchFaceResponse.Data.MatchListItem.FaceItemsItem> faceItems = matchList.get(0).getFaceItems().stream()
|
List<SearchFaceResponse.Data.MatchListItem.FaceItemsItem> faceItems = matchList.get(0).getFaceItems().stream()
|
||||||
.filter(faceItemsItem -> faceItemsItem.getConfidence() > 50).collect(Collectors.toList());
|
.filter(faceItemsItem -> faceItemsItem.getConfidence() > 50).collect(Collectors.toList());
|
||||||
List<Long> faceSampleIds = faceItems.stream()
|
List<Long> faceSampleIds = faceItems.stream()
|
||||||
.map(SearchFaceResponse.Data.MatchListItem.FaceItemsItem::getExtraData)
|
.map(SearchFaceResponse.Data.MatchListItem.FaceItemsItem::getExtraData)
|
||||||
.map(Long::parseLong)
|
.map(Long::parseLong)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
respVo.setSearchResultJson(JSON.toJSONString(matchList.get(0)));
|
|
||||||
respVo.setFirstMatchRate(matchList.get(0).getFaceItems().get(0).getConfidence());
|
respVo.setFirstMatchRate(matchList.get(0).getFaceItems().get(0).getConfidence());
|
||||||
respVo.setSampleListIds(faceSampleIds);
|
respVo.setSampleListIds(faceSampleIds);
|
||||||
respVo.setScore(matchList.get(0).getQualitieScore());
|
|
||||||
return respVo;
|
return respVo;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("人脸搜索失败:{}", e.getMessage());
|
log.error("人脸搜索失败:{}", e.getMessage());
|
||||||
|
@ -14,9 +14,9 @@ spring:
|
|||||||
datasource: # 数据源的相关配置
|
datasource: # 数据源的相关配置
|
||||||
type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP
|
type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动
|
driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动
|
||||||
url: jdbc:mysql://8.134.112.96:3306/liuying_mgmt_re?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
url: jdbc:mysql://106.14.162.214:3306/zt?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||||
username: root
|
username: zt
|
||||||
password: yckj2017
|
password: ZhEnTuAi2024zHeNtUaI
|
||||||
hikari:
|
hikari:
|
||||||
connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 默认:30秒
|
connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 默认:30秒
|
||||||
minimum-idle: 5 # 最小连接数
|
minimum-idle: 5 # 最小连接数
|
||||||
|
Loading…
x
Reference in New Issue
Block a user