This commit is contained in:
2025-01-14 11:26:37 +08:00
parent 02548a3028
commit f2f7fa22c9
10 changed files with 129 additions and 73 deletions

View File

@ -144,41 +144,50 @@ public class AppScenicServiceImpl implements AppScenicService {
sourceReqQuery.setMemberId(userId);
//查询源素材
List<SourceRespVO> sourceList = sourceMapper.queryByRelation(sourceReqQuery);
ContentPageVO sourceVideoContent = new ContentPageVO();
ContentPageVO sourceImageContent = new ContentPageVO();
sourceVideoContent.setName("原片集");
sourceImageContent.setName("照片集");
sourceVideoContent.setScenicId(faceRespVO.getScenicId());
sourceImageContent.setScenicId(faceRespVO.getScenicId());
sourceVideoContent.setContentType(2);
sourceImageContent.setContentType(2);
sourceVideoContent.setLockType(1);
sourceImageContent.setLockType(1);
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(faceRespVO.getScenicId());
sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getType)).keySet()
.stream()
.filter(type -> {
if (Integer.valueOf(1).equals(type)) {
if (Integer.valueOf(1).equals(scenicConfig.getDisableSourceVideo())) {
return false;
}
} else if (Integer.valueOf(2).equals(type)) {
if (Integer.valueOf(1).equals(scenicConfig.getDisableSourceImage())) {
return false;
}
}
return true;
})
.forEach(type -> {
ContentPageVO contentPageVO = new ContentPageVO();
if (type == 1) {
contentPageVO.setName("原片集");
} else {
contentPageVO.setName("照片集");
}
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), type, faceId);
contentPageVO.setSourceType(isBuyRespVO.getGoodsType());
contentPageVO.setContentId(isBuyRespVO.getGoodsId());
if (isBuyRespVO.isBuy()) {
contentPageVO.setIsBuy(1);
} else {
contentPageVO.setIsBuy(0);
}
contentPageVO.setScenicId(faceRespVO.getScenicId());
contentPageVO.setTemplateCoverUrl(sourceList.get(0).getUrl());
contentPageVO.setContentType(2);
contentList.add(contentPageVO);
});
if (!Integer.valueOf(1).equals(scenicConfig.getDisableSourceVideo())) {
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), 1, faceId);
sourceVideoContent.setSourceType(isBuyRespVO.getGoodsType());
sourceVideoContent.setContentId(isBuyRespVO.getGoodsId());
if (isBuyRespVO.isBuy()) {
sourceVideoContent.setIsBuy(1);
} else {
sourceVideoContent.setIsBuy(0);
}
contentList.add(sourceVideoContent);
}
if (!Integer.valueOf(1).equals(scenicConfig.getDisableSourceImage())) {
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), 2, faceId);
sourceImageContent.setSourceType(isBuyRespVO.getGoodsType());
sourceImageContent.setContentId(isBuyRespVO.getGoodsId());
if (isBuyRespVO.isBuy()) {
sourceImageContent.setIsBuy(1);
} else {
sourceImageContent.setIsBuy(0);
}
contentList.add(sourceImageContent);
}
sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getType)).forEach((type, list) -> {
ContentPageVO contentPageVO = new ContentPageVO();
if (type == 1) {
sourceVideoContent.setLockType(0);
sourceVideoContent.setTemplateCoverUrl(list.get(0).getUrl());
} else {
sourceImageContent.setLockType(0);
sourceImageContent.setTemplateCoverUrl(list.get(0).getUrl());
}
});
return ApiResponse.success(contentList);
}

View File

