You've already forked FrameTour-BE
- 添加对配对设备的处理,确保主设备也能正确执行切片任务 - 调整计数器逻辑,使主设备和配对设备的未完成占位符计数一致 - 增强日志记录,明确标识设备占位符满足情况 - 改进进度计算方式,更准确地反映任务完成状态- 在所有占位符满足时提前调用回调函数,提升任务执行效率
This commit is contained in:
@@ -189,33 +189,45 @@ public class VideoPieceGetter {
|
||||
}
|
||||
}
|
||||
isFirst.set(false);
|
||||
// 处理关联设备:如果当前设备是某个主设备的配对设备,也处理主设备
|
||||
if (pairDeviceMap.containsValue(faceSample.getDeviceId())) {
|
||||
// 有关联设备!
|
||||
// 找到对应的deviceId
|
||||
pairDeviceMap.entrySet().stream()
|
||||
.filter(entry -> entry.getValue().equals(faceSample.getDeviceId()))
|
||||
.map(Map.Entry::getKey).forEach(pairDeviceId -> {
|
||||
log.info("找到同景区关联设备:{} -> {}", pairDeviceId, faceSample.getDeviceId());
|
||||
if (pairDeviceId != null) {
|
||||
doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
|
||||
AtomicInteger count = currentUnFinPlaceholder.get(faceSample.getDeviceId().toString());
|
||||
if (count != null && count.decrementAndGet() <= 0) {
|
||||
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
||||
// 让主设备的计数器 -1
|
||||
AtomicInteger pairCount = currentUnFinPlaceholder.get(pairDeviceId.toString());
|
||||
if (pairCount != null && pairCount.decrementAndGet() <= 0) {
|
||||
currentUnFinPlaceholder.remove(pairDeviceId.toString());
|
||||
log.info("设备 {} 的placeholder已满足", pairDeviceId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 处理当前设备
|
||||
doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
|
||||
AtomicInteger count = currentUnFinPlaceholder.get(faceSample.getDeviceId().toString());
|
||||
if (count != null && count.decrementAndGet() <= 0) {
|
||||
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
||||
log.info("设备 {} 的placeholder已满足", faceSample.getDeviceId());
|
||||
}
|
||||
|
||||
// 如果有templateId,检查是否所有placeholder都已满足
|
||||
if (templatePlaceholder != null) {
|
||||
long distinctDeviceCount = templatePlaceholder.stream().distinct().count();
|
||||
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), distinctDeviceCount);
|
||||
int totalPlaceholderCount = templatePlaceholder.size();
|
||||
int remainingCount = currentUnFinPlaceholder.values().stream()
|
||||
.mapToInt(AtomicInteger::get)
|
||||
.sum();
|
||||
log.info("当前进度:已完成 {}/{},剩余 {} 个placeholder未满足",
|
||||
totalPlaceholderCount - remainingCount, totalPlaceholderCount, remainingCount);
|
||||
|
||||
if (currentUnFinPlaceholder.isEmpty()) {
|
||||
if (!invoke.get()) {
|
||||
invoke.set(true);
|
||||
log.info("所有placeholder已满足,提前调用callback");
|
||||
task.getCallback().onInvoke();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user