You've already forked FrameTour-BE
修改
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.ScenicMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
@ -9,6 +10,8 @@ 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.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
@ -22,6 +25,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@ -52,6 +56,27 @@ public class FaceCleaner {
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void deleteNotBuySource(){
|
||||
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;
|
||||
}
|
||||
if (scenicConfig.getUserSourceExpireDay() == null) {
|
||||
log.info("当前景区{},人脸样本过期天数未设置", scenic.getName());
|
||||
return;
|
||||
}
|
||||
int expireDay = scenicConfig.getUserSourceExpireDay();
|
||||
Date endDate = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -expireDay);
|
||||
int deleteCount = sourceMapper.deleteNotBuyRelations(scenic.getId(), endDate);
|
||||
log.info("当前景区{},删除关联素材{}个", scenic.getName(), deleteCount);
|
||||
});
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 30 3 * * ?")
|
||||
public void deleteExpiredSource(){
|
||||
ScenicReqQuery scenicQuery = new ScenicReqQuery();
|
||||
List<ScenicRespVO> scenicList = scenicMapper.list(scenicQuery);
|
||||
@ -80,6 +105,13 @@ public class FaceCleaner {
|
||||
return;
|
||||
}
|
||||
log.info("当前景区{},开始删除原始素材", scenic.getName());
|
||||
Date endDate = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -videoSourceExpireDay);
|
||||
int deleteVideoSourceCount = sourceMapper.deleteNotRelateSource(1, endDate);
|
||||
log.info("当前景区{},删除原始视频素材{}个", scenic.getName(), deleteVideoSourceCount);
|
||||
log.info("当前景区{},开始删除原始图片素材", scenic.getName());
|
||||
Date endDate2 = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -imageSourceExpireDay);
|
||||
int deleteImageSourceCount = sourceMapper.deleteNotRelateSource(2, endDate2);
|
||||
log.info("当前景区{},删除原始图片素材{}个", scenic.getName(), deleteImageSourceCount);
|
||||
});
|
||||
}
|
||||
|
||||
@ -102,6 +134,29 @@ 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().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().noneMatch(videoRespVO -> videoRespVO.getUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除图片文件:{}", fileObject);
|
||||
imageAdapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("图片文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void cleanVideoOss() {
|
||||
log.info("开始清理视频文件");
|
||||
|
Reference in New Issue
Block a user