You've already forked FrameTour-BE
Compare commits
4 Commits
1b2793215f
...
2836326518
Author | SHA1 | Date | |
---|---|---|---|
2836326518 | |||
6091d41df9 | |||
d4f9f1fe0d | |||
d860996f6d |
@@ -72,6 +72,7 @@ import java.io.File;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -80,6 +81,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static com.ycwl.basic.constant.FaceConstant.FACE_LOW_THRESHOLD_PFX;
|
import static com.ycwl.basic.constant.FaceConstant.FACE_LOW_THRESHOLD_PFX;
|
||||||
import static com.ycwl.basic.constant.FaceConstant.FACE_RECOGNITION_COUNT_PFX;
|
import static com.ycwl.basic.constant.FaceConstant.FACE_RECOGNITION_COUNT_PFX;
|
||||||
@@ -489,7 +491,21 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sourceEntities.stream().map(sourceEntity -> {
|
List<SourceEntity> filteredSourceEntities = sourceEntities.stream()
|
||||||
|
.sorted(Comparator.comparing(SourceEntity::getCreateTime).reversed())
|
||||||
|
.collect(Collectors.groupingBy(SourceEntity::getDeviceId))
|
||||||
|
.entrySet()
|
||||||
|
.stream().flatMap(entry -> {
|
||||||
|
DeviceConfigManager configManager = deviceRepository.getDeviceConfigManager(entry.getKey());
|
||||||
|
if (configManager.getInteger("limit_video", 0) > 0) {
|
||||||
|
return Stream.concat(
|
||||||
|
entry.getValue().stream().filter(item -> item.getType() == 2),
|
||||||
|
entry.getValue().stream().filter(item -> item.getType() == 1).limit(Math.min(entry.getValue().size(), configManager.getInteger("limit_video", 0)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return entry.getValue().stream();
|
||||||
|
}).toList();
|
||||||
|
return filteredSourceEntities.stream().map(sourceEntity -> {
|
||||||
DeviceConfigManager deviceConfig = deviceRepository.getDeviceConfigManager(sourceEntity.getDeviceId());
|
DeviceConfigManager deviceConfig = deviceRepository.getDeviceConfigManager(sourceEntity.getDeviceId());
|
||||||
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
|
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
|
||||||
memberSourceEntity.setScenicId(face.getScenicId());
|
memberSourceEntity.setScenicId(face.getScenicId());
|
||||||
@@ -627,13 +643,31 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
.filter(item -> Integer.valueOf(2).equals(item.getType()))
|
.filter(item -> Integer.valueOf(2).equals(item.getType()))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
|
List<FaceSampleEntity> faceSampleList = faceRepository.getFaceSampleList(faceId);
|
||||||
|
if (faceSampleList.isEmpty()) {
|
||||||
|
log.info("faceId:{} sample list not exist", faceId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Long> faceSampleIds = faceSampleList.stream()
|
||||||
|
.sorted(Comparator.comparing(FaceSampleEntity::getCreateAt).reversed())
|
||||||
|
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId))
|
||||||
|
.entrySet()
|
||||||
|
.stream().flatMap(entry -> {
|
||||||
|
DeviceConfigManager configManager = deviceRepository.getDeviceConfigManager(entry.getKey());
|
||||||
|
if (configManager.getInteger("limit_video", 0) > 0) {
|
||||||
|
return entry.getValue().subList(0, Math.min(entry.getValue().size(), configManager.getInteger("limit_video", 0))).stream();
|
||||||
|
}
|
||||||
|
return entry.getValue().stream();
|
||||||
|
}).toList()
|
||||||
|
.stream().map(FaceSampleEntity::getId).toList();
|
||||||
|
log.info("视频切分任务: faceId={}, 原始数量={}, 筛选后数量={}", faceId, faceSampleList.size(), faceSampleIds.size());
|
||||||
log.debug("视频重切逻辑:视频数量 {}, 照片数量 {}", videoCount, photoCount);
|
log.debug("视频重切逻辑:视频数量 {}, 照片数量 {}", videoCount, photoCount);
|
||||||
|
|
||||||
// 只有照片数量大于视频数量时才创建重切任务
|
// 只有照片数量大于视频数量时才创建重切任务
|
||||||
if (photoCount > videoCount) {
|
if (photoCount > videoCount) {
|
||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
task.faceId = faceId;
|
task.faceId = faceId;
|
||||||
task.faceSampleIds = sampleListIds;
|
task.faceSampleIds = faceSampleIds;
|
||||||
task.templateId = null;
|
task.templateId = null;
|
||||||
task.memberId = memberId;
|
task.memberId = memberId;
|
||||||
task.callback = () -> {
|
task.callback = () -> {
|
||||||
@@ -933,11 +967,11 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
statusResp.setStep3Status(true);
|
statusResp.setStep3Status(true);
|
||||||
statusResp.setDisplayText("帧途AI已为您渲染"+ taskStatusByFaceId.getCount() +"个vlog");
|
statusResp.setDisplayText("帧途AI已为您渲染"+ taskStatusByFaceId.getCount() +"个vlog");
|
||||||
} else {
|
} else {
|
||||||
statusResp.setStep3Status(true);
|
statusResp.setStep3Status(false);
|
||||||
statusResp.setDisplayText("帧途AI将会为您渲染vlog,请稍候");
|
statusResp.setDisplayText("帧途AI将会为您渲染vlog,请稍候");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
statusResp.setStep3Status(true);
|
statusResp.setStep3Status(false);
|
||||||
statusResp.setDisplayText("帧途AI正在为您渲染vlog,请稍候");
|
statusResp.setDisplayText("帧途AI正在为您渲染vlog,请稍候");
|
||||||
}
|
}
|
||||||
return statusResp;
|
return statusResp;
|
||||||
|
@@ -164,9 +164,23 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
log.warn("没有有效的关联关系可创建: faceId={}, 原始数量={}", faceId, memberSourceEntityList.size());
|
log.warn("没有有效的关联关系可创建: faceId={}, 原始数量={}", faceId, memberSourceEntityList.size());
|
||||||
}
|
}
|
||||||
memberRelationRepository.clearSCacheByFace(faceId);
|
memberRelationRepository.clearSCacheByFace(faceId);
|
||||||
|
List<FaceSampleEntity> faceSampleList = faceRepository.getFaceSampleList(faceId);
|
||||||
|
List<Long> faceSampleIds = faceSampleList.stream()
|
||||||
|
.sorted(Comparator.comparing(FaceSampleEntity::getCreateAt).reversed())
|
||||||
|
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId))
|
||||||
|
.entrySet()
|
||||||
|
.stream().flatMap(entry -> {
|
||||||
|
DeviceConfigManager configManager = deviceRepository.getDeviceConfigManager(entry.getKey());
|
||||||
|
if (configManager.getInteger("limit_video", 0) > 0) {
|
||||||
|
return entry.getValue().subList(0, Math.min(entry.getValue().size(), configManager.getInteger("limit_video", 0))).stream();
|
||||||
|
}
|
||||||
|
return entry.getValue().stream();
|
||||||
|
}).toList()
|
||||||
|
.stream().map(FaceSampleEntity::getId).toList();
|
||||||
|
log.info("视频切分任务: faceId={}, 原始数量={}, 筛选后数量={}", faceId, sampleListIds.size(), faceSampleIds.size());
|
||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
task.faceId = faceEntity.getId();
|
task.faceId = faceEntity.getId();
|
||||||
task.faceSampleIds = sampleListIds;
|
task.faceSampleIds = faceSampleIds;
|
||||||
task.memberId = face.getMemberId();
|
task.memberId = face.getMemberId();
|
||||||
VideoPieceGetter.addTask(task);
|
VideoPieceGetter.addTask(task);
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -255,7 +256,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void autoCreateTaskByFaceId(Long faceId) {
|
public void autoCreateTaskByFaceId(Long faceId) {
|
||||||
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
FaceEntity faceRespVO = faceRepository.getFace(faceId);
|
||||||
if (faceRespVO == null) {
|
if (faceRespVO == null) {
|
||||||
log.info("faceId:{} is not exist", faceId);
|
log.info("faceId:{} is not exist", faceId);
|
||||||
return;
|
return;
|
||||||
@@ -264,18 +265,30 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
log.info("faceId:{} matchSampleIds is empty", faceId);
|
log.info("faceId:{} matchSampleIds is empty", faceId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<FaceSampleEntity> faceSampleList = faceSampleMapper.listByIds(Arrays.stream(faceRespVO.getMatchSampleIds().split(",")).filter(StringUtils::isNumeric).map(Long::valueOf).collect(Collectors.toList()));
|
List<FaceSampleEntity> faceSampleList = faceRepository.getFaceSampleList(faceId);
|
||||||
if (faceSampleList.isEmpty()) {
|
if (faceSampleList.isEmpty()) {
|
||||||
log.info("faceId:{} faceSampleList is empty", faceId);
|
log.info("faceId:{} faceSampleList is empty", faceId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
List<Long> faceSampleIds = faceSampleList.stream()
|
||||||
|
.sorted(Comparator.comparing(FaceSampleEntity::getCreateAt).reversed())
|
||||||
|
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId)).entrySet()
|
||||||
|
.stream().flatMap(entry -> {
|
||||||
|
DeviceConfigManager configManager = deviceRepository.getDeviceConfigManager(entry.getKey());
|
||||||
|
if (configManager.getInteger("limit_video", 0) > 0) {
|
||||||
|
return entry.getValue().subList(0, Math.min(entry.getValue().size(), configManager.getInteger("limit_video", 0))).stream();
|
||||||
|
}
|
||||||
|
return entry.getValue().stream();
|
||||||
|
}).toList()
|
||||||
|
.stream().map(FaceSampleEntity::getId).toList();
|
||||||
|
log.info("视频切分任务: faceId={}, 原始数量={}, 筛选后数量={}", faceId, faceSampleList.size(), faceSampleIds.size());
|
||||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(faceRespVO.getScenicId());
|
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(faceRespVO.getScenicId());
|
||||||
List<TemplateRespVO> templateList = templateRepository.getTemplateListByScenicId(faceRespVO.getScenicId());
|
List<TemplateRespVO> templateList = templateRepository.getTemplateListByScenicId(faceRespVO.getScenicId());
|
||||||
if (templateList == null || templateList.isEmpty()) {
|
if (templateList == null || templateList.isEmpty()) {
|
||||||
// 没有vlog视频的情况下
|
// 没有vlog视频的情况下
|
||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
task.faceId = faceId;
|
task.faceId = faceId;
|
||||||
task.faceSampleIds = faceSampleList.stream().map(FaceSampleEntity::getId).toList();
|
task.faceSampleIds = faceSampleIds;
|
||||||
task.templateId = null;
|
task.templateId = null;
|
||||||
task.memberId = faceRespVO.getMemberId();
|
task.memberId = faceRespVO.getMemberId();
|
||||||
task.callback = () -> {
|
task.callback = () -> {
|
||||||
@@ -334,7 +347,9 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> faceSampleIds = faceSampleList.stream().collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId)).entrySet()
|
List<Long> faceSampleIds = faceSampleList.stream()
|
||||||
|
.sorted(Comparator.comparing(FaceSampleEntity::getCreateAt).reversed())
|
||||||
|
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId)).entrySet()
|
||||||
.stream().flatMap(entry -> {
|
.stream().flatMap(entry -> {
|
||||||
DeviceConfigManager configManager = deviceRepository.getDeviceConfigManager(entry.getKey());
|
DeviceConfigManager configManager = deviceRepository.getDeviceConfigManager(entry.getKey());
|
||||||
if (configManager.getInteger("limit_video", 0) > 0) {
|
if (configManager.getInteger("limit_video", 0) > 0) {
|
||||||
@@ -343,6 +358,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
return entry.getValue().stream();
|
return entry.getValue().stream();
|
||||||
}).toList()
|
}).toList()
|
||||||
.stream().map(FaceSampleEntity::getId).collect(Collectors.toList());
|
.stream().map(FaceSampleEntity::getId).collect(Collectors.toList());
|
||||||
|
log.info("视频切分任务: faceId={}, 原始数量={}, 筛选后数量={}", faceId, faceSampleList.size(), faceSampleIds.size());
|
||||||
List<SourceEntity> sourceList = sourceMapper.listVideoByScenicFaceRelation(face.getScenicId(), faceId);
|
List<SourceEntity> sourceList = sourceMapper.listVideoByScenicFaceRelation(face.getScenicId(), faceId);
|
||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
task.faceId = faceId;
|
task.faceId = faceId;
|
||||||
|
Reference in New Issue
Block a user