|
@@ -7,6 +7,7 @@ import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.common.constant.CommonOperStatus;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
@@ -21,6 +22,7 @@ import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.BodySegmentStatusBean;
|
|
|
import com.fdkankan.scene.entity.*;
|
|
|
+import com.fdkankan.scene.mapper.ISceneMapper;
|
|
|
import com.fdkankan.scene.oss.OssUtil;
|
|
|
import com.fdkankan.scene.service.*;
|
|
|
import com.fdkankan.scene.util.OssBodySegmentUtil;
|
|
@@ -46,7 +48,7 @@ import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service("sceneService")
|
|
|
-public class SceneServiceImpl implements ISceneService {
|
|
|
+public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implements ISceneService {//extends ServiceImpl<ISceneResourceMapper, SceneResource> implements ISceneResourceService
|
|
|
|
|
|
private static String cloudPointFyunPath = "testdata/%s/data/bundle_%s/building/";
|
|
|
|
|
@@ -194,7 +196,7 @@ public class SceneServiceImpl implements ISceneService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void copyScene(String newNum, String sceneNum, String userName) throws Exception {
|
|
|
+ public void copyScene(String newNum, String sceneNum, String userName, String dataSource) throws Exception {
|
|
|
if(StrUtil.isEmpty(newNum) || StrUtil.isEmpty(sceneNum)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
}
|
|
@@ -205,6 +207,7 @@ public class SceneServiceImpl implements ISceneService {
|
|
|
String oldNum = scenePlus.getNum();
|
|
|
Long plusId = scenePlus.getId();
|
|
|
ScenePlusExt plusExt = scenePlusExtService.getScenePlusExtByPlusId(plusId);
|
|
|
+ String oldDataSource = plusExt.getDataSource();
|
|
|
if(plusExt == null){
|
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
}
|
|
@@ -216,91 +219,108 @@ public class SceneServiceImpl implements ISceneService {
|
|
|
|
|
|
ExecutorService executor = ThreadUtil.newSingleExecutor();
|
|
|
// CompletableFuture.runAsync(() -> {
|
|
|
- String newVideos = plusExt.getVideos();
|
|
|
- if(StrUtil.isNotEmpty(newVideos)){
|
|
|
- newVideos = plusExt.getVideos().replaceAll("/data/data" + oldNum, "/scene_view_data/" + newNum + "/data").replaceAll(oldNum, newNum);
|
|
|
- }
|
|
|
- plusExt.setId(null);
|
|
|
- plusExt.setPlusId(scenePlus.getId());
|
|
|
- plusExt.setDataSource("");
|
|
|
- plusExt.setVideos(newVideos);
|
|
|
- plusExt.setViewCount(0);
|
|
|
- scenePlusExtService.save(plusExt);
|
|
|
-
|
|
|
- SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(plusId);
|
|
|
- Long sceneEditInfoId = sceneEditInfo.getId();
|
|
|
-
|
|
|
- sceneEditInfo.setId(null);
|
|
|
- sceneEditInfo.setScenePlusId(scenePlus.getId());
|
|
|
- sceneEditInfo.setSceneProId(null);
|
|
|
- sceneEditInfo.setTitle(scenePlus.getTitle());
|
|
|
- sceneEditInfoService.save(sceneEditInfo);
|
|
|
-
|
|
|
- SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoId);
|
|
|
- sceneEditInfoExt.setId(null);
|
|
|
- sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
- sceneEditInfoExt.setScenePlusId(scenePlus.getId());
|
|
|
- sceneEditInfoExt.setSceneProId(null);
|
|
|
- sceneEditInfoExtService.save(sceneEditInfoExt);
|
|
|
-
|
|
|
- SceneEditControls sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfoId);
|
|
|
- sceneEditControls.setId(null);
|
|
|
- sceneEditControls.setEditInfoId(sceneEditInfo.getId());
|
|
|
- sceneEditControlsService.save(sceneEditControls);
|
|
|
-
|
|
|
- List<Surveillance> list = surveillanceService.list(new LambdaQueryWrapper<Surveillance>().eq(Surveillance::getNum, oldNum));
|
|
|
- if (!Objects.isNull(list)) {
|
|
|
- list.stream().forEach(item -> {
|
|
|
- item.setNum(newNum);
|
|
|
- item.setId(null);
|
|
|
- surveillanceService.save(item);
|
|
|
- });
|
|
|
- }
|
|
|
+ String newVideos = plusExt.getVideos();
|
|
|
+ if(StrUtil.isNotEmpty(newVideos)){
|
|
|
+ newVideos = plusExt.getVideos().replaceAll("/data/data" + oldNum, "/scene_view_data/" + newNum + "/data").replaceAll(oldNum, newNum);
|
|
|
+ }
|
|
|
+ plusExt.setId(null);
|
|
|
+ plusExt.setPlusId(scenePlus.getId());
|
|
|
+ plusExt.setDataSource(dataSource);
|
|
|
+ plusExt.setVideos(newVideos);
|
|
|
+ plusExt.setViewCount(0);
|
|
|
+ scenePlusExtService.save(plusExt);
|
|
|
+
|
|
|
+ SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(plusId);
|
|
|
+ Long sceneEditInfoId = sceneEditInfo.getId();
|
|
|
+
|
|
|
+ sceneEditInfo.setId(null);
|
|
|
+ sceneEditInfo.setScenePlusId(scenePlus.getId());
|
|
|
+ sceneEditInfo.setSceneProId(null);
|
|
|
+ sceneEditInfo.setTitle(scenePlus.getTitle());
|
|
|
+ sceneEditInfoService.save(sceneEditInfo);
|
|
|
+
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoId);
|
|
|
+ sceneEditInfoExt.setId(null);
|
|
|
+ sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
+ sceneEditInfoExt.setScenePlusId(scenePlus.getId());
|
|
|
+ sceneEditInfoExt.setSceneProId(null);
|
|
|
+ sceneEditInfoExtService.save(sceneEditInfoExt);
|
|
|
+
|
|
|
+ SceneEditControls sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfoId);
|
|
|
+ sceneEditControls.setId(null);
|
|
|
+ sceneEditControls.setEditInfoId(sceneEditInfo.getId());
|
|
|
+ sceneEditControlsService.save(sceneEditControls);
|
|
|
+
|
|
|
+ List<Surveillance> list = surveillanceService.list(new LambdaQueryWrapper<Surveillance>().eq(Surveillance::getNum, oldNum));
|
|
|
+ if (!Objects.isNull(list)) {
|
|
|
+ list.stream().forEach(item -> {
|
|
|
+ item.setNum(newNum);
|
|
|
+ item.setId(null);
|
|
|
+ surveillanceService.save(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- if (!ossUtil.doesObjectExist(String.format(cloudPointFyunPath,oldNum,oldNum) +"vision_edit.txt")){
|
|
|
- return;
|
|
|
- }
|
|
|
- log.info("开始同步点云编辑文件");
|
|
|
- // 上传点云编辑文件,并通知激光系统
|
|
|
- ossUtil.copyObject(String.format(cloudPointFyunPath,oldNum,oldNum) + "vision_edit.txt",
|
|
|
- String.format(cloudPointFyunPath,newNum,newNum) + "vision_edit.txt");
|
|
|
+ if (!ossUtil.doesObjectExist(String.format(cloudPointFyunPath,oldNum,oldNum) +"vision_edit.txt")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ log.info("开始同步点云编辑文件");
|
|
|
+ // 上传点云编辑文件,并通知激光系统
|
|
|
+ ossUtil.copyObject(String.format(cloudPointFyunPath,oldNum,oldNum) + "vision_edit.txt",
|
|
|
+ String.format(cloudPointFyunPath,newNum,newNum) + "vision_edit.txt");
|
|
|
|
|
|
- ossUtil.copyObject(String.format(cloudPointFyunPath,oldNum,oldNum) + "uuidcloud",
|
|
|
- String.format(cloudPointFyunPath,newNum,newNum) + "uuidcloud");
|
|
|
+ ossUtil.copyObject(String.format(cloudPointFyunPath,oldNum,oldNum) + "uuidcloud",
|
|
|
+ String.format(cloudPointFyunPath,newNum,newNum) + "uuidcloud");
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("sceneNum", newNum);
|
|
|
- params.put("businessType", 0);
|
|
|
- // TODO: 2023/7/6 调用文杰接口
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("sceneNum", newNum);
|
|
|
+ params.put("businessType", 0);
|
|
|
+ // TODO: 2023/7/6 调用文杰接口
|
|
|
|
|
|
- try {
|
|
|
+ try {
|
|
|
|
|
|
- // 拷贝场景编辑资源
|
|
|
- String oldEditPath = String.format(UploadFilePath.EDIT_PATH, oldNum);
|
|
|
- String newEditPath = String.format(UploadFilePath.EDIT_PATH, newNum);
|
|
|
- ossUtil.copyObject(oldEditPath, newEditPath);
|
|
|
-
|
|
|
- // 拷贝场景展示资源
|
|
|
- String oldViewPath = String.format(UploadFilePath.VIEW_PATH, oldNum);
|
|
|
- String newViewPath = String.format(UploadFilePath.VIEW_PATH, newNum);
|
|
|
- ossUtil.copyObject(oldViewPath, newViewPath);
|
|
|
-
|
|
|
- //复制计算结果文件
|
|
|
- String oldResultPath = String.format(UploadFilePath.scene_result_data_path, oldNum);
|
|
|
- String newResultPath = String.format(UploadFilePath.scene_result_data_path, newNum);
|
|
|
- ossUtil.copyObject(oldResultPath, newResultPath);
|
|
|
-
|
|
|
- scenePlus.setSceneStatus(-2);
|
|
|
- scenePlusService.updateById(scenePlus);
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
- log.error("复制场景失败-V4-sceneNum:{},error:{}",oldNum,e);
|
|
|
- scenePlus.setSceneStatus(-1);
|
|
|
- scenePlusService.updateById(scenePlus);
|
|
|
- throw new BusinessException(ErrorCode.SYSTEM_BUSY.code(),"复制失败!");
|
|
|
- }
|
|
|
+ // 拷贝场景编辑资源
|
|
|
+ String oldEditPath = String.format(UploadFilePath.EDIT_PATH, oldNum);
|
|
|
+ String newEditPath = String.format(UploadFilePath.EDIT_PATH, newNum);
|
|
|
+ ossUtil.copyObject(oldEditPath, newEditPath);
|
|
|
+
|
|
|
+ // 拷贝场景展示资源
|
|
|
+ String oldViewPath = String.format(UploadFilePath.VIEW_PATH, oldNum);
|
|
|
+ String newViewPath = String.format(UploadFilePath.VIEW_PATH, newNum);
|
|
|
+ ossUtil.copyObject(oldViewPath, newViewPath);
|
|
|
+
|
|
|
+ //复制计算目录
|
|
|
+ FileUtil.copy(oldDataSource, dataSource, true);
|
|
|
+
|
|
|
+ scenePlus.setSceneStatus(-2);
|
|
|
+ scenePlusService.updateById(scenePlus);
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("复制场景失败-V4-sceneNum:{},error:{}",oldNum,e);
|
|
|
+ scenePlus.setSceneStatus(-1);
|
|
|
+ scenePlusService.updateById(scenePlus);
|
|
|
+ throw new BusinessException(ErrorCode.SYSTEM_BUSY.code(),"复制失败!");
|
|
|
+ }
|
|
|
// }, executor).whenComplete((reslut, e) -> {
|
|
|
// log.info("copy-success-");
|
|
|
// });
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Scene getBySceneCode(String sceneCode) {
|
|
|
+ return this.getOne(new LambdaQueryWrapper<Scene>().eq(Scene::getSceneCode, sceneCode));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getDataSource(String num, Integer sceneSource, String dataSource) {
|
|
|
+ if(StrUtil.isEmpty(dataSource)){
|
|
|
+ Scene scene = this.getBySceneCode(num);
|
|
|
+ dataSource = scene.getPath();
|
|
|
+ }
|
|
|
+ if(sceneSource == 4){//D:\4DMega\4DKK_PROGRAM_DATA\dvt600001_202206291618176080\web_laserData\laserData
|
|
|
+ dataSource = dataSource.substring(0, dataSource.indexOf("web_laserData"));
|
|
|
+ }else{
|
|
|
+ dataSource.concat(File.separator);
|
|
|
+ }
|
|
|
+ return dataSource;
|
|
|
+ }
|
|
|
}
|