You've already forked FrameTour-BE
调整
This commit is contained in:
@ -8,7 +8,6 @@ import com.ycwl.basic.biz.TemplateBiz;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.mapper.*;
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
import com.ycwl.basic.model.mobile.goods.GoodsPageVO;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicAppVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
|
||||
@ -16,6 +15,7 @@ import com.ycwl.basic.model.mobile.scenic.ScenicIndexVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginReq;
|
||||
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginRespVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
|
||||
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
@ -31,7 +31,6 @@ import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.JwtTokenUtil;
|
||||
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;
|
||||
@ -39,6 +38,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -58,8 +58,6 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
@Autowired
|
||||
private SourceMapper sourceMapper;
|
||||
@Autowired
|
||||
private TaskMapper taskMapper;
|
||||
@Autowired
|
||||
private VideoMapper videoMapper;
|
||||
@Autowired
|
||||
private TemplateMapper templateMapper;
|
||||
@ -67,11 +65,6 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
private ScenicAccountMapper scenicAccountMapper;
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
@Value("${face.score}")
|
||||
private BigDecimal faceScore;
|
||||
@Autowired
|
||||
private TemplateRepository templateRepository;
|
||||
@Autowired
|
||||
private OrderBiz orderBiz;
|
||||
@Autowired
|
||||
@ -114,9 +107,6 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
if (faceRespVO == null) {
|
||||
return ApiResponse.success(new ArrayList<>());
|
||||
}
|
||||
if (StringUtils.isBlank(faceRespVO.getMatchSampleIds())) {
|
||||
return ApiResponse.success(new ArrayList<>());
|
||||
}
|
||||
List<ContentPageVO> contentList = templateMapper.listFor(faceRespVO.getScenicId());
|
||||
contentList.forEach(contentPageVO -> {
|
||||
List<MemberVideoEntity> memberVideoEntityList = videoMapper.userFaceTemplateVideo(userId, faceId, contentPageVO.getTemplateId());
|
||||
@ -125,8 +115,13 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
contentPageVO.setIsBuy(memberVideoEntityList.get(0).getIsBuy());
|
||||
contentPageVO.setContentId(memberVideoEntityList.get(0).getVideoId());
|
||||
VideoRespVO videoMapperById = videoMapper.getById(contentPageVO.getContentId());
|
||||
contentPageVO.setDuration(videoMapperById.getDuration());
|
||||
contentPageVO.setLockType(-1);
|
||||
if (videoMapperById != null) {
|
||||
contentPageVO.setDuration(videoMapperById.getDuration());
|
||||
contentPageVO.setLockType(-1);
|
||||
} else {
|
||||
contentPageVO.setLockType(0);
|
||||
contentPageVO.setContentType(0);
|
||||
}
|
||||
} else {
|
||||
contentPageVO.setContentType(0);
|
||||
boolean canGenerate = templateBiz.determineTemplateCanGenerate(contentPageVO.getTemplateId(), faceId);
|
||||
@ -234,4 +229,15 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
}
|
||||
return getDetails(account.getScenicId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<List<DeviceRespVO>> getMyDevices() {
|
||||
String userId = BaseContextHandler.getUserId();
|
||||
ScenicAccountEntity account = scenicAccountMapper.findAccountById(userId);
|
||||
if (account == null) {
|
||||
return ApiResponse.fail("用户未绑定景区");
|
||||
}
|
||||
List<DeviceRespVO> deviceRespVOList = deviceMapper.listByScenicIdWithWVP(account.getScenicId());
|
||||
return ApiResponse.success(deviceRespVOList);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.ycwl.basic.model.mobile.scenic.ScenicIndexVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginReq;
|
||||
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginRespVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
|
||||
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
@ -40,4 +41,6 @@ public interface AppScenicService {
|
||||
ApiResponse<List<ContentPageVO>> contentListUseDefaultFace();
|
||||
|
||||
ApiResponse<ScenicRespVO> getMyScenic();
|
||||
|
||||
ApiResponse<List<DeviceRespVO>> getMyDevices();
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
request.setDbName(dbName);
|
||||
request.setImageUrl(faceUrl);
|
||||
request.setLimit(100);
|
||||
request.setQualityScoreThreshold(60f);
|
||||
// request.setQualityScoreThreshold(60f);
|
||||
FaceDetectLog log = FaceDetectLog.quickCreate("预留字段", request);
|
||||
try {
|
||||
SearchFaceResponse response = client.getAcsResponse(request);
|
||||
|
@ -183,6 +183,10 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
List<SourceEntity> sourceEntityList = sourceMapper.listVideoByScenicFaceRelation(scenicId, faceId);
|
||||
Map<String, List<SourceEntity>> sourcesMap = sourceEntityList.stream()
|
||||
.collect(Collectors.groupingBy(item -> item.getDeviceId().toString()));
|
||||
sourcesMap.forEach((key, value) -> {
|
||||
// 每个value只保留第一个
|
||||
value.removeIf(item -> !value.get(0).equals(item));
|
||||
});
|
||||
TaskEntity taskEntity = new TaskEntity();
|
||||
taskEntity.setId(SnowFlakeUtil.getLongId());
|
||||
taskEntity.setFaceId(faceId);
|
||||
@ -227,13 +231,16 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
public void autoCreateTaskByFaceId(Long faceId) {
|
||||
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
||||
if (faceRespVO == null) {
|
||||
log.info("faceId:{} is not exist", faceId);
|
||||
return;
|
||||
}
|
||||
if (!StringUtils.isNotBlank(faceRespVO.getMatchSampleIds())) {
|
||||
log.info("faceId:{} matchSampleIds is empty", faceId);
|
||||
return;
|
||||
}
|
||||
List<FaceSampleEntity> faceSampleList = faceSampleMapper.listByIds(Arrays.stream(faceRespVO.getMatchSampleIds().split(",")).map(Long::valueOf).collect(Collectors.toList()));
|
||||
if (faceSampleList.isEmpty()) {
|
||||
log.info("faceId:{} faceSampleList is empty", faceId);
|
||||
return;
|
||||
}
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(faceRespVO.getScenicId());
|
||||
@ -270,39 +277,39 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (sourceList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (automatic > 0) {
|
||||
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||
taskReqQuery.setFaceId(faceId);
|
||||
taskReqQuery.setTemplateId(templateId);
|
||||
List<TaskRespVO> list = taskMapper.list(taskReqQuery);
|
||||
if (!list.isEmpty()) {
|
||||
list.parallelStream().forEach(task -> {
|
||||
MemberVideoEntity memberVideo = videoMapper.queryRelationByMemberTask(faceRespVO.getMemberId(), task.getId());
|
||||
if (memberVideo == null) {
|
||||
memberVideo = new MemberVideoEntity();
|
||||
memberVideo.setMemberId(faceRespVO.getMemberId());
|
||||
memberVideo.setScenicId(task.getScenicId());
|
||||
memberVideo.setFaceId(faceId);
|
||||
memberVideo.setTemplateId(task.getTemplateId());
|
||||
if (Integer.valueOf(1).equals(scenicConfig.getAllFree())) {
|
||||
memberVideo.setIsBuy(1);
|
||||
} else {
|
||||
memberVideo.setIsBuy(0);
|
||||
}
|
||||
memberVideo.setTaskId(task.getId());
|
||||
VideoEntity video = videoMapper.findByTaskId(task.getId());
|
||||
if (video != null) {
|
||||
memberVideo.setVideoId(video.getId());
|
||||
}
|
||||
videoMapper.addRelation(memberVideo);
|
||||
new Thread(() -> {
|
||||
sendVideoGeneratedServiceNotification(list.get(0).getId(), faceRespVO.getMemberId());
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (automatic > 0) {
|
||||
// TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||
// taskReqQuery.setFaceId(faceId);
|
||||
// taskReqQuery.setTemplateId(templateId);
|
||||
// List<TaskRespVO> list = taskMapper.list(taskReqQuery);
|
||||
// if (!list.isEmpty()) {
|
||||
// list.parallelStream().forEach(task -> {
|
||||
// MemberVideoEntity memberVideo = videoMapper.queryRelationByMemberTask(faceRespVO.getMemberId(), task.getId());
|
||||
// if (memberVideo == null) {
|
||||
// memberVideo = new MemberVideoEntity();
|
||||
// memberVideo.setMemberId(faceRespVO.getMemberId());
|
||||
// memberVideo.setScenicId(task.getScenicId());
|
||||
// memberVideo.setFaceId(faceId);
|
||||
// memberVideo.setTemplateId(task.getTemplateId());
|
||||
// if (Integer.valueOf(1).equals(scenicConfig.getAllFree())) {
|
||||
// memberVideo.setIsBuy(1);
|
||||
// } else {
|
||||
// memberVideo.setIsBuy(0);
|
||||
// }
|
||||
// memberVideo.setTaskId(task.getId());
|
||||
// VideoEntity video = videoMapper.findByTaskId(task.getId());
|
||||
// if (video != null) {
|
||||
// memberVideo.setVideoId(video.getId());
|
||||
// }
|
||||
// videoMapper.addRelation(memberVideo);
|
||||
// new Thread(() -> {
|
||||
// sendVideoGeneratedServiceNotification(list.get(0).getId(), faceRespVO.getMemberId());
|
||||
// }).start();
|
||||
// }
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||
task.faceId = faceId;
|
||||
task.faceSampleIds = faceSampleIds;
|
||||
@ -319,6 +326,10 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
Map<String, List<SourceEntity>> sourcesMap = videoSourceList.stream()
|
||||
.peek(item -> item.setUrl(item.getVideoUrl()))
|
||||
.collect(Collectors.groupingBy(item -> item.getDeviceId().toString()));
|
||||
sourcesMap.forEach((key, value) -> {
|
||||
// 每个value只保留第一个
|
||||
value.removeIf(item -> !value.get(0).equals(item));
|
||||
});
|
||||
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||
taskReqQuery.setFaceId(faceId);
|
||||
taskReqQuery.setTemplateId(templateId);
|
||||
@ -332,6 +343,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
memberVideoEntity.setTemplateId(templateId);
|
||||
memberVideoEntity.setIsBuy(0);
|
||||
if (list.isEmpty()) {
|
||||
log.info("创建任务! faceId:{},templateId:{},taskParams:{}", faceId, templateId, sourcesMap);
|
||||
TaskEntity taskEntity = new TaskEntity();
|
||||
taskEntity.setId(SnowFlakeUtil.getLongId());
|
||||
taskEntity.setScenicId(faceRespVO.getScenicId());
|
||||
@ -343,6 +355,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
taskMapper.add(taskEntity);
|
||||
memberVideoEntity.setTaskId(taskEntity.getId());
|
||||
} else {
|
||||
log.info("重复task! faceId:{},templateId:{},taskParams:{}", faceId, templateId, sourcesMap);
|
||||
memberVideoEntity.setTaskId(list.get(0).getId());
|
||||
VideoEntity video = videoMapper.findByTaskId(list.get(0).getId());
|
||||
if (video != null) {
|
||||
|
Reference in New Issue
Block a user