清理数据根据景区清理
This commit is contained in:
parent
f36416bad2
commit
50a7c2e9c4
@ -1,6 +1,8 @@
|
||||
package com.ycwl.basic.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ycwl.basic.constant.StorageConstant;
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.ScenicMapper;
|
||||
@ -31,6 +33,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ycwl.basic.constant.FaceConstant.USER_FACE_DB_NAME;
|
||||
@ -192,40 +195,49 @@ public class FaceCleaner {
|
||||
private void cleanSourceOss() {
|
||||
log.info("开始清理源视频素材文件");
|
||||
List<SourceRespVO> list = sourceMapper.list(new SourceReqQuery());
|
||||
IStorageAdapter adapter = StorageFactory.use("assets-ext");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir("video-source");
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().filter(videoRespVO -> Objects.nonNull(videoRespVO.getVideoUrl())).noneMatch(videoRespVO -> videoRespVO.getVideoUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除源视频素材文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("源视频素材文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
});
|
||||
log.info("开始清理源图片素材文件");
|
||||
IStorageAdapter imageAdapter = StorageFactory.use("faces");
|
||||
List<StorageFileObject> imageFileObjectList = imageAdapter.listDir("user-photo");
|
||||
imageFileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().filter(videoRespVO -> Objects.nonNull(videoRespVO.getUrl())).noneMatch(videoRespVO -> videoRespVO.getUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除图片文件:{}", fileObject);
|
||||
imageAdapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("图片文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
scenicMapper.list(new ScenicReqQuery()).forEach(scenic -> {
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenic.getId());
|
||||
IStorageAdapter adapter = StorageFactory.get(scenicConfig.getStoreType());
|
||||
adapter.loadConfig(JSONObject.parseObject(scenicConfig.getStoreConfigJson(), Map.class));
|
||||
log.info("开始清理视频文件");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir(StorageConstant.VIDEO_PIECE_PATH);
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().filter(videoRespVO -> Objects.nonNull(videoRespVO.getVideoUrl())).noneMatch(videoRespVO -> videoRespVO.getVideoUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
});
|
||||
log.info("开始清理图片文件");
|
||||
fileObjectList = adapter.listDir(StorageConstant.PHOTO_PATH);
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().filter(videoRespVO -> Objects.nonNull(videoRespVO.getUrl())).noneMatch(videoRespVO -> videoRespVO.getUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
private void cleanVideoOss() {
|
||||
log.info("开始清理视频文件");
|
||||
List<VideoRespVO> videoRespVOS = videoMapper.list(new VideoReqQuery());
|
||||
IStorageAdapter adapter = StorageFactory.use("video");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir("");
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (videoRespVOS.parallelStream().noneMatch(videoRespVO -> videoRespVO.getVideoUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除视频文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("视频文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
List<VideoRespVO> list = videoMapper.list(new VideoReqQuery());
|
||||
scenicMapper.list(new ScenicReqQuery()).forEach(scenic -> {
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenic.getId());
|
||||
IStorageAdapter adapter = StorageFactory.get(scenicConfig.getStoreType());
|
||||
adapter.loadConfig(JSONObject.parseObject(scenicConfig.getStoreConfigJson(), Map.class));
|
||||
log.info("开始清理视频文件");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir(StorageConstant.VLOG_PATH);
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().filter(videoRespVO -> Objects.nonNull(videoRespVO.getVideoUrl())).noneMatch(videoRespVO -> videoRespVO.getVideoUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user