|
@@ -1,9 +1,19 @@
|
|
|
package com.fdkankan.fusion.task;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.fusion.common.util.DateUtils;
|
|
|
+import com.fdkankan.fusion.common.util.MinIoChunkUtils;
|
|
|
+import com.fdkankan.fusion.common.util.UploadToOssUtil;
|
|
|
import com.fdkankan.fusion.entity.CaseLive;
|
|
|
+import com.fdkankan.fusion.entity.Model;
|
|
|
+import com.fdkankan.fusion.entity.UploadChunk;
|
|
|
+import com.fdkankan.fusion.mapper.IModelMapper;
|
|
|
import com.fdkankan.fusion.service.ICaseLiveService;
|
|
|
+import com.fdkankan.fusion.service.IModelService;
|
|
|
+import com.fdkankan.fusion.service.IUploadChunkService;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -15,20 +25,64 @@ import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
import static com.fdkankan.fusion.down.CaseDownService.downProcessKey;
|
|
|
+import static com.fdkankan.fusion.down.CaseDownService.model;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class TaskService {
|
|
|
|
|
|
@Autowired
|
|
|
- ICaseLiveService caseLiveService;
|
|
|
+ IUploadChunkService uploadChunkService;
|
|
|
+ @Autowired
|
|
|
+ IModelService modelService;
|
|
|
+ @Autowired
|
|
|
+ UploadToOssUtil uploadToOssUtil;
|
|
|
+
|
|
|
|
|
|
- @Scheduled(initialDelay = 2000, fixedDelay = 1000 * 60)
|
|
|
+ /**
|
|
|
+ * 清除删除数据资源
|
|
|
+ */
|
|
|
+ @Scheduled(initialDelay = 2000, fixedDelay = 1000 * 60 * 60 * 24)
|
|
|
public void run() {
|
|
|
- List<CaseLive> list = caseLiveService.list();
|
|
|
- for (CaseLive caseLive : list) {
|
|
|
- Date hoursTime = DateUtils.getHoursTime(caseLive.getCreateTime());
|
|
|
- if(hoursTime.getTime() <= new Date().getTime()){
|
|
|
- caseLiveService.removeById(caseLive);
|
|
|
+ List<Model> modelList = modelService.getByDelData();
|
|
|
+ if(modelList.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Model model1 : modelList) {
|
|
|
+ if(StringUtils.isBlank(model1.getModelGlbUrl())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<Model> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(Model::getModelGlbUrl,model1.getModelGlbUrl());
|
|
|
+ long count = modelService.count(wrapper);
|
|
|
+ if(count <=0){
|
|
|
+ log.info("删除文件资源:{},{}",model1.getModelId(),model1.getModelGlbUrl());
|
|
|
+ uploadToOssUtil.deleteModel(model1.getModelId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<UploadChunk> uploadChunks = uploadChunkService.getByDelData();
|
|
|
+ if(uploadChunks.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (UploadChunk uploadChunk : uploadChunks) {
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(uploadChunk.getFileMd5())){
|
|
|
+ LambdaQueryWrapper<UploadChunk> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(UploadChunk::getFileMd5,uploadChunk.getFileMd5());
|
|
|
+ long count = uploadChunkService.count(wrapper);
|
|
|
+ if(count <=0){
|
|
|
+ log.info("删除文件资源:{},{}",MinIoChunkUtils.chunkBucKet,uploadChunk.getFileMd5());
|
|
|
+ MinIoChunkUtils.deleteObject(MinIoChunkUtils.chunkBucKet,uploadChunk.getFileMd5());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(uploadChunk.getFilePath())){
|
|
|
+ LambdaQueryWrapper<UploadChunk> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(UploadChunk::getFilePath,uploadChunk.getFilePath());
|
|
|
+ long count = uploadChunkService.count(wrapper);
|
|
|
+ if(count <=0){
|
|
|
+ log.info("删除文件资源:{},{}",MinIoChunkUtils.chunkBucKet,uploadChunk.getFilePath());
|
|
|
+ MinIoChunkUtils.deleteObject(MinIoChunkUtils.chunkBucKet,uploadChunk.getFilePath());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|