|
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
|
+import com.fdkankan.common.response.ResultData;
|
|
|
import com.fdkankan.common.util.FileUtil;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.common.util.MatrixToImageWriterUtil;
|
|
@@ -93,6 +94,8 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
private String fkankanMiniHost;
|
|
|
@Value("${http.api-v4.upgradeToV4ResultSync}")
|
|
|
private String URL_UPGRADE_TO_V4_RESULT_SYNC;
|
|
|
+ @Value("${repair.caches-images:yes}")
|
|
|
+ private String copyCachesImages;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@@ -263,6 +266,15 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
|
|
|
sceneEditInfo.setTitle(scenePro.getSceneName());
|
|
|
sceneEditInfo.setVersion(sceneEditInfo.getVersion() + 1);
|
|
|
+ if(reUpgrade){
|
|
|
+ }
|
|
|
+
|
|
|
+ if(reUpgrade){
|
|
|
+ //场景重算再掉的升级时,需要把imgVersion累加
|
|
|
+ sceneEditInfo.setImgVersion(sceneEditInfo.getImgVersion() + 1);
|
|
|
+ //如果是重算升级,需要重置平面图标识为否
|
|
|
+ sceneEditInfo.setFloorPlanUser(CommonStatus.NO.code().intValue());
|
|
|
+ }
|
|
|
sceneEditInfoService.updateById(sceneEditInfo);
|
|
|
|
|
|
}
|
|
@@ -289,21 +301,27 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
|
|
|
|
|
|
//将全景图缓存到缓存目录
|
|
|
- List<String> imagesList = cn.hutool.core.io.FileUtil.listFileNames(path + "/caches/images");
|
|
|
- String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
|
|
|
- //先清除旧的全景图
|
|
|
- cn.hutool.core.io.FileUtil.del(cachedImagesPath);
|
|
|
- String visionPath = path + "/results/vision.txt";
|
|
|
- List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
|
|
|
- imagesList.stream().forEach(fileName -> {
|
|
|
- if(panoramaImageList.contains(fileName)){
|
|
|
- String srcPath = path + "/caches/images/" + fileName;
|
|
|
- String targetPath = cachedImagesPath + fileName;
|
|
|
- log.info("源文件:{}, 目标文件:{}", srcPath, targetPath);
|
|
|
- cn.hutool.core.io.FileUtil.copy(srcPath, targetPath, true);
|
|
|
+ try {
|
|
|
+ List<String> imagesList = cn.hutool.core.io.FileUtil.listFileNames(path + "/caches/images");
|
|
|
+ String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
|
|
|
+ //先清除旧的全景图
|
|
|
+ cn.hutool.core.io.FileUtil.del(cachedImagesPath);
|
|
|
+ String visionPath = path + "/results/vision.txt";
|
|
|
+ List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
|
|
|
+ imagesList.stream().forEach(fileName -> {
|
|
|
+ if(panoramaImageList.contains(fileName)){
|
|
|
+ String srcPath = path + "/caches/images/" + fileName;
|
|
|
+ String targetPath = cachedImagesPath + fileName;
|
|
|
+ log.info("源文件:{}, 目标文件:{}", srcPath, targetPath);
|
|
|
+ cn.hutool.core.io.FileUtil.copy(srcPath, targetPath, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("拷贝全景图失败,num="+num, e);
|
|
|
+ if("yes".equals(copyCachesImages)){
|
|
|
+ throw e;
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
+ }
|
|
|
// if(CollUtil.isNotEmpty(imagesList)){
|
|
|
// imagesList.stream().forEach(str -> {
|
|
|
// String filePath = str.substring(str.lastIndexOf(File.separator) + 1);
|
|
@@ -374,13 +392,13 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
uploadToOssUtil.copyFiles(imagePath + "logo-main.png", editUsersPath + "loadingLogo-user.png");
|
|
|
uploadToOssUtil.copyFiles(imagePath + "logo-main.png", viewUsersPath + "loadingLogo-user.png");
|
|
|
}
|
|
|
+ String thumbUrl = scenePro.getThumb().replace(imagePath, viewImagesPath);
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getOne(
|
|
|
new LambdaQueryWrapper<ScenePlusExt>()
|
|
|
.eq(ScenePlusExt::getPlusId, scenePro.getId()));
|
|
|
if(StrUtil.isNotEmpty(scenePro.getThumb())
|
|
|
&& scenePro.getThumb().contains(imagePath)
|
|
|
&& !reUpgrade){
|
|
|
- String thumbUrl = null;
|
|
|
if(scenePro.getThumb().contains("thumbSmallImg.jpg")){
|
|
|
uploadToOssUtil.copyFiles(imagePath + "thumbBigImg.jpg", editUsersPath + "thumb-1k.jpg");
|
|
|
uploadToOssUtil.copyFiles(imagePath + "thumbBigImg.jpg", viewUsersPath + "thumb-1k.jpg");
|
|
@@ -389,19 +407,18 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
uploadToOssUtil.copyFiles(imagePath + "thumbSmallImg.jpg", editUsersPath + "thumb-128.jpg");
|
|
|
uploadToOssUtil.copyFiles(imagePath + "thumbSmallImg.jpg", viewUsersPath + "thumb-128.jpg");
|
|
|
thumbUrl = this.ossUrlPrefix + String.format(UploadFilePath.USER_VIEW_PATH, num) + "thumb-128.jpg";
|
|
|
- }else{
|
|
|
- thumbUrl = scenePro.getThumb().replace(imagePath, viewImagesPath);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- String webSite = sceneUrl + num;
|
|
|
- scenePro.setThumb(thumbUrl);
|
|
|
- scenePro.setWebSite(webSite);
|
|
|
- sceneProService.updateById(scenePro);
|
|
|
+ String webSite = sceneUrl + num;
|
|
|
+ scenePro.setThumb(thumbUrl);
|
|
|
+ scenePro.setWebSite(webSite);
|
|
|
+ sceneProService.updateById(scenePro);
|
|
|
+
|
|
|
+ scenePlusExt.setThumb(thumbUrl);
|
|
|
+ scenePlusExt.setWebSite(webSite);
|
|
|
+ scenePlusExtService.updateById(scenePlusExt);
|
|
|
|
|
|
- scenePlusExt.setThumb(thumbUrl);
|
|
|
- scenePlusExt.setWebSite(webSite);
|
|
|
- scenePlusExtService.updateById(scenePlusExt);
|
|
|
- }
|
|
|
if(StrUtil.isNotEmpty(sceneEditInfo.getBoxVideos())){
|
|
|
JSONArray boxVideoArr = JSON.parseArray(sceneEditInfo.getBoxVideos());
|
|
|
for(int i = 0; i < boxVideoArr.size(); i++){
|
|
@@ -424,6 +441,16 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ //上传vision.txt、vision2.txt
|
|
|
+ String visionTxtPath = scenePlusExt.getDataSource() + "/results/vision.txt";
|
|
|
+ String vision2TxtPath = scenePlusExt.getDataSource() + "/results/vision2.txt";
|
|
|
+ if(cn.hutool.core.io.FileUtil.exist(visionTxtPath)){
|
|
|
+ uploadToOssUtil.upload(visionTxtPath, imageViewPath + "vision.txt");
|
|
|
+ }
|
|
|
+ if(cn.hutool.core.io.FileUtil.exist(vision2TxtPath)){
|
|
|
+ uploadToOssUtil.upload(visionTxtPath, imageViewPath + "vision2.txt");
|
|
|
+ }
|
|
|
+
|
|
|
//生成scene.json
|
|
|
// 生成新的scene.json,上传至scene_view_data/<num>/data
|
|
|
SceneJsonBean sceneJson = new SceneJsonBean();
|
|
@@ -440,6 +467,8 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
sceneJson.setVideos(JSON.parseObject(scenePro.getVideos()));
|
|
|
}
|
|
|
sceneJson.setVersion(sceneEditInfo.getVersion());
|
|
|
+ //发布马赛克列表
|
|
|
+ sceneJson.setMosaicList(this.getMosaicList(num));
|
|
|
//上传sceneJson文件
|
|
|
String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH+"scene.json", num);
|
|
|
uploadToOssUtil.upload(JSON.toJSONBytes(sceneJson), sceneJsonPath);
|
|
@@ -457,7 +486,7 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
fdkankanMiniClient.upgradeToV4ResultSync(url,
|
|
|
RequestSceneProV4.builder()
|
|
|
.id(sceneProId)
|
|
|
- .webSite(scenePro.getWebSite())
|
|
|
+ .webSite(scenePlusExt.getWebSite())
|
|
|
.thumb(scenePlusExt.getThumb())
|
|
|
.build(),
|
|
|
new FdkkMiniReqSuccessCallback(), new FdkkMiniReqErrorCallback()
|
|
@@ -481,6 +510,18 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public List<JSONObject> getMosaicList(String num) throws Exception {
|
|
|
+
|
|
|
+ String key = String.format(RedisKey.SCENE_MOSAIC_DATA, num);
|
|
|
+ Map<String, String> map = redisUtil.hmget(key);
|
|
|
+ if(CollUtil.isEmpty(map)){
|
|
|
+ ResultData.ok(new String[0]);
|
|
|
+ }
|
|
|
+ return map.values().stream()
|
|
|
+ .map(mosaic-> JSON.parseObject(mosaic))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
private void copyFileOss(String num, AtomicInteger completeCnt, AtomicInteger count, List<String> keyList, String sourcePath, String targetPah){
|
|
|
if(CollUtil.isEmpty(keyList))
|
|
|
return;
|