|
@@ -0,0 +1,119 @@
|
|
|
|
+package com.fdkankan.scene.service.impl;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
|
+import cn.hutool.core.util.CharsetUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.core.util.ZipUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
|
+import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
|
+import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
|
|
+import com.fdkankan.scene.entity.SceneAsynOperLog;
|
|
|
|
+import com.fdkankan.scene.entity.ScenePlus;
|
|
|
|
+import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
|
+import com.fdkankan.scene.service.IRemovePortraitService;
|
|
|
|
+import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
|
|
+import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
|
+import com.fdkankan.scene.service.IScenePlusService;
|
|
|
|
+import com.fdkankan.scene.vo.UploadPanoramaVO;
|
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class RemovePortraitServiceImpl implements IRemovePortraitService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
|
+ @Resource
|
|
|
|
+ private FYunFileServiceInterface fileServiceInterface;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneEditInfoService sceneEditInfoService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void removePortrait(JSONObject param) throws Exception {
|
|
|
|
+ String num = param.getString("num");
|
|
|
|
+
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
+
|
|
|
|
+ //原始计算根目录
|
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
|
+ //全景图计算根目录
|
|
|
|
+ String target = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + uuid;
|
|
|
|
+ //解压缩文件存放目录
|
|
|
|
+ String targetImagesPath = target + "/extras/images/";
|
|
|
|
+ //下载文件
|
|
|
|
+ String cacheImagesPath = String.format(UploadFilePath.scene_result_data_path, num) + "caches/images/";
|
|
|
|
+ List<String> imagesList = fileServiceInterface.listRemoteFiles(cacheImagesPath);
|
|
|
|
+ if(CollUtil.isNotEmpty(imagesList)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ imagesList.stream().forEach(key->{
|
|
|
|
+ if(key.endsWith(".jpg")){
|
|
|
|
+ fileServiceInterface.downloadFile(key, targetImagesPath + FileUtil.getName(key));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
|
+// fYunFileService.downloadFile(bucket, imgViewPath + "vision.modeldata", target + File.separator + "extras" + File.separator + "vision.modeldata");
|
|
|
|
+// CreateObjUtil.convertVisionmodeldataToTxt(target + File.separator + "extras" + File.separator + "vision.modeldata",
|
|
|
|
+// target + File.separator + "extras" + File.separator + "vision.txt");
|
|
|
|
+//
|
|
|
|
+// String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
|
|
|
|
+// fYunFileService.downloadFile(bucket, ossResultPath + "data.json", target + File.separator+"data.json");
|
|
|
|
+// fYunFileService.downloadFile(bucket, ossResultPath + "project.json", target + File.separator+"project.json");
|
|
|
|
+
|
|
|
|
+ //data.json增加extras为执行重建算法
|
|
|
|
+ JSONObject floorplanJson = new JSONObject();
|
|
|
|
+ floorplanJson.put("has_source_images", true);
|
|
|
|
+ floorplanJson.put("has_vision_txt", true);
|
|
|
|
+
|
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
|
+ dataJson.put("extras", floorplanJson);
|
|
|
|
+ dataJson.put("split_type", "SPLIT_V28");
|
|
|
|
+ //V5表示不需要生成high,low文件
|
|
|
|
+ String skyboxType = "SKYBOX_V6";
|
|
|
|
+ if(scenePlusExt.getSceneScheme() == 11){
|
|
|
|
+ skyboxType = "SKYBOX_V7";
|
|
|
|
+ }
|
|
|
|
+ //sceneScheme为3切成瓦片图
|
|
|
|
+ if(scenePlusExt.getSceneScheme() == 3){
|
|
|
|
+ if("4k".equals(scenePlusExt.getSceneResolution())){
|
|
|
|
+ skyboxType = "SKYBOX_V14";
|
|
|
|
+ }else{
|
|
|
|
+ skyboxType = "SKYBOX_V13";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dataJson.put("skybox_type", skyboxType);
|
|
|
|
+ FileUtil.writeUtf8String(dataJson.toJSONString(), target + File.separator+"data.json");
|
|
|
|
+
|
|
|
|
+ if(new File(target + File.separator + "capture").exists()){
|
|
|
|
+ new File(target + File.separator + "capture").delete();
|
|
|
|
+ }
|
|
|
|
+ if(new File(target + File.separator + "results").exists()){
|
|
|
|
+ FileUtils.delAllFile(target + File.separator + "results");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sceneEditInfoService.uploadPanoramaHandler(num,bucket,target,imgViewPath,new ArrayList<>(),targetImagesPath);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|