|
@@ -6,11 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
|
|
+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.JwtUtil;
|
|
|
|
|
|
+import com.fdkankan.common.util.*;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
@@ -28,14 +27,13 @@ import com.fdkankan.ucenter.vo.response.SceneNumVo;
|
|
import com.fdkankan.ucenter.vo.response.SceneVo;
|
|
import com.fdkankan.ucenter.vo.response.SceneVo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
-import org.slf4j.Logger;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
-import java.io.IOException;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -85,6 +83,15 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
@Autowired
|
|
@Autowired
|
|
RedisUtil redisUtil;
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
|
|
+ @Value("${main.url}")
|
|
|
|
+ private String mainUrl;
|
|
|
|
+
|
|
|
|
+ @Value("${scene.pro.url}")
|
|
|
|
+ private String sceneProUrl;
|
|
|
|
+
|
|
|
|
+ @Value("${scene.pro.new.url}")
|
|
|
|
+ private String sceneProNewUrl;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HashMap<String, SceneNumVo> findSceneNumber(String token) {
|
|
public HashMap<String, SceneNumVo> findSceneNumber(String token) {
|
|
User user = userService.getByUserName(JwtUtil.getUsername(token));
|
|
User user = userService.getByUserName(JwtUtil.getUsername(token));
|
|
@@ -353,6 +360,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
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);
|
|
}
|
|
}
|
|
@@ -376,18 +384,22 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail) {
|
|
|
|
|
|
+ public void copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail) throws Exception {
|
|
SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
|
|
SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
|
|
|
|
|
|
String oldNum = oldScene.getNum();
|
|
String oldNum = oldScene.getNum();
|
|
//复制数据库数据
|
|
//复制数据库数据
|
|
oldScene.setId(null);
|
|
oldScene.setId(null);
|
|
|
|
+ oldScene.setStatus(0);
|
|
oldScene.setNum(newNum);
|
|
oldScene.setNum(newNum);
|
|
oldScene.setSceneName(oldScene.getSceneName().concat("(copy)"));
|
|
oldScene.setSceneName(oldScene.getSceneName().concat("(copy)"));
|
|
oldScene.setWebSite(oldScene.getWebSite().replace(oldScene.getNum(), newNum));
|
|
oldScene.setWebSite(oldScene.getWebSite().replace(oldScene.getNum(), newNum));
|
|
oldScene.setThumb(oldScene.getThumb().replace(oldScene.getNum(), newNum));
|
|
oldScene.setThumb(oldScene.getThumb().replace(oldScene.getNum(), newNum));
|
|
oldScene.setVideos(oldScene.getVideos().replace(oldNum,newNum));
|
|
oldScene.setVideos(oldScene.getVideos().replace(oldNum,newNum));
|
|
- //更新video
|
|
|
|
|
|
+ oldScene.setViewCount(0);
|
|
|
|
+ String preDataSource = oldScene.getDataSource();
|
|
|
|
+ oldScene.setDataSource(this.setDataSource(preDataSource,oldScene.getSceneSource()));
|
|
|
|
+
|
|
this.save(oldScene);
|
|
this.save(oldScene);
|
|
|
|
|
|
sceneCopyLogService.saveByNum(oldNum,newNum,oldScene.getUserId());
|
|
sceneCopyLogService.saveByNum(oldNum,newNum,oldScene.getUserId());
|
|
@@ -405,33 +417,20 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
oldEditScene.setFloorPlanPng(oldEditScene.getFloorPlanPng() == null ? null : oldEditScene.getFloorPlanPng().replace(oldNum, newNum));
|
|
oldEditScene.setFloorPlanPng(oldEditScene.getFloorPlanPng() == null ? null : oldEditScene.getFloorPlanPng().replace(oldNum, newNum));
|
|
sceneProEditService.save(oldEditScene);
|
|
sceneProEditService.save(oldEditScene);
|
|
|
|
|
|
|
|
+ this.setQrCode(oldScene.getBuildType(), oldScene.getNum());
|
|
CompletableFuture.runAsync(() -> {
|
|
CompletableFuture.runAsync(() -> {
|
|
try {
|
|
try {
|
|
log.info("开始复制场景-{}", new Date());
|
|
log.info("开始复制场景-{}", new Date());
|
|
|
|
|
|
- //oss复制源文件
|
|
|
|
- String buildModelPath = ConstantFilePath.BUILD_MODEL_PATH;
|
|
|
|
- if(oldScene.getSceneSource().equals(4)){
|
|
|
|
- buildModelPath = ConstantFilePath.BUILD_MODEL_LASER_PATH;
|
|
|
|
- }
|
|
|
|
- CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + oldScene.getDataSource().replace(buildModelPath, "")+"/", oldScene.getDataSource());
|
|
|
|
-
|
|
|
|
- List<String> urlList = new ArrayList<>();
|
|
|
|
- FileUtils.readfilePath(oldScene.getDataSource(), urlList);
|
|
|
|
- Map<String,String> fileMap = new HashMap<>();
|
|
|
|
- for(String url : urlList){
|
|
|
|
- fileMap.put(url, ConstantFilePath.OSS_PREFIX + url.replace(buildModelPath, ""));
|
|
|
|
- }
|
|
|
|
- uploadToOssUtil.uploadMulFiles(fileMap);
|
|
|
|
-
|
|
|
|
//oss复制计算结果资源
|
|
//oss复制计算结果资源
|
|
- downloadFromoldNumFromOss(oldNum, newNum);
|
|
|
|
|
|
+ this.copyOssSource("v3",oldNum,newNum);
|
|
|
|
+ this.copyLocalSource(oldNum,newNum);
|
|
|
|
|
|
- // 复制本地secen.json
|
|
|
|
- copyOldSceneLocalToNew(oldNum, newNum);
|
|
|
|
updateSceneJson("v3",oldScene.getVideos(),newNum,oldScene.getSceneName(),oldScene.getWebSite(),oldScene.getThumb(),oldScene.getId());
|
|
updateSceneJson("v3",oldScene.getVideos(),newNum,oldScene.getSceneName(),oldScene.getWebSite(),oldScene.getThumb(),oldScene.getId());
|
|
//上传资源到oss
|
|
//上传资源到oss
|
|
uploadNewSceneToOss(newNum);
|
|
uploadNewSceneToOss(newNum);
|
|
|
|
+ oldScene.setStatus(-2);
|
|
|
|
+ this.updateById(oldScene);
|
|
log.info("复制场景结束-{}", new Date());
|
|
log.info("复制场景结束-{}", new Date());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("复制场景异常", e);
|
|
log.error("复制场景异常", e);
|
|
@@ -440,41 +439,78 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 从旧场景下载资源
|
|
|
|
- * @param sceneNum
|
|
|
|
- * @param newNum
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- private void downloadFromoldNumFromOss(String sceneNum, String newNum) throws Exception {
|
|
|
|
- CreateObjUtil.ossUtilCp("images/images" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "images/images" + newNum);
|
|
|
|
- CreateObjUtil.ossUtilCp("data/data" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "data/data" + newNum);
|
|
|
|
- CreateObjUtil.ossUtilCp("voice/voice" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "voice/voice" + newNum);
|
|
|
|
- CreateObjUtil.ossUtilCp("video/video" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "video/video" + newNum);
|
|
|
|
- }
|
|
|
|
|
|
+ @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);
|
|
|
|
|
|
- /**
|
|
|
|
- * 从本地旧场景拷贝资源到新场景
|
|
|
|
- * @param sceneNum
|
|
|
|
- * @param newNum
|
|
|
|
- */
|
|
|
|
- private void copyOldSceneLocalToNew(String sceneNum, String newNum) throws IOException {
|
|
|
|
- FileUtils.copyFolderAllFiles(ConstantFilePath.SCENE_PATH + "data/data" + sceneNum + "/",
|
|
|
|
- ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/", true);
|
|
|
|
|
|
+ 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, ""));
|
|
|
|
+ }
|
|
|
|
+ uploadToOssUtil.uploadMulFiles(fileMap);
|
|
|
|
+
|
|
|
|
+ FileUtils.delAllFile(newDataSource);
|
|
|
|
+
|
|
|
|
+ FileUtils.copyFolderAllFiles(preDataSource+"/",newDataSource+"/", true);
|
|
|
|
+ return datasourceFix.concat(datasourceFix);
|
|
|
|
+ }
|
|
|
|
|
|
- // 复制本地视频
|
|
|
|
- FileUtils.copyFolderAllFiles(ConstantFilePath.SCENE_PATH + "video/video" + sceneNum + "/",
|
|
|
|
- ConstantFilePath.SCENE_PATH + "video/video" + newNum + "/", true);
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void copyOssSource(String type ,String sceneNum, String newNum) throws Exception {
|
|
|
|
+ List<String > copyList = new ArrayList<>();
|
|
|
|
+ if(type.equals("v3")){
|
|
|
|
+ copyList.add("images/images" + sceneNum);
|
|
|
|
+ copyList.add("data/data" + sceneNum);
|
|
|
|
+ copyList.add("voice/voice" + sceneNum);
|
|
|
|
+ copyList.add("video/video"+ sceneNum);
|
|
|
|
+ }else if(type.equals("v4")){
|
|
|
|
+ String oldEditPath = String.format(UploadFilePath.EDIT_PATH, sceneNum);
|
|
|
|
+ String oldViewPath = String.format(UploadFilePath.VIEW_PATH, sceneNum);
|
|
|
|
+ copyList.add(oldEditPath);
|
|
|
|
+ copyList.add(oldViewPath);
|
|
|
|
+ }
|
|
|
|
+ for (String sourcePath : copyList) {
|
|
|
|
+ uploadToOssUtil.copyFiles(sourcePath,sourcePath.replaceAll(sceneNum,newNum));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- // 复制本地二维码
|
|
|
|
- FileUtils.copyFile(ConstantFilePath.SCENE_QR_CODE_PATH + sceneNum + ".png",
|
|
|
|
- ConstantFilePath.SCENE_QR_CODE_PATH + newNum + ".png", true);
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void copyLocalSource(String sceneNum, String newNum) throws Exception {
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"images/images" + sceneNum,ConstantFilePath.SCENE_PATH +"images/images" + newNum);
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"data/data" + sceneNum,ConstantFilePath.SCENE_PATH +"data/data" + newNum);
|
|
|
|
+ reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/link-scene.json",sceneNum, newNum);
|
|
|
|
+ reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/hot.json",sceneNum, newNum);
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"voice/voice" + sceneNum,ConstantFilePath.SCENE_PATH +"voice/voice" + newNum);
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"video/video" + sceneNum,ConstantFilePath.SCENE_PATH +"video/video" + newNum);
|
|
|
|
+ }
|
|
|
|
|
|
- // 复制本地二维码
|
|
|
|
- FileUtils.copyFile(ConstantFilePath.SCENE_QR_CODE_PATH + sceneNum + "_en.png",
|
|
|
|
- ConstantFilePath.SCENE_QR_CODE_PATH + newNum + "_en.png", true);
|
|
|
|
|
|
+ private void reloadFile(String filePath,String sceneNum, String newNum) throws Exception {
|
|
|
|
+ // 修改link-scene.json
|
|
|
|
+ String content = FileUtils.readFile(filePath);
|
|
|
|
+ if (!ObjectUtils.isEmpty(content)) {
|
|
|
|
+ content = content.replaceAll(sceneNum, newNum);
|
|
|
|
+ FileUtils.writeFile(filePath,content);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 上传新场景资源到oss
|
|
* 上传新场景资源到oss
|
|
* @param newNum
|
|
* @param newNum
|
|
@@ -502,15 +538,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
map.put("thumb",thumb);
|
|
map.put("thumb",thumb);
|
|
map.put("num",newNum);
|
|
map.put("num",newNum);
|
|
map.put("id",id);
|
|
map.put("id",id);
|
|
- String localPath ;
|
|
|
|
String uploadPath ;
|
|
String uploadPath ;
|
|
|
|
+ String localPath = ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json";
|
|
if(type.equals("v3")){
|
|
if(type.equals("v3")){
|
|
- localPath = ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json";
|
|
|
|
uploadPath = localPath.replace(ConstantFilePath.SCENE_PATH, "");
|
|
uploadPath = localPath.replace(ConstantFilePath.SCENE_PATH, "");
|
|
}else {
|
|
}else {
|
|
- localPath = ConstantFilePath.SCENE_V4_PATH +"scene_view_data/"+ newNum + File.separator + "data" +File.separator +"scene.json";
|
|
|
|
uploadPath =localPath.replace(ConstantFilePath.SCENE_V4_PATH, "");
|
|
uploadPath =localPath.replace(ConstantFilePath.SCENE_V4_PATH, "");
|
|
-
|
|
|
|
}
|
|
}
|
|
FileUtils.writeJsonFile(localPath, map);
|
|
FileUtils.writeJsonFile(localPath, map);
|
|
if(type.equals("v4")){
|
|
if(type.equals("v4")){
|
|
@@ -660,4 +693,29 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
redisUtil.incr(redisKey,1);
|
|
redisUtil.incr(redisKey,1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ScenePro findByFileId(String fileId) {
|
|
|
|
+ LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.like(ScenePro::getDataSource,fileId);
|
|
|
|
+ List<ScenePro> list = this.list(wrapper);
|
|
|
|
+ if(list !=null && list.size() >0){
|
|
|
|
+ return list.get(0);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setQrCode(String buildType,String num) throws Exception {
|
|
|
|
+ String basePath = mainUrl;
|
|
|
|
+ if("V2".equals(buildType)){
|
|
|
|
+ basePath += sceneProUrl;
|
|
|
|
+ }
|
|
|
|
+ if("V3".equals(buildType)){
|
|
|
|
+ basePath += sceneProNewUrl;
|
|
|
|
+ }
|
|
|
|
+ MatrixToImageWriterUtil.createQRCode(basePath + num, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+num+".png", false,null);
|
|
|
|
+ MatrixToImageWriterUtil.createQRCode(basePath + num + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+num+"_en.png", false,null);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|