This commit is contained in:
2025-04-27 14:17:20 +08:00
parent 7583c9e22e
commit 7771f85618

View File

@ -129,7 +129,7 @@ public class VideoPieceGetter {
new ArrayBlockingQueue<>(512),
threadFactory
);
List<String> currentPlaceholder = new ArrayList<>();
List<String> currentUnFinPlaceholder = new ArrayList<>();
List<FaceSampleEntity> list = faceSampleMapper.listByIds(task.getFaceSampleIds());
Map<Long, Long> pairDeviceMap = new ConcurrentHashMap<>();
if (!list.isEmpty()) {
@ -143,16 +143,24 @@ public class VideoPieceGetter {
}
});
}
Collection<List<FaceSampleEntity>> collection = list.stream()
Map<Long, List<FaceSampleEntity>> collection = list.stream()
.filter(faceSample -> {
if (templatePlaceholder != null) {
return templatePlaceholder.contains(faceSample.getDeviceId().toString());
}
return true;
})
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId))
.values();
collection.forEach(faceSampleList -> {
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId));
if (templatePlaceholder != null) {
IntStream.range(0, templatePlaceholder.size()).forEach(i -> {
currentUnFinPlaceholder.add(templatePlaceholder.get(i));
});
} else {
collection.keySet().forEach(i -> {
currentUnFinPlaceholder.add(i.toString());
});
}
collection.values().forEach(faceSampleList -> {
executor.execute(() -> {
AtomicBoolean isFirst = new AtomicBoolean(true);
faceSampleList.forEach(faceSample -> {
@ -174,14 +182,14 @@ public class VideoPieceGetter {
boolean result = doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
if (templatePlaceholder != null) {
if (templatePlaceholder.contains(faceSample.getDeviceId().toString())) {
if (!currentPlaceholder.contains(faceSample.getDeviceId().toString())) {
if (currentUnFinPlaceholder.contains(faceSample.getDeviceId().toString())) {
if (result) {
currentPlaceholder.add(faceSample.getDeviceId().toString());
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
}
}
}
log.info("当前进度:{}/{}", currentPlaceholder.size(), collection.size());
if (currentPlaceholder.size() >= collection.size()) {
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), collection.size());
if (currentUnFinPlaceholder.size() <= 0) {
if (!invoke.get()) {
invoke.set(true);
task.getCallback().onInvoke();
@ -197,14 +205,14 @@ public class VideoPieceGetter {
boolean result = doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
if (templatePlaceholder != null) {
if (templatePlaceholder.contains(faceSample.getDeviceId().toString())) {
if (!currentPlaceholder.contains(faceSample.getDeviceId().toString())) {
if (currentUnFinPlaceholder.contains(faceSample.getDeviceId().toString())) {
if (result) {
currentPlaceholder.add(faceSample.getDeviceId().toString());
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
}
}
}
log.info("当前进度:{}/{}", currentPlaceholder.size(), collection.size());
if (currentPlaceholder.size() >= collection.size()) {
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), collection.size());
if (currentUnFinPlaceholder.size() <= 0) {
if (!invoke.get()) {
invoke.set(true);
task.getCallback().onInvoke();