|
@@ -11,19 +11,12 @@ import cn.hutool.core.util.ZipUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
-import com.fdkankan.common.constant.SceneDownloadProgressStatus;
|
|
|
-import com.fdkankan.common.constant.SceneFrom;
|
|
|
-import com.fdkankan.common.constant.SceneKind;
|
|
|
-import com.fdkankan.common.constant.SceneResolution;
|
|
|
-import com.fdkankan.common.constant.ServerCode;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
-import com.fdkankan.download.bean.CurrentDownloadNumUtil;
|
|
|
-import com.fdkankan.download.bean.DownLoadProgressBean;
|
|
|
-import com.fdkankan.download.bean.DownLoadTaskBean;
|
|
|
-import com.fdkankan.download.bean.ImageType;
|
|
|
-import com.fdkankan.download.bean.ImageTypeDetail;
|
|
|
+import com.fdkankan.download.bean.*;
|
|
|
import com.fdkankan.download.entity.ScenePlus;
|
|
|
import com.fdkankan.download.entity.ScenePlusExt;
|
|
|
import com.fdkankan.download.entity.ScenePro;
|
|
@@ -89,6 +82,7 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
|
|
|
private static final List<ImageType> imageTypes = Lists.newArrayList();
|
|
|
static{
|
|
|
+ imageTypes.add(ImageType.builder().name("4k_face").size("4096").ranges(new String[]{"0", "511", "1023", "1535", "2047","2559","3071","3583"}).build());
|
|
|
imageTypes.add(ImageType.builder().name("2k_face").size("2048").ranges(new String[]{"0", "511", "1023", "1535"}).build());
|
|
|
imageTypes.add(ImageType.builder().name("1k_face").size("1024").ranges(new String[]{"0", "511"}).build());
|
|
|
imageTypes.add(ImageType.builder().name("512_face").size("512").ranges(new String[]{"0"}).build());
|
|
@@ -110,7 +104,7 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
private String wwwroot;
|
|
|
@Value("${zip.nThreads}")
|
|
|
private int zipNthreads;
|
|
|
- @Value("${oss.bucket:4dkankan}")
|
|
|
+ @Value("${fyun.bucket:4dkankan}")
|
|
|
private String bucket;
|
|
|
@Value("${fyun.type}")
|
|
|
private String uploadType;
|
|
@@ -234,16 +228,15 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
zipFile.getParentFile().mkdirs();
|
|
|
}
|
|
|
|
|
|
- String sceneJsonData = fYunFileService.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
|
|
|
- JSONObject sceneJson = JSONUtil.parseObj(sceneJsonData);
|
|
|
- String resolution = sceneJson.getStr("sceneResolution");
|
|
|
+ SceneViewInfo sceneViewInfo = this.getSceneJson(num);
|
|
|
+ String resolution = sceneViewInfo.getSceneResolution();
|
|
|
//国际版存在已经切好图的情况,下载时不需要再切图,只需要把文件直接下载下来打包就可以了
|
|
|
- if(SceneKind.FACE.code().equals(sceneJson.getStr("sceneKind"))){
|
|
|
+ if(SceneKind.FACE.code().equals(sceneViewInfo.getSceneKind())){
|
|
|
resolution = "notNeadCut";
|
|
|
}
|
|
|
|
|
|
int imagesVersion = -1;
|
|
|
- Integer version = sceneJson.getInt("version");
|
|
|
+ Integer version = sceneViewInfo.getVersion();
|
|
|
if(Objects.nonNull(version)){
|
|
|
imagesVersion = version;
|
|
|
}
|
|
@@ -257,7 +250,7 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
log.info("打包oss文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
|
|
|
//重新写入scene.json(去掉密码访问设置)
|
|
|
- this.zipSceneJson(num, sceneJson);
|
|
|
+ this.zipSceneJson(num, sceneViewInfo);
|
|
|
|
|
|
//写入启动命令
|
|
|
this.zipBat(num, "v4");
|
|
@@ -278,11 +271,42 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
this.updateProgress( null, num, SceneDownloadProgressStatus.DOWNLOAD_FAILED.code(), null, "v4");
|
|
|
throw e;
|
|
|
}finally {
|
|
|
-// FileUtil.del(zipPath);
|
|
|
-// FileUtil.del(String.format(this.sourceLocal, num, ""));
|
|
|
+ FileUtil.del(zipPath);
|
|
|
+ FileUtil.del(String.format(this.sourceLocal, num, ""));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private SceneViewInfo getSceneJson(String num){
|
|
|
+ String sceneJsonData = redisUtil.get(String.format(RedisKey.SCENE_JSON, num));
|
|
|
+ if(StrUtil.isEmpty(sceneJsonData)){
|
|
|
+ sceneJsonData = fYunFileService.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
|
|
|
+ }
|
|
|
+ sceneJsonData = sceneJsonData.replace(this.publicUrl, "");
|
|
|
+ SceneViewInfo sceneInfoVO = JSON.parseObject(sceneJsonData, SceneViewInfo.class);
|
|
|
+ sceneInfoVO.setScenePassword(null);
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
|
|
|
+ sceneInfoVO.setFloorPlanAngle(0f);
|
|
|
+ }
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
|
|
|
+ sceneInfoVO.setFloorPlanCompass(0f);
|
|
|
+ }
|
|
|
+ SceneEditControlsVO controls = sceneInfoVO.getControls();
|
|
|
+ if(Objects.isNull(controls.getShowShare())){
|
|
|
+ controls.setShowShare(CommonStatus.YES.code().intValue());
|
|
|
+ }
|
|
|
+ if(Objects.isNull(controls.getShowCapture())){
|
|
|
+ controls.setShowCapture(CommonStatus.YES.code().intValue());
|
|
|
+ }
|
|
|
+ if(Objects.isNull(controls.getShowBillboardTitle())){
|
|
|
+ controls.setShowBillboardTitle(CommonStatus.YES.code().intValue());
|
|
|
+ }
|
|
|
+ if(Objects.isNull(controls.getShowDrawTitle())){
|
|
|
+ controls.setShowDrawTitle(CommonStatus.YES.code().intValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ return sceneInfoVO;
|
|
|
+ }
|
|
|
+
|
|
|
public void downloadHandlerV3(DownLoadTaskBean downLoadTaskBean) throws Exception{
|
|
|
|
|
|
String num = downLoadTaskBean.getSceneNum();
|
|
@@ -412,6 +436,7 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
zipSuccess = false;
|
|
|
}
|
|
|
}
|
|
|
+ executorService.shutdown();
|
|
|
if(!zipSuccess){
|
|
|
throw new Exception("打包oss文件失败");
|
|
|
}
|
|
@@ -438,6 +463,9 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
if((filePath.contains(imageNumPath + "panorama/") && filePath.contains("tiles/" + resolution))
|
|
|
|| filePath.contains(imageNumPath + "tiles/" + resolution + "/")) {
|
|
|
this.processImage(num, filePath, resolution, imagesVersion, cacheKeys);
|
|
|
+ //更新进度
|
|
|
+ this.updateProgress(new BigDecimal(count.incrementAndGet()).divide(new BigDecimal(total), 6, BigDecimal.ROUND_HALF_UP),
|
|
|
+ num, SceneDownloadProgressStatus.DOWNLOADING.code(), null, version);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -545,25 +573,20 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- private void zipSceneJson(String num, JSONObject sceneJson) throws Exception{
|
|
|
+ private void zipSceneJson(String num, SceneViewInfo sceneViewInfo) throws Exception{
|
|
|
//访问密码置0
|
|
|
- JSONObject controls = sceneJson.getJSONObject("controls");
|
|
|
- controls.set("showLock", 0);
|
|
|
- String videos = sceneJson.getStr("videos");
|
|
|
- videos = videos.replaceAll(File.separator.concat("oss").concat(File.separator), "");
|
|
|
- sceneJson.replace("videos", videos);
|
|
|
- log.info("videos:{}",videos);
|
|
|
+ SceneEditControlsVO controls = sceneViewInfo.getControls();
|
|
|
+ controls.setShowLock(CommonStatus.NO.code().intValue());
|
|
|
String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
|
|
|
- log.info("sceneJson.toString():{}",sceneJson.toString());
|
|
|
- FileUtil.writeUtf8String(sceneJson.toString().replaceAll(File.separator.concat("oss").concat(File.separator), "")
|
|
|
- , String.format(this.sourceLocal, num, this.wwwroot + sceneJsonPath));
|
|
|
+ FileUtil.writeUtf8String(JSON.toJSONString(sceneViewInfo, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero), String.format(this.sourceLocal, num, this.wwwroot + sceneJsonPath));
|
|
|
}
|
|
|
|
|
|
private void zipGetInfoJson(String num, JSONObject getInfo) throws Exception{
|
|
|
|
|
|
//访问密码置0
|
|
|
String getInfoKey = String.format("data/data%s/", num) + "getInfo.json";
|
|
|
- FileUtil.writeUtf8String(getInfo.toString(), String.format(this.sourceLocal, num, this.wwwroot + getInfoKey));
|
|
|
+ String getInfoStr = getInfo.toString().replace(this.publicUrl, "");
|
|
|
+ FileUtil.writeUtf8String(getInfoStr, String.format(this.sourceLocal, num, this.wwwroot + getInfoKey));
|
|
|
}
|
|
|
|
|
|
private void processImage(String sceneNum, String key, String resolution, int imagesVersion, Set<String> imgKeys) throws Exception{
|
|
@@ -586,6 +609,10 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
}
|
|
|
for (ImageType imageType : imageTypes) {
|
|
|
|
|
|
+ if(imageType.getName().equals("4k_face") && !"4k".equals(resolution)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
List<ImageTypeDetail> items = Lists.newArrayList();
|
|
|
String[] ranges = imageType.getRanges();
|
|
|
for(int i = 0; i < ranges.length; i++){
|
|
@@ -650,9 +677,11 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
String fileName = key.substring(key.lastIndexOf("/") + 1);
|
|
|
String url = this.resourceUrl + key.replace(fileName, URLEncoder.encode(fileName, "UTF-8")) + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
if(key.contains("hot.json") || key.contains("link-scene.json")){
|
|
|
-// String content = FileUtils.getStringFromUrl(url);
|
|
|
String content = fYunFileService.getFileContent(key);
|
|
|
- content.replace(publicUrl, "")
|
|
|
+ if(StrUtil.isEmpty(content)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ content = content.replace(publicUrl, "")
|
|
|
// .replace(publicUrl+"v3/", "")
|
|
|
.replace("https://spc.html","spc.html")
|
|
|
.replace("https://smobile.html", "smobile.html");
|