|
@@ -9,6 +9,8 @@ import com.fdkankan.base.constant.SceneConstant;
|
|
|
import com.fdkankan.base.mapper.base.IBaseMapper;
|
|
|
import com.fdkankan.base.service.impl.BaseServiceImpl;
|
|
|
import com.fdkankan.base.util.ConvertUtils;
|
|
|
+import com.fdkankan.common.SceneOssFileEnum;
|
|
|
+import com.fdkankan.common.constant.Constant;
|
|
|
import com.fdkankan.common.constant.ConstantFileName;
|
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
|
import com.fdkankan.common.exception.BaseRuntimeException;
|
|
@@ -28,6 +30,8 @@ import com.fdkankan.scene.entity.SceneProEntity;
|
|
|
import com.fdkankan.scene.feign.DepartmentFeign;
|
|
|
import com.fdkankan.scene.mapper.ISceneProEditMapper;
|
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
|
+import com.fdkankan.scene.param.scene.DownloadVideoParam;
|
|
|
+import com.fdkankan.scene.param.scene.OperaVideoParam;
|
|
|
import com.fdkankan.scene.service.ICameraService;
|
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
|
import com.fdkankan.scene.util.CreateObjUtil;
|
|
@@ -49,6 +53,7 @@ import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by Hb_zzZ on 2019/7/23.
|
|
@@ -1634,79 +1639,6 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
|
|
|
|
|
|
scenejson.put("floorEditVer", sceneProEditEntity.getFloorEditVer());
|
|
|
scenejson.put("floorPublishVer", sceneProEditEntity.getFloorEditVer());
|
|
|
-// }else {
|
|
|
-//
|
|
|
-// String path = sceneProEntity.getDataSource();
|
|
|
-// if(path != null && !"".equals(path) && path.startsWith("http")){
|
|
|
-// path = ConstantFilePath.BUILD_MODEL_PATH + path.split("/")[path.split("/").length - 2];
|
|
|
-// }
|
|
|
-// path = path + "_edit";
|
|
|
-// String projectNum = base.getSceneNum();
|
|
|
-//
|
|
|
-// //读取upload文件,检验需要上传的文件是否存在
|
|
|
-// 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){
|
|
|
-// 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") == 2 && !fileJson.containsKey("pack-file")){
|
|
|
-// map.put(path + File.separator + "results" +File.separator+ fileName,"images/images"+
|
|
|
-// projectNum+"/"+ConstantFileName.modelUUID+"_50k_texture_jpg_high1/"+fileName.replace("tex/", ""));
|
|
|
-// }
|
|
|
-//
|
|
|
-// //2048的模型和贴图
|
|
|
-// if(fileJson.getIntValue("clazz") == 16){
|
|
|
-// map.put(path + File.separator + "results" + File.separator+ fileName,"data/data"+
|
|
|
-// projectNum+ File.separator + fileName);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k.dam.lzma");
|
|
|
-// map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
-//// map.put(path + File.separator + "results" +File.separator+"modeldata.js","data/"+projectNum+"/"+"modeldata.js");
|
|
|
-//
|
|
|
-//// map.put(path + File.separator + "results" +File.separator+"vision.modeldata", "images/images"+projectNum+"/"+"vision.modeldata");
|
|
|
-//// if(new File(path + File.separator + "results" +File.separator+"vision2.modeldata").exists()){
|
|
|
-//// map.put(path + File.separator + "results" +File.separator+"vision2.modeldata", "images/images"+projectNum+"/"+"vision2.modeldata");
|
|
|
-//// }
|
|
|
-//// List<String> list1 = FileUtil.readfileNamesForDirectory(path + File.separator + "results" +File.separator+"tex",".jpg");
|
|
|
-//// for(int i=0;i<list1.size();++i)
|
|
|
-//// {
|
|
|
-//// String imgName = list1.get(i);
|
|
|
-//// map.put(path + File.separator + "results" +File.separator+"tex"+File.separator+imgName,"images/images"+projectNum+"/"+Constant.modelUUID+"_50k_texture_jpg_high1/"+imgName);
|
|
|
-//// }
|
|
|
-//
|
|
|
-// File file = new File(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum);
|
|
|
-// if(!file.exists())
|
|
|
-// {
|
|
|
-// file.mkdir();
|
|
|
-// }
|
|
|
-// log.info("计算大场景:开始上传大场景文件到阿里——"+projectNum);
|
|
|
-// //上传修改后的本地的缩略图
|
|
|
-// map.put(dataBuffer.toString() + "floor.json", dataBuf.toString() + "floor.json");
|
|
|
-//
|
|
|
-// //发布重新建模场景,将floorPublishVer设为floorEditVer的值
|
|
|
-// sceneProEditEntity.setFloorPublishVer(sceneProEditEntity.getFloorEditVer());
|
|
|
-//
|
|
|
-// scenejson.put("floorEditVer", sceneProEditEntity.getFloorEditVer());
|
|
|
-// scenejson.put("floorPublishVer", sceneProEditEntity.getFloorEditVer());
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//重算全景图并上传oss或视频上传oss
|
|
@@ -3117,8 +3049,6 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
|
|
|
String path = sceneProEntity.getDataSource();
|
|
|
|
|
|
String url = "";
|
|
|
-// String zipName = "";
|
|
|
-
|
|
|
if("image".equals(type)){
|
|
|
if(!new File(path + "/caches/images/" + fileName).exists()){
|
|
|
throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3018, LoginConstant.FAILURE_MSG_3018);
|
|
@@ -3131,38 +3061,38 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
|
|
|
//复制打包数据,并且改名
|
|
|
FileUtils.copyFile(path + "/caches/images/" + fileName, imagesBuffer.toString() + "caches/" + planId + ".jpg", true);
|
|
|
// //将图片打成zip包
|
|
|
-// zipName = imagesBuffer.toString() + "caches/" + sceneNum + "-image-" + planId + ".zip";
|
|
|
-// FileUtils.zipFile(zipName, imagesBuffer.toString() + "caches/" + planId + ".jpg");
|
|
|
-//
|
|
|
-// url = mainIntranetUrl + zipName.replace(ConstantFilePath.BASE_PATH + "/", "");
|
|
|
-
|
|
|
url = mainIntranetUrl + "scene/" + imagesBuf.toString() + "caches/" + planId + ".jpg";
|
|
|
}
|
|
|
|
|
|
if("video".equals(type)){
|
|
|
-// if(!new File(path + "/caches/videos/" + fileName).exists()){
|
|
|
-// throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3018, LoginConstant.FAILURE_MSG_3018);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //备份原始数据
|
|
|
-// if(!new File(imagesBuffer.toString() + "caches/back-" + fileName).exists()){
|
|
|
-// FileUtils.copyFile(path + "/caches/videos/" + fileName, imagesBuffer.toString() + "caches/back-" + fileName, false);
|
|
|
-// }
|
|
|
-// //复制打包数据,并且改名
|
|
|
-// FileUtils.copyFile(path + "/caches/videos/" + fileName, imagesBuffer.toString() + "caches/" + planId + ".mp4", true);
|
|
|
-//// //将视频打成zip包
|
|
|
-//// zipName = imagesBuffer.toString() + "caches/" + sceneNum + "-video-" + planId + ".zip";
|
|
|
-//// FileUtils.zipFile(zipName, imagesBuffer.toString() + "caches/" + planId + ".mp4");
|
|
|
-//// url = mainIntranetUrl + zipName.replace(ConstantFilePath.BASE_PATH + "/", "");
|
|
|
-//
|
|
|
-// url = mainIntranetUrl + "scene/" + imagesBuf.toString() + "caches/" + planId + ".mp4";
|
|
|
-
|
|
|
//使用oss的路径
|
|
|
url = prefixAli + "video/video" + sceneProEntity.getNum() + "/" + planId + ".mp4";
|
|
|
}
|
|
|
return url;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String downloadVideo(DownloadVideoParam downloadVideoParam) throws Exception {
|
|
|
+ String fileName = downloadVideoParam.getPlanId() + ".mp4";
|
|
|
+ String newFileName = downloadVideoParam.getPlanId() + Constant.SCENE_VIDEO_SHARE_SUFFIX +".mp4";
|
|
|
+ String url = prefixAli + "video/video" + downloadVideoParam.getSceneNum() + "/" + newFileName;
|
|
|
+
|
|
|
+ // oss下载原视频
|
|
|
+ String ossFile = "video/video" + downloadVideoParam.getSceneNum() + "/" + fileName;
|
|
|
+ String targetFile = ConstantFilePath.SCENE_PATH + "video/video" + downloadVideoParam.getSceneNum() + "/" + fileName;
|
|
|
+ CreateObjUtil.ossUtilCp(ossFile, targetFile);
|
|
|
+
|
|
|
+ // 生成水印视频
|
|
|
+ CreateObjUtil.generateShareVideo(targetFile);
|
|
|
+
|
|
|
+ // 上传到oss
|
|
|
+ uploadToOssUtil.uploadMulFilesV2(SceneOssFileEnum.VIDEO, downloadVideoParam.getSceneNum(), newFileName);
|
|
|
+
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Result uploadPanoramaOrVideo(String sceneNum, String fileName, String type, MultipartFile file, String planId) throws Exception {
|
|
|
if(StringUtils.isEmpty(sceneNum) || StringUtils.isEmpty(fileName) || StringUtils.isEmpty(type) || StringUtils.isEmpty(planId)){
|
|
@@ -3872,4 +3802,55 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 操作球幕视频
|
|
|
+ * @param operaVideoDTO
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void operaVideo(OperaVideoParam operaVideoDTO) throws Exception {
|
|
|
+ SceneProEntity sceneProEntity = findBySceneNum(operaVideoDTO.getNum());
|
|
|
+ if(sceneProEntity == null){
|
|
|
+ throw new BaseRuntimeException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ String strsceneInfos = FileUtils.readFile(dataBuffer + "scene.json");
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
+ if(strsceneInfos != null) {
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject object = putVideoDataToSceneJson(operaVideoDTO, scenejson);
|
|
|
+ FileUtils.writeFile(dataBuffer + "scene.json", scenejson.toString());
|
|
|
+
|
|
|
+ Map<String, String> uploadMap = new HashMap<>();
|
|
|
+ uploadMap.put(dataBuffer + "scene.json", dataBuf + "scene.json");
|
|
|
+ uploadToOssUtil.uploadMulFiles(uploadMap);
|
|
|
+
|
|
|
+ sceneProEntity.setVideos(object.toString());
|
|
|
+ update(sceneProEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // todo
|
|
|
+ private JSONObject putVideoDataToSceneJson(OperaVideoParam operaVideoDTO, JSONObject scenejson) {
|
|
|
+ Object data = scenejson.get("data");
|
|
|
+ if (data == null || data instanceof JSONArray == false) {
|
|
|
+ throw new BaseRuntimeException("json数据data异常");
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = (JSONArray) data;
|
|
|
+ Object jsonObj = jsonArray.stream().filter(j -> operaVideoDTO.getId().equals(((JSONObject)j).get("id")))
|
|
|
+ .findAny().orElseThrow(() -> new BaseRuntimeException("json数据data里找不到对应记录"));
|
|
|
+
|
|
|
+ ((JSONObject)jsonObj).put("show", operaVideoDTO.getShow());
|
|
|
+ return ((JSONObject)jsonObj);
|
|
|
+ }
|
|
|
+
|
|
|
}
|