Browse Source

山东版本修改提交

xiewj 1 year ago
parent
commit
4d4b0a5117
23 changed files with 170 additions and 4071 deletions
  1. 7 8
      720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneListener.java
  2. 0 20
      720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneMigrateListener.java
  3. 0 27
      720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/ScenePayStatusListener.java
  4. 0 236
      720yun_fd_consumer/gis_consumer/src/main/java/com/gis/util/AliyunOssUtil.java
  5. 4 0
      720yun_fd_consumer/gis_consumer_oss/pom.xml
  6. 12 0
      720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/command/CmdConstant.java
  7. 0 346
      720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/AliYunOssUtil.java
  8. 0 184
      720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/AwsOssUtil.java
  9. 12 1248
      720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/FileAndOssUtil.java
  10. 104 0
      720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/OssShUtil.java
  11. 5 1
      720yun_fd_consumer/pom.xml
  12. 4 0
      720yun_fd_manage/gis_common/pom.xml
  13. 0 38
      720yun_fd_manage/gis_oss/pom.xml
  14. 0 292
      720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/AliYunOssUtil.java
  15. 0 161
      720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/AwsOssUtil.java
  16. 9 76
      720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/FileAndOssUtil.java
  17. 0 177
      720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/QiNiuOssUtil.java
  18. 0 1
      720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/QrCodeUtils.java
  19. 0 1244
      720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/UploadToOssUtil.java
  20. 0 1
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/SysUserServiceImpl.java
  21. 6 8
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/TestServiceImpl.java
  22. 2 3
      720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java
  23. 5 0
      720yun_fd_manage/pom.xml

+ 7 - 8
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneListener.java

@@ -8,7 +8,7 @@ import cn.hutool.http.HttpResponse;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.amazonaws.services.dynamodbv2.xspec.S;
+import com.fdkankan.filestorage.FileStorageTemplate;
 import com.gis.constant.CmdConstant;
 import com.gis.constant.ConfigConstant;
 import com.gis.entity.RelicsSceneInitQueueDTO;
@@ -17,7 +17,6 @@ import com.gis.entity.SceneQueueDTO;
 import com.gis.entity.WorkEntity;
 import com.gis.exception.BaseRuntimeException;
 import com.gis.mq.RabbitMqProducerUtil;
-import com.gis.oss.util.AliYunOssUtil;
 import com.gis.oss.util.FileAndOssUtil;
 import com.gis.service.ScenePanoService;
 import com.gis.service.WorkService;
