逻辑修正
This commit is contained in:
parent
f0b8d85dcc
commit
ff39208d80
@ -386,14 +386,13 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (faceSampleList.isEmpty()) {
|
||||
log.info("faceId:{} sample list not exist", faceId);
|
||||
}
|
||||
if (automatic == 1) {
|
||||
if (templateBiz.determineTemplateCanGenerate(templateId, faceId, false)) {
|
||||
// 临时写死,当自动生成视频,切片也算合成中,并更新状态
|
||||
taskStatusBiz.setFaceCutStatus(face.getId(), 0);
|
||||
}
|
||||
if (templateBiz.determineTemplateCanGenerate(templateId, faceId, false)) {
|
||||
// 临时写死,当自动生成视频,切片也算合成中,并更新状态
|
||||
taskStatusBiz.setFaceCutStatus(face.getId(), 0);
|
||||
} else {
|
||||
taskStatusBiz.setFaceCutStatus(face.getId(), 2);
|
||||
}
|
||||
List<Long> faceSampleIds = faceSampleList.stream().map(FaceSampleEntity::getId).collect(Collectors.toList());
|
||||
List<SourceEntity> sourceList = sourceMapper.listVideoByScenicFaceRelation(face.getScenicId(), faceId);
|
||||
// ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(face.getScenicId());
|
||||
// if (automatic > 0) {
|
||||
// TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||
@ -434,7 +433,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
task.templateId = templateId;
|
||||
task.memberId = face.getMemberId();
|
||||
task.callback = () -> {
|
||||
log.info("task callback");
|
||||
log.info("task callback: {}", task);
|
||||
boolean canGenerate = templateBiz.determineTemplateCanGenerate(templateId, faceId);
|
||||
if (!canGenerate) {
|
||||
log.info("task callback: 不能生成,templateId: {}", templateId);
|
||||
@ -529,10 +528,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
};
|
||||
if (faceSampleIds.isEmpty()) {
|
||||
// 没有人脸样本
|
||||
if (!sourceList.isEmpty()) {
|
||||
// 但是有原片
|
||||
task.callback.onInvoke();
|
||||
}
|
||||
task.callback.onInvoke();
|
||||
} else {
|
||||
VideoPieceGetter.addTask(task);
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
@ -112,6 +114,7 @@ public class VideoPieceGetter {
|
||||
// taskStatusBiz.setFaceCutStatus(task.faceId, 0);
|
||||
// }
|
||||
AtomicBoolean invoke = new AtomicBoolean(false);
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor(8, 16, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(32));
|
||||
List<String> currentPlaceholder = new ArrayList<>();
|
||||
List<FaceSampleEntity> list = faceSampleMapper.listByIds(task.getFaceSampleIds());
|
||||
Collection<List<FaceSampleEntity>> collection = list.stream()
|
||||
@ -124,7 +127,7 @@ public class VideoPieceGetter {
|
||||
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId))
|
||||
.values();
|
||||
collection.forEach(faceSampleList -> {
|
||||
new Thread(() -> {
|
||||
executor.execute(() -> {
|
||||
faceSampleList.parallelStream().forEach(faceSample -> {
|
||||
DeviceEntity device = deviceRepository.getDevice(faceSample.getDeviceId());
|
||||
DeviceConfigEntity config = deviceRepository.getDeviceConfig(faceSample.getDeviceId());
|
||||
@ -252,10 +255,17 @@ public class VideoPieceGetter {
|
||||
}
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
});
|
||||
});
|
||||
if (task.faceId != null) {
|
||||
taskStatusBiz.setFaceCutStatus(task.faceId, 1);
|
||||
try {
|
||||
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
|
||||
executor.shutdown();
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
} finally {
|
||||
if (task.faceId != null) {
|
||||
taskStatusBiz.setFaceCutStatus(task.faceId, 1);
|
||||
}
|
||||
}
|
||||
if (null != task.getCallback()) {
|
||||
if (!invoke.get()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user