|
@@ -1,6 +1,7 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -18,8 +19,10 @@ import com.fdkankan.common.constant.RecStatus;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.model.utils.ComputerUtil;
|
|
|
import com.fdkankan.model.utils.SceneUtil;
|
|
|
+import com.fdkankan.scene.bean.RequestScene;
|
|
|
import com.fdkankan.scene.entity.SceneDataDownload;
|
|
|
import com.fdkankan.scene.service.ISceneDataDownloadService;
|
|
|
+import com.fdkankan.web.response.Result;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import com.fdkankan.model.utils.ConvertUtils;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
@@ -104,7 +107,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
private String mainUrl;
|
|
|
@Value("${scene.pro.url}")
|
|
|
private String sceneProUrl;
|
|
|
- @Value("${scene.pro.new.url}")
|
|
|
+ @Value("${scene.pro.v3.url}")
|
|
|
private String sceneProNewUrl;
|
|
|
@Value("${hot.domain.list}")
|
|
|
private String hotDomainList;
|
|
@@ -3249,4 +3252,130 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result createScene(RequestScene param) throws Exception {
|
|
|
+ if(StrUtil.isEmpty(param.getNum())){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuffer dataBuf = new StringBuffer()
|
|
|
+ .append("data").append(File.separator)
|
|
|
+ .append("data").append(param.getNum());
|
|
|
+
|
|
|
+ StringBuffer imagesBuf = new StringBuffer()
|
|
|
+ .append("images").append(File.separator)
|
|
|
+ .append("images").append(param.getNum());
|
|
|
+
|
|
|
+ StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
|
|
|
+ StringBuffer imagesBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(imagesBuf.toString());
|
|
|
+
|
|
|
+ FileUtils.delAllFile(imagesBuffer.toString() + "/results/");
|
|
|
+ FileUtils.delAllFile(imagesBuffer.toString() + "/extras/");
|
|
|
+ //远程复制oss资源
|
|
|
+ fYunFileService.downloadFileByCommand(imagesBuffer.toString() + "/extras/" + param.getObjName(), imagesBuf.toString() + File.separator + param.getObjName());
|
|
|
+ //obj文件修改名字
|
|
|
+ FileUtils.copyFile(imagesBuffer.toString() + "/extras/" + param.getObjName(), imagesBuffer.toString() + "/extras/mesh.obj", true);
|
|
|
+ FileUtils.deleteFile(imagesBuffer.toString() + "/extras/" + param.getObjName());
|
|
|
+
|
|
|
+ fYunFileService.downloadFileByCommand(imagesBuffer.toString() + "/extras/" + param.getMntName(), imagesBuf.toString() + File.separator + param.getMntName());
|
|
|
+ fYunFileService.downloadFileByCommand(imagesBuffer.toString() + "/extras/", imagesBuf.toString() + File.separator + "dacf7dfa24ae47fab8fcebfe4dc41ab9_50k_texture_jpg_high1");
|
|
|
+ //将文件复制出去
|
|
|
+ String[] imgs = new File(imagesBuffer.toString() + "/extras/dacf7dfa24ae47fab8fcebfe4dc41ab9_50k_texture_jpg_high1").list();
|
|
|
+ for(String img : imgs){
|
|
|
+ FileUtils.copyFile(imagesBuffer.toString() + "/extras/dacf7dfa24ae47fab8fcebfe4dc41ab9_50k_texture_jpg_high1/" + img,
|
|
|
+ imagesBuffer.toString() + "/extras/" + img, true);
|
|
|
+ }
|
|
|
+ fYunFileService.downloadFileByCommand(imagesBuffer.toString() + File.separator + "vision.txt", imagesBuf.toString() + File.separator + "vision.txt");
|
|
|
+
|
|
|
+ //创建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(imagesBuffer.toString() + "/data.json", dataJson.toString());
|
|
|
+
|
|
|
+ //调用objToTxt算法
|
|
|
+ CreateObjUtil.objToTxt(imagesBuffer.toString(), "");
|
|
|
+
|
|
|
+ String uploadJsonPath = imagesBuffer.toString() + File.separator + "results" +File.separator+"upload.json";
|
|
|
+ boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, maxCheckTimes, waitTime);
|
|
|
+ if(!exist){
|
|
|
+ log.error("upload.json数据出错");
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+ String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
+ 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_5012);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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(imagesBuffer.toString() + File.separator + "results" + File.separator + fileName).exists()) {
|
|
|
+ throw new Exception(imagesBuffer.toString() + File.separator + "results" + File.separator + fileName + "文件不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //tex文件夹
|
|
|
+ if (fileJson.getIntValue("clazz") == 15) {
|
|
|
+ map.put(imagesBuffer.toString() + File.separator + "results" + File.separator + fileName, "images/images" +
|
|
|
+ param.getNum() + "/dacf7dfa24ae47fab8fcebfe4dc41ab9_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CreateObjUtil.convertTxtToDam(imagesBuffer.toString() + File.separator + "results" +File.separator+"modeldata.txt", imagesBuffer.toString() + File.separator + "results" +File.separator+ "dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
|
|
|
+ CreateObjUtil.convertDamToLzma(imagesBuffer.toString() + File.separator + "results" +File.separator+ "dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
|
|
|
+ CreateObjUtil.convertTxtToDam(imagesBuffer.toString() + File.separator + "results" +File.separator+"modeldata.txt", imagesBuffer.toString() + File.separator + "results" + File.separator+ "dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
|
|
|
+ map.put(imagesBuffer.toString() + File.separator + "results" +File.separator+"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam.lzma", "images/images"+param.getNum()+"/"+"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam.lzma");
|
|
|
+ map.put(imagesBuffer.toString() + File.separator + "results" +File.separator+"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam", "images/images"+param.getNum()+"/"+"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
|
|
|
+
|
|
|
+ FileUtils.deleteFile(imagesBuffer.toString() + "/vision.modeldata");
|
|
|
+ CreateObjUtil.convertTxtToVisionmodeldata(imagesBuffer.toString() + "/vision.txt", imagesBuffer.toString() + "/vision.modeldata");
|
|
|
+ map.put(imagesBuffer.toString() + "/vision.modeldata", "images/images"+param.getNum()+"/vision.modeldata");
|
|
|
+
|
|
|
+ fYunFileService.uploadMulFiles(map);
|
|
|
+
|
|
|
+ ScenePro proEntity = this.findBySceneNum(param.getNum());
|
|
|
+ if(proEntity == null){
|
|
|
+ proEntity = new ScenePro();
|
|
|
+ proEntity.setSceneName("四维看看");
|
|
|
+ proEntity.setSceneDec("<p>四维看看 让空间讲故事</p>");
|
|
|
+ proEntity.setSceneScheme(2);
|
|
|
+ proEntity.setNum(param.getNum());
|
|
|
+ proEntity.setUserId(param.getUserId());
|
|
|
+ proEntity.setWebSite(mainUrl + sceneProNewUrl + param.getNum());
|
|
|
+ proEntity.setStatus(1);
|
|
|
+ proEntity.setPayStatus(1);
|
|
|
+ proEntity.setBuildType("V3");
|
|
|
+
|
|
|
+ if(param.getSceneSource()!=null){
|
|
|
+ proEntity.setSceneSource(Integer.parseInt(param.getSceneSource()));
|
|
|
+ }
|
|
|
+
|
|
|
+ this.save(proEntity);
|
|
|
+
|
|
|
+ SceneProEdit proEditEntity = new SceneProEdit();
|
|
|
+ proEditEntity.setProId(proEntity.getId());
|
|
|
+ sceneProEditService.save(proEditEntity);
|
|
|
+
|
|
|
+ JSONObject scenejson = JSONObject.parseObject(JSONObject.toJSONString(proEntity));
|
|
|
+ scenejson.put("visions", 1);
|
|
|
+ FileUtils.writeFile(dataBuffer.toString() + File.separator+"scene.json", scenejson.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success(mainUrl + sceneProNewUrl + param.getNum());
|
|
|
+
|
|
|
+ }
|
|
|
}
|