You've already forked FrameTour-BE
区分临时和本地存储
This commit is contained in:
@@ -38,5 +38,7 @@ public interface ScenicService {
|
||||
|
||||
IStorageAdapter getScenicTmpStorageAdapter(Long scenicId);
|
||||
|
||||
IStorageAdapter getScenicLocalStorageAdapter(Long scenicId);
|
||||
|
||||
IFaceBodyAdapter getScenicFaceBodyAdapter(Long scenicId);
|
||||
}
|
||||
|
@@ -199,6 +199,7 @@ public class ScenicServiceImpl implements ScenicService {
|
||||
scenicFaceBodyAdapterMap.remove(config.getScenicId());
|
||||
scenicStorageAdapterMap.remove(config.getScenicId());
|
||||
scenicTmpStorageAdapterMap.remove(config.getScenicId());
|
||||
scenicLocalStorageAdapterMap.remove(config.getScenicId());
|
||||
}
|
||||
|
||||
|
||||
@@ -240,6 +241,26 @@ public class ScenicServiceImpl implements ScenicService {
|
||||
return adapter;
|
||||
});
|
||||
}
|
||||
private static final Map<Long, IStorageAdapter> scenicLocalStorageAdapterMap = new ConcurrentHashMap<>();
|
||||
@Override
|
||||
public IStorageAdapter getScenicLocalStorageAdapter(Long scenicId) {
|
||||
return scenicLocalStorageAdapterMap.computeIfAbsent(scenicId, (key) -> {
|
||||
IStorageAdapter adapter;
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenicId);
|
||||
if (scenicConfig != null && scenicConfig.getLocalStoreType() != null) {
|
||||
try {
|
||||
adapter = StorageFactory.get(scenicConfig.getLocalStoreType());
|
||||
adapter.loadConfig(JSONObject.parseObject(scenicConfig.getLocalStoreConfigJson(), Map.class));
|
||||
} catch (StorageUnsupportedException ignored) {
|
||||
return getScenicStorageAdapter(scenicId);
|
||||
}
|
||||
} else {
|
||||
return getScenicStorageAdapter(scenicId);
|
||||
}
|
||||
return adapter;
|
||||
});
|
||||
}
|
||||
|
||||
private static final Map<Long, IFaceBodyAdapter> scenicFaceBodyAdapterMap = new ConcurrentHashMap<>();
|
||||
@Override
|
||||
public IFaceBodyAdapter getScenicFaceBodyAdapter(Long scenicId) {
|
||||
|
@@ -58,6 +58,7 @@ import com.ycwl.basic.storage.utils.StorageUtil;
|
||||
import com.ycwl.basic.task.VideoPieceGetter;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import com.ycwl.basic.utils.VideoReUploader;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -124,6 +125,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
private TaskStatusBiz taskStatusBiz;
|
||||
@Autowired
|
||||
private DeviceRepository deviceRepository;
|
||||
@Autowired
|
||||
private VideoReUploader videoReUploader;
|
||||
|
||||
|
||||
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
|
||||
@@ -587,9 +590,10 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
videoMapper.add(video);
|
||||
}
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(task.getScenicId());
|
||||
IStorageAdapter adapter = scenicService.getScenicStorageAdapter(task.getScenicId());
|
||||
IStorageAdapter adapter = scenicService.getScenicTmpStorageAdapter(task.getScenicId());
|
||||
String filename = StorageUtil.joinPath(StorageConstant.VLOG_PATH, task.getId() + "_" + task.getScenicId() + ".mp4");
|
||||
adapter.setAcl(StorageAcl.PUBLIC_READ, filename);
|
||||
videoReUploader.addVideoTask(task.getVideoUrl(), video.getId());
|
||||
int isBuy = 0;
|
||||
FaceEntity face = faceRepository.getFace(task.getFaceId());
|
||||
if (face != null) {
|
||||
@@ -646,7 +650,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (task == null) {
|
||||
return null;
|
||||
}
|
||||
IStorageAdapter adapter = scenicService.getScenicStorageAdapter(task.getScenicId());
|
||||
IStorageAdapter adapter = scenicService.getScenicTmpStorageAdapter(task.getScenicId());
|
||||
String filename = StorageUtil.joinPath(StorageConstant.VLOG_PATH, task.getId() + "_" + task.getScenicId() + ".mp4");
|
||||
if (StringUtils.isBlank(task.getVideoUrl())) {
|
||||
// 生成
|
||||
|
Reference in New Issue
Block a user