You've already forked FrameTour-BE
模板支持相同机位
This commit is contained in:
@ -33,7 +33,6 @@ public class TemplateRepository {
|
|||||||
return template.getChildren().stream()
|
return template.getChildren().stream()
|
||||||
.filter(item -> item.getIsPlaceholder() == 1)
|
.filter(item -> item.getIsPlaceholder() == 1)
|
||||||
.map(TemplateRespVO::getSourceUrl)
|
.map(TemplateRespVO::getSourceUrl)
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,18 +269,22 @@ public class GoodsServiceImpl implements GoodsService {
|
|||||||
}
|
}
|
||||||
TaskEntity task = videoTaskRepository.getTaskById(videoRespVO.getTaskId());
|
TaskEntity task = videoTaskRepository.getTaskById(videoRespVO.getTaskId());
|
||||||
JSONObject paramJson = JSON.parseObject(task.getTaskParams());
|
JSONObject paramJson = JSON.parseObject(task.getTaskParams());
|
||||||
long deviceCount;
|
AtomicInteger deviceCount = new AtomicInteger();
|
||||||
goodsDetailVO.setShotTime(taskTaskService.getTaskShotDate(task.getId()));
|
goodsDetailVO.setShotTime(taskTaskService.getTaskShotDate(task.getId()));
|
||||||
if (paramJson == null) {
|
if (paramJson == null) {
|
||||||
deviceCount = 1;
|
deviceCount.set(1);
|
||||||
} else {
|
} else {
|
||||||
List<String> templatePlaceholder = templateRepository.getTemplatePlaceholder(task.getTemplateId());
|
List<String> templatePlaceholder = templateRepository.getTemplatePlaceholder(task.getTemplateId());
|
||||||
deviceCount = paramJson.keySet().stream()
|
paramJson.entrySet().stream()
|
||||||
.filter(StringUtils::isNumeric)
|
.filter(entry -> StringUtils.isNumeric(entry.getKey()))
|
||||||
.filter(templatePlaceholder::contains)
|
.forEach(entry -> {
|
||||||
.count();
|
if (templatePlaceholder.contains(entry.getKey())) {
|
||||||
|
deviceCount.getAndIncrement();
|
||||||
|
templatePlaceholder.remove(entry.getKey());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
goodsDetailVO.setLensNum((int) deviceCount);
|
goodsDetailVO.setLensNum(deviceCount.get());
|
||||||
return ApiResponse.success(goodsDetailVO);
|
return ApiResponse.success(goodsDetailVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,7 @@ public class SourceServiceImpl implements SourceService {
|
|||||||
// 下载切片
|
// 下载切片
|
||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
task.faceSampleIds = Collections.singletonList(source.getFaceSampleId());
|
task.faceSampleIds = Collections.singletonList(source.getFaceSampleId());
|
||||||
|
task.force = true;
|
||||||
VideoPieceGetter.addTask(task);
|
VideoPieceGetter.addTask(task);
|
||||||
}
|
}
|
||||||
return ApiResponse.success("任务已下发");
|
return ApiResponse.success("任务已下发");
|
||||||
|
@ -274,10 +274,15 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
log.info("task callback: 没有视频源");
|
log.info("task callback: 没有视频源");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sourcesMap.forEach((key, value) -> {
|
List<String> templatePlaceholder = templateRepository.getTemplatePlaceholder(templateId);
|
||||||
// 每个value只保留第一个
|
if (templatePlaceholder.stream().distinct().count() == templatePlaceholder.size()) {
|
||||||
value.removeIf(item -> !value.get(0).equals(item));
|
sourcesMap.forEach((key, value) -> {
|
||||||
});
|
// 每个value只保留第一个
|
||||||
|
value.removeIf(item -> !value.get(0).equals(item));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
||||||
|
}
|
||||||
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||||
taskReqQuery.setFaceId(faceId);
|
taskReqQuery.setFaceId(faceId);
|
||||||
taskReqQuery.setTemplateId(templateId);
|
taskReqQuery.setTemplateId(templateId);
|
||||||
@ -469,10 +474,15 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
log.info("task callback: 没有视频源,templateId: {}", templateId);
|
log.info("task callback: 没有视频源,templateId: {}", templateId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sourcesMap.forEach((key, value) -> {
|
List<String> templatePlaceholder = templateRepository.getTemplatePlaceholder(templateId);
|
||||||
// 每个value只保留第一个
|
if (templatePlaceholder.stream().distinct().count() == templatePlaceholder.size()) {
|
||||||
value.removeIf(item -> !value.get(0).equals(item));
|
sourcesMap.forEach((key, value) -> {
|
||||||
});
|
// 每个value只保留第一个
|
||||||
|
value.removeIf(item -> !value.get(0).equals(item));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
||||||
|
}
|
||||||
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||||
taskReqQuery.setFaceId(faceId);
|
taskReqQuery.setFaceId(faceId);
|
||||||
taskReqQuery.setTemplateId(templateId);
|
taskReqQuery.setTemplateId(templateId);
|
||||||
|
@ -75,6 +75,7 @@ public class VideoPieceGetter {
|
|||||||
public Long memberId;
|
public Long memberId;
|
||||||
public Long faceId;
|
public Long faceId;
|
||||||
public Long templateId;
|
public Long templateId;
|
||||||
|
public boolean force;
|
||||||
|
|
||||||
public static interface Callback {
|
public static interface Callback {
|
||||||
void onInvoke();
|
void onInvoke();
|
||||||
@ -170,6 +171,7 @@ public class VideoPieceGetter {
|
|||||||
} catch (InterruptedException ignore) {
|
} catch (InterruptedException ignore) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isFirst.set(false);
|
||||||
if (pairDeviceMap.containsValue(faceSample.getDeviceId())) {
|
if (pairDeviceMap.containsValue(faceSample.getDeviceId())) {
|
||||||
// 有关联设备!
|
// 有关联设备!
|
||||||
// 找到对应的deviceId
|
// 找到对应的deviceId
|
||||||
@ -179,40 +181,18 @@ public class VideoPieceGetter {
|
|||||||
log.info("找到同景区关联设备:{} -> {}", pairDeviceId, faceSample.getDeviceId());
|
log.info("找到同景区关联设备:{} -> {}", pairDeviceId, faceSample.getDeviceId());
|
||||||
if (pairDeviceId != null) {
|
if (pairDeviceId != null) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
boolean result = doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
|
doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
|
||||||
if (templatePlaceholder != null) {
|
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
||||||
if (templatePlaceholder.contains(faceSample.getDeviceId().toString())) {
|
|
||||||
if (currentUnFinPlaceholder.contains(faceSample.getDeviceId().toString())) {
|
|
||||||
if (result) {
|
|
||||||
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), collection.size());
|
|
||||||
if (currentUnFinPlaceholder.size() <= 0) {
|
|
||||||
if (!invoke.get()) {
|
|
||||||
invoke.set(true);
|
|
||||||
task.getCallback().onInvoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
isFirst.set(false);
|
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
boolean result = doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
|
doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
|
||||||
|
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
||||||
if (templatePlaceholder != null) {
|
if (templatePlaceholder != null) {
|
||||||
if (templatePlaceholder.contains(faceSample.getDeviceId().toString())) {
|
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), templatePlaceholder.size());
|
||||||
if (currentUnFinPlaceholder.contains(faceSample.getDeviceId().toString())) {
|
if (currentUnFinPlaceholder.isEmpty()) {
|
||||||
if (result) {
|
|
||||||
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), collection.size());
|
|
||||||
if (currentUnFinPlaceholder.size() <= 0) {
|
|
||||||
if (!invoke.get()) {
|
if (!invoke.get()) {
|
||||||
invoke.set(true);
|
invoke.set(true);
|
||||||
task.getCallback().onInvoke();
|
task.getCallback().onInvoke();
|
||||||
@ -250,7 +230,7 @@ public class VideoPieceGetter {
|
|||||||
|
|
||||||
SourceEntity source = sourceMapper.querySameVideo(faceSampleId, device.getId());
|
SourceEntity source = sourceMapper.querySameVideo(faceSampleId, device.getId());
|
||||||
|
|
||||||
if (source == null) {
|
if (source == null || task.force) {
|
||||||
BigDecimal cutPre = BigDecimal.valueOf(5L);
|
BigDecimal cutPre = BigDecimal.valueOf(5L);
|
||||||
BigDecimal cutPost = BigDecimal.valueOf(4L);
|
BigDecimal cutPost = BigDecimal.valueOf(4L);
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
@ -299,38 +279,44 @@ public class VideoPieceGetter {
|
|||||||
// 上传成功后删除文件
|
// 上传成功后删除文件
|
||||||
outFile.delete();
|
outFile.delete();
|
||||||
}
|
}
|
||||||
SourceEntity imgSource = sourceMapper.findBySampleId(faceSampleId);
|
if (source == null) {
|
||||||
SourceEntity sourceEntity = new SourceEntity();
|
SourceEntity imgSource = sourceMapper.findBySampleId(faceSampleId);
|
||||||
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
SourceEntity sourceEntity = new SourceEntity();
|
||||||
sourceEntity.setCreateTime(baseTime);
|
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
||||||
if (imgSource != null) {
|
sourceEntity.setCreateTime(baseTime);
|
||||||
sourceEntity.setUrl(imgSource.getUrl());
|
if (imgSource != null) {
|
||||||
sourceEntity.setPosJson(imgSource.getPosJson());
|
sourceEntity.setUrl(imgSource.getUrl());
|
||||||
}
|
sourceEntity.setPosJson(imgSource.getPosJson());
|
||||||
sourceEntity.setVideoUrl(url);
|
|
||||||
sourceEntity.setFaceSampleId(faceSampleId);
|
|
||||||
sourceEntity.setScenicId(device.getScenicId());
|
|
||||||
sourceEntity.setDeviceId(deviceId);
|
|
||||||
sourceEntity.setType(1);
|
|
||||||
if (task.memberId != null && task.faceId != null) {
|
|
||||||
MemberSourceEntity videoSource = new MemberSourceEntity();
|
|
||||||
videoSource.setMemberId(task.getMemberId());
|
|
||||||
videoSource.setType(1);
|
|
||||||
videoSource.setFaceId(task.getFaceId());
|
|
||||||
videoSource.setScenicId(device.getScenicId());
|
|
||||||
videoSource.setSourceId(sourceEntity.getId());
|
|
||||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), device.getScenicId(), 1, task.getFaceId());
|
|
||||||
if (isBuy.isBuy()) { // 如果用户买过
|
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else if (isBuy.isFree()) { // 全免费逻辑
|
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else {
|
|
||||||
videoSource.setIsBuy(0);
|
|
||||||
}
|
}
|
||||||
sourceMapper.addRelation(videoSource);
|
sourceEntity.setVideoUrl(url);
|
||||||
|
sourceEntity.setFaceSampleId(faceSampleId);
|
||||||
|
sourceEntity.setScenicId(device.getScenicId());
|
||||||
|
sourceEntity.setDeviceId(deviceId);
|
||||||
|
sourceEntity.setType(1);
|
||||||
|
if (task.memberId != null && task.faceId != null) {
|
||||||
|
MemberSourceEntity videoSource = new MemberSourceEntity();
|
||||||
|
videoSource.setMemberId(task.getMemberId());
|
||||||
|
videoSource.setType(1);
|
||||||
|
videoSource.setFaceId(task.getFaceId());
|
||||||
|
videoSource.setScenicId(device.getScenicId());
|
||||||
|
videoSource.setSourceId(sourceEntity.getId());
|
||||||
|
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), device.getScenicId(), 1, task.getFaceId());
|
||||||
|
if (isBuy.isBuy()) { // 如果用户买过
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else if (isBuy.isFree()) { // 全免费逻辑
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else {
|
||||||
|
videoSource.setIsBuy(0);
|
||||||
|
}
|
||||||
|
sourceMapper.addRelation(videoSource);
|
||||||
|
}
|
||||||
|
sourceMapper.add(sourceEntity);
|
||||||
|
videoReUploader.addTask(url, sourceEntity.getId());
|
||||||
|
} else {
|
||||||
|
source.setVideoUrl(url);
|
||||||
|
sourceMapper.update(source);
|
||||||
|
videoReUploader.addTask(url, source.getId());
|
||||||
}
|
}
|
||||||
sourceMapper.add(sourceEntity);
|
|
||||||
videoReUploader.addTask(sourceEntity.getVideoUrl(), sourceEntity.getId());
|
|
||||||
} else {
|
} else {
|
||||||
// 有原视频
|
// 有原视频
|
||||||
if (task.memberId != null && task.faceId != null) {
|
if (task.memberId != null && task.faceId != null) {
|
||||||
|
@ -84,7 +84,7 @@ public class VideoTaskGenerator {
|
|||||||
query.setStartTime(DateUtil.beginOfDay(new Date()));
|
query.setStartTime(DateUtil.beginOfDay(new Date()));
|
||||||
query.setEndTime(DateUtil.endOfDay(new Date()));
|
query.setEndTime(DateUtil.endOfDay(new Date()));
|
||||||
List<FaceRespVO> list = faceMapper.list(query);
|
List<FaceRespVO> list = faceMapper.list(query);
|
||||||
list.stream().parallel().forEach(face -> {
|
list.forEach(face -> {
|
||||||
faceService.matchFaceId(face.getId(), false);
|
faceService.matchFaceId(face.getId(), false);
|
||||||
if (Integer.valueOf(3).equals(scenicConfig.getBookRoutine())) {
|
if (Integer.valueOf(3).equals(scenicConfig.getBookRoutine())) {
|
||||||
// 全部生成
|
// 全部生成
|
||||||
|
Reference in New Issue
Block a user