You've already forked FrameTour-BE
指定设备提前预约
This commit is contained in:
@ -3,10 +3,15 @@ package com.ycwl.basic.task;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.ScenicMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.pc.faceSample.req.FaceSampleReqQuery;
|
||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.service.task.TaskFaceService;
|
||||
import com.ycwl.basic.storage.StorageFactory;
|
||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||
@ -31,6 +36,10 @@ public class FaceCleaner {
|
||||
private FaceSampleMapper faceSampleMapper;
|
||||
@Autowired
|
||||
private SourceMapper sourceMapper;
|
||||
@Autowired
|
||||
private VideoMapper videoMapper;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
|
||||
@Scheduled(cron = "0 0 4 * * ?")
|
||||
public void clean(){
|
||||
@ -44,11 +53,43 @@ public class FaceCleaner {
|
||||
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void deleteExpiredSource(){
|
||||
|
||||
ScenicReqQuery scenicQuery = new ScenicReqQuery();
|
||||
List<ScenicRespVO> scenicList = scenicMapper.list(scenicQuery);
|
||||
scenicList.parallelStream().forEach(scenic -> {
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenic.getId());
|
||||
if (scenicConfig == null) {
|
||||
log.info("当前景区{},无配置信息", scenic.getName());
|
||||
return;
|
||||
}
|
||||
int imageSourceExpireDay = 7;
|
||||
int videoSourceExpireDay = 7;
|
||||
if (scenicConfig.getImageSourceStoreDay() != null) {
|
||||
imageSourceExpireDay = scenicConfig.getImageSourceStoreDay();
|
||||
} else {
|
||||
log.info("当前景区{},原始素材保存天数未设置,默认7天", scenic.getName());
|
||||
}
|
||||
if (scenicConfig.getVideoSourceStoreDay() != null) {
|
||||
videoSourceExpireDay = scenicConfig.getVideoSourceStoreDay();
|
||||
} else {
|
||||
log.info("当前景区{},原始素材保存天数未设置,默认7天", scenic.getName());
|
||||
}
|
||||
if (Integer.valueOf(1).equals(scenicConfig.getDisableSourceVideo())) {
|
||||
return;
|
||||
}
|
||||
if (Integer.valueOf(1).equals(scenicConfig.getDisableSourceImage())) {
|
||||
return;
|
||||
}
|
||||
log.info("当前景区{},开始删除原始素材", scenic.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 5 * * ?")
|
||||
public void clear(){
|
||||
public void clearOss(){
|
||||
cleanFaceSampleOss();
|
||||
cleanSourceOss();
|
||||
cleanVideoOss();
|
||||
}
|
||||
private void cleanFaceSampleOss() {
|
||||
log.info("开始清理人脸文件");
|
||||
List<FaceSampleRespVO> faceSampleRespVOS = faceSampleMapper.list(new FaceSampleReqQuery());
|
||||
IStorageAdapter adapter = StorageFactory.use("faces");
|
||||
@ -60,4 +101,20 @@ public class FaceCleaner {
|
||||
}
|
||||
});
|
||||
}
|
||||
private void cleanSourceOss() {
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user