|
@@ -42,6 +42,7 @@ import com.fdkankan.scene.service.*;
|
|
|
import com.fdkankan.scene.vo.*;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Sets;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.joda.time.DateTime;
|
|
@@ -4168,167 +4169,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResultData savePanorama(FileParamVO param, MultipartFile file) throws Exception {
|
|
|
- String sceneNum = param.getNum();
|
|
|
- String sid = param.getSid();
|
|
|
- String imagesName = param.getFileName();
|
|
|
- if(StrUtil.isEmpty(sceneNum) || StrUtil.isEmpty(sid)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
-
|
|
|
- ScenePro scenePro = baseMapper.findByNum(sceneNum);
|
|
|
- if(scenePro == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
- SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
|
|
|
-
|
|
|
- StringBuffer dataBuf = new StringBuffer()
|
|
|
- .append("data").append(File.separator)
|
|
|
- .append("data").append(scenePro.getNum())
|
|
|
- .append(File.separator);
|
|
|
-
|
|
|
- StringBuffer imagesBuf = new StringBuffer()
|
|
|
- .append("images").append(File.separator)
|
|
|
- .append("images").append(scenePro.getNum())
|
|
|
- .append(File.separator);
|
|
|
-
|
|
|
- StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
|
|
|
- StringBuffer imagesBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(imagesBuf.toString());
|
|
|
-
|
|
|
- String path = sceneProExt.getDataSource();
|
|
|
- String target = imagesBuffer.toString() + "panorama/" + sid;
|
|
|
- FileUtils.deleteDirectory(target);
|
|
|
-
|
|
|
- //文件上传的位置可以自定义
|
|
|
- String filePath = target + File.separator + "extras/images" + File.separator + imagesName;
|
|
|
-
|
|
|
- File targetFile = new File(filePath);
|
|
|
- if(!targetFile.getParentFile().exists()){
|
|
|
- targetFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
-
|
|
|
- //上传文件
|
|
|
- file.transferTo(targetFile);
|
|
|
-
|
|
|
- //调用算法切全景图
|
|
|
- FileUtils.copyFile(path + File.separator + "data.json", target + File.separator+"data.json", true);
|
|
|
- FileUtils.copyFile(path + File.separator + "project.json", target + File.separator+"project.json", true);
|
|
|
-
|
|
|
- JSONObject visionJson = new JSONObject();
|
|
|
- JSONArray visionArray = new JSONArray();
|
|
|
- visionJson.put("uuid", imagesName.substring(0, imagesName.lastIndexOf(".")));
|
|
|
- visionJson.put("group", 1);
|
|
|
- visionJson.put("subgroup", 0);
|
|
|
- visionArray.add(visionJson);
|
|
|
- JSONObject vision = new JSONObject();
|
|
|
- vision.put("sweepLocations", visionArray);
|
|
|
- FileUtils.writeFile(target + "/extras" + File.separator + "vision.txt", new String(vision.toString().getBytes(), "UTF-8"));
|
|
|
-
|
|
|
- //data.json增加extras为执行重建算法
|
|
|
- String data = FileUtils.readFile(target + File.separator + "data.json");
|
|
|
- if(data != null){
|
|
|
- JSONObject floorplanJson = new JSONObject();
|
|
|
- floorplanJson.put("has_source_images", true);
|
|
|
- floorplanJson.put("has_vision_txt", true);
|
|
|
-
|
|
|
- JSONObject dataJson = JSONObject.parseObject(data);
|
|
|
- dataJson.put("extras", floorplanJson);
|
|
|
- dataJson.put("split_type", "SPLIT_V8");//替换全景图算法
|
|
|
- //V5表示不需要生成high,low文件
|
|
|
- dataJson.put("skybox_type", "SKYBOX_V6");//默认4k minion
|
|
|
- if(scenePro.getSceneScheme() == 11){
|
|
|
- dataJson.put("skybox_type", "SKYBOX_V7");//pro 2k
|
|
|
- }
|
|
|
- if(scenePro.getSceneScheme() == 3){
|
|
|
- dataJson.put("skybox_type", "SKYBOX_V4");
|
|
|
- }
|
|
|
- FileUtils.writeFile(target + File.separator+"data.json", new String(dataJson.toString().getBytes(), "UTF-8"));
|
|
|
- }
|
|
|
-
|
|
|
- //创建文件夹软连接并且复制data.json和project.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");
|
|
|
- }
|
|
|
- //下载data.fdage
|
|
|
- if(StorageType.AWS.code().equals(this.type)){
|
|
|
- //亚马逊保持旧方式,超链接capture
|
|
|
- CreateObjUtil.createSoftConnection(path + File.separator + "capture", target + File.separator + "capture");
|
|
|
- }
|
|
|
- CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", target + File.separator + "capture/");
|
|
|
-
|
|
|
- CreateObjUtil.build3dModel(target , "1");
|
|
|
-
|
|
|
- //读取upload文件,检验需要上传的文件是否存在
|
|
|
- String uploadData = FileUtils.readFile(target + File.separator + "results" +File.separator+"upload.json");
|
|
|
- JSONObject uploadJson = null;
|
|
|
- JSONArray array = null;
|
|
|
- if(uploadData!=null) {
|
|
|
- uploadJson = JSONObject.parseObject(uploadData);
|
|
|
- array = uploadJson.getJSONArray("upload");
|
|
|
- }
|
|
|
- if(array == null){
|
|
|
- log.info("计算全景图失败,没有upload.json");
|
|
|
- }
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- JSONObject fileJson = null;
|
|
|
- String fileName = "";
|
|
|
- String img = "";
|
|
|
- for(int i = 0, len = array.size(); i < len; i++){
|
|
|
- fileJson = array.getJSONObject(i);
|
|
|
- fileName = fileJson.getString("file");
|
|
|
- //文件不存在抛出异常
|
|
|
- if(!new File(target + File.separator + "results" +File.separator + fileName).exists()){
|
|
|
- throw new Exception(target + File.separator + "results" +File.separator + fileName+"文件不存在");
|
|
|
- }
|
|
|
-
|
|
|
- //low文件夹
|
|
|
- if(fileJson.getIntValue("clazz") == 4){
|
|
|
- img = "/results" + File.separator + fileName;
|
|
|
-
|
|
|
- map.put(target + File.separator + "results" +File.separator+ fileName,"images/images"+
|
|
|
- scenePro.getNum()+"/pan/low/"+ fileName.replace("low/", ""));
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
|
|
|
- if(fileJson.getIntValue("clazz") == 5){
|
|
|
- map.put(target + File.separator + "results" + File.separator+ fileName,"images/images"+
|
|
|
- scenePro.getNum()+ "/panorama_edit/" + sid + File.separator + fileName);
|
|
|
- }
|
|
|
-
|
|
|
- //tiles文件夹,亚马逊瓦片图
|
|
|
- if(fileJson.getIntValue("clazz") == 7 ){
|
|
|
- map.put(target + File.separator + "results" + File.separator+ fileName,"images/images"+
|
|
|
- scenePro.getNum()+ File.separator + fileName);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //上传全景图
|
|
|
- map.put(filePath, "images/images"+ scenePro.getNum()+ File.separator + "pan/high/" + imagesName);
|
|
|
-
|
|
|
- uploadToOssUtil.uploadMulFiles(map);
|
|
|
-
|
|
|
- String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
|
|
|
- JSONObject scenejson = new JSONObject();
|
|
|
- if(strsceneInfos!=null) {
|
|
|
- scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
- }
|
|
|
-
|
|
|
- scenejson.put("uploadPanoramaImg", 1);
|
|
|
- scenejson.put("version", scenejson.getIntValue("version") + 1);
|
|
|
- FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
|
|
|
-
|
|
|
- Map<String, String> result = new HashMap<>();
|
|
|
- result.put("type", scenePro.getSceneScheme() == 11? "2k" : "4k");
|
|
|
- result.put("img", "scene/" + imagesBuf.toString() + "panorama/" + sid + img);
|
|
|
- result.put("path", "images/images"+ scenePro.getNum()+ "/panorama_edit/" + sid);
|
|
|
- return ResultData.ok(result);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public ResultData savePanoramaJson(FileParamVO param) throws Exception {
|