|
@@ -16,13 +16,13 @@ import com.gis.common.util.FileUtils;
|
|
import com.gis.common.util.Result;
|
|
import com.gis.common.util.Result;
|
|
import com.gis.service.AliOssService;
|
|
import com.gis.service.AliOssService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.junit.Test;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.lang.reflect.Array;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -53,34 +53,46 @@ public class AliOssServiceImpl implements AliOssService {
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
- String workId = param.getWorkId();
|
|
|
|
- // 1.删除旧目录
|
|
|
|
- fileUtils.del("download/" + workId);
|
|
|
|
|
|
+ String workIds = param.getWorkId();
|
|
|
|
+ BaseRuntimeException.isBlank(workIds, null, "作品码不能为空");
|
|
|
|
|
|
- // 2.下载someData.json
|
|
|
|
- downloadSomeDataJson(workId);
|
|
|
|
|
|
+ List<String> list = Arrays.asList(workIds);
|
|
|
|
+ log.info("需要下载作品数量:{}", list.size());
|
|
|
|
|
|
- // 4. 获取导览图集合, key:场景码
|
|
|
|
- HashMap<String, String> sceneData = getGuideThumbBySomeData(workId);
|
|
|
|
|
|
+ ArrayList<Object> pathList = new ArrayList<>();
|
|
|
|
+ int i = 1;
|
|
|
|
+ for (String workId : list) {
|
|
|
|
+ // 1.删除旧目录
|
|
|
|
+ fileUtils.del("download/" + workId);
|
|
|
|
|
|
- // 5.下载导览图
|
|
|
|
- downloadGuideThumb(sceneData, workId);
|
|
|
|
|
|
+ // 2.下载someData.json
|
|
|
|
+ downloadSomeDataJson(workId);
|
|
|
|
|
|
|
|
+ // 4. 获取导览图集合, key:场景码
|
|
|
|
+ HashMap<String, String> sceneData = getGuideThumbBySomeData(workId);
|
|
|
|
|
|
- if (!"dev".equals(configConstant.active)) {
|
|
|
|
- // 6.下载场景
|
|
|
|
- downloadScenes(sceneData, workId, param.getEvn());
|
|
|
|
|
|
+ // 5.下载导览图
|
|
|
|
+ downloadGuideThumb(sceneData, workId);
|
|
|
|
|
|
- // 7.压缩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";
|
|
|
|
+ pathList.add(outPath);
|
|
|
|
+ log.info("第 {} 个作品已下载完, 作品码:{}", i, workId);
|
|
|
|
+ i ++ ;
|
|
|
|
+ }
|
|
|
|
|
|
- String outPath = configConstant.serverBasePath + "/download/" + workId + ".zip";
|
|
|
|
|
|
|
|
DateUtils.expendTime(startTime);
|
|
DateUtils.expendTime(startTime);
|
|
|
|
|
|
- return Result.success(outPath);
|
|
|
|
|
|
+ return Result.success(pathList);
|
|
}
|
|
}
|
|
|
|
|
|
private void zipWork(String workId) {
|
|
private void zipWork(String workId) {
|
|
@@ -220,6 +232,14 @@ public class AliOssServiceImpl implements AliOssService {
|
|
long end = System.currentTimeMillis();
|
|
long end = System.currentTimeMillis();
|
|
log.info("目录下载完成: {}, 耗时:{} s", sceneCode, (end - start) / 1000);
|
|
log.info("目录下载完成: {}, 耗时:{} s", sceneCode, (end - start) / 1000);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void test(){
|
|
|
|
+ String str = "1,2,3";
|
|
|
|
+ List<String> strings = Arrays.asList(str);
|
|
|
|
+ System.out.println(strings);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|