@ -187,30 +187,6 @@ public class FaceServiceImpl implements FaceService {
faceMapper.update(faceEntity);
faceRepository.clearFaceCache(faceEntity.getId());
}
if (sampleListIds == null) {
return ApiResponse.fail("请先游玩后再来获取视频吧");
}
// 匹配原片:照片
List<SourceEntity> sourceEntities = sourceMapper.listBySampleIds(sampleListIds);
List<MemberSourceEntity> memberSourceEntityList = sourceEntities.stream().map(sourceEntity -> {
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
memberSourceEntity.setScenicId(scenicId);
memberSourceEntity.setFaceId(faceEntity.getId());
memberSourceEntity.setMemberId(userId);
memberSourceEntity.setSourceId(sourceEntity.getId());
memberSourceEntity.setType(sourceEntity.getType());
IsBuyRespVO isBuy = orderBiz.isBuy(userId, scenicId, sourceEntity.getType(), sourceEntity.getId());
if (isBuy.isBuy()) { // 如果用户买过
memberSourceEntity.setIsBuy(1);
} else if (isBuy.isFree()) { // 全免费逻辑
memberSourceEntity.setIsBuy(1);
} else {
memberSourceEntity.setIsBuy(0);
}
return memberSourceEntity;
}).collect(Collectors.toList());
sourceMapper.addRelations(memberSourceEntityList);
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
StatisticsRecordAddReq statisticsRecordAddReq = new StatisticsRecordAddReq();
statisticsRecordAddReq.setMemberId(userId);
statisticsRecordAddReq.setType(StatisticEnum.UPLOAD_FACE.code);
@ -220,11 +196,33 @@ public class FaceServiceImpl implements FaceService {
FaceRecognizeResp resp = new FaceRecognizeResp();
resp.setUrl(faceUrl);
resp.setFaceId(faceEntity.getId());
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
task.faceId = faceEntity.getId();
task.faceSampleIds = sampleListIds;
task.memberId = userId;
VideoPieceGetter.addTask(task);
if (sampleListIds != null && !sampleListIds.isEmpty()) {// 匹配原片:照片
List<SourceEntity> sourceEntities = sourceMapper.listBySampleIds(sampleListIds);
List<MemberSourceEntity> memberSourceEntityList = sourceEntities.stream().map(sourceEntity -> {
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
memberSourceEntity.setScenicId(scenicId);
memberSourceEntity.setFaceId(faceEntity.getId());
memberSourceEntity.setMemberId(userId);
memberSourceEntity.setSourceId(sourceEntity.getId());
memberSourceEntity.setType(sourceEntity.getType());
IsBuyRespVO isBuy = orderBiz.isBuy(userId, scenicId, sourceEntity.getType(), sourceEntity.getId());
if (isBuy.isBuy()) { // 如果用户买过
memberSourceEntity.setIsBuy(1);
} else if (isBuy.isFree()) { // 全免费逻辑
memberSourceEntity.setIsBuy(1);
} else {
memberSourceEntity.setIsBuy(0);
}
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);
}
return ApiResponse.success(resp);
}

View File

@ -60,6 +60,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
@ -143,8 +144,24 @@ public class TaskTaskServiceImpl implements TaskService {
renderWorkerMapper.update(worker);
TaskSyncRespVo resp = new TaskSyncRespVo();
// Template
List<TemplateRespVO> updTemplateList;
if (req.getTemplateList() != null) {
updTemplateList = new ArrayList<>();
// 上报了本地模板列表
req.getTemplateList().forEach(template -> {
if (StringUtils.isNumeric(template.getId())) {
TemplateRespVO dbTemplate = templateRepository.getTemplate(Long.parseLong(template.getId()));
if (!dbTemplate.getUpdateTime().equals(template.getUpdateTime())) {
updTemplateList.add(dbTemplate);
}
}
});
} else {
updTemplateList = templateRepository.getAllEnabledTemplateList();
}
List<TaskRespVO> taskList = taskMapper.selectNotRunning();
resp.setTasks(taskList);
resp.setTemplates(updTemplateList);
taskList.forEach(task -> {
taskMapper.assignToWorker(task.getId(), worker.getId());
videoTaskRepository.clearTaskCache(task.getId());