|
@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.fdkankan.common.util.FileMd5Util;
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
import com.fdkankan.model.constants.ConstantFileName;
|
|
import com.fdkankan.model.constants.ConstantFileName;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
@@ -15,6 +16,8 @@ import com.fdkankan.common.constant.ConstantUrl;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.RecStatus;
|
|
import com.fdkankan.common.constant.RecStatus;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.scene.entity.SceneDataDownload;
|
|
|
|
+import com.fdkankan.scene.service.ISceneDataDownloadService;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.model.utils.ConvertUtils;
|
|
import com.fdkankan.model.utils.ConvertUtils;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
@@ -92,6 +95,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
private FYunFileServiceInterface fYunFileService;
|
|
private FYunFileServiceInterface fYunFileService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneService sceneService;
|
|
private ISceneService sceneService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneDataDownloadService sceneDataDownloadService;
|
|
|
|
|
|
@Value("${main.url}")
|
|
@Value("${main.url}")
|
|
private String mainUrl;
|
|
private String mainUrl;
|
|
@@ -2775,4 +2780,478 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData uploadFloorJsonAjk(String sceneNum, String ajkJson, String cameraJson, String floorPlanJson, MultipartFile[] file) throws Exception {
|
|
|
|
+// log.info("画墙重建模型开始时间:" + start);
|
|
|
|
+
|
|
|
|
+ String lock = sceneNum.toString().intern();
|
|
|
|
+
|
|
|
|
+ synchronized(lock){
|
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isEmpty(sceneNum)){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ScenePro sceneProEntity = this.findBySceneNum(sceneNum);
|
|
|
|
+ if(sceneProEntity == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SceneProEdit sceneProEditEntity = sceneProEditService.findBySceneProId(sceneProEntity.getId());
|
|
|
|
+ if(sceneProEditEntity == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新scene.json文件
|
|
|
|
+ String strsceneInfos = FileUtils.readFile(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + sceneNum + File.separator + "scene.json");
|
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
|
+ if(strsceneInfos!=null)
|
|
|
|
+ {
|
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
|
+ }else {
|
|
|
|
+ new File(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + sceneNum + File.separator + "scene.json").createNewFile();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String path = sceneProEntity.getDataSource();
|
|
|
|
+ if(path != null && !"".equals(path) && path.startsWith("http")){
|
|
|
|
+ path = ConstantFilePath.BUILD_MODEL_PATH + File.separator + path.split("/")[path.split("/").length - 2];
|
|
|
|
+ }
|
|
|
|
+ String target = path + "_ajk";
|
|
|
|
+ File editPath = new File(target);
|
|
|
|
+ if(!editPath.exists()){
|
|
|
|
+ editPath.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //创建文件夹软连接并且复制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 + "caches").exists()){
|
|
|
|
+ //删除link
|
|
|
|
+ new File(target + File.separator + "caches" + File.separator + "images").delete();
|
|
|
|
+ //删除所有文件
|
|
|
|
+ FileUtils.delAllFile(target + File.separator + "caches");
|
|
|
|
+ }
|
|
|
|
+ if(new File(target + File.separator + "results").exists()){
|
|
|
|
+ FileUtils.delAllFile(target + File.separator + "results");
|
|
|
|
+ }
|
|
|
|
+ //创建文件夹,并link文件夹
|
|
|
|
+ new File(target + File.separator + "caches").mkdirs();
|
|
|
|
+ CreateObjUtil.createSoftConnection(path + File.separator + "capture", target + File.separator + "capture");
|
|
|
|
+ if(new File(path + File.separator + "caches" + File.separator + "images").exists()){
|
|
|
|
+ CreateObjUtil.createSoftConnection(path + File.separator + "caches" + File.separator + "images", target + File.separator + "caches" + File.separator + "images");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 project = FileUtils.readFile(target + File.separator+"project.json");
|
|
|
|
+ if(project != null){
|
|
|
|
+ JSONObject projectJson = JSONObject.parseObject(project);
|
|
|
|
+ projectJson.put("parent", projectJson.get("uuid"));
|
|
|
|
+ projectJson.put("uuid", UUID.randomUUID().toString());
|
|
|
|
+ projectJson.put("time", System.currentTimeMillis());
|
|
|
|
+ FileUtils.writeFile(path + File.separator + "project.json", projectJson.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String data = FileUtils.readFile(target + File.separator+"data.json");
|
|
|
|
+ if(data != null){
|
|
|
|
+ JSONObject floorplanJson = new JSONObject();
|
|
|
|
+ floorplanJson.put("has_floor_ajk_json", true);
|
|
|
|
+ floorplanJson.put("has_vision_txt", true);
|
|
|
|
+ floorplanJson.put("has_floorplan_json", true);
|
|
|
|
+
|
|
|
|
+ JSONObject dataJson = JSONObject.parseObject(data);
|
|
|
|
+ dataJson.put("extras", floorplanJson);
|
|
|
|
+ //V5表示不需要生成high,low文件
|
|
|
|
+ dataJson.put("skybox_type", "SKYBOX_V8");
|
|
|
|
+ dataJson.put("split_type", "SPLIT_V10");
|
|
|
|
+ FileUtils.writeFile(target + File.separator+"data.json", new String(dataJson.toString().getBytes(), "UTF-8"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //文件上传的位置可以自定义
|
|
|
|
+ log.info("画墙重建模型开始");
|
|
|
|
+ File targetFile = new File(target + File.separator + "extras" + File.separator + "floor_ajk.json");
|
|
|
|
+ if(!targetFile.getParentFile().exists()){
|
|
|
|
+ targetFile.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ if(targetFile.exists()){
|
|
|
|
+ FileUtils.deleteFile(target + File.separator + "extras" + File.separator + "floor_ajk.json");
|
|
|
|
+ }
|
|
|
|
+ // 保存
|
|
|
|
+ FileUtils.writeFile(target + File.separator + "extras" + File.separator + "floorplan.json", new String(floorPlanJson.getBytes(), "UTF-8"));
|
|
|
|
+
|
|
|
|
+ FileUtils.writeFile(target + File.separator + "extras" + File.separator + "floor_ajk.json", new String(ajkJson.getBytes(), "UTF-8"));
|
|
|
|
+ FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+sceneNum + File.separator + "floor_ajk.json", new String(ajkJson.getBytes(), "UTF-8"));
|
|
|
|
+
|
|
|
|
+ FileUtils.writeFile(target + File.separator + "extras" + File.separator + "vision.txt", new String(cameraJson.getBytes(), "UTF-8"));
|
|
|
|
+ FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+sceneNum + File.separator + "camera.json", new String(cameraJson.getBytes(), "UTF-8"));
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < file.length; i ++){
|
|
|
|
+
|
|
|
|
+ File cadImg = new File(target + File.separator + "extras" + File.separator + "Floorplans/" + file[i].getOriginalFilename());
|
|
|
|
+ if(!cadImg.getParentFile().exists()){
|
|
|
|
+ cadImg.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ if(cadImg.exists())
|
|
|
|
+ {
|
|
|
|
+ cadImg.delete();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ file[i].transferTo(cadImg);
|
|
|
|
+ }
|
|
|
|
+ //下载封面图
|
|
|
|
+ FileUtils.downLoadFromUrl(sceneProEntity.getThumb() + "?t=" + System.currentTimeMillis(),
|
|
|
|
+ "Cover.png", target + File.separator + "extras" + File.separator + "CoverImage");
|
|
|
|
+ //转换成jpg
|
|
|
|
+ FileUtils.pngToJpg(target + File.separator + "extras" + File.separator + "CoverImage/Cover.png",
|
|
|
|
+ target + File.separator + "extras" + File.separator + "CoverImage/Cover.jpg");
|
|
|
|
+// FileUtils.deleteFile(target + File.separator + "extras" + File.separator + "CoverImage/Cover.png");
|
|
|
|
+
|
|
|
|
+ //安居客算法运行
|
|
|
|
+ log.info("安居客算法:开始建模——"+sceneNum);
|
|
|
|
+
|
|
|
|
+ CreateObjUtil.build3dModel(target , "1");
|
|
|
|
+ if(!new File(target + File.separator + "results" + File.separator + "upload.json").exists()){
|
|
|
|
+ return ResultData.error(ErrorCode.FAILURE_CODE_5042);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String zipPath = target + File.separator + "results/" + sceneNum + ".zip";
|
|
|
|
+ new File(zipPath).delete();
|
|
|
|
+
|
|
|
|
+// FileUtils.zipFile(zipPath, target + File.separator + "results/ajk/");
|
|
|
|
+ String command = "bash /opt/ossutil/gzip.sh " + zipPath.replace(".zip", "") + " " + target + File.separator + "results/ajk/";
|
|
|
|
+ log.info("压缩文件:" + command);
|
|
|
|
+ CreateObjUtil.callshell(command);
|
|
|
|
+
|
|
|
|
+ if(!new File(zipPath).exists()){
|
|
|
|
+ return ResultData.error(ErrorCode.FAILURE_CODE_5043);
|
|
|
|
+ }
|
|
|
|
+ String fileMD5 = FileMd5Util.getFileMD5(new File(zipPath));
|
|
|
|
+
|
|
|
|
+ fYunFileService.uploadFile(zipPath, "data_download/" + sceneNum + ".zip");
|
|
|
|
+
|
|
|
|
+ SceneDataDownload sceneDataDownloadEntity = sceneDataDownloadService.findBySceneNum(sceneNum);
|
|
|
|
+ if(sceneDataDownloadEntity == null){
|
|
|
|
+ sceneDataDownloadEntity = new SceneDataDownload();
|
|
|
|
+ sceneDataDownloadEntity.setSceneNum(sceneNum);
|
|
|
|
+ sceneDataDownloadEntity.setDownloadPath(ossPrefixUrl + "data_download/" + sceneNum + ".zip");
|
|
|
|
+ sceneDataDownloadEntity.setFileMd5(fileMD5);
|
|
|
|
+ sceneDataDownloadService.save(sceneDataDownloadEntity);
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sceneDataDownloadEntity.setFileMd5(fileMD5);
|
|
|
|
+ sceneDataDownloadEntity.setUpdateTime(new Date());
|
|
|
|
+ sceneDataDownloadService.updateById(sceneDataDownloadEntity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData uploadPanoramaOrVideo(String sceneNum, String fileName, String type, MultipartFile file, String planId) throws Exception {
|
|
|
|
+ if(org.apache.commons.lang3.StringUtils
|
|
|
|
+ .isEmpty(sceneNum) || org.apache.commons.lang3.StringUtils
|
|
|
|
+ .isEmpty(fileName) || org.apache.commons.lang3.StringUtils
|
|
|
|
+ .isEmpty(type) || org.apache.commons.lang3.StringUtils.isEmpty(planId)){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ScenePro sceneProEntity = this.findBySceneNum(sceneNum);
|
|
|
|
+ if(sceneProEntity == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!fileName.endsWith(".jpg") && !fileName.endsWith(".mp4")){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5023);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StringBuffer dataBuf = new StringBuffer()
|
|
|
|
+ .append("data").append(File.separator)
|
|
|
|
+ .append("data").append(sceneProEntity.getNum())
|
|
|
|
+ .append(File.separator);
|
|
|
|
+
|
|
|
|
+ StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String path = sceneProEntity.getDataSource();
|
|
|
|
+
|
|
|
|
+ if(path != null && !"".equals(path) && path.startsWith("http")){
|
|
|
|
+ path = ConstantFilePath.BUILD_MODEL_PATH + File.separator + path.split("/")[path.split("/").length - 2];
|
|
|
|
+ }
|
|
|
|
+ String target = path + "_images";
|
|
|
|
+
|
|
|
|
+ //文件上传的位置可以自定义
|
|
|
|
+ String filePath = "";
|
|
|
|
+ if("image".equals(type)){
|
|
|
|
+ filePath = target + File.separator + "extras/images" + File.separator + fileName;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if("video".equals(type)){
|
|
|
|
+ filePath = target + File.separator + "extras/video" + File.separator + fileName;
|
|
|
|
+ }
|
|
|
|
+ File targetFile = new File(filePath);
|
|
|
|
+ if(!targetFile.getParentFile().exists()){
|
|
|
|
+ targetFile.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //上传文件
|
|
|
|
+ file.transferTo(targetFile);
|
|
|
|
+
|
|
|
|
+ String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
|
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
|
+ if(strsceneInfos!=null) {
|
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
|
+ }
|
|
|
|
+ if(type.equals("video")){
|
|
|
|
+ scenejson.put("buildImages", 2);
|
|
|
|
+ FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
|
|
|
|
+ }else{
|
|
|
|
+ scenejson.put("buildImages", 1);
|
|
|
|
+ if(scenejson.containsKey("planId")){
|
|
|
|
+ scenejson.put("planId",scenejson.getString("planId").concat(","+planId));
|
|
|
|
+ }else{
|
|
|
|
+ scenejson.put("planId",planId);
|
|
|
|
+ }
|
|
|
|
+ FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData uploadObjAndImg(String sceneNum, MultipartFile file) throws Exception{
|
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isEmpty(sceneNum)){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ScenePro sceneProEntity = this.findBySceneNum(sceneNum);
|
|
|
|
+ if(sceneProEntity == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SceneProEdit sceneProEditEntity = sceneProEditService.findBySceneProId(sceneProEntity.getId());
|
|
|
|
+ if(sceneProEditEntity == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (file == null || file.getSize() <= 0) {
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StringBuffer dataBuf = new StringBuffer()
|
|
|
|
+ .append("data").append(File.separator)
|
|
|
|
+ .append("data").append(sceneProEntity.getNum())
|
|
|
|
+ .append(File.separator);
|
|
|
|
+
|
|
|
|
+ StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
|
|
|
|
+
|
|
|
|
+ //文件上传的位置可以自定义
|
|
|
|
+ String path = sceneProEntity.getDataSource() + "_obj2txt";
|
|
|
|
+ String zipPath = path + "/zip/";
|
|
|
|
+ String filePath = path + "/extras/";
|
|
|
|
+
|
|
|
|
+ FileUtils.delAllFile(path + "/results/");
|
|
|
|
+ File targetFile = new File(filePath);
|
|
|
|
+ if (!targetFile.exists()) {
|
|
|
|
+ targetFile.mkdirs();
|
|
|
|
+ }else {
|
|
|
|
+ FileUtils.delAllFile(filePath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ targetFile = new File(zipPath);
|
|
|
|
+ if (!targetFile.exists()) {
|
|
|
|
+ targetFile.mkdirs();
|
|
|
|
+ }else {
|
|
|
|
+ FileUtils.delAllFile(zipPath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ targetFile = new File(zipPath + file.getOriginalFilename());
|
|
|
|
+ if(!targetFile.getParentFile().exists()){
|
|
|
|
+ targetFile.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ // 保存
|
|
|
|
+ synchronized(this)
|
|
|
|
+ {
|
|
|
|
+ if(targetFile.exists())
|
|
|
|
+ {
|
|
|
|
+ FileUtils.deleteFile(zipPath + file.getOriginalFilename());
|
|
|
|
+ }
|
|
|
|
+ file.transferTo(targetFile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileUtils.decompress(zipPath + file.getOriginalFilename(), zipPath + "data/");
|
|
|
|
+
|
|
|
|
+ //源文件数据,判断是否有多个文件夹,有多个就提示错误,有一个就将文件夹里数据迁移到extras目录,无直接迁移到extras目录
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ String targetName = "";
|
|
|
|
+ File dataFile = new File(zipPath + "data/");
|
|
|
|
+ for(File data : dataFile.listFiles()){
|
|
|
|
+ if(data.isDirectory() && flag){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
|
|
|
|
+ }
|
|
|
|
+ if(data.isDirectory() && !flag){
|
|
|
|
+ flag = true;
|
|
|
|
+ targetName = data.getName();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean objFlag = false;
|
|
|
|
+ boolean mtlFlag = false;
|
|
|
|
+ if(StrUtil.isEmpty(targetName)){
|
|
|
|
+ for(File data : dataFile.listFiles()){
|
|
|
|
+ if(data.getName().endsWith(".obj") && objFlag){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(data.getName().endsWith(".jpg") || data.getName().endsWith(".png")){
|
|
|
|
+ if(!FileUtils.checkFileSizeIsLimit(data.length(), 1.5, "M")){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(data.getName().endsWith(".obj") && !objFlag){
|
|
|
|
+ if(!FileUtils.checkFileSizeIsLimit(data.length(), 20, "M")){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
|
+ }
|
|
|
|
+ objFlag = true;
|
|
|
|
+ FileUtils.copyFile(zipPath + "data/" + data.getName(), filePath + "mesh.obj", true);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(data.getName().endsWith(".mtl")){
|
|
|
|
+ mtlFlag = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileUtils.copyFile(zipPath + "data/" + data.getName(), filePath + data.getName(), true);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ for(File data : new File(zipPath + "data/" + targetName).listFiles()){
|
|
|
|
+ if(data.isDirectory()){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
|
|
|
|
+ }
|
|
|
|
+ if(data.getName().endsWith(".obj") && objFlag){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(data.getName().endsWith(".jpg") || data.getName().endsWith(".png")){
|
|
|
|
+ if(!FileUtils.checkFileSizeIsLimit(data.length(), 1.5, "M")){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(data.getName().endsWith(".obj") && !objFlag){
|
|
|
|
+ if(!FileUtils.checkFileSizeIsLimit(data.length(), 20, "M")){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ objFlag = true;
|
|
|
|
+ FileUtils.copyFile(zipPath + "data/" + targetName + File.separator + data.getName(), filePath + "mesh.obj", true);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(data.getName().endsWith(".mtl")){
|
|
|
|
+ mtlFlag = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileUtils.copyFile(zipPath + "data/" + targetName + File.separator + data.getName(), filePath + data.getName(), true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!mtlFlag && !objFlag){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //创建data.json
|
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
|
+ dataJson.put("obj2txt", true);
|
|
|
|
+ dataJson.put("split_type", "SPLIT_V6");
|
|
|
|
+ dataJson.put("data_describe", "double spherical");
|
|
|
|
+ dataJson.put("skybox_type", "SKYBOX_V5");
|
|
|
|
+ FileUtils.writeFile(path + "/data.json", dataJson.toString());
|
|
|
|
+
|
|
|
|
+ //调用objToTxt算法
|
|
|
|
+ //判断V2还是V3
|
|
|
|
+ if("V2".equals(sceneProEntity.getBuildType())){
|
|
|
|
+ CreateObjUtil.objToTxt(path , "1");
|
|
|
|
+ }
|
|
|
|
+ if("V3".equals(sceneProEntity.getBuildType())){
|
|
|
|
+ CreateObjUtil.build3dModel(path , "1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String uploadData = FileUtils.readFile(path + 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.error("upload.json数据出错");
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5017);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String,String> map = new HashMap<String,String>();
|
|
|
|
+ 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(path + File.separator + "results" + File.separator + fileName).exists()) {
|
|
|
|
+ throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //tex文件夹
|
|
|
|
+ if (fileJson.getIntValue("clazz") == 15) {
|
|
|
|
+ map.put(path + File.separator + "results" + File.separator + fileName, "images/images" +
|
|
|
|
+ sceneNum + "/" + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
|
|
|
|
+
|
|
|
|
+ //复制一份到images本地
|
|
|
|
+ FileUtils.copyFile(path + File.separator + "results" +File.separator + fileName,
|
|
|
|
+ ConstantFilePath.SCENE_PATH+"images"+File.separator+"images"+sceneNum + File.separator +
|
|
|
|
+ ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""), true);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"modeldata.txt", path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k.dam");
|
|
|
|
+ CreateObjUtil.convertDamToLzma(path + File.separator + "results");
|
|
|
|
+ CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"modeldata.txt", path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
|
+ map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma", "images/images"+sceneNum+"/"+ConstantFileName.modelUUID+"_50k.dam.lzma");
|
|
|
|
+ map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam", "images/images"+sceneNum+"/"+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
|
+
|
|
|
|
+ fYunFileService.uploadMulFiles(map);
|
|
|
|
+
|
|
|
|
+ FileUtils.copyFile(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam",
|
|
|
|
+ ConstantFilePath.SCENE_PATH+"images"+File.separator+"images"+sceneNum + File.separator + ConstantFileName.modelUUID+"_50k.dam", true);
|
|
|
|
+ FileUtils.copyFile(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma",
|
|
|
|
+ ConstantFilePath.SCENE_PATH+"images"+File.separator+"images"+sceneNum + File.separator + ConstantFileName.modelUUID+"_50k.dam.lzma", true);
|
|
|
|
+ log.info("文件复制到本地ecs完成——"+sceneNum);
|
|
|
|
+
|
|
|
|
+ String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
|
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
|
+ if(strsceneInfos!=null) {
|
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
|
+ }
|
|
|
|
+ //更新scene.json文件
|
|
|
|
+ if(strsceneInfos!=null)
|
|
|
|
+ {
|
|
|
|
+ scenejson.put("isUploadObj", true);
|
|
|
|
+ scenejson.put("version", sceneProEditEntity.getVersion() + 1);
|
|
|
|
+ scenejson.put("floorEditVer", sceneProEditEntity.getFloorEditVer() + 1);
|
|
|
|
+ scenejson.put("floorPublishVer", sceneProEditEntity.getFloorPublishVer() + 1);
|
|
|
|
+ FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+sceneNum+File.separator+"scene.json", scenejson.toString());
|
|
|
|
+ log.info("写入scene.json文件完成——"+sceneNum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //floorEditVer字段增加1
|
|
|
|
+ sceneProEditEntity.setVersion(sceneProEditEntity.getVersion() + 1);
|
|
|
|
+ sceneProEditEntity.setFloorPublishVer(sceneProEditEntity.getFloorPublishVer() + 1);
|
|
|
|
+ sceneProEditEntity.setFloorEditVer(sceneProEditEntity.getFloorEditVer() + 1);
|
|
|
|
+ sceneProEditService.updateById(sceneProEditEntity);
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|