Просмотр исходного кода

全景看看下载支持sit,pro

wuweihao 3 лет назад
Родитель
Сommit
680e462033

+ 2 - 1
gis_application/src/main/resources/static/oss_download.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
 ossdir=$1
 locathpath=$2
-/opt/ossutil/ossutil64 cp \-rf oss://oss-xiaoan/$ossdir  $locathpath
+bucket=$3
+/opt/ossutil/ossutil64 cp \-rf oss://$bucket/$ossdir  $locathpath

+ 2 - 1
gis_common/src/main/java/com/gis/common/constant/CmdConstant.java

@@ -36,7 +36,8 @@ public class CmdConstant {
      * ossUtil下载脚本
      * inPath: oss目录
      * outPath: 下载到本地目录
+     * @bucket: oss bucket
      */
-    public final static String OSSUTIL_DOWNLOAD_DIR = "bash /root/java/age_convert_8003/oss_download.sh @inPath @outPath";
+    public final static String OSSUTIL_DOWNLOAD_DIR = "bash /root/java/age_convert_8003/oss_download.sh @inPath @outPath @bucket";
 
 }

+ 1 - 1
gis_service/src/main/java/com/gis/service/AliOssService.java

@@ -12,5 +12,5 @@ import java.util.List;
 public interface AliOssService {
 
 
-    Result batchDownload(List<String> code);
+    Result batchDownload(List<String> code, String bucket);
 }

+ 4 - 3
gis_service/src/main/java/com/gis/service/impl/AliOssServiceImpl.java

@@ -27,13 +27,13 @@ public class AliOssServiceImpl implements AliOssService {
 
 
     @Override
-    public Result batchDownload(List<String> code) {
+    public Result batchDownload(List<String> code, String bucket) {
         log.info("输入场景码数量: {}", code.size());
         String outPath = configConstant.serverBasePath + "720yun_" + StrUtils.getTimeStr();
         log.info("下载目录: {}", outPath);
         int i = 1;
         for (String sceneCode : code) {
-            downloadOss(sceneCode, outPath);
+            downloadOss(sceneCode, outPath, bucket);
             log.info("第:{} 下载完成, 场景为:{}",  i, sceneCode);
             i++;
         }
@@ -46,11 +46,12 @@ public class AliOssServiceImpl implements AliOssService {
      * 下载oss目录
      *  @outPath 下载时会以目录形式下载, 指定输出根目录
      */
-    private void downloadOss(String sceneCode, String outPath){
+    private void downloadOss(String sceneCode, String outPath, String bucket){
         String cmd = CmdConstant.OSSUTIL_DOWNLOAD_DIR;
         String inPath = PathConstant.OSS_720YUN_MANAGE + File.separator + sceneCode;
         cmd = cmd.replaceAll("@inPath", inPath);
         cmd = cmd.replaceAll("@outPath", outPath);
+        cmd = cmd.replaceAll("@bucket", bucket);
         log.info("ossCmd: " + cmd);
         long start = System.currentTimeMillis();
         CmdUtils.callshell(cmd);

+ 4 - 4
gis_web/src/main/java/com/gis/web/controller/AliOssController.java

@@ -26,10 +26,10 @@ public class AliOssController {
     @Autowired
     AliOssService aliOssService;
 
-    @PostMapping("download")
-    @ApiOperation(value = "720yun-批量下载场景数据", notes = "批量下载, 场景码以逗号分隔")
-    public Result batchDownload(@RequestBody List<String> code){
-        return aliOssService.batchDownload(code);
+    @PostMapping("download/{bucket}")
+    @ApiOperation(value = "720yun-批量下载场景数据", notes = "批量下载, 场景码以逗号分隔, bucket: oss-xiaoan:全景看看sit, 4dkankan:全景看看pro")
+    public Result batchDownload(@RequestBody List<String> code, @PathVariable String bucket){
+        return aliOssService.batchDownload(code, bucket);
     }