You've already forked FrameTour-BE
修改
This commit is contained in:
@ -101,12 +101,11 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
}
|
||||
if (reqVo.getDevices() != null && !reqVo.getDevices().isEmpty()) {
|
||||
for (WvpSyncReqVo.DeviceItem deviceItem : reqVo.getDevices()) {
|
||||
DeviceEntity device = deviceMapper.getByDeviceNo(deviceItem.getDeviceNo());
|
||||
DeviceEntity device = deviceRepository.getDeviceByDeviceNo(deviceItem.getDeviceNo());
|
||||
if (device != null) {
|
||||
device.setOnline(deviceItem.getOnline());
|
||||
device.setKeepaliveAt(deviceItem.getKeepaliveAt());
|
||||
deviceMapper.updateEntity(device);
|
||||
deviceRepository.clearDeviceCache(device.getId());
|
||||
deviceRepository.updateOnlineStatus(device.getId(), null, 1, deviceItem.getKeepaliveAt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import java.util.Date;
|
||||
|
||||
public interface TaskService {
|
||||
TaskSyncRespVo handleSyncTask(TaskReqVo req);
|
||||
boolean createRenderTask(Long scenicId, Long templateId, Long faceId);
|
||||
|
||||
TemplateRespVO workerGetTemplate(Long templateId, WorkerAuthReqVo req);
|
||||
|
||||
|
@ -15,6 +15,7 @@ import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.mapper.TaskMapper;
|
||||
import com.ycwl.basic.mapper.TemplateMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.mobile.order.PriceObj;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
@ -43,7 +44,9 @@ import com.ycwl.basic.notify.adapters.INotifyAdapter;
|
||||
import com.ycwl.basic.notify.entity.NotifyContent;
|
||||
import com.ycwl.basic.notify.enums.NotifyType;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.repository.OrderRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.VideoRepository;
|
||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.task.TaskService;
|
||||
import com.ycwl.basic.storage.StorageFactory;
|
||||
@ -104,6 +107,10 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
private TemplateBiz templateBiz;
|
||||
@Autowired
|
||||
private FaceRepository faceRepository;
|
||||
@Autowired
|
||||
private VideoRepository videoRepository;
|
||||
@Autowired
|
||||
private OrderRepository orderRepository;
|
||||
|
||||
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
|
||||
String accessKey = req.getAccessKey();
|
||||
@ -170,34 +177,6 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRenderTask(Long scenicId, Long templateId, Long faceId) {
|
||||
boolean canGenerate = templateBiz.determineTemplateCanGenerate(templateId, faceId);
|
||||
if (!canGenerate) {
|
||||
return false;
|
||||
}
|
||||
FaceEntity face = faceRepository.getFace(faceId);
|
||||
if (face == null) {
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
taskEntity.setTemplateId(templateId);
|
||||
taskEntity.setScenicId(scenicId);
|
||||
taskEntity.setTaskParams(JSON.toJSONString(sourcesMap));
|
||||
taskEntity.setStatus(0);
|
||||
taskMapper.add(taskEntity);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateRespVO workerGetTemplate(@NonNull Long templateId, @NonNull WorkerAuthReqVo req) {
|
||||
if (templateId == null) {
|
||||
@ -346,13 +325,34 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
memberVideoEntity.setIsBuy(0);
|
||||
if (list.isEmpty()) {
|
||||
log.info("创建任务! faceId:{},templateId:{},taskParams:{}", faceId, templateId, sourcesMap);
|
||||
TaskEntity taskEntity = new TaskEntity();
|
||||
taskEntity.setId(SnowFlakeUtil.getLongId());
|
||||
taskEntity.setScenicId(face.getScenicId());
|
||||
taskEntity.setFaceId(faceId);
|
||||
taskEntity.setTemplateId(templateId);
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(face.getScenicId());
|
||||
TaskEntity taskEntity = null;
|
||||
if (Integer.valueOf(0).equals(scenicConfig.getTemplateNewVideoType())) {
|
||||
log.info("景区{}启用:templateNewVideoType:全新视频原位替换", face.getScenicId());
|
||||
taskReqQuery.setTemplateId(templateId);
|
||||
List<TaskEntity> templateTaskList = taskMapper.listEntity(taskReqQuery);
|
||||
if (!templateTaskList.isEmpty()) {
|
||||
taskEntity = templateTaskList.get(0);
|
||||
log.info("已有旧生成的视频:{}", taskEntity);
|
||||
MemberVideoEntity taskVideoRelation = videoMapper.queryRelationByMemberTask(face.getMemberId(), taskEntity.getId());
|
||||
if (taskVideoRelation != null) {
|
||||
log.info("已有旧关联记录的视频:{}", taskVideoRelation);
|
||||
memberVideoEntity.setIsBuy(taskVideoRelation.getIsBuy());
|
||||
memberVideoEntity.setOrderId(taskVideoRelation.getOrderId());
|
||||
}
|
||||
taskMapper.deleteById(taskEntity.getId());
|
||||
}
|
||||
}
|
||||
if (taskEntity == null) {
|
||||
taskEntity = new TaskEntity();
|
||||
taskEntity.setId(SnowFlakeUtil.getLongId());
|
||||
taskEntity.setScenicId(face.getScenicId());
|
||||
taskEntity.setFaceId(faceId);
|
||||
taskEntity.setTemplateId(templateId);
|
||||
taskEntity.setAutomatic(automatic);
|
||||
}
|
||||
taskEntity.setWorkerId(null);
|
||||
taskEntity.setStatus(0);
|
||||
taskEntity.setAutomatic(automatic);
|
||||
taskEntity.setTaskParams(JSON.toJSONString(sourcesMap));
|
||||
taskMapper.add(taskEntity);
|
||||
memberVideoEntity.setTaskId(taskEntity.getId());
|
||||
@ -361,8 +361,12 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
memberVideoEntity.setTaskId(list.get(0).getId());
|
||||
VideoEntity video = videoMapper.findByTaskId(list.get(0).getId());
|
||||
if (video != null) {
|
||||
PriceObj priceObj = orderBiz.queryPrice(list.get(0).getScenicId(), 0, video.getId());
|
||||
if (priceObj.isFree()) {
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), list.get(0).getScenicId(), 0, video.getId());
|
||||
if (isBuy.isBuy()) {
|
||||
memberVideoEntity.setIsBuy(1);
|
||||
memberVideoEntity.setOrderId(isBuy.getOrderId());
|
||||
}
|
||||
if (isBuy.isFree()) {
|
||||
memberVideoEntity.setIsBuy(1);
|
||||
}
|
||||
memberVideoEntity.setVideoId(video.getId());
|
||||
@ -427,9 +431,30 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
videoMapper.add(video);
|
||||
}
|
||||
int isBuy = 0;
|
||||
PriceObj priceObj = orderBiz.queryPrice(task.getScenicId(), 0, video.getId());
|
||||
if (priceObj.isFree()) {
|
||||
isBuy = 1;
|
||||
FaceEntity face = faceRepository.getFace(task.getFaceId());
|
||||
if (face != null) {
|
||||
IsBuyRespVO priceObj = orderBiz.isBuy(face.getMemberId(), task.getScenicId(), 0, video.getId());
|
||||
if (priceObj.isBuy()) {
|
||||
isBuy = 1;
|
||||
}
|
||||
if (priceObj.isFree()) {
|
||||
isBuy = 1;
|
||||
}
|
||||
if (isBuy != 1) {
|
||||
// 判断景区新生成免费送逻辑
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(task.getScenicId());
|
||||
if (Integer.valueOf(2).equals(scenicConfig.getTemplateNewVideoType())) {
|
||||
log.info("景区{}启用:templateNewVideoType:全新视频不需要重新购买", task.getScenicId());
|
||||
// 全新视频,不需要重新购买,旧视频在我的里面查看
|
||||
List<MemberVideoEntity> entityList = videoMapper.listRelationByFaceAndTemplate(face.getMemberId(), face.getId(), task.getTemplateId());
|
||||
Optional<MemberVideoEntity> buy = entityList.stream().filter(item -> Integer.valueOf(1).equals(item.getIsBuy())).findAny();
|
||||
if (buy.isPresent()) {
|
||||
log.info("人脸{},模板{},已经被购买过,{}", face.getId(), task.getTemplateId(), buy.get());
|
||||
// 买过
|
||||
isBuy = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
videoMapper.updateRelationWhenTaskSuccess(taskId, video.getId(), isBuy);
|
||||
new Thread(() -> {
|
||||
|
Reference in New Issue
Block a user