dengsixing 3 年之前
父节点
当前提交
66d069b348
共有 1 个文件被更改,包括 35 次插入41 次删除
  1. 35 41
      src/main/java/com/fdkankan/repair/service/impl/SceneUpgradeToV4Service.java

+ 35 - 41
src/main/java/com/fdkankan/repair/service/impl/SceneUpgradeToV4Service.java

@@ -321,47 +321,15 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
             List<String> imageKeys = uploadToOssUtil.listKeys(imagePath);
             List<String> videoKeys = uploadToOssUtil.listKeys(videoPath);
             List<String> voiceKeys = uploadToOssUtil.listKeys(voicePath);
-            if(CollUtil.isNotEmpty(dataKeys))
-                list.addAll(dataKeys);
-                count.addAndGet(dataKeys.size());
-            if(CollUtil.isNotEmpty(imageKeys))
-                list.addAll(imageKeys);
-                count.addAndGet(imageKeys.size());
-            if(CollUtil.isNotEmpty(videoKeys))
-                list.addAll(videoKeys);
-                count.addAndGet(videoKeys.size());
-            if(CollUtil.isNotEmpty(voiceKeys))
-                list.addAll(voiceKeys);
-                count.addAndGet(voiceKeys.size());
-            if(CollUtil.isNotEmpty(dataKeys)){
-                list.parallelStream().forEach(key->{
-                    try {
-                        String targetKey = null;
-                        if(key.contains(dataPath)){
-                            targetKey = key.replace(dataPath, dataViewPath);
-                        }
-                        if(key.contains(imagePath)){
-                            targetKey = key.replace(imagePath, imageViewPath);
-                        }
-                        if(key.contains(videoPath)){
-                            targetKey = key.replace(videoPath, videoViewPath);
-                        }
-                        uploadToOssUtil.copyObject(key, targetKey);
-                        this.updateProgress(num,
-                            10 +
-                                (new BigDecimal(completeCnt.incrementAndGet())
-                                .divide(new BigDecimal(count.get()), 6, BigDecimal.ROUND_HALF_UP)
-                                    .multiply(new BigDecimal(0.7))
-                                    .multiply(new BigDecimal(100))
-                                    .setScale(0, RoundingMode.UP)
-                                    .intValue()),
-                            ProgressStatus.DO_OSS.code()
-                        );
-                    } catch (IOException e) {
-                        log.error("文件拷贝出错,key:{}", key);
-                    }
-                });
-            }
+            if(CollUtil.isNotEmpty(dataKeys)) count.addAndGet(dataKeys.size());
+            if(CollUtil.isNotEmpty(imageKeys)) count.addAndGet(imageKeys.size());
+            if(CollUtil.isNotEmpty(videoKeys)) count.addAndGet(videoKeys.size());
+            if(CollUtil.isNotEmpty(voiceKeys)) count.addAndGet(voiceKeys.size());
+            this.copyFileOss(num, completeCnt, count, dataKeys, dataPath, dataViewPath);
+            this.copyFileOss(num, completeCnt, count, imageKeys, imagePath, imageViewPath);
+            this.copyFileOss(num, completeCnt, count, videoKeys, videoPath, videoViewPath);
+            this.copyFileOss(num, completeCnt, count, voiceKeys, voicePath, voiceViewPath);
+
 
             //全景图上传、球幕视频
             Map<String, String> map = new HashMap<>();
@@ -509,6 +477,32 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
         }
     }
 
+    private void copyFileOss(String num, AtomicInteger completeCnt, AtomicInteger count, List<String> keyList, String sourcePath, String targetPah){
+        if(CollUtil.isEmpty(keyList))
+            return;
+        keyList.parallelStream().forEach(key->{
+            try {
+                String targetKey = null;
+                if(key.contains(sourcePath)){
+                    targetKey = key.replace(sourcePath, targetPah);
+                }
+                uploadToOssUtil.copyObject(key, targetKey);
+                this.updateProgress(num,
+                    10 +
+                        (new BigDecimal(completeCnt.incrementAndGet())
+                            .divide(new BigDecimal(count.get()), 6, BigDecimal.ROUND_HALF_UP)
+                            .multiply(new BigDecimal(0.7))
+                            .multiply(new BigDecimal(100))
+                            .setScale(0, RoundingMode.UP)
+                            .intValue()),
+                    ProgressStatus.DO_OSS.code()
+                );
+            } catch (IOException e) {
+                log.error("文件拷贝出错,key:{}", key);
+            }
+        });
+    }
+
     private Float getFloorPlanCompass(String num){
         String objectContent =
             uploadToOssUtil.getObjectContent(bucket, "data/data" + num + "/houst_floor.json");