|
@@ -1,29 +1,40 @@
|
|
package com.fdkankan.scene.service.impl;
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
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.constant.ConstantFilePath;
|
|
|
|
+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.response.ResultData;
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
|
+import com.fdkankan.common.util.CreateObjUtil;
|
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.scene.bean.RequestSceneProV4;
|
|
import com.fdkankan.scene.bean.RequestSceneProV4;
|
|
import com.fdkankan.scene.entity.SceneCooperation;
|
|
import com.fdkankan.scene.entity.SceneCooperation;
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
|
|
+import com.fdkankan.scene.entity.SceneProEdit;
|
|
import com.fdkankan.scene.entity.SceneResource;
|
|
import com.fdkankan.scene.entity.SceneResource;
|
|
import com.fdkankan.scene.entity.SceneResourceCooperation;
|
|
import com.fdkankan.scene.entity.SceneResourceCooperation;
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
import com.fdkankan.scene.service.ISceneCooperationService;
|
|
import com.fdkankan.scene.service.ISceneCooperationService;
|
|
|
|
+import com.fdkankan.scene.service.ISceneProEditService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.service.ISceneResourceCooperationService;
|
|
import com.fdkankan.scene.service.ISceneResourceCooperationService;
|
|
import com.fdkankan.scene.service.ISceneResourceService;
|
|
import com.fdkankan.scene.service.ISceneResourceService;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import java.io.File;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -44,6 +55,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
private ISceneResourceCooperationService sceneResourceCooperationService;
|
|
private ISceneResourceCooperationService sceneResourceCooperationService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneResourceService sceneResourceService;
|
|
private ISceneResourceService sceneResourceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneProEditService sceneProEditService;
|
|
|
|
+ @Value("${main.url}")
|
|
|
|
+ private String mainUrl;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResultData upgradeToV4ResultSync(RequestSceneProV4 param) throws Exception {
|
|
public ResultData upgradeToV4ResultSync(RequestSceneProV4 param) throws Exception {
|
|
@@ -102,4 +117,141 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
public ScenePro findBySceneNum(String num) {
|
|
public ScenePro findBySceneNum(String num) {
|
|
return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
|
|
return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData uploadLogoBottomStatus(String sceneNum, String status) throws Exception {
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StringBuffer dataBuf = new StringBuffer()
|
|
|
|
+ .append("data").append(File.separator)
|
|
|
|
+ .append("data").append(sceneProEntity.getNum())
|
|
|
|
+ .append(File.separator);
|
|
|
|
+ StringBuffer imagesBuf = new StringBuffer()
|
|
|
|
+ .append("images").append(File.separator)
|
|
|
|
+ .append("images").append(sceneProEntity.getNum())
|
|
|
|
+ .append(File.separator);
|
|
|
|
+
|
|
|
|
+ StringBuffer imagesBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(imagesBuf.toString());
|
|
|
|
+ StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
|
|
|
|
+
|
|
|
|
+ String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
|
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
|
+ if(strsceneInfos!=null) {
|
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ scenejson.put("showLogoBottom", Integer.valueOf(status));
|
|
|
|
+ scenejson.put("version", scenejson.getIntValue("version") + 1);
|
|
|
|
+ FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
|
|
|
|
+
|
|
|
|
+ sceneProEditEntity.setVersion(scenejson.getIntValue("version") + 1);
|
|
|
|
+ sceneProEditEntity.setShowLogoBottom(Integer.valueOf(status));
|
|
|
|
+ sceneProEditService.updateById(sceneProEditEntity);
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData downloadTexData(String sceneNum) throws Exception {
|
|
|
|
+ ScenePro sceneProEntity = this.findBySceneNum(sceneNum);
|
|
|
|
+ if(sceneProEntity == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!new File(ConstantFilePath.SCENE_PATH + "images/images" + sceneNum).exists()){
|
|
|
|
+ new File(ConstantFilePath.SCENE_PATH + "images/images" + sceneNum).mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //上传过的资源
|
|
|
|
+ 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 strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
|
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
|
+ if(strsceneInfos!=null) {
|
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String newData = sceneProEntity.getDataSource() + "_obj2txt/extras";
|
|
|
|
+ String newResultData = sceneProEntity.getDataSource() + "_obj2txt/results/upload.json";
|
|
|
|
+ if(scenejson.containsKey("isUploadObj") && new File(newData).exists() && new File(newResultData).exists()){
|
|
|
|
+ FileUtils.zipFile(ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/" + sceneNum + ".zip", newData);
|
|
|
|
+ return ResultData.ok(mainUrl + "scene/images/images" + sceneNum + "/" + sceneNum + ".zip?t=" +System.currentTimeMillis());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String buildType = sceneProEntity.getBuildType();
|
|
|
|
+ if("V3".equals(buildType)){
|
|
|
|
+ //V3版本去oss下载2048模型
|
|
|
|
+ String meshPath = ConstantFilePath.SCENE_PATH + "data/data" + sceneNum + "/mesh";
|
|
|
|
+ FileUtils.deleteDirectory(meshPath);
|
|
|
|
+ CreateObjUtil.ossUtilCp("data/data" + sceneNum + "/mesh", meshPath);
|
|
|
|
+ if(new File(meshPath.concat("/mesh")).listFiles().length > 0){
|
|
|
|
+ for(File file : new File(meshPath.concat("/mesh")).listFiles()){
|
|
|
|
+ if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
|
+ !"mesh.obj".equals(file.getName())){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
|
+ !"mesh.mtl".equals(file.getName())){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ FileUtils.zipFile(ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/" + sceneNum + ".zip", meshPath);
|
|
|
|
+ return ResultData.ok(mainUrl + "scene/images/images" + sceneNum + "/" + sceneNum + ".zip?t=" +System.currentTimeMillis());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //V2版本在本地获取模型资源
|
|
|
|
+ //修改过的资源
|
|
|
|
+ String editData = sceneProEntity.getDataSource() + "_edit/caches/tex";
|
|
|
|
+ String resultData = sceneProEntity.getDataSource() + "_edit/results";
|
|
|
|
+ if (new File(editData).exists() && new File(resultData).exists()){
|
|
|
|
+ for(File file : new File(editData).listFiles()){
|
|
|
|
+ if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
|
+ !"mesh.obj".equals(file.getName())){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
|
+ !"mesh.mtl".equals(file.getName())){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileUtils.zipFile(ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/" + sceneNum + ".zip", editData);
|
|
|
|
+ return ResultData.ok(mainUrl + "scene/images/images" + sceneNum + "/" + sceneNum + ".zip?t=" +System.currentTimeMillis());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //没上传过返回源资源
|
|
|
|
+ String dataPath = sceneProEntity.getDataSource() + "/caches/tex";
|
|
|
|
+ File dataFile = new File(dataPath);
|
|
|
|
+ if(!dataFile.exists()){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3018);
|
|
|
|
+ }
|
|
|
|
+ for(File file : dataFile.listFiles()){
|
|
|
|
+ if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
|
+ !"mesh.obj".equals(file.getName())){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
|
+ !"mesh.mtl".equals(file.getName())){
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileUtils.zipFile(ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/" + sceneNum + ".zip", dataPath);
|
|
|
|
+ return ResultData.ok(mainUrl + "scene/images/images" + sceneNum + "/" + sceneNum + ".zip?t=" +System.currentTimeMillis());
|
|
|
|
+ }
|
|
}
|
|
}
|