|
@@ -3,22 +3,26 @@ package com.fdkankan.scene.service.impl;
|
|
import cn.hutool.core.img.ImgUtil;
|
|
import cn.hutool.core.img.ImgUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.lang.UUID;
|
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.fdkankan.common.constant.CommonOperStatus;
|
|
import com.fdkankan.common.constant.CommonOperStatus;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
|
|
+import com.fdkankan.common.constant.SceneVersionType;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
|
+import com.fdkankan.common.util.SnowflakeIdGenerator;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
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.BodySegmentStatusBean;
|
|
import com.fdkankan.scene.bean.BodySegmentStatusBean;
|
|
-import com.fdkankan.scene.entity.ScenePlus;
|
|
|
|
|
|
+import com.fdkankan.scene.entity.*;
|
|
import com.fdkankan.scene.oss.OssUtil;
|
|
import com.fdkankan.scene.oss.OssUtil;
|
|
-import com.fdkankan.scene.service.IScenePlusService;
|
|
|
|
-import com.fdkankan.scene.service.ISceneService;
|
|
|
|
|
|
+import com.fdkankan.scene.service.*;
|
|
import com.fdkankan.scene.util.OssBodySegmentUtil;
|
|
import com.fdkankan.scene.util.OssBodySegmentUtil;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -34,13 +38,18 @@ import java.awt.image.BufferedImage;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.nio.file.FileSystemException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service("sceneService")
|
|
@Service("sceneService")
|
|
public class SceneServiceImpl implements ISceneService {
|
|
public class SceneServiceImpl implements ISceneService {
|
|
|
|
|
|
|
|
+ private static String cloudPointFyunPath = "testdata/%s/data/bundle_%s/building/";
|
|
|
|
+
|
|
@Value("${queue.bodySegment:body-segment}")
|
|
@Value("${queue.bodySegment:body-segment}")
|
|
private String queueName;
|
|
private String queueName;
|
|
@Value("${oss.bodySegment.bucket:4dkankan-huadong}")
|
|
@Value("${oss.bodySegment.bucket:4dkankan-huadong}")
|
|
@@ -56,6 +65,16 @@ public class SceneServiceImpl implements ISceneService {
|
|
private OssUtil ossUtil;
|
|
private OssUtil ossUtil;
|
|
@Autowired
|
|
@Autowired
|
|
private IScenePlusService scenePlusService;
|
|
private IScenePlusService scenePlusService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneEditInfoService sceneEditInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneEditInfoExtService sceneEditInfoExtService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneEditControlsService sceneEditControlsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISurveillanceService surveillanceService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResultData uploadBodySegment(MultipartFile file, Integer rotate) throws Exception {
|
|
public ResultData uploadBodySegment(MultipartFile file, Integer rotate) throws Exception {
|
|
@@ -165,7 +184,7 @@ public class SceneServiceImpl implements ISceneService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void delete(String sceneNum,Long userId) {
|
|
|
|
|
|
+ public void delete(String sceneNum,Long userId) throws FileSystemException {
|
|
if(StringUtils.isEmpty(sceneNum)){
|
|
if(StringUtils.isEmpty(sceneNum)){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
}
|
|
}
|
|
@@ -176,30 +195,113 @@ public class SceneServiceImpl implements ISceneService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void copyScene(String sceneNum, String oldNum, String userName) throws Exception {
|
|
|
|
- if(StringUtils.isEmpty(sceneNum)){
|
|
|
|
|
|
+ public void copyScene(String newNum, String sceneNum, String userName) throws Exception {
|
|
|
|
+ if(StrUtil.isEmpty(newNum) || StrUtil.isEmpty(sceneNum)){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
}
|
|
}
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
|
|
if(scenePlus== null){
|
|
if(scenePlus== null){
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
}
|
|
}
|
|
|
|
+ String oldNum = scenePlus.getNum();
|
|
|
|
+ Long plusId = scenePlus.getId();
|
|
|
|
+ ScenePlusExt plusExt = scenePlusExtService.getScenePlusExtByPlusId(plusId);
|
|
|
|
+ if(plusExt == null){
|
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
|
+ }
|
|
|
|
+ scenePlus.setNum(newNum);
|
|
|
|
+ scenePlus.setTitle(scenePlus.getTitle() +"(copy)");
|
|
|
|
+ scenePlus.setSceneStatus(0);
|
|
|
|
+ scenePlus.setId(null);
|
|
|
|
+ scenePlusService.save(scenePlus);
|
|
|
|
|
|
- String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
- Long sceneId = scenePlus.getId();
|
|
|
|
- Long newSceneId = null;
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
- if(scenePlus != null){ //v4场景复制
|
|
|
|
- log.info("场景复制--V4--OldNum:{},oldTitle:{},newNum:{}", scenePlus.getNum(),scenePlus.getTitle(),newNum);
|
|
|
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoId);
|
|
|
|
+ sceneEditInfoExt.setId(null);
|
|
|
|
+ sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
|
+ sceneEditInfoExt.setScenePlusId(scenePlus.getId());
|
|
|
|
+ sceneEditInfoExt.setSceneProId(null);
|
|
|
|
+ sceneEditInfoExtService.save(sceneEditInfoExt);
|
|
|
|
|
|
- newSceneId = scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity);
|
|
|
|
- }
|
|
|
|
- log.info("场景复制--完成--sceneId:{}",newSceneId);
|
|
|
|
|
|
+ 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");
|
|
|
|
+
|
|
|
|
+ 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 调用文杰接口
|
|
|
|
+
|
|
|
|
+ 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(),"复制失败!");
|
|
|
|
+ }
|
|
|
|
+// }, executor).whenComplete((reslut, e) -> {
|
|
|
|
+// log.info("copy-success-");
|
|
|
|
+// });
|
|
|
|
+ }
|
|
}
|
|
}
|