Bladeren bron

去掉oss文件大小统计任务

dsx 2 jaren geleden
bovenliggende
commit
decc1e1d07
2 gewijzigde bestanden met toevoegingen van 150 en 122 verwijderingen
  1. 33 5
      .gitignore
  2. 117 117
      src/main/java/com/fdkankan/job/job/CountSizeOssHandler.java

+ 33 - 5
.gitignore

@@ -1,7 +1,35 @@
+# Created by .ignore support plugin (hsz.mobi)
+### Java template
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+### Example user template template
+### Example user template
+
+# IntelliJ project files
 .idea
-.classpath
-.project
 *.iml
-target/
-.DS_Store
-.gitattributes
+out
+gen
+/**/target/

+ 117 - 117
src/main/java/com/fdkankan/job/job/CountSizeOssHandler.java

@@ -1,117 +1,117 @@
-package com.fdkankan.job.job;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.spring.SpringUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.aliyun.oss.OSSClient;
-import com.aliyun.oss.model.ListObjectsRequest;
-import com.aliyun.oss.model.OSSObjectSummary;
-import com.aliyun.oss.model.ObjectListing;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.fdkankan.common.constant.PayStatus;
-import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.fyun.face.FYunFileServiceInterface;
-import com.fdkankan.job.entity.*;
-import com.fdkankan.job.service.*;
-import com.fdkankan.model.constants.ConstantFilePath;
-import com.fdkankan.model.constants.UploadFilePath;
-import com.fdkankan.redis.util.RedisUtil;
-import com.xxl.job.core.context.XxlJobHelper;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.io.File;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * <p>
- * v4场景回退v3
- * </p>
- *
- * @author dengsixing
- * @since 2022/12/16
- **/
-@Slf4j
-@Component
-public class CountSizeOssHandler {
-
-    @Autowired
-    private FYunFileServiceInterface fYunFileService;
-    @Autowired
-    OSSClient ossClient;
-
-    @XxlJob("countSizeOssHandler")
-    public void V4toV3Handler(){
-        XxlJobHelper.log("countSizeOssHandler start.....");
-
-        List<String> dirList = null;
-        String dirs = XxlJobHelper.getJobParam();
-        if(StrUtil.isNotEmpty(dirs)){
-            dirList = Arrays.asList(dirs.split(","));
-        }
-
-        Map<String, Long> map = new HashMap<>();
-
-        try {
-            boolean flag = true;
-            String nextMaker = null;
-            ListObjectsRequest listObjectsRequest = new ListObjectsRequest("4dkankan");
-            //指定下一级文件
-            listObjectsRequest.setPrefix(dirs);
-            //设置分页的页容量
-            listObjectsRequest.setMaxKeys(200);
-            do {
-                //获取下一页的起始点,它的下一项
-                listObjectsRequest.setMarker(nextMaker);
-                ObjectListing objectListing = ossClient.listObjects(listObjectsRequest);
-                for (OSSObjectSummary objectSummary : objectListing.getObjectSummaries()) {
-                    String key = objectSummary.getKey();
-                    try {
-                        String[] split = key.split("/");
-                        key = split[1];
-                        Long size = map.get(key);
-                        if(Objects.isNull(size)){
-                            size = 0L;
-                        }
-                        size += objectSummary.getSize();
-                        map.put(key, size);
-                    }catch (Exception e){
-                        log.error("错误的key:{}", key);
-                    }
-                }
-
-                nextMaker = objectListing.getNextMarker();
-                //全部执行完后,为false
-                flag = objectListing.isTruncated();
-            } while (flag);
-
-            Set<String> strings = map.keySet();
-            Long total = 0L;
-            for (String key : strings) {
-                total += map.get(key);
-                log.info(key + ":" + map.get(key));
-            }
-
-            log.info("总大小:{}", total);
-
-        } catch (Exception e) {
-            log.error("失败了", e);
-        }
-
-
-
-        XxlJobHelper.log("countSizeOssHandler end.....");
-    }
-
-
-
-
-}
+//package com.fdkankan.job.job;
+//
+//import cn.hutool.core.collection.CollUtil;
+//import cn.hutool.core.io.FileUtil;
+//import cn.hutool.core.util.StrUtil;
+//import cn.hutool.extra.spring.SpringUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONObject;
+//import com.aliyun.oss.OSSClient;
+//import com.aliyun.oss.model.ListObjectsRequest;
+//import com.aliyun.oss.model.OSSObjectSummary;
+//import com.aliyun.oss.model.ObjectListing;
+//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+//import com.fdkankan.common.constant.PayStatus;
+//import com.fdkankan.common.util.FileUtils;
+//import com.fdkankan.fyun.face.FYunFileServiceInterface;
+//import com.fdkankan.job.entity.*;
+//import com.fdkankan.job.service.*;
+//import com.fdkankan.model.constants.ConstantFilePath;
+//import com.fdkankan.model.constants.UploadFilePath;
+//import com.fdkankan.redis.util.RedisUtil;
+//import com.xxl.job.core.context.XxlJobHelper;
+//import com.xxl.job.core.handler.annotation.XxlJob;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.stereotype.Component;
+//import org.springframework.util.CollectionUtils;
+//
+//import java.io.File;
+//import java.util.*;
+//import java.util.stream.Collectors;
+//
+///**
+// * <p>
+// * v4场景回退v3
+// * </p>
+// *
+// * @author dengsixing
+// * @since 2022/12/16
+// **/
+//@Slf4j
+//@Component
+//public class CountSizeOssHandler {
+//
+//    @Autowired
+//    private FYunFileServiceInterface fYunFileService;
+//    @Autowired
+//    OSSClient ossClient;
+//
+//    @XxlJob("countSizeOssHandler")
+//    public void V4toV3Handler(){
+//        XxlJobHelper.log("countSizeOssHandler start.....");
+//
+//        List<String> dirList = null;
+//        String dirs = XxlJobHelper.getJobParam();
+//        if(StrUtil.isNotEmpty(dirs)){
+//            dirList = Arrays.asList(dirs.split(","));
+//        }
+//
+//        Map<String, Long> map = new HashMap<>();
+//
+//        try {
+//            boolean flag = true;
+//            String nextMaker = null;
+//            ListObjectsRequest listObjectsRequest = new ListObjectsRequest("4dkankan");
+//            //指定下一级文件
+//            listObjectsRequest.setPrefix(dirs);
+//            //设置分页的页容量
+//            listObjectsRequest.setMaxKeys(200);
+//            do {
+//                //获取下一页的起始点,它的下一项
+//                listObjectsRequest.setMarker(nextMaker);
+//                ObjectListing objectListing = ossClient.listObjects(listObjectsRequest);
+//                for (OSSObjectSummary objectSummary : objectListing.getObjectSummaries()) {
+//                    String key = objectSummary.getKey();
+//                    try {
+//                        String[] split = key.split("/");
+//                        key = split[1];
+//                        Long size = map.get(key);
+//                        if(Objects.isNull(size)){
+//                            size = 0L;
+//                        }
+//                        size += objectSummary.getSize();
+//                        map.put(key, size);
+//                    }catch (Exception e){
+//                        log.error("错误的key:{}", key);
+//                    }
+//                }
+//
+//                nextMaker = objectListing.getNextMarker();
+//                //全部执行完后,为false
+//                flag = objectListing.isTruncated();
+//            } while (flag);
+//
+//            Set<String> strings = map.keySet();
+//            Long total = 0L;
+//            for (String key : strings) {
+//                total += map.get(key);
+//                log.info(key + ":" + map.get(key));
+//            }
+//
+//            log.info("总大小:{}", total);
+//
+//        } catch (Exception e) {
+//            log.error("失败了", e);
+//        }
+//
+//
+//
+//        XxlJobHelper.log("countSizeOssHandler end.....");
+//    }
+//
+//
+//
+//
+//}