wuweihao преди 3 години
родител
ревизия
d289eacb00

+ 4 - 0
gis_common/src/main/java/com/gis/common/constant/ConfigConstant.java

@@ -11,6 +11,10 @@ import org.springframework.stereotype.Component;
 @Component
 public class ConfigConstant {
 
+    /**环境配置*/
+    @Value("${spring.profiles.active}")
+    public String active;
+
     /** 服务器文件地址*/
     @Value("${server.file.path}")
     public  String serverBasePath;

+ 27 - 24
gis_service/src/main/java/com/gis/service/impl/AliOssServiceImpl.java

@@ -38,7 +38,7 @@ public class AliOssServiceImpl implements AliOssService {
     @Autowired
     FileUtils fileUtils;
 
-    static final  HashMap<Object, String> bucketMap;
+    static final HashMap<Object, String> bucketMap;
 
     static {
         bucketMap = new HashMap<>();
@@ -66,13 +66,17 @@ public class AliOssServiceImpl implements AliOssService {
         // 5.下载导览图
         downloadGuideThumb(sceneData, workId);
 
-        // 3.下载场景
-        downloadScenes(sceneData, workId, param.getEvn());
 
-        // 6.压缩zip
-        zipWork(workId);
+        if (!"dev".equals(configConstant.active)) {
+            // 6.下载场景
+            downloadScenes(sceneData, workId, param.getEvn());
+
+            // 7.压缩zip
+            zipWork(workId);
+        }
 
-        String outPath = configConstant.serverBasePath + "/download/" + workId +".zip";
+
+        String outPath = configConstant.serverBasePath + "/download/" + workId + ".zip";
 
         DateUtils.expendTime(startTime);
 
@@ -80,11 +84,11 @@ public class AliOssServiceImpl implements AliOssService {
     }
 
     private void zipWork(String workId) {
-        String outPath = configConstant.serverBasePath + "/download/" + workId +".zip";
+        String outPath = configConstant.serverBasePath + "/download/" + workId + ".zip";
 
         String cmd = CmdConstant.zip;
         cmd = cmd.replaceAll("@output", outPath);
-        cmd = cmd.replaceAll("@workPace", configConstant.serverBasePath + "/download" );
+        cmd = cmd.replaceAll("@workPace", configConstant.serverBasePath + "/download");
         // 已引入工作目录, 直接填写目录即可
         cmd = cmd.replaceAll("@inDir", workId);
 
@@ -97,7 +101,7 @@ public class AliOssServiceImpl implements AliOssService {
     /**
      * 下载场景目录
      */
-    private void downloadScenes(List<String> sceneCodes, String workId, String evn){
+    private void downloadScenes(List<String> sceneCodes, String workId, String evn) {
         log.info("输入场景码数量: {}", sceneCodes.size());
 
         String bucket = bucketMap.get(evn);
@@ -106,7 +110,7 @@ public class AliOssServiceImpl implements AliOssService {
         int i = 1;
         for (String sceneCode : sceneCodes) {
             downloadOss(sceneCode, bucket, workId);
-            log.info("第:{} 下载完成, 场景为:{}",  i, sceneCode);
+            log.info("第:{} 下载完成, 场景为:{}", i, sceneCode);
             i++;
         }
     }
@@ -114,7 +118,7 @@ public class AliOssServiceImpl implements AliOssService {
     /**
      * 下载场景目录
      */
-    private void downloadScenes(HashMap<String, String> guideThumbs, String workId, String evn){
+    private void downloadScenes(HashMap<String, String> guideThumbs, String workId, String evn) {
         log.info("输入场景码数量: {}", guideThumbs.size());
 
         String bucket = bucketMap.get(evn);
@@ -124,7 +128,7 @@ public class AliOssServiceImpl implements AliOssService {
         for (Map.Entry<String, String> entry : guideThumbs.entrySet()) {
             String sceneCode = entry.getKey();
             downloadOss(sceneCode, bucket, workId);
-            log.info("第:{} 下载完成, 场景为:{}",  i, sceneCode);
+            log.info("第:{} 下载完成, 场景为:{}", i, sceneCode);
             i++;
         }
         log.info("场景已下载完成");
@@ -140,7 +144,7 @@ public class AliOssServiceImpl implements AliOssService {
      *
      * @param workId
      */
-    private  HashMap<String, String> getGuideThumbBySomeData(String workId){
+    private HashMap<String, String> getGuideThumbBySomeData(String workId) {
         String someDataPath = configConstant.serverBasePath + "/download/" + workId + "/someData.json";
         String str = FileUtil.readString(someDataPath, "utf-8");
         JSONObject parent = JSONObject.parseObject(str);
@@ -160,26 +164,26 @@ public class AliOssServiceImpl implements AliOssService {
     }
 
 
-
     /**
      * 下载导览封面图片
+     *
      * @param iconMap 需要下载的缩略图
      * @param workId
      */
-    private void downloadGuideThumb(Map<String, String> iconMap, String workId){
+    private void downloadGuideThumb(Map<String, String> iconMap, String workId) {
         String savePath = configConstant.serverBasePath + "/download/" + workId + "/images/";
-        if (!FileUtil.exist(savePath)){
+        if (!FileUtil.exist(savePath)) {
             FileUtil.mkdir(savePath);
         }
         for (Map.Entry<String, String> m : iconMap.entrySet()) {
             String sceneCode = m.getKey();
             String ossUrl = m.getValue();
-            if (!ossUrl.contains("preview.jpg")){
+            if (!ossUrl.contains("preview.jpg")) {
                 String fileName = StrUtil.subAfter(ossUrl, "/", true);
                 fileName = StrUtil.subBefore(fileName, "?d", true);
                 String filePath = savePath + fileName;
-                HttpUtil.downloadFile(ossUrl, filePath);
                 log.info("场景:{} 保存路径: {}", sceneCode, filePath);
+                HttpUtil.downloadFile(ossUrl, filePath);
             }
 
         }
@@ -190,9 +194,9 @@ public class AliOssServiceImpl implements AliOssService {
     /**
      * 下载someData.json
      */
-    private void downloadSomeDataJson(String workId){
+    private void downloadSomeDataJson(String workId) {
         String baseUrl = "https://4dkk.4dage.com/720yun_fd_manage/";
-        String url = baseUrl + workId + "/someData.json?m="+ System.currentTimeMillis();
+        String url = baseUrl + workId + "/someData.json?m=" + System.currentTimeMillis();
         String savePath = configConstant.serverBasePath + "/download/" + workId + "/someData.json";
         HttpUtil.downloadFile(url, savePath);
         log.info("下载someData.json完成: {}", workId);
@@ -200,11 +204,10 @@ public class AliOssServiceImpl implements AliOssService {
 
     /**
      * 下载oss目录
-     *  @outPath 下载时会以目录形式下载, 指定输出根目录
-     *
      *
+     * @outPath 下载时会以目录形式下载, 指定输出根目录
      */
-    private void downloadOss(String sceneCode,  String bucket, String workId){
+    private void downloadOss(String sceneCode, String bucket, String workId) {
         String cmd = CmdConstant.OSSUTIL_DOWNLOAD_DIR;
         String inPath = PathConstant.OSS_720YUN_MANAGE + File.separator + sceneCode;
         String outPath = configConstant.serverBasePath + "/download/" + workId;
@@ -215,7 +218,7 @@ public class AliOssServiceImpl implements AliOssService {
         long start = System.currentTimeMillis();
         CmdUtils.callshell(cmd);
         long end = System.currentTimeMillis();
-        log.info("目录下载完成: {}, 耗时:{} s" , sceneCode, (end-start)/1000 );
+        log.info("目录下载完成: {}, 耗时:{} s", sceneCode, (end - start) / 1000);
     }
 }