@@ -36,6 +35,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 
+import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -58,8 +58,6 @@ import java.util.regex.Pattern;
 public class SceneListener {
 
     @Autowired
-    AliYunOssUtil aliyunOssUtil;
-    @Autowired
     ConfigConstant configConstant;
     @Autowired
     FileAndOssUtil fileAndOssUtil;
@@ -76,7 +74,8 @@ public class SceneListener {
 
     @Value("${queue.scene-queue-work}")
     String sceneQueueWork;
-
+    @Resource
+    private FileStorageTemplate ossUtil;
 
     /**
      * 全景场景初始化方法
@@ -274,7 +273,7 @@ public class SceneListener {
     private void updateOssStatusJson(String sceneCode, int status) throws IOException {
         //修改OSS,status状态 scene_view_data/场景码/data/status.json
         String statusJson = "scene_view_data/"+sceneCode+"/data/status.json";
-        Boolean exist=aliyunOssUtil.existKey("4dkankan",statusJson);
+        Boolean exist=ossUtil.doesObjectExist("4dkankan",statusJson);
         if (exist){
             String statusJsonUrl = "http://4dkk.4dage.com/"+statusJson;
             HttpResponse execute = HttpRequest.get(statusJsonUrl+"?m="+System.currentTimeMillis()).execute();
@@ -344,7 +343,7 @@ public class SceneListener {
             sceneCode = RandomUtils.getSceneCode("fd720_");
             newName = sceneCode + ".jpg";
             filePath = configConstant.serverBasePath + sceneCode+ "/" + newName;
-            aliyunOssUtil.downloadFile("4dkankan",item,filePath );
+            ossUtil.downloadFile("4dkankan",item,filePath );
             entity = new ScenePanoEntity();
             entity.setFilePath(filePath);
             entity.setFileName(FileUtil.getName(filePath));
@@ -377,7 +376,7 @@ public class SceneListener {
 
 
             log.info("生成过,重新下载");
-            aliyunOssUtil.downloadFile("4dkankan",item,filePath );
+            ossUtil.downloadFile("4dkankan",item,filePath );
             log.info("下载完成重新切图");
             long size = FileUtil.size(new File(filePath));
             size = size / 1024;

+ 0 - 20
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneMigrateListener.java

@@ -1,27 +1,17 @@
 package com.gis.listener;
 
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpResponse;
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.gis.constant.CmdConstant;
 import com.gis.constant.ConfigConstant;
 import com.gis.entity.OpenSceneMigrateDto;
 import com.gis.entity.WorkEntity;
-import com.gis.exception.BaseRuntimeException;
 import com.gis.mq.RabbitMqProducerUtil;
-import com.gis.oss.util.AliYunOssUtil;
 import com.gis.oss.util.FileAndOssUtil;
 import com.gis.service.ScenePanoService;
 import com.gis.service.WorkService;
-import com.gis.util.CmdUtils;
-import com.gis.util.FileUtils;
 import com.gis.util.QrCodeUtils;
-import com.gis.util.RandomUtils;
 import com.rabbitmq.client.Channel;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
@@ -29,19 +19,11 @@ import org.springframework.amqp.core.Message;
 import org.springframework.amqp.rabbit.annotation.Queue;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 
-import java.io.File;
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * 消息监听器
@@ -55,8 +37,6 @@ import java.util.regex.Pattern;
 public class SceneMigrateListener {
 
     @Autowired
-    AliYunOssUtil aliyunOssUtil;
-    @Autowired
     ConfigConstant configConstant;
     @Autowired
     FileAndOssUtil fileAndOssUtil;

+ 0 - 27
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/ScenePayStatusListener.java

@@ -1,30 +1,11 @@
 package com.gis.listener;
 
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpResponse;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.gis.constant.CmdConstant;
-import com.gis.constant.ConfigConstant;
-import com.gis.entity.RelicsSceneInitQueueDTO;
-import com.gis.entity.ScenePanoEntity;
 import com.gis.entity.SceneQueueDTO;
 import com.gis.entity.WorkEntity;
-import com.gis.exception.BaseRuntimeException;
-import com.gis.mq.RabbitMqProducerUtil;
-import com.gis.oss.util.AliYunOssUtil;
-import com.gis.oss.util.FileAndOssUtil;
-import com.gis.service.ScenePanoService;
 import com.gis.service.WorkService;
-import com.gis.util.CmdUtils;
-import com.gis.util.FileUtils;
-import com.gis.util.QrCodeUtils;
-import com.gis.util.RandomUtils;
 import com.rabbitmq.client.Channel;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
@@ -32,19 +13,11 @@ import org.springframework.amqp.core.Message;
 import org.springframework.amqp.rabbit.annotation.Queue;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 
-import java.io.File;
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * 消息监听器

+ 0 - 236
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/util/AliyunOssUtil.java

@@ -1,236 +0,0 @@
-package com.gis.util;
-
-import com.aliyun.oss.OSSClient;
-import com.aliyun.oss.model.OSSObject;
-import com.aliyun.oss.model.OSSObjectSummary;
-import com.aliyun.oss.model.ObjectListing;
-import com.gis.constant.ConfigConstant;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 阿里云oss工具类
- */
-@Slf4j
-@Component
-public class AliyunOssUtil {
-
-    @Autowired
-    ConfigConstant configConstant;
-
-    @Autowired
-    FileUtils fileUtils;
-
-
-//    private static final String END_POINT = "http://oss-cn-shenzhen.aliyuncs.com";
-//    private static final String ACCESS_KEY_ID = "LTAIUrvuHqj8pvry";
-//    private static final String ACCESS_KEY_SECREY = "JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4";
-//    private static final String BUCKET_NAME = "oss-xiaoan";
-
-    // 加载对象
-//    private static OSSClient ossClient = new OSSClient(END_POINT, ACCESS_KEY_ID, ACCESS_KEY_SECREY);
-//    private static OSSClient ossClient = new OSSClient(END_POINT, ACCESS_KEY_ID, ACCESS_KEY_SECREY);
-
-    private OSSClient init(){
-        return new OSSClient(configConstant.ossPoint, configConstant.ossKey, configConstant.ossSecrecy);
-    }
-
-
-    public void delete(String key) throws IOException {
-        OSSClient ossClient = init();
-        try {
-
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.deleteObject(configConstant.ossBucket, key);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    //上传的数据是byte[],key是上传后的文件名
-    public void upload(byte[] data, String key) throws IOException {
-        OSSClient ossClient = init();
-        try {
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(configConstant.ossBucket, key, new ByteArrayInputStream(data));
-        } catch (Exception e) {
-            log.error(e.toString() + key);
-        }
-    }
-
-
-    public void upload(String filePath, String key) {
-        OSSClient ossClient = init();
-        try {
-            File file = new File(filePath);
-            if (!file.exists()) {
-                log.error("要上传的文件不存在:" + filePath);
-            }
-            ossClient.putObject(configConstant.ossBucket, key, new File(filePath));
-
-        } catch (Exception e) {
-            log.error(e.toString() + filePath);
-        }
-    }
-
-    public  void upload2(String filePath, String key) {
-        OSSClient ossClient = init();
-        try {
-
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(configConstant.ossBucket, key, new File(filePath));
-        } catch (Exception e) {
-            log.error(e.toString() + filePath);
-        }
-    }
-
-
-    /**
-     * 上传的数据是文件夹,参数是文件夹路径,key是上传后的文件名
-     *
-     * @param filepaths key : 原文件路径
-     *                  value: oss路径, oss会自动创建目录
-     */
-
-    public  void uploadMulFiles(Map<String, String> filepaths) {
-        if (filepaths == null) {
-            return;
-        }
-        log.info("开始批量上传到阿里云:" + new Date().toString());
-        if (filepaths.size() > 50) {
-            int i = 1;
-            for (String filePath : filepaths.keySet()) {
-                if (i%100 == 0) {
-
-                    log.info("i= " +i + ", 文件:" + filePath + "到阿里云:" + filepaths.get(filePath));
-                }
-                upload2(filePath, filepaths.get(filePath));
-                i ++ ;
-            }
-            log.info("上传文件数量:"+ i);
-        } else {
-            for (String filePath : filepaths.keySet()) {
-                log.debug("文件:" + filePath + "到阿里云:" + filepaths.get(filePath));
-                upload(filePath, filepaths.get(filePath));
-            }
-        }
-        log.info("批量上传阿里云完毕:" + new Date().toString());
-    }
-
-
-    /**
-     * 可以删除目录
-     *
-     * @param prefix 图片路径
-     * @return
-     */
-    public  int deleteFile(String prefix) {
-        OSSClient ossClient = init();
-        ObjectListing objectListing = ossClient.listObjects(configConstant.ossBucket, prefix);
-        List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
-        try {
-            for (OSSObjectSummary s : sums) {
-                delete(s.getKey());
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return sums.size();
-    }
-
-
-
-    /**
-     * 上传目录到oss
-     * @param dirPath 目录地址
-     * @param sceneCode 场景码
-     * @param ossBasePath oss基础地址
-     * @throws IOException
-     */
-    public void uploadDir(String dirPath, String sceneCode, String ossBasePath, String houseId) throws IOException {
-//        Map map = FileUtils.eachFile(dirPath, sceneCode, ossBasePath, houseId);
-        Map map = fileUtils.eachFile(dirPath, sceneCode, ossBasePath, houseId);
-
-        uploadMulFiles(map);
-        log.info("oss上传完成");
-    }
-
-
-
-
-
-    /**
-     * 通过文件名判断并获取OSS服务文件上传时文件的contentType
-     *
-     * @param fileName 文件名
-     * @return 文件的contentType
-     */
-    private static String getContentType(String fileName) {
-        log.info("getContentType:" + fileName);
-        // 文件的后缀名
-        String fileExtension = fileName.substring(fileName.lastIndexOf("."));
-        if (".bmp".equalsIgnoreCase(fileExtension)) {
-            return "image/bmp";
-        }
-        if (".gif".equalsIgnoreCase(fileExtension)) {
-            return "image/gif";
-        }
-        if (".jpeg".equalsIgnoreCase(fileExtension) || ".jpg".equalsIgnoreCase(fileExtension)
-                || ".png".equalsIgnoreCase(fileExtension)) {
-            return "image/jpeg";
-        }
-        if (".html".equalsIgnoreCase(fileExtension)) {
-            return "text/html";
-        }
-        if (".txt".equalsIgnoreCase(fileExtension)) {
-            return "text/plain";
-        }
-        if (".vsd".equalsIgnoreCase(fileExtension)) {
-            return "application/vnd.visio";
-        }
-        if (".ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) {
-            return "application/vnd.ms-powerpoint";
-        }
-        if (".doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) {
-            return "application/msword";
-        }
-        if (".xml".equalsIgnoreCase(fileExtension)) {
-            return "text/xml";
-        }
-        if (".pdf".equalsIgnoreCase(fileExtension)) {
-            return "application/pdf";
-        }
-        // 默认返回类型
-        return "image/jpeg";
-    }
-
-    /**
-     * 以流下载图片
-     *
-     * @param
-     * @return
-     * @Title: getInputStreamByFileUrl
-     * @Description: 根据文件路径获取InputStream流
-     * @return: InputStream
-     */
-    public InputStream getInputStreamByFileUrl(String filePath) {
-        // ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
-        OSSClient ossClient = init();
-        OSSObject ossObject = ossClient.getObject(configConstant.ossBucket, filePath);
-        return ossObject.getObjectContent();
-    }
-
-
-
-
-
-}

+ 4 - 0
720yun_fd_consumer/gis_consumer_oss/pom.xml

@@ -191,6 +191,10 @@
             <version>3.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-filestorage</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.iherus</groupId>
             <artifactId>qrext4j</artifactId>
         </dependency>

+ 12 - 0
720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/command/CmdConstant.java

@@ -45,4 +45,16 @@ public class CmdConstant {
      */
 //    public final static String UPLOAD_DIR = "sudo bash /opt/ossutil/fyun-upload.sh %s %s %s %s folder";
     public final static String UPLOAD_DIR = "bash /opt/ossutil/fyun-upload.sh %s %s %s %s folder";
+
+    /**
+     * oss文件上传命令 bash /opt/ossutil/fyun-upload.sh {bucket} {srcPath} {destPath} {fyunType} {opType}
+     * opType: file or folder
+     * fyunType : oss ,aws
+     */
+    public static final String FYUN_UPLOAD = "sudo bash /mnt/shell/fyun/fyun-upload.sh %s %s /%s %s %s";
+
+    public static final String FYUN_DOWN = "sudo bash /mnt/shell/fyun/fyun-download.sh %s /%s %s %s %s";
+
+    public static final String FYUN_DELETE = "sudo bash /mnt/shell/fyun/fyun-deled.sh %s /%s %s %s %s";
+
 }

+ 0 - 346
720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/AliYunOssUtil.java

@@ -1,346 +0,0 @@
-package com.gis.oss.util;
-
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.RuntimeUtil;
-import com.alibaba.fastjson.JSON;
-import com.aliyun.oss.OSSClient;
-import com.aliyun.oss.model.*;
-import com.gis.oss.command.CmdConstant;
-import com.gis.oss.command.CmdUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * 阿里云oss工具类
- */
-@Slf4j
-@Component
-public class AliYunOssUtil {
-
-//    @Autowired
-//    ConfigConstant configConstant;
-
-    @Value("${oss.key}")
-    public  String ossKey;
-
-    @Value("${oss.secrecy}")
-    public  String ossSecrecy;
-
-    @Value("${oss.bucket}")
-    public  String ossBucket;
-
-    @Value("${oss.point}")
-    public  String ossPoint;
-
-
-    // 加载对象
-    private OSSClient init(){
-//        return new OSSClient(configConstant.ossPoint, configConstant.ossKey, configConstant.ossSecrecy);
-        return new OSSClient(ossPoint, ossKey, ossSecrecy);
-    }
-
-
-
-    public  void delete(String key) throws IOException {
-        OSSClient ossClient = init();
-        try {
-
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.deleteObject(ossBucket, key);
-            ossClient.deleteObject(ossBucket, key);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    //上传的数据是byte[],key是上传后的文件名
-    public void upload(byte[] data, String key) throws IOException {
-        OSSClient ossClient = init();
-        try {
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(ossBucket, key, new ByteArrayInputStream(data));
-        } catch (Exception e) {
-            log.error(e.toString() + key);
-        }
-    }
-    /**
-     * 获取文件内容-阿里云
-     * @param objectName
-     * @return
-     */
-    public boolean existKey(String bucket,String objectName){
-        //创建oss客户端
-        OSSClient ossClient = init();
-        // ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
-        try{
-            boolean exist = ossClient.doesObjectExist(bucket, objectName);
-            return exist;
-        }catch (Exception e){
-            log.error("s4判断是否存在key异常,key=" + objectName, e);
-        }finally {
-            if(ossClient != null){
-                ossClient.shutdown();
-            }
-        }
-        return false;
-    }
-    /**
-     *
-     * @param data
-     * @param key
-     * @param contentType : 不设置,默认浏览器打开图片
-     * application/octet-stream 使用cdn后会自动下载
-     * @throws IOException
-     */
-    public void upload(byte[] data, String key, String contentType) throws IOException {
-        OSSClient ossClient = init();
-
-        // 创建上传文件的元信息,可以通过文件元信息设置HTTP header。
-        ObjectMetadata meta = new ObjectMetadata();
-        meta.setContentType(contentType);
-
-        try {
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(ossBucket, key, new ByteArrayInputStream(data), meta);
-        } catch (Exception e) {
-            log.error(e.toString() + key);
-        }
-    }
-    /**
-     *
-     * @param data
-     * @param key
-     * application/octet-stream 使用cdn后会自动下载
-     * @throws IOException
-     */
-    public void upload(String bucket,byte[] data, String key ) throws IOException {
-        OSSClient ossClient = init();
-        // 创建上传文件的元信息,可以通过文件元信息设置HTTP header。
-        try {
-            ObjectMetadata metadata = new ObjectMetadata();
-            if (key.contains(".jpg")) {
-                metadata.setContentType("image/jpeg");
-            } else if (key.contains(".png")) {
-                metadata.setContentType("image/png");
-            } else if (key.contains(".json")) {
-                metadata.setContentType("application/json");
-            }
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(bucket, key, new ByteArrayInputStream(data),metadata);
-        } catch (Exception e) {
-            log.error(e.toString() + key);
-        }
-    }
-
-
-    public void upload(String filePath, String key) {
-        OSSClient ossClient = init();
-        try {
-            File file = new File(filePath);
-            if (!file.exists()) {
-                log.error("要上传的文件不存在:" + filePath);
-            }
-            ObjectMetadata metadata = new ObjectMetadata();
-            if (filePath.contains(".jpg")) {
-                metadata.setContentType("image/jpeg");
-            } else if (filePath.contains(".png")) {
-                metadata.setContentType("image/png");
-            } else if (filePath.contains(".json")) {
-                metadata.setContentType("application/json");
-            }
-            ossClient.putObject(ossBucket, key, new File(filePath),metadata);
-
-        } catch (Exception e) {
-            log.error(e.toString() + filePath);
-        }
-    }
-
-    public  void upload2(String filePath, String key) {
-        OSSClient ossClient = init();
-        try {
-
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(ossBucket, key, new File(filePath));
-        } catch (Exception e) {
-            log.error(e.toString() + filePath);
-        }
-    }
-
-
-    /**
-     * 上传的数据是文件夹,参数是文件夹路径,key是上传后的文件名
-     *
-     * @param filepaths key : 原文件路径
-     *                  value: oss路径, oss会自动创建目录
-     */
-    public  void uploadMulFiles(Map<String, String> filepaths) {
-        if (filepaths == null) {
-            return;
-        }
-        log.info("开始批量上传到阿里云:" + new Date().toString());
-        if (filepaths.size() > 50) {
-            for (String filePath : filepaths.keySet()) {
-                upload2(filePath, filepaths.get(filePath));
-            }
-        } else {
-            for (String filePath : filepaths.keySet()) {
-                log.info("文件:" + filePath + "到阿里云:" + filepaths.get(filePath));
-                upload(filePath, filepaths.get(filePath));
-            }
-        }
-        log.info("批量上传阿里云完毕:" + new Date().toString());
-    }
-
-    public List<String> getFileFolder(String bucket, String keyName) {
-        log.info("获取文件夹bucket-{},路径{}",bucket,keyName);
-        OSSClient ossClient = init();
-        List<String> keyList = new ArrayList<>();
-        try {
-            boolean flag = true;
-            String nextMaker = null;
-            ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucket);
-            //指定下一级文件
-            listObjectsRequest.setPrefix(keyName);
-            //设置分页的页容量
-            listObjectsRequest.setMaxKeys(200);
-            do {
-                //获取下一页的起始点,它的下一项
-                listObjectsRequest.setMarker(nextMaker);
-                ObjectListing objectListing = ossClient.listObjects(listObjectsRequest);
-                List<String> collect = objectListing.getObjectSummaries().parallelStream()
-                        .map(OSSObjectSummary::getKey).collect(Collectors.toList());
-                if (!CollectionUtils.isEmpty(collect)) {
-                    keyList.addAll(collect);
-                }
-                nextMaker = objectListing.getNextMarker();
-                //全部执行完后,为false
-                flag = objectListing.isTruncated();
-            } while (flag);
-        } catch (Exception e) {
-            log.error("获取文件列表失败,path=" + keyName, e);
-            e.printStackTrace();
-        }
-        log.info("获取文件夹集合={}", JSON.toJSONString(keyList));
-        return keyList;
-    }
-    public ObjectMetadata downloadFile(String bucket, String pathKey, String file) {
-        OSSClient ossClient = init();
-        GetObjectRequest request = new GetObjectRequest(bucket, pathKey);
-        log.info("下载开始:下载bucket={},下载pathKey={},下载filePath={}", bucket, pathKey, file);
-        File downloadFile = new File(file);
-        if (!FileUtil.exist(downloadFile.getParent())){
-            FileUtil.mkdir(downloadFile.getParent());
-        }
-        return ossClient.getObject(request, downloadFile);
-    }
-    /**
-     * 可以删除目录
-     *
-     * @param prefix 图片路径
-     * @return
-     */
-    public  int deleteFile(String prefix) {
-        OSSClient ossClient = init();
-        ObjectListing objectListing = ossClient.listObjects(ossBucket, prefix);
-        List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
-        try {
-            for (OSSObjectSummary s : sums) {
-                delete(s.getKey());
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return sums.size();
-    }
-
-    public  void main(String[] args) throws IOException {
-
-        HashMap<String, String> map = new HashMap<>();
-//		map.put("F:\\test\\aa.jpg", "kanfang/test/aa.jpg");
-        map.put("F:\\test\\oss\\floor.json", "kanfang/test/faa.json");
-        uploadMulFiles(map);
-
-
-    }
-
-
-
-
-
-
-    /**
-     * 通过文件名判断并获取OSS服务文件上传时文件的contentType
-     *
-     * @param fileName 文件名
-     * @return 文件的contentType
-     */
-    private static String getContentType(String fileName) {
-        log.info("getContentType:" + fileName);
-        // 文件的后缀名
-        String fileExtension = fileName.substring(fileName.lastIndexOf("."));
-        if (".bmp".equalsIgnoreCase(fileExtension)) {
-            return "image/bmp";
-        }
-        if (".gif".equalsIgnoreCase(fileExtension)) {
-            return "image/gif";
-        }
-        if (".jpeg".equalsIgnoreCase(fileExtension) || ".jpg".equalsIgnoreCase(fileExtension)
-                || ".png".equalsIgnoreCase(fileExtension)) {
-            return "image/jpeg";
-        }
-        if (".html".equalsIgnoreCase(fileExtension)) {
-            return "text/html";
-        }
-        if (".txt".equalsIgnoreCase(fileExtension)) {
-            return "text/plain";
-        }
-        if (".vsd".equalsIgnoreCase(fileExtension)) {
-            return "application/vnd.visio";
-        }
-        if (".ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) {
-            return "application/vnd.ms-powerpoint";
-        }
-        if (".doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) {
-            return "application/msword";
-        }
-        if (".xml".equalsIgnoreCase(fileExtension)) {
-            return "text/xml";
-        }
-        if (".pdf".equalsIgnoreCase(fileExtension)) {
-            return "application/pdf";
-        }
-        // 默认返回类型
-        return "image/jpeg";
-    }
-
-    /**
-     * 以流下载图片
-     *
-     * @param
-     * @return
-     * @Title: getInputStreamByFileUrl
-     * @Description: 根据文件路径获取InputStream流
-     * @return: InputStream
-     */
-    public  InputStream getInputStreamByFileUrl(String filePath) {
-        // ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
-        OSSClient ossClient = init();
-        OSSObject ossObject = ossClient.getObject(ossBucket, filePath);
-        return ossObject.getObjectContent();
-    }
-
-
-    public void uploadBySh(String filePath, String key) {
-        String cmd = String.format(CmdConstant.UPLOAD_DIR, ossBucket, filePath, key , "oss");
-        CmdUtils.callShell(cmd);
-    }
-}

+ 0 - 184
720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/AwsOssUtil.java

@@ -1,184 +0,0 @@
-package com.gis.oss.util;
-
-import cn.hutool.core.util.RuntimeUtil;
-import com.amazonaws.auth.AWSStaticCredentialsProvider;
-import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.regions.Regions;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.AmazonS3ClientBuilder;
-import com.amazonaws.services.s3.model.CannedAccessControlList;
-import com.amazonaws.services.s3.model.DeleteObjectsRequest;
-import com.amazonaws.services.s3.model.PutObjectRequest;
-import com.amazonaws.services.s3.model.S3ObjectSummary;
-import com.gis.oss.command.CmdConstant;
-import com.gis.oss.command.CmdUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * aws-s3工具类
- */
-@Slf4j
-@Component
-public class AwsOssUtil {
-
-
-//    @Value("${oss.key:AKIAWCV5QFZ3ZNELKYUY}")
-    private static String s3key="AKIAWCV5QFZ3ZNELKYUY";
-
-//    @Value("${oss.secrecy:epS5ghyR4LJ7rxk/qJO9ZYh6m9Oz6g5haKDu4yws}")
-    private static String s3secrecy="epS5ghyR4LJ7rxk/qJO9ZYh6m9Oz6g5haKDu4yws";
-
-    @Value("${oss.bucket}")
-    private String bucket;
-
-    public void uploadAws(String filePath, String key1){
-        uploadAwsWithHeaders(filePath,key1,null);
-    }
-
-    public void uploadAws(byte[] data,String objectName){
-        BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrecy);
-        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
-                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
-                .withRegion(Regions.EU_WEST_2)
-                .build();
-        try {
-            com.amazonaws.services.s3.model.ObjectMetadata metadata = new com.amazonaws.services.s3.model.ObjectMetadata();
-            s3.putObject(this.bucket, objectName, new ByteArrayInputStream(data), metadata);
-        }catch (Exception e){
-            log.error("s3上传文件失败", e);
-        }finally {
-            if(s3 != null){
-                s3.shutdown();
-            }
-        }
-    }
-    public void uploadAws(String bucket,byte[] data,String objectName){
-        BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrecy);
-        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
-                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
-                .withRegion(Regions.EU_WEST_2)
-                .build();
-        try {
-            com.amazonaws.services.s3.model.ObjectMetadata metadata = new com.amazonaws.services.s3.model.ObjectMetadata();
-            s3.putObject(bucket, objectName, new ByteArrayInputStream(data), metadata);
-        }catch (Exception e){
-            log.error("s3上传文件失败", e);
-        }finally {
-            if(s3 != null){
-                s3.shutdown();
-            }
-        }
-    }
-
-    public void uploadAwsWithHeaders(String filePath, String key1,Map<String,String> headers){
-        try{
-            uploadS3File(filePath, key1);
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * s3上传文件
-     * @param filePath
-     * @param key1
-     * @throws IOException
-     */
-    private void uploadS3File(String filePath, String key1) throws Exception {
-        /**
-         * 创建s3对象
-         */
-        BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrecy);
-        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
-                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
-                .withRegion(Regions.EU_WEST_2)
-                .build();
-        try{
-            File file = new File(filePath);
-            if(!file.exists()){
-                log.info("要上传s3的文件不存在");
-                return;
-            }
-
-            // 设置文件并设置公读
-            com.amazonaws.services.s3.model.ObjectMetadata metadata = new com.amazonaws.services.s3.model.ObjectMetadata();
-            if(filePath.contains(".jpg")){
-                metadata.setContentType("image/jpeg");
-            }
-            if(filePath.contains(".png")){
-                metadata.setContentType("image/png");
-            }
-//            PutObjectRequest request = new PutObjectRequest(s3bucket, key1, file);
-            PutObjectRequest request = new PutObjectRequest(bucket, key1, file);
-            request.withCannedAcl(CannedAccessControlList.PublicRead);
-            request.withMetadata(metadata);
-
-            // 上传文件
-            com.amazonaws.services.s3.model.PutObjectResult putObjectResult = s3.putObject(request);
-            if (StringUtils.isNotEmpty(putObjectResult.getETag())) {
-                log.info("s3上传文件成功:" + key1);
-            }
-        }catch (Exception e){
-            throw e;
-        }finally {
-            s3.shutdown();
-        }
-
-    }
-
-    private void deleteAwsFile(String prefix){
-
-        int maxKeys = 200;
-        String nextMaker = null;
-        BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrecy);
-        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
-                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
-                .withRegion(Regions.EU_WEST_2)
-                .build();
-        try {
-            com.amazonaws.services.s3.model.ListObjectsRequest listObjectsRequest = new com.amazonaws.services.s3.model.ListObjectsRequest();
-            listObjectsRequest.setBucketName(this.bucket);
-            listObjectsRequest.setPrefix(prefix);
-            listObjectsRequest.setMaxKeys(maxKeys);
-
-            com.amazonaws.services.s3.model.ObjectListing objectListing;
-            do{
-                listObjectsRequest.setMarker(nextMaker);
-                objectListing = s3.listObjects(listObjectsRequest);
-                List<S3ObjectSummary> objectSummaries = objectListing.getObjectSummaries();
-                List<DeleteObjectsRequest.KeyVersion> keys =objectSummaries.stream().map(summary->new DeleteObjectsRequest.KeyVersion(summary.getKey())).collect(Collectors.toList());
-
-                com.amazonaws.services.s3.model.DeleteObjectsRequest multiObjectDeleteRequest =
-                        new com.amazonaws.services.s3.model.DeleteObjectsRequest(this.bucket)
-                                .withKeys(keys)
-                                .withQuiet(false);
-                com.amazonaws.services.s3.model.DeleteObjectsResult delObjRes = s3.deleteObjects(multiObjectDeleteRequest);
-                int successfulDeletes = delObjRes.getDeletedObjects().size();
-                log.info("删除aws文件成功,删除文件数;{}", successfulDeletes);
-                nextMaker = objectListing.getNextMarker();
-            }while (objectListing.isTruncated());
-        }catch (Exception e){
-            log.error("删除was文件失败,path="+prefix, e);
-        }finally {
-            if(s3 != null){
-                s3.shutdown();
-            }
-        }
-    }
-
-
-    public void uploadBySh(String filePath, String key) {
-        String cmd = String.format(CmdConstant.UPLOAD_DIR, bucket, filePath, key , "aws");
-         CmdUtils.callShell(cmd);
-    }
-}

File diff suppressed because it is too large
+ 12 - 1248
720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/FileAndOssUtil.java


+ 104 - 0
720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/OssShUtil.java

@@ -0,0 +1,104 @@
+package com.gis.oss.util;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.fdkankan.filestorage.FileStorageTemplate;
+import com.gis.oss.command.CmdConstant;
+import com.gis.oss.command.StreamGobblerLine;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Xiewj
+ * @date 2023/6/6
+ */
+@Slf4j
+@Component
+public class OssShUtil {
+    @Autowired
+    FileStorageTemplate fileStorageTemplate;
+    /**
+     * 调用sh脚本上传oss
+     */
+    public static void ossUploadDir(String cmd){
+
+//        log.info("ossCmd: " + cmd);
+        long start = System.currentTimeMillis();
+        callLineSh(cmd);
+        long end = System.currentTimeMillis();
+        log.info("场景码目录:{} 上传完成, 耗时:{} s" , (end-start)/1000 );
+    }
+
+//    public static void ossDeleteDir(String srcPath) {
+//        log.info("删除目录开始,路径:{} s" ,srcPath);
+//        long start = System.currentTimeMillis();
+//        String opType = srcPath.contains(".")? "file":"folder" ;
+//        FileStorageTemplate bean = SpringUtil.getBean(FileStorageTemplate.class);
+//        String cmd = String.format(CmdConstant.FYUN_DELETE, bean.getBucket(),fdkkLaserConfig.getDefaultFolder(),srcPath,bean.getActive(),opType);
+//        log.info("ossDeleteDir-{}",cmd);
+//        callLineSh(cmd);
+//        long end = System.currentTimeMillis();
+//        log.info("删除目录完成, 耗时:{} s" , (end-start)/1000 );
+//    }
+    /**
+     * oss文件上传命令 bash /opt/ossutil/fyun-upload.sh {bucket} {srcPath} {destPath} {fyunType} {opType}
+     * opType: file or folder
+     *  //@param bucket     桶名
+     * @param srcPath    源文件路径
+     * @param destPath   目标文件路径
+     *  //@param fyunType   oss or aws
+     */
+    public static void yunUpload(String srcPath,String destPath){
+        String opType = srcPath.contains(".")? "file":"folder" ;
+        FileStorageTemplate bean = SpringUtil.getBean(FileStorageTemplate.class);
+        String cmd = String.format(CmdConstant.FYUN_UPLOAD, bean.getBucket(),srcPath,destPath,bean.getActive(),opType);
+        callLineSh(cmd);
+    }
+    public static void yunDownload(String srcPath,String destPath){
+
+        String opType = srcPath.contains(".")? "file":"folder" ;
+        FileStorageTemplate bean = SpringUtil.getBean(FileStorageTemplate.class);
+        if("/".equals(srcPath.substring(0,1))){
+            srcPath = srcPath.substring(1);
+        }
+        String cmd = String.format(CmdConstant.FYUN_DOWN,bean.getBucket(),srcPath,destPath,bean.getActive(),opType);
+        callLineSh(cmd);
+    }
+    public static void yunDownloadOther(String srcPath,String destPath,String bucket,String active){
+        String opType = srcPath.contains(".")? "file":"folder" ;
+        FileStorageTemplate bean = SpringUtil.getBean(FileStorageTemplate.class);
+        if("/".equals(srcPath.substring(0,1))){
+            srcPath = srcPath.substring(1);
+        }
+        String cmd = String.format(CmdConstant.FYUN_DOWN,bucket,srcPath,destPath,active,opType);
+        callLineSh(cmd);
+    }
+    public static void yunDownload(String bucket,String srcPath,String destPath){
+        String opType = srcPath.contains(".")? "file":"folder" ;
+        if("/".equals(srcPath.substring(0,1))){
+            srcPath = srcPath.substring(1);
+        }
+        FileStorageTemplate bean = SpringUtil.getBean(FileStorageTemplate.class);
+        String cmd = String.format(CmdConstant.FYUN_DOWN,bucket,srcPath,destPath,bean.getActive(),opType);
+        callLineSh(cmd);
+    }
+    /**
+     * @param command 命令
+     */
+    public static void callLineSh(String command){
+        log.info("cmd: " + command);
+        try {
+            String[] cmd = new String[]{"/bin/sh", "-c", command};
+            Process process = Runtime.getRuntime().exec(cmd);
+            log.info("开始运行");
+            StreamGobblerLine errorGobbler = new StreamGobblerLine(process.getErrorStream(), "ERROR");
+            errorGobbler.start();
+            // 200行打印一次日志
+            StreamGobblerLine outGobbler = new StreamGobblerLine(process.getInputStream(), "STDOUT", null);
+            outGobbler.start();
+            process.waitFor();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 5 - 1
720yun_fd_consumer/pom.xml

@@ -102,7 +102,11 @@
                 <artifactId>4dkankan-utils-rabbitmq</artifactId>
                 <version>3.0.0-SNAPSHOT</version>
             </dependency>
-
+            <dependency>
+                <groupId>com.fdkankan</groupId>
+                <artifactId>4dkankan-utils-filestorage</artifactId>
+                <version>3.0.0-SNAPSHOT</version>
+            </dependency>
             <!-- lombok -->
             <dependency>
                 <groupId>org.projectlombok</groupId>

+ 4 - 0
720yun_fd_manage/gis_common/pom.xml

@@ -174,6 +174,10 @@
             <groupId>org.iherus</groupId>
             <artifactId>qrext4j</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-filestorage</artifactId>
+        </dependency>
         <!-- redis-config 需要此包 -->
         <!--<dependency>-->
             <!--<groupId>com.fasterxml.jackson.core</groupId>-->

+ 0 - 38
720yun_fd_manage/gis_oss/pom.xml

@@ -22,46 +22,8 @@
             <artifactId>gis_common</artifactId>
         </dependency>
 
-        <!--AliYun sdk-->
-        <dependency>
-            <groupId>com.aliyun</groupId>
-            <artifactId>aliyun-java-sdk-core</artifactId>
-            <version>4.0.3</version>
-        </dependency>
-        <dependency>
-            <groupId>com.aliyun</groupId>
-            <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
-            <version>1.1.0</version>
-        </dependency>
-        <dependency>
-            <groupId>com.aliyun.oss</groupId>
-            <artifactId>aliyun-sdk-oss</artifactId>
-            <version>2.5.0</version>
-        </dependency>
 
 
-        <!--七牛云oss info-->
-        <dependency>
-            <groupId>com.qiniu</groupId>
-            <artifactId>happy-dns-java</artifactId>
-            <version>0.1.6</version>
-            <scope>compile</scope>
-        </dependency>
-
-
-        <dependency>
-            <groupId>com.qiniu</groupId>
-            <artifactId>qiniu-java-sdk</artifactId>
-            <version>7.10.0</version>
-        </dependency>
-
-
-        <!--aws s3 -->
-        <dependency>
-            <groupId>com.amazonaws</groupId>
-            <artifactId>aws-java-sdk</artifactId>
-            <version>1.11.327</version>
-        </dependency>
 
         <dependency>
             <groupId>commons-fileupload</groupId>

+ 0 - 292
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/AliYunOssUtil.java

@@ -1,292 +0,0 @@
-package com.gis.oss.util;
-
-import cn.hutool.core.collection.CollUtil;
-import com.aliyun.oss.ClientException;
-import com.aliyun.oss.OSSClient;
-import com.aliyun.oss.model.*;
-import com.gis.common.constant.ConfigConstant;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.*;
-import java.net.URLDecoder;
-import java.util.*;
-
-/**
- * 阿里云oss工具类
- * 参考:https://help.aliyun.com/document_detail/84842.htm?spm=a2c4g.11186623.0.0.606a282dA00Gt3#t22290.html
- */
-@Slf4j
-@Component
-public class AliYunOssUtil {
-
-    @Autowired
-    ConfigConstant configConstant;
-
-    // 加载对象
-    private OSSClient init(){
-        return new OSSClient(configConstant.ossPoint, configConstant.ossKey, configConstant.ossSecrecy);
-    }
-
-
-
-    public  void delete(String key) throws IOException {
-        OSSClient ossClient = init();
-        try {
-
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.deleteObject(configConstant.ossBucket, key);
-            ossClient.deleteObject(configConstant.ossBucket, key);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    //上传的数据是byte[],key是上传后的文件名
-    public void upload(byte[] data, String key) throws IOException {
-        OSSClient ossClient = init();
-        try {
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(configConstant.ossBucket, key, new ByteArrayInputStream(data));
-        } catch (Exception e) {
-            log.error(e.toString() + key);
-        }
-    }
-
-    /**
-     *
-     * @param data
-     * @param key
-     * @param contentType : 不设置,默认浏览器打开图片
-     * application/octet-stream 使用cdn后会自动下载
-     * @throws IOException
-     */
-    public void upload(byte[] data, String key, String contentType) throws IOException {
-        OSSClient ossClient = init();
-
-        // 创建上传文件的元信息,可以通过文件元信息设置HTTP header。
-        ObjectMetadata meta = new ObjectMetadata();
-        meta.setContentType(contentType);
-
-        try {
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(configConstant.ossBucket, key, new ByteArrayInputStream(data), meta);
-        } catch (Exception e) {
-            log.error(e.toString() + key);
-        }
-    }
-
-
-    public void upload(String filePath, String key) {
-        OSSClient ossClient = init();
-        try {
-            File file = new File(filePath);
-            if (!file.exists()) {
-                log.error("要上传的文件不存在:" + filePath);
-            }
-            ossClient.putObject(configConstant.ossBucket, key, new File(filePath));
-
-        } catch (Exception e) {
-            log.error(e.toString() + filePath);
-        }
-    }
-
-    public  void upload2(String filePath, String key) {
-        OSSClient ossClient = init();
-        try {
-
-            // 2019-2-28 启动aliyun oss 空间
-            ossClient.putObject(configConstant.ossBucket, key, new File(filePath));
-        } catch (Exception e) {
-            log.error(e.toString() + filePath);
-        }
-    }
-
-
-    /**
-     * 上传的数据是文件夹,参数是文件夹路径,key是上传后的文件名
-     *
-     * @param filepaths key : 原文件路径
-     *                  value: oss路径, oss会自动创建目录
-     */
-    public  void uploadMulFiles(Map<String, String> filepaths) {
-        if (filepaths == null) {
-            return;
-        }
-        log.info("开始批量上传到阿里云:" + new Date().toString());
-        if (filepaths.size() > 50) {
-            for (String filePath : filepaths.keySet()) {
-                upload2(filePath, filepaths.get(filePath));
-            }
-        } else {
-            for (String filePath : filepaths.keySet()) {
-                log.info("文件:" + filePath + "到阿里云:" + filepaths.get(filePath));
-                upload(filePath, filepaths.get(filePath));
-            }
-        }
-        log.info("批量上传阿里云完毕:" + new Date().toString());
-    }
-
-
-    /**
-     * 可以删除目录
-     *
-     * @param prefix 图片路径
-     * @return
-     */
-    public  int deleteDir(String prefix) {
-        OSSClient ossClient = init();
-        ObjectListing objectListing = ossClient.listObjects(configConstant.ossBucket, prefix);
-        List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
-        try {
-            for (OSSObjectSummary s : sums) {
-                delete(s.getKey());
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return sums.size();
-    }
-
-    /**
-     * 2023-1-31
-     * 删除单个文件, 不能删除目录
-     * @param ossKey 填写文件完整路径。文件完整路径中不能包含Bucket名称。
-     * 同时也不能以“/”或者“\”开头。
-     */
-    public void deleteFile(String ossKey) {
-        OSSClient ossClient = init();
-        try {
-            ossClient.deleteObject(configConstant.ossBucket, ossKey);
-            log.info("删除oss文件完成:{}", ossKey);
-        } catch (ClientException e) {
-            e.printStackTrace();
-        }
-    }
-
-
-
-    public void deleteOssFile(String prefix){
-        int maxKeys = 200;
-        OSSClient ossClient = init();
-        try {
-
-            String nextMarker = null;
-            ObjectListing objectListing;
-
-            do {
-                objectListing = ossClient.listObjects(new ListObjectsRequest(configConstant.ossBucket).withPrefix(prefix).withMarker(nextMarker).withMaxKeys(maxKeys));
-                List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
-                if (CollUtil.isEmpty(sums)) {
-                    return;
-                }
-                List<String> keys = new ArrayList<>();
-                for (OSSObjectSummary sum : sums) {
-                    keys.add(sum.getKey());
-                }
-                DeleteObjectsRequest deleteObjectsRequest =
-                        new DeleteObjectsRequest(configConstant.ossBucket).withKeys(keys).withEncodingType("url");
-                DeleteObjectsResult deleteObjectsResult = ossClient
-                        .deleteObjects(deleteObjectsRequest);
-                List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
-                try {
-                    for (String deletedObject : deletedObjects) {
-                        String decode = URLDecoder.decode(deletedObject, "UTF-8");
-                        log.info("删除oss文件:{}", decode);
-                    }
-                } catch (UnsupportedEncodingException e) {
-                    e.printStackTrace();
-                }
-
-            }while (objectListing.isTruncated());
-        }catch (Exception  e){
-            e.printStackTrace();
-        }finally {
-            if(ossClient != null){
-                ossClient.shutdown();
-            }
-        }
-    }
-
-    public  void main(String[] args) throws IOException {
-
-        HashMap<String, String> map = new HashMap<>();
-//		map.put("F:\\test\\aa.jpg", "kanfang/test/aa.jpg");
-        map.put("F:\\test\\oss\\floor.json", "kanfang/test/faa.json");
-        uploadMulFiles(map);
-
-
-    }
-
-
-
-
-
-
-    /**
-     * 通过文件名判断并获取OSS服务文件上传时文件的contentType
-     *
-     * @param fileName 文件名
-     * @return 文件的contentType
-     */
-    private static String getContentType(String fileName) {
-        log.info("getContentType:" + fileName);
-        // 文件的后缀名
-        String fileExtension = fileName.substring(fileName.lastIndexOf("."));
-        if (".bmp".equalsIgnoreCase(fileExtension)) {
-            return "image/bmp";
-        }
-        if (".gif".equalsIgnoreCase(fileExtension)) {
-            return "image/gif";
-        }
-        if (".jpeg".equalsIgnoreCase(fileExtension) || ".jpg".equalsIgnoreCase(fileExtension)
-                || ".png".equalsIgnoreCase(fileExtension)) {
-            return "image/jpeg";
-        }
-        if (".html".equalsIgnoreCase(fileExtension)) {
-            return "text/html";
-        }
-        if (".txt".equalsIgnoreCase(fileExtension)) {
-            return "text/plain";
-        }
-        if (".vsd".equalsIgnoreCase(fileExtension)) {
-            return "application/vnd.visio";
-        }
-        if (".ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) {
-            return "application/vnd.ms-powerpoint";
-        }
-        if (".doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) {
-            return "application/msword";
-        }
-        if (".xml".equalsIgnoreCase(fileExtension)) {
-            return "text/xml";
-        }
-        if (".pdf".equalsIgnoreCase(fileExtension)) {
-            return "application/pdf";
-        }
-        // 默认返回类型
-        return "image/jpeg";
-    }
-
-    /**
-     * 以流下载图片
-     *
-     * @param
-     * @return
-     * @Title: getInputStreamByFileUrl
-     * @Description: 根据文件路径获取InputStream流
-     * @return: InputStream
-     */
-    public  InputStream getInputStreamByFileUrl(String filePath) {
-        // ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
-        OSSClient ossClient = init();
-        OSSObject ossObject = ossClient.getObject(configConstant.ossBucket, filePath);
-        return ossObject.getObjectContent();
-    }
-
-
-
-
-
-}

+ 0 - 161
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/AwsOssUtil.java

@@ -1,161 +0,0 @@
-package com.gis.oss.util;
-
-import com.amazonaws.auth.AWSStaticCredentialsProvider;
-import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.regions.Regions;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.AmazonS3ClientBuilder;
-import com.amazonaws.services.s3.model.CannedAccessControlList;
-import com.amazonaws.services.s3.model.DeleteObjectsRequest;
-import com.amazonaws.services.s3.model.PutObjectRequest;
-import com.amazonaws.services.s3.model.S3ObjectSummary;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * aws-s3工具类
- */
-@Slf4j
-@Component
-public class AwsOssUtil {
-
-
-//    @Value("${oss.key:AKIAWCV5QFZ3ZNELKYUY}")
-    private static String s3key="AKIAWCV5QFZ3ZNELKYUY";
-
-//    @Value("${oss.secrecy:epS5ghyR4LJ7rxk/qJO9ZYh6m9Oz6g5haKDu4yws}")
-    private static String s3secrecy="epS5ghyR4LJ7rxk/qJO9ZYh6m9Oz6g5haKDu4yws";
-
-    @Value("${oss.bucket}")
-    private String bucket;
-
-    public void uploadAws(String filePath, String key1){
-        uploadAwsWithHeaders(filePath,key1,null);
-    }
-
-    public void uploadAws(byte[] data,String objectName){
-        BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrecy);
-        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
-                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
-                .withRegion(Regions.EU_WEST_2)
-                .build();
-        try {
-            com.amazonaws.services.s3.model.ObjectMetadata metadata = new com.amazonaws.services.s3.model.ObjectMetadata();
-            s3.putObject(this.bucket, objectName, new ByteArrayInputStream(data), metadata);
-        }catch (Exception e){
-            log.error("s3上传文件失败", e);
-        }finally {
-            if(s3 != null){
-                s3.shutdown();
-            }
-        }
-    }
-
-    public void uploadAwsWithHeaders(String filePath, String key1,Map<String,String> headers){
-        try{
-            uploadS3File(filePath, key1);
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * s3上传文件
-     * @param filePath
-     * @param key1
-     * @throws IOException
-     */
-    private void uploadS3File(String filePath, String key1) throws Exception {
-        /**
-         * 创建s3对象
-         */
-        BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrecy);
-        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
-                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
-                .withRegion(Regions.EU_WEST_2)
-                .build();
-        try{
-            File file = new File(filePath);
-            if(!file.exists()){
-                log.info("要上传s3的文件不存在");
-                return;
-            }
-
-            // 设置文件并设置公读
-            com.amazonaws.services.s3.model.ObjectMetadata metadata = new com.amazonaws.services.s3.model.ObjectMetadata();
-            if(filePath.contains(".jpg")){
-                metadata.setContentType("image/jpeg");
-            }
-            if(filePath.contains(".png")){
-                metadata.setContentType("image/png");
-            }
-//            PutObjectRequest request = new PutObjectRequest(s3bucket, key1, file);
-            PutObjectRequest request = new PutObjectRequest(bucket, key1, file);
-            request.withCannedAcl(CannedAccessControlList.PublicRead);
-            request.withMetadata(metadata);
-
-            // 上传文件
-            com.amazonaws.services.s3.model.PutObjectResult putObjectResult = s3.putObject(request);
-            if (StringUtils.isNotEmpty(putObjectResult.getETag())) {
-                log.info("s3上传文件成功:" + key1);
-            }
-        }catch (Exception e){
-            throw e;
-        }finally {
-            s3.shutdown();
-        }
-
-    }
-
-    public void deleteAwsFile(String prefix){
-
-        int maxKeys = 200;
-        String nextMaker = null;
-        BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrecy);
-        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
-                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
-                .withRegion(Regions.EU_WEST_2)
-                .build();
-        try {
-            com.amazonaws.services.s3.model.ListObjectsRequest listObjectsRequest = new com.amazonaws.services.s3.model.ListObjectsRequest();
-            listObjectsRequest.setBucketName(this.bucket);
-            listObjectsRequest.setPrefix(prefix);
-            listObjectsRequest.setMaxKeys(maxKeys);
-
-            com.amazonaws.services.s3.model.ObjectListing objectListing;
-            do{
-                listObjectsRequest.setMarker(nextMaker);
-                objectListing = s3.listObjects(listObjectsRequest);
-                List<S3ObjectSummary> objectSummaries = objectListing.getObjectSummaries();
-                List<DeleteObjectsRequest.KeyVersion> keys =objectSummaries.stream().map(summary->new DeleteObjectsRequest.KeyVersion(summary.getKey())).collect(Collectors.toList());
-
-                com.amazonaws.services.s3.model.DeleteObjectsRequest multiObjectDeleteRequest =
-                        new com.amazonaws.services.s3.model.DeleteObjectsRequest(this.bucket)
-                                .withKeys(keys)
-                                .withQuiet(false);
-                com.amazonaws.services.s3.model.DeleteObjectsResult delObjRes = s3.deleteObjects(multiObjectDeleteRequest);
-                int successfulDeletes = delObjRes.getDeletedObjects().size();
-                log.info("删除aws文件成功,删除文件数;{}", successfulDeletes);
-                nextMaker = objectListing.getNextMarker();
-            }while (objectListing.isTruncated());
-        }catch (Exception e){
-            log.error("删除was文件失败,path="+prefix, e);
-        }finally {
-            if(s3 != null){
-                s3.shutdown();
-            }
-        }
-    }
-
-
-
-}

+ 9 - 76
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/FileAndOssUtil.java

@@ -22,10 +22,8 @@ import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
 import com.amazonaws.services.s3.model.GetObjectRequest;
 import com.amazonaws.services.s3.model.PutObjectRequest;
 import com.amazonaws.services.s3.model.*;
+import com.fdkankan.filestorage.FileStorageTemplate;
 import com.gis.oss.constant.StorageType;
-import com.qiniu.common.Zone;
-import com.qiniu.storage.Configuration;
-import com.qiniu.storage.UploadManager;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileItemFactory;
@@ -38,6 +36,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
+import javax.annotation.Resource;
 import java.io.*;
 import java.net.FileNameMap;
 import java.net.URL;
@@ -53,46 +52,8 @@ import java.util.stream.Collectors;
 @Component
 public class FileAndOssUtil {
 
-//	Zone zone = Zone.autoZone();
-//
-//	Configuration config = new Configuration(zone);
-//	UploadManager uploadManager = new UploadManager(config);
-//
-//	@Value("${oss.point:http://oss-cn-shenzhen-internal.aliyuncs.com}")
-//	private String point;
-//
-//	@Value("${oss.key:LTAIUrvuHqj8pvry}")
-//	private String key;
-//
-//	@Value("${oss.secrey:JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4}")
-//	private String secrey;
-//
-//	@Value("${oss.bucket:4dkankan}")
-//	private String bucket;
-//
-//	@Value("${oss.sdk:4dscene}")
-//	private String bucketSdk;
-//
-	@Value("${oss.type}")
-	private String type;
-//
-//	@Value("${aws.s3key:AKIAWCV5QFZ3ZNELKYUY}")
-//	private String s3key;
-//
-//	@Value("${aws.s3secrey:epS5ghyR4LJ7rxk/qJO9ZYh6m9Oz6g5haKDu4yws}")
-//	private String s3secrey;
-//
-//	@Value("${aws.s3bucket:4dkankan}")
-//	private String s3bucket;
-//
-//	@Value("${local.path:/home/4dkankan}")
-//	private String localPath;
-
-	@Autowired
-	AliYunOssUtil aliyunOssUtil;
-
-	@Autowired
-	AwsOssUtil awsOssUtil;
+	@Resource
+	private FileStorageTemplate ossUtil;
 
 	/**
 	 * oss文件上传命令
@@ -104,37 +65,13 @@ public class FileAndOssUtil {
 	//上传的数据是byte[],key是上传后的文件名
 	public void upload(byte[] data,String key1) throws IOException{
 //		log.info("开始上传文件 源路径:{},目标路径:{}, type:{}" , new String(data, "UTF-8"), key1, type);
-		log.info("开始上传文件 ,目标路径:{}, type:{}" ,  key1, type);
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-//				uploadOss(data,key1);
-				aliyunOssUtil.upload(data, key1);
-				break;
-			case AWS:
-//				uploadAws(data,key1);
-				awsOssUtil.uploadAws(data, key1);
-				break;
-			case LOCAL:
-//				uploadLocal(data,key1);
-				break;
-		}
+		log.info("开始上传文件 ,目标路径:{}, type:{}" ,  key1);
+		ossUtil.uploadFileBytes(key1,data);
 	}
 
 	public void upload(String filePath, String key1) {
-		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , filePath, key1, type);
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				aliyunOssUtil.upload(filePath,key1);
-				break;
-			case AWS:
-				awsOssUtil.uploadAws(filePath,key1);
-				break;
-			case LOCAL:
-//				uploadLocal(filePath,key1);
-				break;
-		}
+		log.info("开始上传文件 源路径:{},目标路径:{}" , filePath, key1);
+		ossUtil.uploadFile(key1,filePath);
 	}
 
 //	public void uploadFileWithHeaders(String filePath, String key1,Map<String,String> headers) {
@@ -204,11 +141,7 @@ public class FileAndOssUtil {
 		if (StringUtils.isBlank(prefix)){
 			return 0;
 		}
-		switch (type){
-			case "oss":aliyunOssUtil.deleteFile(prefix); break;
-			case "aws": awsOssUtil.deleteAwsFile(prefix); break;
-			case "local":FileUtil.del(prefix);  break;
-		}
+		ossUtil.deleteObject(prefix);
 		return 1;
 	}
 //

+ 0 - 177
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/QiNiuOssUtil.java

@@ -1,177 +0,0 @@
-package com.gis.oss.util;
-
-import com.gis.common.exception.BaseRuntimeException;
-import com.qiniu.common.QiniuException;
-import com.qiniu.http.Response;
-import com.qiniu.storage.BucketManager;
-import com.qiniu.storage.Configuration;
-import com.qiniu.storage.Region;
-import com.qiniu.storage.UploadManager;
-import com.qiniu.storage.model.FileInfo;
-import com.qiniu.util.Auth;
-import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
-
-import java.util.Map;
-
-/**
- * 七牛云oss上传工具
- */
-@Slf4j
-public class QiNiuOssUtil {
-
-    private static String ACCESS_KEY = "dlPPwgZky_F-iP8CbSbJpiAtAcqw3BYwb9rdHMrS";
-    private static String SECRET_KEY = "YEtkLKDsImXB-8m1CT1zV_YwCwwGvrUvo2ktj9KZ";
-
-    // 大场景 super 华南区域
-    private static String bucketName = "super";
-
-
-    //构造一个带指定 Region 对象的配置类, Region.region2(): 华南区域
-//    private static Configuration cfg = new Configuration(Region.region2());
-//    private static Configuration cfg = new Configuration(Zone.autoZone());
-    private static Configuration cfg = new Configuration(Region.huanan());
-
-    // 华北
-//    private static String bucketName = "model3d";
-//    private static Configuration cfg = new Configuration(Zone.autoZone());
-
-    //...其他参数参考类注释
-    private static UploadManager uploadManager = new UploadManager(cfg);
-
-    private static Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
-//    private static  String upToken = auth.uploadToken(bucketName);
-
-
-
-    /**
-     * localFilePath: 本地文件路径
-     * ossFilePath: ossw文件存放路径, 注意前面不要用"/" ,data/aa.jpg
-     */
-    public static void upload(String localFilePath, String ossFilePath) throws QiniuException {
-        // 覆盖需要把ossKey放到uploadToken里
-        String upToken = auth.uploadToken(bucketName, ossFilePath);
-        Response response = uploadManager.put(localFilePath, ossFilePath, upToken);
-        if (response.statusCode!=200){
-            String errorMsg = response.toString();
-            log.error("七牛云响应值:{}", errorMsg);
-            BaseRuntimeException.isTrue(true, null, "七牛云返回上传失败: " + errorMsg);
-        }
-    }
-
-
-    public static void main(String[] args) throws QiniuException {
-        String localFilePath = "F:\\test\\ngin\\11.txt";
-        String ossFilePath = "data/owen/11.txt";
-        upload(localFilePath, ossFilePath);
-        System.out.println("11111");
-
-//        getInfo(ossFilePath);
-    }
-
-
-    /**
-     * 批量上传
-     * key: localFilePath
-     * value: ossFilePath
-     */
-    public static void uploads(Map<String, String> param) {
-        log.info("开始批量上传到七牛云");
-        String upToken = auth.uploadToken(bucketName);
-        param.forEach((key, val)->{
-            try {
-                uploadManager.put(key, val, upToken);
-            } catch (QiniuException e) {
-                e.printStackTrace();
-            }
-        });
-        log.info("完成批量上传到七牛云");
-    }
-
-
-
-    /**
-     * by owen 2022-5-13
-     * @param key :文件路径
-     * 第一级目录不能带/ 例如: owen/aa.jpg
-     * 不支持删除目录, 删除目录使用脚本
-     */
-    public static void delete(String key){
-        BucketManager bucketManager = new BucketManager(auth, cfg);
-        try {
-            bucketManager.delete(bucketName, key);
-        } catch (QiniuException ex) {
-            //如果遇到异常,说明删除失败
-            log.error(ex.response.toString());
-        }
-    }
-
-
-
-
-    @Test
-    public void testDelete(){
-        delete("owen/a");
-    }
-
-
-    /**
-     * 获取文件信息
-     * @param key
-     */
-    public static void getInfo(String key){
-
-        BucketManager bucketManager = new BucketManager(auth, cfg);
-        try {
-            FileInfo fileInfo = bucketManager.stat(bucketName, key);
-            System.out.println(fileInfo.hash);
-            System.out.println(fileInfo.fsize);
-            System.out.println(fileInfo.mimeType);
-            System.out.println(fileInfo.putTime);
-        } catch (QiniuException ex) {
-            System.err.println(ex.response.toString());
-        }
-    }
-
-
-//    /**
-//     * 测试demo
-//     */
-//    @Test
-//    public void test() {
-//        //构造一个带指定 Region 对象的配置类
-//        Configuration cfg = new Configuration();
-//        //...其他参数参考类注释
-//
-//        UploadManager uploadManager = new UploadManager(cfg);
-//        //...生成上传凭证,然后准备上传
-//
-//        //如果是Windows情况下,格式是 D:\\qiniu\\test.png
-//        String localFilePath = "F:\\test\\22.jpg";
-//        //默认不指定key的情况下,以文件内容的hash值作为文件名
-//        Date date = new Date();
-//        String key = "data_" + date + ".jpg";
-//
-//        Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
-//        String upToken = auth.uploadToken(bucketName);
-//
-//        try {
-//            Response response = uploadManager.put(localFilePath, key, upToken);
-//            //解析上传成功的结果
-//            DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
-//            System.out.println(response.bodyString());
-//            System.out.println(putRet.key);
-//            System.out.println(putRet.hash);
-//        } catch (QiniuException ex) {
-//            Response r = ex.response;
-//            System.err.println(r.toString());
-//            try {
-//                System.err.println(r.bodyString());
-//            } catch (QiniuException ex2) {
-//                //ignore
-//            }
-//        }
-//
-//    }
-
-}

+ 0 - 1
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/QrCodeUtils.java

@@ -10,7 +10,6 @@ import cn.hutool.core.util.URLUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
 import cn.hutool.http.HttpUtil;
-import com.amazonaws.services.dynamodbv2.xspec.S;
 import com.gis.common.constant.ConfigConstant;
 import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
 import lombok.extern.slf4j.Slf4j;

File diff suppressed because it is too large
+ 0 - 1244
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/UploadToOssUtil.java


+ 0 - 1
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/SysUserServiceImpl.java

@@ -1,7 +1,6 @@
 package com.gis.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
-import com.amazonaws.services.dynamodbv2.xspec.S;
 import com.gis.common.util.RedisUtil;
 import com.gis.domain.entity.SysUserEntity;
 import com.gis.mapper.IBaseMapper;

+ 6 - 8
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/TestServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.filestorage.FileStorageTemplate;
 import com.gis.common.constant.ConfigConstant;
 import com.gis.common.constant.ErrorEnum;
 import com.gis.common.exception.BaseRuntimeException;
@@ -16,7 +17,6 @@ import com.gis.common.util.Result;
 import com.gis.domain.dto.TestShDto;
 import com.gis.domain.entity.FodderEntity;
 import com.gis.domain.entity.WorkEntity;
-import com.gis.oss.util.AliYunOssUtil;
 import com.gis.oss.util.FileAndOssUtil;
 import com.gis.service.FodderService;
 import com.gis.service.TestService;
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
@@ -48,10 +49,6 @@ public class TestServiceImpl implements TestService {
     ConfigConstant configConstant;
 
 
-
-    @Autowired
-    AliYunOssUtil aliyunOssUtil;
-
     @Autowired
     WorkService workService;
 
@@ -68,7 +65,8 @@ public class TestServiceImpl implements TestService {
     @Autowired
     VisitTask visitTask;
 
-
+    @Resource
+    private FileStorageTemplate ossUtil;
     @Override
     public Result batchReplaceSomeData(String isBatch) {
         String basePath = "F:\\work\\四维-全景看看\\data\\";
@@ -445,7 +443,7 @@ public class TestServiceImpl implements TestService {
         BaseRuntimeException.isTrue(!FileUtil.isFile(tourPath), ErrorEnum.FAILURE_CODE_3103.code(), "服务器tour.xml文件不存在");
 
         String ossKeyPath = configConstant.ossBasePath + id + "/tour.xml";
-        aliyunOssUtil.upload(tourPath, ossKeyPath);
+        ossUtil.uploadFile( ossKeyPath,tourPath);
         log.info("tour.xml上传完成 : {}", ossKeyPath);
     }
 
@@ -714,7 +712,7 @@ public class TestServiceImpl implements TestService {
         log.info("oss准备上传: {}", srcPath);
         String targetPath = configConstant.ossBasePath + workId + "/someData.json";
         log.info("oss上传地址: {}", targetPath);
-        aliyunOssUtil.upload(srcPath, targetPath);
+        ossUtil.uploadFile(targetPath,srcPath);
         log.info("上传oss完成: {}", targetPath);
 
     }

+ 2 - 3
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -1,18 +1,17 @@
 package com.gis.web.controller;
 
 import cn.hutool.core.io.FileUtil;
+import com.fdkankan.filestorage.FileStorageTemplate;
 import com.gis.common.constant.ConfigConstant;
 import com.gis.common.mq.RabbitMqProducerUtil;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.DoSliceDTO;
 import com.gis.domain.dto.TestShDto;
 import com.gis.domain.entity.WorkEntity;
-import com.gis.oss.util.AliYunOssUtil;
 import com.gis.oss.util.FileUtils;
 import com.gis.service.FodderService;
 import com.gis.service.TestService;
 import com.gis.service.WorkService;
-import com.gis.task.VisitTask;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -64,7 +63,7 @@ public class TestController extends BaseController {
     TestService testService;
 
     @Autowired
-    AliYunOssUtil aliyunOssUtil;
+    FileStorageTemplate ossUtil;
 
     @Autowired
     FodderService fodderService;

+ 5 - 0
720yun_fd_manage/pom.xml

@@ -307,6 +307,11 @@
                 <artifactId>4dkankan-utils-rabbitmq</artifactId>
                 <version>3.0.0-SNAPSHOT</version>
             </dependency>
+            <dependency>
+                <groupId>com.fdkankan</groupId>
+                <artifactId>4dkankan-utils-filestorage</artifactId>
+                <version>3.0.0-SNAPSHOT</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>