|
@@ -6,9 +6,12 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.fdkankan.common.bean.DownLoadProgressBean;
|
|
import com.fdkankan.common.bean.DownLoadProgressBean;
|
|
import com.fdkankan.common.bean.DownLoadTaskBean;
|
|
import com.fdkankan.common.bean.DownLoadTaskBean;
|
|
import com.fdkankan.common.constant.SceneDownloadProgressStatus;
|
|
import com.fdkankan.common.constant.SceneDownloadProgressStatus;
|
|
|
|
+import com.fdkankan.common.constant.SceneFrom;
|
|
|
|
+import com.fdkankan.common.constant.SceneResolution;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
import com.fdkankan.common.response.ResultData;
|
|
import com.fdkankan.common.response.ResultData;
|
|
@@ -96,6 +99,9 @@ public class SceneDownloadHandlerServiceImpl {
|
|
@Value("${zip.nThreads}")
|
|
@Value("${zip.nThreads}")
|
|
private int zipNthreads;
|
|
private int zipNthreads;
|
|
|
|
|
|
|
|
+ @Value("${oss.bucket:4dkankan}")
|
|
|
|
+ private String bucket;
|
|
|
|
+
|
|
@Value("${upload.type:oss}")
|
|
@Value("${upload.type:oss}")
|
|
private String uploadType;
|
|
private String uploadType;
|
|
@Value("${download.config.resource-url}")
|
|
@Value("${download.config.resource-url}")
|
|
@@ -170,19 +176,28 @@ public class SceneDownloadHandlerServiceImpl {
|
|
}
|
|
}
|
|
ZipOutputStream out = new ZipOutputStream(zipFile);
|
|
ZipOutputStream out = new ZipOutputStream(zipFile);
|
|
|
|
|
|
- JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
|
|
|
|
- String resolution = "2k";
|
|
|
|
- if(getInfoJson.getInt("sceneSource") != null &&
|
|
|
|
- (getInfoJson.getInt("sceneSource") == 3 || getInfoJson.getInt("sceneSource") == 4)){
|
|
|
|
- resolution = "4k";
|
|
|
|
|
|
+// JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
|
|
|
|
+ String sceneJsonData = uploadToOssUtil.getObjectContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
|
|
|
|
+ JSONObject sceneJson = JSONUtil.parseObj(sceneJsonData);
|
|
|
|
+ String resolution = "4k";
|
|
|
|
+ String sceneForm = sceneJson.getStr("sceneFrom");
|
|
|
|
+ if(StrUtil.isNotEmpty(sceneForm) && SceneFrom.PRO.code().equals(sceneForm)){
|
|
|
|
+ resolution = "2k";
|
|
|
|
+ }
|
|
|
|
+ //国际版存在已经切好图的情况,下载时不需要再切图,只需要把文件直接下载下来打包就可以了
|
|
|
|
+ String sceneResolution = sceneJson.getStr("sceneResolution");
|
|
|
|
+ if(SceneResolution.TILES.code().equals(sceneResolution)){
|
|
|
|
+ resolution = "notNeadCut";
|
|
}
|
|
}
|
|
|
|
+
|
|
int imagesVersion = -1;
|
|
int imagesVersion = -1;
|
|
// TODO: 2022/3/29 V4版本目前没有imagesVersion字段,暂时用version字段替代
|
|
// TODO: 2022/3/29 V4版本目前没有imagesVersion字段,暂时用version字段替代
|
|
// if(getInfoJson.getInt("imagesVersion") != null){
|
|
// if(getInfoJson.getInt("imagesVersion") != null){
|
|
// imagesVersion = getInfoJson.getInt("imagesVersion");
|
|
// imagesVersion = getInfoJson.getInt("imagesVersion");
|
|
// }
|
|
// }
|
|
- if(getInfoJson.getInt("version") != null){
|
|
|
|
- imagesVersion = getInfoJson.getInt("version");
|
|
|
|
|
|
+ Integer version = sceneJson.getInt("version");
|
|
|
|
+ if(Objects.nonNull(version)){
|
|
|
|
+ imagesVersion = version;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -198,6 +213,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
long end2 = Calendar.getInstance().getTimeInMillis();
|
|
long end2 = Calendar.getInstance().getTimeInMillis();
|
|
log.info("打包oss文件耗时, num:{}, time:{}", num, end2 - end1);
|
|
log.info("打包oss文件耗时, num:{}, time:{}", num, end2 - end1);
|
|
|
|
|
|
|
|
+ //重新写入scene.json(去掉密码访问设置)
|
|
|
|
+ this.zipSceneJson(out, this.wwwroot, num, sceneJson);
|
|
|
|
|
|
//写入启动命令
|
|
//写入启动命令
|
|
this.zipBat(out, num);
|
|
this.zipBat(out, num);
|
|
@@ -272,14 +289,16 @@ public class SceneDownloadHandlerServiceImpl {
|
|
return;
|
|
return;
|
|
|
|
|
|
//切图
|
|
//切图
|
|
- if((filePath.contains(imageNumPath + "panorama/") && filePath.contains("tiles/" + resolution))
|
|
|
|
- || filePath.contains(imageNumPath + "tiles/" + resolution + "/")) {
|
|
|
|
- this.processImage(filePath, out, resolution, imagesVersion, cacheKeys);
|
|
|
|
- return;
|
|
|
|
|
|
+ if(!"notNeadCut".equals(resolution)){
|
|
|
|
+ if((filePath.contains(imageNumPath + "panorama/") && filePath.contains("tiles/" + resolution))
|
|
|
|
+ || filePath.contains(imageNumPath + "tiles/" + resolution + "/")) {
|
|
|
|
+ this.processImage(filePath, out, resolution, imagesVersion, cacheKeys);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//其他文件打包
|
|
//其他文件打包
|
|
- this.ProcessFiles(filePath, out, this.wwwroot, cacheKeys);
|
|
|
|
|
|
+ this.ProcessFiles(num, filePath, out, this.wwwroot, cacheKeys);
|
|
}
|
|
}
|
|
|
|
|
|
private void zipLocalFiles(ZipOutputStream out, List<String> v3localFilePaths, String v3localPath, String num, AtomicInteger count, int total) throws Exception{
|
|
private void zipLocalFiles(ZipOutputStream out, List<String> v3localFilePaths, String v3localPath, String num, AtomicInteger count, int total) throws Exception{
|
|
@@ -361,6 +380,16 @@ public class SceneDownloadHandlerServiceImpl {
|
|
return getInfoJson;
|
|
return getInfoJson;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void zipSceneJson(ZipOutputStream out, String root, String num, JSONObject sceneJson) throws Exception{
|
|
|
|
+
|
|
|
|
+ //访问密码置0
|
|
|
|
+ JSONObject controls = sceneJson.getJSONObject("controls");
|
|
|
|
+ controls.set("showLock", 0);
|
|
|
|
+
|
|
|
|
+ String sceneJsonPath = root + String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
|
|
|
|
+ this.zipBytes(out, sceneJsonPath, sceneJson.toString().getBytes());
|
|
|
|
+ }
|
|
|
|
+
|
|
private void processImage(String key, ZipOutputStream out, String resolution, int imagesVersion, Set<String> imgKeys) throws Exception{
|
|
private void processImage(String key, ZipOutputStream out, String resolution, int imagesVersion, Set<String> imgKeys) throws Exception{
|
|
|
|
|
|
String fileName = key.substring(key.lastIndexOf("/")+1, key.indexOf("."));
|
|
String fileName = key.substring(key.lastIndexOf("/")+1, key.indexOf("."));
|
|
@@ -424,10 +453,13 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public void ProcessFiles(String key, ZipOutputStream out, String prefix, Set<String> cacheKeys) throws Exception{
|
|
|
|
|
|
+ public void ProcessFiles(String num, String key, ZipOutputStream out, String prefix, Set<String> cacheKeys) throws Exception{
|
|
if(cacheKeys.contains(key)){
|
|
if(cacheKeys.contains(key)){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ if(key.equals(String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json")){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
cacheKeys.add(key);
|
|
cacheKeys.add(key);
|
|
String url = this.resourceUrl + key + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
String url = this.resourceUrl + key + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
if(key.contains("hot.json") || key.contains("link-scene.json")){
|
|
if(key.contains("hot.json") || key.contains("link-scene.json")){
|