|
@@ -1,5 +1,6 @@
|
|
package com.fdkankan.manage.service.impl;
|
|
package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
|
|
+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.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -9,11 +10,9 @@ import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.response.PageInfo;
|
|
import com.fdkankan.common.response.PageInfo;
|
|
-import com.fdkankan.common.util.CreateObjUtil;
|
|
|
|
-import com.fdkankan.common.util.FileUtils;
|
|
|
|
-import com.fdkankan.common.util.MatrixToImageWriterUtil;
|
|
|
|
-import com.fdkankan.common.util.RandomUtil;
|
|
|
|
|
|
+import com.fdkankan.common.util.*;
|
|
import com.fdkankan.manage.httpClient.service.LaserService;
|
|
import com.fdkankan.manage.httpClient.service.LaserService;
|
|
|
|
+import com.fdkankan.manage.util.CreateObjUtilSelf;
|
|
import com.fdkankan.manage.util.MangerUploadToOssUtil;
|
|
import com.fdkankan.manage.util.MangerUploadToOssUtil;
|
|
import com.fdkankan.manage.common.CameraConstant;
|
|
import com.fdkankan.manage.common.CameraConstant;
|
|
import com.fdkankan.manage.entity.*;
|
|
import com.fdkankan.manage.entity.*;
|
|
@@ -80,6 +79,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
@Value("${scene.pro.new.url}")
|
|
@Value("${scene.pro.new.url}")
|
|
private String sceneProNewUrl;
|
|
private String sceneProNewUrl;
|
|
|
|
+ @Value("${oss.bucket}")
|
|
|
|
+ private String bucket;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ScenePro getByNum(String num) {
|
|
public ScenePro getByNum(String num) {
|
|
@@ -296,6 +297,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
scenePlus.setUserId(cameraDetail.getUserId());
|
|
scenePlus.setUserId(cameraDetail.getUserId());
|
|
scenePlusService.updateById(scenePlus);
|
|
scenePlusService.updateById(scenePlus);
|
|
}
|
|
}
|
|
|
|
+ if(cameraDetail.getType() == 10){ //深时场景
|
|
|
|
+ laserService.move(param.getNum(),oldCamera.getSnCode(),camera.getSnCode());
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -307,18 +311,22 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
}
|
|
}
|
|
Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
|
|
Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
|
|
-
|
|
|
|
|
|
+ Camera camera = cameraService.getById(cameraId);
|
|
|
|
+ if(camera == null){
|
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
|
|
|
|
+ }
|
|
CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
|
|
CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
|
|
if(detailEntity == null){
|
|
if(detailEntity == null){
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
|
|
}
|
|
}
|
|
String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
|
|
|
|
|
|
+
|
|
if(scenePro !=null){ //v3场景复制
|
|
if(scenePro !=null){ //v3场景复制
|
|
- this.copyV3Scene(scenePro,newNum,detailEntity);
|
|
|
|
|
|
+ this.copyV3Scene(scenePro,newNum,detailEntity,camera.getSnCode());
|
|
}
|
|
}
|
|
if(scenePlus != null){ //v4场景复制
|
|
if(scenePlus != null){ //v4场景复制
|
|
- scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity);
|
|
|
|
|
|
+ scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity,camera.getSnCode());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -339,7 +347,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail) throws Exception {
|
|
|
|
|
|
+ public void copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail,String snCode) throws Exception {
|
|
SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
|
|
SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
|
|
|
|
|
|
String oldNum = oldScene.getNum();
|
|
String oldNum = oldScene.getNum();
|
|
@@ -353,7 +361,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
oldScene.setVideos(oldScene.getVideos().replace(oldNum,newNum));
|
|
oldScene.setVideos(oldScene.getVideos().replace(oldNum,newNum));
|
|
oldScene.setViewCount(0);
|
|
oldScene.setViewCount(0);
|
|
String preDataSource = oldScene.getDataSource();
|
|
String preDataSource = oldScene.getDataSource();
|
|
- oldScene.setDataSource(this.setDataSource(preDataSource,oldScene.getSceneSource()));
|
|
|
|
|
|
+ String time = DateUtil.date2String(new Date(),DateUtil.YYYYMMDDHHMMSSSSS_DATA_FORMAT);
|
|
|
|
+ oldScene.setDataSource(this.setDataSource(preDataSource,time));
|
|
|
|
|
|
this.save(oldScene);
|
|
this.save(oldScene);
|
|
|
|
|
|
@@ -377,6 +386,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
try {
|
|
try {
|
|
log.info("开始复制场景-{}", new Date());
|
|
log.info("开始复制场景-{}", new Date());
|
|
|
|
|
|
|
|
+ this.copyDataSource(oldScene.getDataSource(),preDataSource,oldScene.getSceneType(),time);
|
|
//oss复制计算结果资源
|
|
//oss复制计算结果资源
|
|
this.copyOssSource("v3",oldNum,newNum);
|
|
this.copyOssSource("v3",oldNum,newNum);
|
|
this.copyLocalSource(oldNum,newNum);
|
|
this.copyLocalSource(oldNum,newNum);
|
|
@@ -391,6 +401,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
log.error("复制场景异常", e);
|
|
log.error("复制场景异常", e);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ if(oldScene.getSceneType() == 4){ //深时场景
|
|
|
|
+ laserService.copy(snCode,oldScene.getCreateTime(),newNum,oldScene.getStatus(),oldEditScene.getSceneKey(),oldScene.getSceneName(),oldScene.getUserId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -431,36 +444,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String setDataSource(String preDataSource,Integer sceneSource) throws Exception {
|
|
|
|
- String datasourceFix;
|
|
|
|
- String newDataSource;
|
|
|
|
- // 判断场景是否拷贝过
|
|
|
|
- ScenePro entity;
|
|
|
|
- do{
|
|
|
|
- datasourceFix = RandomUtil.generateShortUuid();
|
|
|
|
- entity = this.findByFileId(preDataSource.concat(datasourceFix));
|
|
|
|
- }while(!ObjectUtils.isEmpty(entity));
|
|
|
|
- newDataSource = datasourceFix.concat(datasourceFix);
|
|
|
|
-
|
|
|
|
- //oss复制源文件
|
|
|
|
- String buildModelPath = ConstantFilePath.BUILD_MODEL_PATH;
|
|
|
|
- if(sceneSource.equals(4)){
|
|
|
|
- buildModelPath = ConstantFilePath.BUILD_MODEL_LASER_PATH;
|
|
|
|
- }
|
|
|
|
- CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX +newDataSource.replace(buildModelPath, "")+"/", newDataSource);
|
|
|
|
-
|
|
|
|
- List<String> urlList = new ArrayList<>();
|
|
|
|
- FileUtils.readfilePath(newDataSource, urlList);
|
|
|
|
- Map<String,String> fileMap = new HashMap<>();
|
|
|
|
- for(String url : urlList){
|
|
|
|
- fileMap.put(url, ConstantFilePath.OSS_PREFIX + url.replace(buildModelPath, ""));
|
|
|
|
- }
|
|
|
|
- mangeUploadToOssUtil.uploadMulFiles(fileMap);
|
|
|
|
-
|
|
|
|
- FileUtils.delAllFile(newDataSource);
|
|
|
|
-
|
|
|
|
- FileUtils.copyFolderAllFiles(preDataSource+"/",newDataSource+"/", true);
|
|
|
|
- return datasourceFix.concat(datasourceFix);
|
|
|
|
|
|
+ public String setDataSource(String preDataSource,String time) throws Exception {
|
|
|
|
+ SnowflakeIdGenerator snowflakeIdGenerator = new SnowflakeIdGenerator(16,16);
|
|
|
|
+ String[] datasource = preDataSource.split("/");
|
|
|
|
+ datasource[4] = snowflakeIdGenerator.nextId()+"";
|
|
|
|
+ datasource[5] = datasource[3]+"_"+ time;
|
|
|
|
+ return Arrays.stream(datasource).collect(Collectors.joining("/"));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -522,4 +511,30 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
FileUtils.writeFile(filePath,content);
|
|
FileUtils.writeFile(filePath,content);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void copyDataSource(String newDataSource,String oldDataSource,Integer sceneType,String time) throws Exception{
|
|
|
|
+ //oss复制源文件
|
|
|
|
+ String buildModelPath = ConstantFilePath.BUILD_MODEL_PATH;
|
|
|
|
+ if(sceneType == 4){ //深时
|
|
|
|
+ buildModelPath = ConstantFilePath.BUILD_MODEL_LASER_PATH;
|
|
|
|
+ }
|
|
|
|
+ CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + oldDataSource.replace(buildModelPath, "")+"/", newDataSource);
|
|
|
|
+
|
|
|
|
+ // 修改data.fdage
|
|
|
|
+ String data = FileUtils.readFile(newDataSource + "/data.fdage");
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
|
+ if(ObjectUtils.isEmpty(jsonObject)){
|
|
|
|
+ log.error("data.fdage文件不存在");
|
|
|
|
+ throw new BusinessException(-1,"拷贝场景出错,data.fdage文件不存在");
|
|
|
|
+ }
|
|
|
|
+ jsonObject.put("uuidtime",time);
|
|
|
|
+ FileUtils.writeFile(newDataSource + "/data.fdage", jsonObject.toJSONString());
|
|
|
|
+ CreateObjUtilSelf.ossUtilCpFolder(newDataSource, bucket.concat("/" + ConstantFilePath.OSS_PREFIX + newDataSource.replace(buildModelPath, "")));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ FileUtils.delAllFile(newDataSource);
|
|
|
|
+
|
|
|
|
+ FileUtils.copyFolderAllFiles(oldDataSource+"/",newDataSource+"/", true);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|