瀏覽代碼

v4.12.0 增加定时清除异步下载压缩包定时任务

dengsixing 1 年之前
父節點
當前提交
dd2c2c5d0e

+ 13 - 2
src/main/java/com/fdkankan/scene/schedule/ScheduleJob.java

@@ -1,5 +1,6 @@
 package com.fdkankan.scene.schedule;
 
+import com.fdkankan.common.constant.SceneAsynFuncType;
 import com.fdkankan.redis.constant.RedisLockKey;
 import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.scene.service.ISceneAsynOperLogService;
@@ -29,15 +30,25 @@ public class ScheduleJob {
     private RedisLockUtil redisLockUtil;
 
     /**
-     * 每天凌晨一点执行
+     * 清除异步批量下载全景图OSS压缩包
      */
     @Scheduled(cron="0 0 1 * * ?")
     public void cleanDownloadPanorama() {
         log.info("定时清除全景图压缩包开始");
-        sceneAsynOperLogService.cleanDownloadPanorama();
+        sceneAsynOperLogService.cleanDownloadOssPage(SceneAsynFuncType.PANORAMIC_IMAGE.code(), 1);
         log.info("定时清除全景图压缩包完毕");
     }
 
+    /**
+     * 清除异步批量下载全景图OSS压缩包
+     */
+    @Scheduled(cron="0 0 1 * * ?")
+    public void cleanDownloadModel() {
+        log.info("定时清除模型压缩包开始");
+        sceneAsynOperLogService.cleanDownloadOssPage(SceneAsynFuncType.MODEL.code(), 1);
+        log.info("定时清除模型压缩包完毕");
+    }
+
 //    /**
 //     * 删除场景原始资源
 //     * 每天凌晨执行

+ 1 - 1
src/main/java/com/fdkankan/scene/service/ISceneAsynOperLogService.java

@@ -21,7 +21,7 @@ public interface ISceneAsynOperLogService extends IService<SceneAsynOperLog> {
 
     ResultData getAsynOperLog(SceneAsynOperLogParamVO param);
 
-    void cleanDownloadPanorama();
+    void cleanDownloadOssPage(String asynFuncType, int preMonth);
 
     void checkSceneAsynOper(String num, String operType, String module, String function);
 

+ 6 - 6
src/main/java/com/fdkankan/scene/service/impl/SceneAsynOperLogServiceImpl.java

@@ -78,20 +78,20 @@ public class SceneAsynOperLogServiceImpl extends ServiceImpl<ISceneAsynOperLogMa
     }
 
     @Override
-    public void cleanDownloadPanorama() {
+    public void cleanDownloadOssPage(String asynFuncType, int preMonth) {
 
         List<SceneAsynOperLog> downloadList = this.list(
             new LambdaQueryWrapper<SceneAsynOperLog>()
                 .eq(SceneAsynOperLog::getOperType, SceneAsynOperType.DOWNLOAD.code())
                 .eq(SceneAsynOperLog::getModule, SceneAsynModuleType.UPLOAD_DOWNLOAD.code())
-                .eq(SceneAsynOperLog::getFunc, SceneAsynFuncType.PANORAMIC_IMAGE.code()));
+                .eq(SceneAsynOperLog::getFunc, asynFuncType));
         if(CollUtil.isEmpty(downloadList)){
             return;
         }
-        DateTime preMonth = DateUtil.offsetMonth(Calendar.getInstance().getTime(), -1);
+        DateTime preDate = DateUtil.offsetMonth(Calendar.getInstance().getTime(), -preMonth);
         List<SceneAsynOperLog> deleteList = downloadList.parallelStream().filter(log -> {
-            if (log.getCreateTime().before(preMonth)) {
-                return Boolean.TRUE;
+            if (log.getCreateTime().before(preDate)) {
+                return true;
             }
             return false;
         }).collect(Collectors.toList());
@@ -108,7 +108,7 @@ public class SceneAsynOperLogServiceImpl extends ServiceImpl<ISceneAsynOperLogMa
                 try {
                     fYunFileService.deleteFile(item.getUrl());
                 } catch (IOException e) {
-                    log.warn("删除oss全景图下载压缩包失败,key:{}", item.getUrl());
+                    log.warn("删除oss下载压缩包失败,key:{}", item.getUrl());
                 }
             }
         });

+ 1 - 1
src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -1364,7 +1364,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
             if(!panoramaImageList.contains(fileName)){
                 throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
             }
-            String url = ossUrlPrefix + ossResultPath + fileName;
+            String url = ossResultPath + fileName;
             String downloadName = fileName;
             map.put("asyn", CommonStatus.NO.code());
             map.put("fileUrl", url + "?t=" + System.currentTimeMillis());

+ 2 - 2
src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -1122,7 +1122,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         //删除本地文件
         FileUtil.del(meshLocalPath);
         FileUtil.del(zipFilePath);
-        String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
+        String url = "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
         return url;
     }
 
@@ -1178,7 +1178,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         ZipUtil.zip(meshPath, zipPath);
         //上传压缩包
         fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
-        String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
+        String url = "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
         FileUtil.del(zipPath);
         return url;
     }