You've already forked FrameTour-BE
feat(basic): 添加模板片段更新状态缓存支持
- 在FaceStatusManager中新增按模板ID区分的人脸片段更新状态缓存键 - 更新TaskTaskServiceImpl以设置模板渲染状态 - 在任务回调逻辑中增加对模板渲染状态的更新操作 - 修改任务删除逻辑为更新状态加10的临时解决方案 - 移除旧有的切割任务状态更新逻辑,统一使用模板渲染状态管理
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package com.ycwl.basic.task;
|
||||
|
||||
import cn.hutool.core.thread.ThreadFactoryBuilder;
|
||||
import com.ycwl.basic.biz.FaceStatusManager;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
import com.ycwl.basic.biz.TaskStatusBiz;
|
||||
import com.ycwl.basic.constant.StorageConstant;
|
||||
import com.ycwl.basic.device.DeviceFactory;
|
||||
import com.ycwl.basic.device.entity.common.FileObject;
|
||||
import com.ycwl.basic.device.operator.IDeviceStorageOperator;
|
||||
import com.ycwl.basic.enums.FaceCutStatus;
|
||||
import com.ycwl.basic.integration.common.manager.DeviceConfigManager;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
||||
@@ -74,8 +75,6 @@ public class VideoPieceGetter {
|
||||
@Autowired
|
||||
private TemplateRepository templateRepository;
|
||||
@Autowired
|
||||
private TaskStatusBiz taskStatusBiz;
|
||||
@Autowired
|
||||
private VideoReUploader videoReUploader;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@@ -85,6 +84,8 @@ public class VideoPieceGetter {
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
public static final String PROBE_SIZE = "16M";
|
||||
@Autowired
|
||||
private FaceStatusManager faceStatusManager;
|
||||
|
||||
@Data
|
||||
public static class Task {
|
||||
@@ -151,19 +152,21 @@ public class VideoPieceGetter {
|
||||
);
|
||||
Map<String, AtomicInteger> currentUnFinPlaceholder = new ConcurrentHashMap<>();
|
||||
List<FaceSampleEntity> list = faceSampleMapper.listByIds(task.getFaceSampleIds());
|
||||
Map<Long, Long> pairDeviceMap = new ConcurrentHashMap<>();
|
||||
if (!list.isEmpty()) {
|
||||
Long scenicId = list.getFirst().getScenicId();
|
||||
List<DeviceV2DTO> allDeviceByScenicId = deviceRepository.getAllDeviceByScenicId(scenicId);
|
||||
allDeviceByScenicId.forEach(device -> {
|
||||
Long deviceId = device.getId();
|
||||
DeviceConfigManager deviceConfig = deviceRepository.getDeviceConfigManager(deviceId);
|
||||
Long pairDevice = deviceConfig.getLong("pair_device");
|
||||
if (pairDevice != null) {
|
||||
pairDeviceMap.putIfAbsent(deviceId, pairDevice);
|
||||
}
|
||||
});
|
||||
if (list == null || list.isEmpty()) {
|
||||
task.callback.onInvoke();
|
||||
return;
|
||||
}
|
||||
Map<Long, Long> pairDeviceMap = new ConcurrentHashMap<>();
|
||||
Long scenicId = list.getFirst().getScenicId();
|
||||
List<DeviceV2DTO> allDeviceByScenicId = deviceRepository.getAllDeviceByScenicId(scenicId);
|
||||
allDeviceByScenicId.forEach(device -> {
|
||||
Long deviceId = device.getId();
|
||||
DeviceConfigManager deviceConfig = deviceRepository.getDeviceConfigManager(deviceId);
|
||||
Long pairDevice = deviceConfig.getLong("pair_device");
|
||||
if (pairDevice != null) {
|
||||
pairDeviceMap.putIfAbsent(deviceId, pairDevice);
|
||||
}
|
||||
});
|
||||
Map<Long, List<FaceSampleEntity>> collection = list.stream()
|
||||
.filter(faceSample -> {
|
||||
if (templatePlaceholder != null) {
|
||||
@@ -253,12 +256,16 @@ public class VideoPieceGetter {
|
||||
invoke.set(true);
|
||||
log.info("[Callback调用] 所有placeholder已满足,currentUnFinPlaceholder为空,提前调用callback");
|
||||
task.getCallback().onInvoke();
|
||||
} else {
|
||||
log.warn("[Callback跳过] 所有placeholder已满足,但callback已被调用过");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (task.faceId != null) {
|
||||
// 经过切片后,可能有新的人脸切片生成,需要更新人脸状态
|
||||
templateRepository.getTemplateListByScenicId(scenicId).forEach(template -> {
|
||||
faceStatusManager.markHasNewPieces(task.faceId, template.getId());
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
try {
|
||||
@@ -271,18 +278,16 @@ public class VideoPieceGetter {
|
||||
} catch (InterruptedException e) {
|
||||
log.info("executor已中断![A:{}/T:{}/F:{}]", executor.getActiveCount(), executor.getTaskCount(), executor.getCompletedTaskCount());
|
||||
} finally {
|
||||
if (task.faceId != null) {
|
||||
taskStatusBiz.setFaceCutStatus(task.faceId, 1);
|
||||
if (null != task.getCallback()) {
|
||||
if (!invoke.get()) {
|
||||
invoke.set(true);
|
||||
log.info("[Callback调用] 兜底调用callback,currentUnFinPlaceholder剩余设备数={}",
|
||||
currentUnFinPlaceholder.size());
|
||||
task.getCallback().onInvoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != task.getCallback()) {
|
||||
if (!invoke.get()) {
|
||||
invoke.set(true);
|
||||
log.info("[Callback调用] 兜底调用callback,currentUnFinPlaceholder剩余设备数={}",
|
||||
currentUnFinPlaceholder.size());
|
||||
task.getCallback().onInvoke();
|
||||
} else {
|
||||
log.info("[Callback跳过] 兜底检查,callback已被调用过");
|
||||
if (task.faceId != null) {
|
||||
faceStatusManager.setFaceCutStatus(task.faceId, FaceCutStatus.COMPLETED);
|
||||
}
|
||||
}
|
||||
if (task.getFaceId() != null) {
|
||||
|
||||
Reference in New Issue
Block a user