You've already forked FrameTour-BE
refactor(task):优化视频片段获取逻辑并增强日志记录
- 移除任务执行前的空列表检查,统一通过VideoPieceGetter.addTask处理 - 增强Placeholder初始化阶段的日志输出,区分有无templateId情况- 细化计数器递减过程中的日志信息,记录设备关联及剩余数量 - 完善进度检查时的日志内容,增加已完成与未完成的统计显示- 补充Callback调用条件判断,避免重复触发并记录调用状态 - 添加兜底逻辑中对Callback是否已触发的判断和相应日志提示
This commit is contained in:
@@ -457,11 +457,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
taskStatusBiz.setFaceCutStatus(faceId, 2);
|
taskStatusBiz.setFaceCutStatus(faceId, 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!sourceList.isEmpty()) {
|
VideoPieceGetter.addTask(task);
|
||||||
task.callback.onInvoke();
|
|
||||||
} else {
|
|
||||||
VideoPieceGetter.addTask(task);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -173,10 +173,18 @@ public class VideoPieceGetter {
|
|||||||
templatePlaceholder.forEach(deviceId -> {
|
templatePlaceholder.forEach(deviceId -> {
|
||||||
currentUnFinPlaceholder.computeIfAbsent(deviceId, k -> new AtomicInteger(0)).incrementAndGet();
|
currentUnFinPlaceholder.computeIfAbsent(deviceId, k -> new AtomicInteger(0)).incrementAndGet();
|
||||||
});
|
});
|
||||||
|
log.info("[Placeholder初始化] 有templateId,初始化完成:placeholder总数={}, 不同设备数={}, 详细计数={}",
|
||||||
|
templatePlaceholder.size(),
|
||||||
|
currentUnFinPlaceholder.size(),
|
||||||
|
currentUnFinPlaceholder.entrySet().stream()
|
||||||
|
.map(e -> e.getKey() + "=" + e.getValue().get())
|
||||||
|
.collect(Collectors.joining(", ")));
|
||||||
} else {
|
} else {
|
||||||
collection.keySet().forEach(deviceId -> {
|
collection.keySet().forEach(deviceId -> {
|
||||||
currentUnFinPlaceholder.put(deviceId.toString(), new AtomicInteger(1));
|
currentUnFinPlaceholder.put(deviceId.toString(), new AtomicInteger(1));
|
||||||
});
|
});
|
||||||
|
log.info("[Placeholder初始化] 无templateId,初始化完成:设备数={}",
|
||||||
|
currentUnFinPlaceholder.size());
|
||||||
}
|
}
|
||||||
collection.values().forEach(faceSampleList -> {
|
collection.values().forEach(faceSampleList -> {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
@@ -199,9 +207,15 @@ public class VideoPieceGetter {
|
|||||||
doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
|
doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
|
||||||
// 让主设备的计数器 -1
|
// 让主设备的计数器 -1
|
||||||
AtomicInteger pairCount = currentUnFinPlaceholder.get(pairDeviceId.toString());
|
AtomicInteger pairCount = currentUnFinPlaceholder.get(pairDeviceId.toString());
|
||||||
if (pairCount != null && pairCount.decrementAndGet() <= 0) {
|
if (pairCount != null) {
|
||||||
currentUnFinPlaceholder.remove(pairDeviceId.toString());
|
int remaining = pairCount.decrementAndGet();
|
||||||
log.info("设备 {} 的placeholder已满足", pairDeviceId);
|
log.info("[计数器更新] 关联设备 {} 计数器递减,剩余={}, currentUnFinPlaceholder总数={}",
|
||||||
|
pairDeviceId, remaining, currentUnFinPlaceholder.size());
|
||||||
|
if (remaining <= 0) {
|
||||||
|
currentUnFinPlaceholder.remove(pairDeviceId.toString());
|
||||||
|
log.info("[Placeholder完成] 设备 {} 的placeholder已满足并移除,剩余设备数={}",
|
||||||
|
pairDeviceId, currentUnFinPlaceholder.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -210,9 +224,15 @@ public class VideoPieceGetter {
|
|||||||
// 处理当前设备
|
// 处理当前设备
|
||||||
doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
|
doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
|
||||||
AtomicInteger count = currentUnFinPlaceholder.get(faceSample.getDeviceId().toString());
|
AtomicInteger count = currentUnFinPlaceholder.get(faceSample.getDeviceId().toString());
|
||||||
if (count != null && count.decrementAndGet() <= 0) {
|
if (count != null) {
|
||||||
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
int remaining = count.decrementAndGet();
|
||||||
log.info("设备 {} 的placeholder已满足", faceSample.getDeviceId());
|
log.info("[计数器更新] 设备 {} 计数器递减,剩余={}, currentUnFinPlaceholder总数={}",
|
||||||
|
faceSample.getDeviceId(), remaining, currentUnFinPlaceholder.size());
|
||||||
|
if (remaining <= 0) {
|
||||||
|
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
|
||||||
|
log.info("[Placeholder完成] 设备 {} 的placeholder已满足并移除,剩余设备数={}",
|
||||||
|
faceSample.getDeviceId(), currentUnFinPlaceholder.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有templateId,检查是否所有placeholder都已满足
|
// 如果有templateId,检查是否所有placeholder都已满足
|
||||||
@@ -221,14 +241,17 @@ public class VideoPieceGetter {
|
|||||||
int remainingCount = currentUnFinPlaceholder.values().stream()
|
int remainingCount = currentUnFinPlaceholder.values().stream()
|
||||||
.mapToInt(AtomicInteger::get)
|
.mapToInt(AtomicInteger::get)
|
||||||
.sum();
|
.sum();
|
||||||
log.info("当前进度:已完成 {}/{},剩余 {} 个placeholder未满足",
|
log.info("[进度检查] 当前进度:已完成 {}/{},剩余 {} 个placeholder未满足,剩余设备数={}",
|
||||||
totalPlaceholderCount - remainingCount, totalPlaceholderCount, remainingCount);
|
totalPlaceholderCount - remainingCount, totalPlaceholderCount, remainingCount,
|
||||||
|
currentUnFinPlaceholder.size());
|
||||||
|
|
||||||
if (currentUnFinPlaceholder.isEmpty()) {
|
if (currentUnFinPlaceholder.isEmpty()) {
|
||||||
if (!invoke.get()) {
|
if (!invoke.get()) {
|
||||||
invoke.set(true);
|
invoke.set(true);
|
||||||
log.info("所有placeholder已满足,提前调用callback");
|
log.info("[Callback调用] 所有placeholder已满足,currentUnFinPlaceholder为空,提前调用callback");
|
||||||
task.getCallback().onInvoke();
|
task.getCallback().onInvoke();
|
||||||
|
} else {
|
||||||
|
log.warn("[Callback跳过] 所有placeholder已满足,但callback已被调用过");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,7 +275,11 @@ public class VideoPieceGetter {
|
|||||||
if (null != task.getCallback()) {
|
if (null != task.getCallback()) {
|
||||||
if (!invoke.get()) {
|
if (!invoke.get()) {
|
||||||
invoke.set(true);
|
invoke.set(true);
|
||||||
|
log.info("[Callback调用] 兜底调用callback,currentUnFinPlaceholder剩余设备数={}",
|
||||||
|
currentUnFinPlaceholder.size());
|
||||||
task.getCallback().onInvoke();
|
task.getCallback().onInvoke();
|
||||||
|
} else {
|
||||||
|
log.info("[Callback跳过] 兜底检查,callback已被调用过");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (task.getFaceId() != null) {
|
if (task.getFaceId() != null) {
|
||||||
|
Reference in New Issue
Block a user