|
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.amazonaws.services.devicefarm.model.UploadType;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -49,6 +50,7 @@ import com.fdkankan.scene.vo.*;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.errorprone.annotations.Var;
|
|
|
import java.io.File;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -610,27 +612,40 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
@Override
|
|
|
public List<String> uploadPanorama(String num, MultipartFile file) throws Exception {
|
|
|
|
|
|
+ ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
+ if(scenePro == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+ SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
|
|
|
+
|
|
|
+ //原始计算根目录
|
|
|
+ String path = sceneProExt.getDataSource();
|
|
|
+ //全景图计算根目录
|
|
|
+ String target = path + "_images";
|
|
|
+ //解压缩文件存放目录
|
|
|
+ String targetImagesPath = target + "/extras/images";
|
|
|
+ //压缩文件保存目录
|
|
|
+ String zipTargetFilePath = targetImagesPath + File.separator + file.getOriginalFilename();
|
|
|
+
|
|
|
//压缩包保存到本地
|
|
|
- String path = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
|
|
|
+// String cachePath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
|
|
|
// String path = "F:\\mnt\\4Dkankan\\scene\\t-ieXdyGl6Md\\caches\\images\\";
|
|
|
|
|
|
//先删除本地文件
|
|
|
- FileUtils.deleteDirectory(path);
|
|
|
-
|
|
|
- String targetFilePath = path + File.separator + file.getOriginalFilename();
|
|
|
- File targetFile = new File(targetFilePath);
|
|
|
+ FileUtils.deleteDirectory(targetImagesPath);
|
|
|
+ File targetFile = new File(zipTargetFilePath);
|
|
|
if(!targetFile.getParentFile().exists()){
|
|
|
targetFile.getParentFile().mkdirs();
|
|
|
}
|
|
|
file.transferTo(targetFile);
|
|
|
|
|
|
//解压zip包
|
|
|
- FileUtil.unZip(targetFilePath, path);
|
|
|
+ FileUtil.unZip(zipTargetFilePath, targetImagesPath);
|
|
|
//删除压缩包
|
|
|
- FileUtil.delFile(targetFilePath);
|
|
|
+ FileUtil.delFile(zipTargetFilePath);
|
|
|
|
|
|
//获取解压后的文件列表
|
|
|
- List<String> uploadFileList = FileUtil.getFileList(path);
|
|
|
+ List<String> uploadFileList = FileUtil.getFileList(targetImagesPath);
|
|
|
if(CollUtil.isEmpty(uploadFileList)){
|
|
|
return null;
|
|
|
}
|
|
@@ -661,12 +676,108 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
//上传
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
uploadFileList.stream().forEach(filePath->{
|
|
|
- map.put(filePath, filePath.replace(path, imgCachePath));
|
|
|
+ map.put(filePath, filePath.replace(targetImagesPath, imgCachePath));
|
|
|
});
|
|
|
+ //上传模型文件到缓存目录
|
|
|
uploadToOssUtil.uploadMulFiles(map);
|
|
|
|
|
|
- //删除本地目录
|
|
|
- FileUtils.deleteDirectory(path);
|
|
|
+ String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
+ if(StorageType.AWS.code().equals(this.type)){
|
|
|
+ FileUtils.downLoadFromUrl(ConstantUrl.PREFIX_AWS + imgViewPath + "vision.modeldata" + "?m="+new Date().getTime(),
|
|
|
+ "vision.modeldata", target + File.separator + "extras" + File.separator);
|
|
|
+ }
|
|
|
+ if(StorageType.OSS.code().equals(this.type)){
|
|
|
+ FileUtils.downLoadFromUrl(prefixAli + imgViewPath + "vision.modeldata" + "?m="+new Date().getTime(),
|
|
|
+ "vision.modeldata", target + File.separator + "extras" + File.separator);
|
|
|
+ }
|
|
|
+ CreateObjUtil.convertVisionmodeldataToTxt(target + File.separator + "extras" + File.separator + "vision.modeldata",
|
|
|
+ target + File.separator + "extras" + File.separator + "vision.txt");
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ //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);
|
|
|
+ //V5表示不需要生成high,low文件
|
|
|
+ dataJson.put("skybox_type", "SKYBOX_V6");
|
|
|
+ if(scenePro.getSceneScheme() == 11){
|
|
|
+ dataJson.put("skybox_type", "SKYBOX_V7");
|
|
|
+ }
|
|
|
+ dataJson.put("split_type", "SPLIT_V8");
|
|
|
+ //sceneScheme为3切成瓦片图
|
|
|
+ if(scenePro.getSceneScheme() == 3){
|
|
|
+ dataJson.put("skybox_type", "SKYBOX_V4");
|
|
|
+ }
|
|
|
+ FileUtils.writeFile(target + File.separator+"data.json", new String(dataJson.toString().getBytes(), "UTF-8"));
|
|
|
+ }
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ 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");
|
|
|
+ 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){
|
|
|
+ throw new Exception("upload.json数据出错");
|
|
|
+ }
|
|
|
+ JSONObject fileJson = null;
|
|
|
+ String fileName = "";
|
|
|
+ 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 + "文件不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //high文件夹
|
|
|
+ if (fileJson.getIntValue("clazz") == 3) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ imgViewPath + "pan/high/" + fileName.replace("high/", ""));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //low文件夹
|
|
|
+ if (fileJson.getIntValue("clazz") == 4) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ imgViewPath + "pan/low/" + fileName.replace("low/", ""));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
|
|
|
+ if (fileJson.getIntValue("clazz") == 5) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ imgViewPath + fileName);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //tiles文件夹,亚马逊瓦片图
|
|
|
+ if (fileJson.getIntValue("clazz") == 7) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ imgViewPath + fileName);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
}
|