diff --git a/src/main/java/com/ycwl/basic/task/VideoPieceGetter.java b/src/main/java/com/ycwl/basic/task/VideoPieceGetter.java index 5ee903c..0c983c2 100644 --- a/src/main/java/com/ycwl/basic/task/VideoPieceGetter.java +++ b/src/main/java/com/ycwl/basic/task/VideoPieceGetter.java @@ -129,7 +129,7 @@ public class VideoPieceGetter { new ArrayBlockingQueue<>(512), threadFactory ); - List currentPlaceholder = new ArrayList<>(); + List currentUnFinPlaceholder = new ArrayList<>(); List list = faceSampleMapper.listByIds(task.getFaceSampleIds()); Map pairDeviceMap = new ConcurrentHashMap<>(); if (!list.isEmpty()) { @@ -143,16 +143,24 @@ public class VideoPieceGetter { } }); } - Collection> collection = list.stream() + Map> 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();