bug修复

This commit is contained in:
2025-02-05 11:28:50 +08:00
parent 0b861f0e21
commit 7892c0f5cc
21 changed files with 324 additions and 95 deletions

View File

@ -1,9 +1,16 @@
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.model.pc.faceSample.req.FaceSampleReqQuery;
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
import com.ycwl.basic.service.task.TaskFaceService;
import com.ycwl.basic.storage.StorageFactory;
import com.ycwl.basic.storage.adapters.IStorageAdapter;
import com.ycwl.basic.storage.entity.StorageFileObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
@ -20,7 +27,10 @@ public class FaceCleaner {
private ScenicMapper scenicMapper;
@Autowired
private TaskFaceService faceService;
@Autowired
private FaceSampleMapper faceSampleMapper;
@Autowired
private SourceMapper sourceMapper;
@Scheduled(cron = "0 0 4 * * ?")
public void clean(){
@ -31,4 +41,23 @@ public class FaceCleaner {
faceService.batchDeleteExpiredFace(scenic.getId());
});
}
@Scheduled(cron = "0 0 3 * * ?")
public void deleteExpiredSource(){
}
@Scheduled(cron = "0 0 5 * * ?")
public void clear(){
log.info("开始清理人脸文件");
List<FaceSampleRespVO> faceSampleRespVOS = faceSampleMapper.list(new FaceSampleReqQuery());
IStorageAdapter adapter = StorageFactory.use("faces");
List<StorageFileObject> fileObjectList = adapter.listDir("user-face");
fileObjectList.parallelStream().forEach(fileObject -> {
if(faceSampleRespVOS.parallelStream().noneMatch(faceSampleRespVO -> faceSampleRespVO.getFaceUrl().contains(fileObject.getFullPath()))){
log.info("删除人脸文件:{}", fileObject);
adapter.deleteFile(fileObject.getFullPath());
}
});
}
}