|
@@ -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;
|
|
@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.common.constant.*;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
+import com.fdkankan.common.util.ComputerUtil;
|
|
|
import com.fdkankan.common.util.CreateObjUtil;
|
|
|
import com.fdkankan.common.util.FileMd5Util;
|
|
|
import com.fdkankan.common.util.FileUtil;
|
|
@@ -33,6 +35,7 @@ import com.fdkankan.scene.bean.SceneJsonBean;
|
|
|
import com.fdkankan.scene.entity.SceneDataDownload;
|
|
|
import com.fdkankan.scene.entity.SceneEditControls;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
|
+import com.fdkankan.scene.entity.SceneEditInfoExt;
|
|
|
import com.fdkankan.scene.entity.ScenePlus;
|
|
|
import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
@@ -43,6 +46,7 @@ import com.fdkankan.scene.factory.ScreenshotHandlerFactory;
|
|
|
import com.fdkankan.scene.mapper.ISceneEditInfoMapper;
|
|
|
import com.fdkankan.scene.service.ISceneDataDownloadService;
|
|
|
import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
|
+import com.fdkankan.scene.service.ISceneEditInfoExtService;
|
|
|
import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
|
import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
@@ -52,6 +56,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;
|
|
@@ -110,6 +115,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
@Autowired
|
|
|
PlatformUserClient platformUserClient;
|
|
|
@Autowired
|
|
|
+ private ISceneEditInfoExtService sceneEditInfoExtService;
|
|
|
+ @Autowired
|
|
|
IScenePlusService scenePlusService;
|
|
|
@Autowired
|
|
|
IScenePlusExtService scenePlusExtService;
|
|
@@ -174,6 +181,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
String num = param.getNum();
|
|
|
|
|
|
//根据场景码查询数据库
|
|
|
+ ScenePro scenePro = sceneProService.findBySceneNum(sceneNum);
|
|
|
+ SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
|
|
|
+ SceneEditInfo sceneEditInfo = this.getBySceneProId(scenePro.getId());
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = null;
|
|
|
+ SceneEditControls sceneEditControls = null;
|
|
|
// ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
// SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
@@ -185,6 +197,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneEditInfo.setSceneProId(scenePlus.getId());
|
|
|
}else{
|
|
|
sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
|
|
|
+ sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
|
|
|
+ }
|
|
|
+ if(sceneEditInfoExt == null){
|
|
|
+ sceneEditInfoExt = new SceneEditInfoExt();
|
|
|
+ sceneEditInfoExt.setFloorPlanAngle(0f);
|
|
|
+ sceneEditInfoExt.setFloorPlanCompass(0f);
|
|
|
}
|
|
|
|
|
|
// if(sceneEditControls == null){
|
|
@@ -192,7 +210,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
// }
|
|
|
|
|
|
//生成sceneJson
|
|
|
- SceneJsonBean sceneJson = BeanUtil.copyProperties(sceneEditInfo, SceneJsonBean.class);
|
|
|
+ SceneJsonBean sceneJson = new SceneJsonBean();
|
|
|
+ BeanUtil.copyProperties(sceneEditInfoExt, sceneJson);
|
|
|
+ BeanUtil.copyProperties(sceneEditInfo, sceneJson);
|
|
|
SceneEditControlsVO sceneEditControlsVO = BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class);
|
|
|
sceneJson.setControls(sceneEditControlsVO);
|
|
|
sceneJson.setNum(num);
|
|
@@ -208,7 +228,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
//处理热点数据,生成hot.json
|
|
|
- this.publicHotData(num, sceneJson, sceneEditInfo);
|
|
|
+ this.publicHotData(num, sceneEditInfo);
|
|
|
|
|
|
// TODO: 2022/3/2 这里的逻辑放在上传球幕视频接口中做了,这里先暂时注释掉,以后要删除
|
|
|
//处理球幕视频
|
|
@@ -241,6 +261,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}else{
|
|
|
this.updateById(sceneEditInfo);
|
|
|
}
|
|
|
+ sceneEditInfoExt.setSceneProId(scenePro.getId());
|
|
|
+ sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
+ sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
|
|
|
|
|
|
// sceneEditControls.setEditInfoId(sceneEditInfo.getId());
|
|
|
// if(sceneEditControls.getId() == null){
|
|
@@ -290,7 +313,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneEditInfo.setBuildVideoStatus(CommonStatus.NO.code());
|
|
|
}
|
|
|
|
|
|
- private void publicHotData(String sceneNum, SceneJsonBean sceneJson, SceneEditInfo sceneEditInfo) throws IOException {
|
|
|
+ private void publicHotData(String sceneNum, SceneEditInfo sceneEditInfo) throws IOException {
|
|
|
String hotDataKey = String.format(RedisKey.SCENE_HOT_DATA, sceneNum);
|
|
|
Map<String, String> hotMap = redisUtil.hmget(hotDataKey);
|
|
|
List<String> hotList = Lists.newArrayList();
|
|
@@ -348,8 +371,17 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
if(Objects.isNull(sceneEditInfo)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
|
|
|
SceneEditControls sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
|
|
|
- SceneInfoVO sceneInfoVO = BeanUtil.copyProperties(sceneEditInfo, SceneInfoVO.class);
|
|
|
+ SceneInfoVO sceneInfoVO = new SceneInfoVO();
|
|
|
+ BeanUtil.copyProperties(sceneEditInfoExt, sceneInfoVO);
|
|
|
+ BeanUtil.copyProperties(sceneEditInfo, sceneInfoVO);
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
|
|
|
+ sceneInfoVO.setFloorPlanAngle(0f);
|
|
|
+ }
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
|
|
|
+ sceneInfoVO.setFloorPlanCompass(0f);
|
|
|
+ }
|
|
|
sceneInfoVO.setControls(BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class));
|
|
|
sceneInfoVO.setNum(num);
|
|
|
//生成sceneJson
|
|
@@ -416,9 +448,16 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
String sceneJson = redisUtil.get(key);
|
|
|
SceneInfoVO sceneInfoVO = null;
|
|
|
//先查询redis
|
|
|
- if(StrUtil.isNotEmpty(sceneJson)){
|
|
|
+ if(StrUtil.isNotEmpty(sceneJson)) {
|
|
|
sceneInfoVO = JSON.parseObject(sceneJson, SceneInfoVO.class);
|
|
|
this.setExtData(sceneInfoVO, scenePlus.getCameraId());
|
|
|
+ sceneInfoVO.setScenePassword(null);
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
|
|
|
+ sceneInfoVO.setFloorPlanAngle(0f);
|
|
|
+ }
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
|
|
|
+ sceneInfoVO.setFloorPlanCompass(0f);
|
|
|
+ }
|
|
|
return sceneInfoVO;
|
|
|
}
|
|
|
|
|
@@ -429,6 +468,13 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return null;
|
|
|
sceneInfoVO = JSON.parseObject(objectContent, SceneInfoVO.class);
|
|
|
this.setExtData(sceneInfoVO, scenePlus.getCameraId());
|
|
|
+ sceneInfoVO.setScenePassword(null);
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
|
|
|
+ sceneInfoVO.setFloorPlanAngle(0f);
|
|
|
+ }
|
|
|
+ if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
|
|
|
+ sceneInfoVO.setFloorPlanCompass(0f);
|
|
|
+ }
|
|
|
redisUtil.set(key, JSON.toJSONString(sceneInfoVO));
|
|
|
|
|
|
return sceneInfoVO;
|
|
@@ -478,8 +524,16 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
String filePathStr = null;
|
|
|
|
|
|
String floors = fileInfoJson.getString("floors");
|
|
|
- String cadInfo = fileInfoJson.getString("cadInfo");
|
|
|
+ String cadInfo = null;
|
|
|
+ Float angel = null;
|
|
|
+ Float compass = null;
|
|
|
String floorJsonData = fileInfoJson.getString("floorJsonData");
|
|
|
+ if(StrUtil.isNotBlank(floorJsonData)){
|
|
|
+ JSONObject jsonObject = JSON.parseObject(floorJsonData);
|
|
|
+ cadInfo = jsonObject.getString("cadInfo");
|
|
|
+ angel = jsonObject.getFloat("angle");
|
|
|
+ compass = jsonObject.getFloat("compass");
|
|
|
+ }
|
|
|
// String filePaths = fileInfoJson.getString("filePaths");
|
|
|
// Byte reSet = fileInfoJson.getByte("reset");
|
|
|
|
|
@@ -495,6 +549,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
// }
|
|
|
|
|
|
//处理户型图数据
|
|
|
+ JSONObject floorUserJson = null;
|
|
|
if(StrUtil.isNotEmpty(floors)) {
|
|
|
//如果入参是空,则加载服务器的
|
|
|
if(StrUtil.isEmpty(floorJsonData)){
|
|
@@ -507,7 +562,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
//如果floors不为空,需要根据对应楼层id修改楼层名称
|
|
|
if (StrUtil.isNotEmpty(floorJsonData)) {
|
|
|
- JSONObject floorUserJson = this.updateFloorName(floors, floorJsonData);
|
|
|
+ floorUserJson = this.updateFloorName(floors, floorJsonData);
|
|
|
floorJsonData = floorUserJson.toJSONString();
|
|
|
}
|
|
|
}
|
|
@@ -564,6 +619,20 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
this.save(sceneEditInfoDb);
|
|
|
}
|
|
|
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoDb.getId());
|
|
|
+ if(Objects.isNull(sceneEditInfoExt)){
|
|
|
+ sceneEditInfoExt = new SceneEditInfoExt();
|
|
|
+ sceneEditInfoExt.setEditInfoId(sceneEditInfoDb.getId());
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(angel)){
|
|
|
+ sceneEditInfoExt.setFloorPlanAngle(angel);
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(compass)){
|
|
|
+ sceneEditInfoExt.setFloorPlanCompass(compass);
|
|
|
+ }
|
|
|
+ sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
|
|
|
+
|
|
|
+
|
|
|
return ResultData.ok();
|
|
|
|
|
|
}
|
|
@@ -577,18 +646,29 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
|
|
SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = null;
|
|
|
if(Objects.nonNull(sceneEditInfoDb)){
|
|
|
LambdaUpdateWrapper<SceneEditInfo> updateWrapper = new LambdaUpdateWrapper<SceneEditInfo>()
|
|
|
.setSql("version=version+" + 1)
|
|
|
.set(SceneEditInfo::getFloorPlanUser, CommonStatus.NO.code())
|
|
|
.eq(SceneEditInfo::getId, sceneEditInfoDb.getId());
|
|
|
this.update(updateWrapper);
|
|
|
+
|
|
|
+ sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoDb.getId());
|
|
|
}else{
|
|
|
sceneEditInfoDb = new SceneEditInfo();
|
|
|
sceneEditInfoDb.setScenePlusId(scenePlus.getId());
|
|
|
sceneEditInfoDb.setFloorPlanUser(CommonStatus.NO.code());
|
|
|
this.save(sceneEditInfoDb);
|
|
|
}
|
|
|
+ if(Objects.isNull(sceneEditInfoExt)){
|
|
|
+ sceneEditInfoExt = new SceneEditInfoExt();
|
|
|
+ sceneEditInfoExt.setSceneProId(scenePro.getId());
|
|
|
+ sceneEditInfoExt.setEditInfoId(sceneEditInfoDb.getId());
|
|
|
+ }
|
|
|
+ sceneEditInfoExt.setFloorPlanAngle(0f);
|
|
|
+ sceneEditInfoExt.setFloorPlanCompass(0f);
|
|
|
+ sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
|
|
|
|
|
|
return ResultData.ok();
|
|
|
|
|
@@ -622,31 +702,50 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<String> uploadPanorama(String num, MultipartFile file) throws Exception {
|
|
|
+ public ResultData uploadPanorama(String num, MultipartFile file) throws Exception {
|
|
|
+
|
|
|
+ //校验压缩包格式
|
|
|
+ log.info("全景图压缩包文件名:" + file.getOriginalFilename());
|
|
|
+ if(!file.getOriginalFilename().endsWith(".zip")){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7014);
|
|
|
}
|
|
|
|
|
|
//列出caches/images中的文件列表
|
|
@@ -669,18 +768,122 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
//有文件对不上号,就退出
|
|
|
if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
- return notExistFileList;
|
|
|
+ return ResultData.error(ErrorCode.FAILURE_CODE_7012, notExistFileList);
|
|
|
}
|
|
|
|
|
|
//上传
|
|
|
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 uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
|
|
|
+ Thread.sleep(2000);
|
|
|
+ boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 3, 5000);
|
|
|
+ if(!exist){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5042);
|
|
|
+ }
|
|
|
+ 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){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(map.size()>0) {
|
|
|
+ uploadToOssUtil.uploadMulFiles(map);
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
}
|
|
@@ -708,24 +911,18 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
String imageUrl = ossUrlPrefix + filePath + "?t=" + System.currentTimeMillis();
|
|
|
FileUtils.downLoadFromUrl(imageUrl, fileName, localImagesPath);
|
|
|
}
|
|
|
- //上传
|
|
|
- uploadToOssUtil.upload(localImagesPath + fileName, String.format(cacheImageFormat, num) + fileName);
|
|
|
- String url = ossUrlPrefix + String.format(cacheImageFormat, num) + fileName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("fileUrl", url + "?t=" + System.currentTimeMillis());
|
|
|
- map.put("fileName", fileName);
|
|
|
- return ResultData.ok(map);
|
|
|
+ }else{
|
|
|
+ //先下载到本地
|
|
|
+ List<String> keyList = uploadToOssUtil.listKeys(imgCachePath);
|
|
|
+ if (!StorageType.LOCAL.code().equals(this.type)) {// TODO: 2022/2/15 这里有可能有问题,可能还需要考虑本地部署的情况
|
|
|
+ keyList.stream().forEach(key->{
|
|
|
+ String file = key.substring(key.lastIndexOf("/") + 1);
|
|
|
+ String imageUrl = ossUrlPrefix + imgCachePath + file + "?t=" + System.currentTimeMillis();
|
|
|
+ FileUtils.downLoadFromUrl(imageUrl, file, localImagesPath);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //先下载到本地
|
|
|
- List<String> keyList = uploadToOssUtil.listKeys(imgCachePath);
|
|
|
- if (!StorageType.LOCAL.code().equals(this.type)) {// TODO: 2022/2/15 这里有可能有问题,可能还需要考虑本地部署的情况
|
|
|
- keyList.stream().forEach(key->{
|
|
|
- String file = key.substring(key.lastIndexOf("/") + 1);
|
|
|
- String imageUrl = ossUrlPrefix + imgCachePath + file + "?t=" + System.currentTimeMillis();
|
|
|
- FileUtils.downLoadFromUrl(imageUrl, file, localImagesPath);
|
|
|
- });
|
|
|
- }
|
|
|
//打包
|
|
|
String zipName = num + "_images.zip";
|
|
|
String zipPath = cachePath + zipName;
|
|
@@ -815,7 +1012,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
@Override
|
|
|
public DownloadVO downloadBallScreenVideo(BallScreenVideoParamVO param) {
|
|
|
- String videoPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + param.getFileName();
|
|
|
+ String videoPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, param.getNum()) + param.getFileName();
|
|
|
String url = ossUrlPrefix + videoPath + "?t=" + System.currentTimeMillis();
|
|
|
return DownloadVO.builder()
|
|
|
.fileName(param.getFileName())
|
|
@@ -826,9 +1023,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
@Override
|
|
|
public ResultData uploadBallScreenVideo(String num, String fileName, MultipartFile file) throws Exception {
|
|
|
|
|
|
+ //校验格式
|
|
|
if(!fileName.endsWith(".mp4")){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7007.code(), ErrorCode.FAILURE_CODE_7007.formatMessage("mp4"));
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7016);
|
|
|
}
|
|
|
+ String videosViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
|
|
|
|
|
|
// ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
@@ -839,6 +1038,24 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
|
|
String path = scenePlusExt.getDataSource();
|
|
|
+ //校验文件名
|
|
|
+ String videos = scenePro.getVideos();
|
|
|
+ if(StrUtil.isEmpty(videos)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7012);
|
|
|
+ }
|
|
|
+ JSONObject videosJson = JSON.parseObject(videos);
|
|
|
+ JSONArray dataArr = videosJson.getJSONArray("data");
|
|
|
+ boolean exists = false;
|
|
|
+ for (Object o : dataArr) {
|
|
|
+ JSONObject jsonObject = (JSONObject)o;
|
|
|
+ if(jsonObject.getString("id").equals(fileName.replace(".mp4", ""))){
|
|
|
+ exists = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!exists){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7012);
|
|
|
+ }
|
|
|
|
|
|
if(path != null && !"".equals(path) && path.startsWith("http")){
|
|
|
path = ConstantFilePath.BUILD_MODEL_PATH + File.separator + path.split("/")[path.split("/").length - 2];
|
|
@@ -862,7 +1079,6 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_7009);
|
|
|
}
|
|
|
|
|
|
- String videosViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
|
|
|
for(String videoName : video.list()){
|
|
|
log.info("球幕视频名称:{}", videoName);
|
|
|
uploadToOssUtil.upload(target + File.separator + "extras/video/" + videoName,videosViewPath + videoName);
|
|
@@ -1020,16 +1236,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
String uploadJsonPath = target + File.separator + "results" + File.separator + "upload.json";
|
|
|
log.info("uploadJsonPath=" + uploadJsonPath);
|
|
|
//因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
|
|
|
- int checkTimes = 1;
|
|
|
- boolean exist = false;
|
|
|
- do {
|
|
|
- if(new File(uploadJsonPath).exists()){
|
|
|
- exist = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- Thread.sleep(5000);
|
|
|
- ++checkTimes;
|
|
|
- }while (checkTimes <= 3);
|
|
|
+ boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 3, 5000);
|
|
|
if(!exist){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5042);
|
|
|
}
|
|
@@ -1072,6 +1279,19 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResultData checkKey(SceneCheckKeyParamVO param) throws Exception {
|
|
|
+
|
|
|
+ String sceneJson = redisUtil.get(String.format(RedisKey.SCENE_JSON, param.getNum()));
|
|
|
+ SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
|
|
|
+
|
|
|
+ if(!param.getPassword().equals(sceneJsonBean.getScenePassword())){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5021);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
private void updateBoxVideos(SceneEditInfo sceneEditInfo, Long scenePlusId, String boxVideos){
|
|
|
if(Objects.isNull(sceneEditInfo)){
|
|
|
sceneEditInfo = new SceneEditInfo();
|