You've already forked FrameTour-BE
bug
This commit is contained in:
@ -33,6 +33,7 @@ public interface TemplateMapper {
|
||||
int deleteConfigByTemplateId(Long templateId);
|
||||
int deleteConfigById(Long id);
|
||||
List<TemplateEntity> listEnabledByScenicId(Long scenicId);
|
||||
List<TemplateEntity> listEnabled();
|
||||
List<Long> listEnabledTemplateIdByScenicId(Long scenicId);
|
||||
List<ContentPageVO> listFor(@Param("scenicId") Long scenicId);
|
||||
}
|
||||
|
@ -3,8 +3,11 @@ package com.ycwl.basic.model.task.req;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class TaskReqVo extends WorkerAuthReqVo {
|
||||
private ClientStatusReqVo clientStatus;
|
||||
private List<TemplateCheckVO> templateList;
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.ycwl.basic.model.task.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class TemplateCheckVO {
|
||||
private String id;
|
||||
private Date updateTime;
|
||||
}
|
@ -18,16 +18,18 @@ public class OrderRepository {
|
||||
public static final String ORDER_ITEM_CACHE_KEY = "order:user:%s:type:%s:id:%s";
|
||||
|
||||
public boolean checkUserBuyItem(Long userId, int goodsType, Long goodsId) {
|
||||
if (redisTemplate.hasKey(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId))) {
|
||||
return "1".equals(redisTemplate.opsForValue().get(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId)));
|
||||
synchronized (this) {
|
||||
if (redisTemplate.hasKey(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId))) {
|
||||
return "1".equals(redisTemplate.opsForValue().get(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId)));
|
||||
}
|
||||
OrderEntity orderEntity = orderMapper.getUserBuyItem(userId, goodsType, goodsId);
|
||||
if (orderEntity == null) {
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId), "0", 60, TimeUnit.SECONDS);
|
||||
return false;
|
||||
}
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId), "1");
|
||||
return true;
|
||||
}
|
||||
OrderEntity orderEntity = orderMapper.getUserBuyItem(userId, goodsType, goodsId);
|
||||
if (orderEntity == null) {
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId), "0", 60, TimeUnit.SECONDS);
|
||||
return false;
|
||||
}
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId), "1");
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkUserBuyFaceSourceImage(Long userId, Long faceId) {
|
||||
|
@ -5,12 +5,14 @@ import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.TemplateMapper;
|
||||
import com.ycwl.basic.model.pc.template.entity.TemplateConfigEntity;
|
||||
import com.ycwl.basic.model.pc.template.entity.TemplateEntity;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -44,6 +46,14 @@ public class TemplateRepository {
|
||||
}
|
||||
}
|
||||
|
||||
public List<TemplateRespVO> getAllEnabledTemplateList() {
|
||||
List<TemplateEntity> entityList = templateMapper.listEnabled();
|
||||
if (entityList == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return entityList.stream().map(entity -> getTemplate(entity.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<TemplateRespVO> getTemplateListByScenicId(Long scenicId) {
|
||||
List<Long> idList;
|
||||
if (redisTemplate.hasKey(String.format(TEMPLATE_ID_BY_SCENIC_ID_CACHE_KEY, scenicId))) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -118,7 +118,7 @@ public class VideoPieceGetter {
|
||||
DeviceConfigEntity config = deviceRepository.getDeviceConfig(faceSample.getDeviceId());
|
||||
|
||||
SourceEntity source = sourceMapper.querySameVideo(faceSample.getId(), device.getId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), faceSample.getScenicId(), 1, faceSample.getId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), faceSample.getScenicId(), 1, task.getFaceId());
|
||||
if (source == null) {
|
||||
BigDecimal cutPre = BigDecimal.valueOf(5L);
|
||||
BigDecimal cutPost = BigDecimal.valueOf(4L);
|
||||
|
Reference in New Issue
Block a user