|
@@ -75,17 +75,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
FdKKClient fdKKClient;
|
|
|
|
|
|
|
|
|
- @Value("${main.url}")
|
|
|
- private String mainUrl;
|
|
|
-
|
|
|
- @Value("${scene.pro.url}")
|
|
|
- private String sceneProUrl;
|
|
|
-
|
|
|
- @Value("${scene.pro.new.url}")
|
|
|
- private String sceneProNewUrl;
|
|
|
- @Value("${oss.bucket}")
|
|
|
- private String bucket;
|
|
|
-
|
|
|
@Override
|
|
|
public ScenePro getByNum(String num) {
|
|
|
LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -327,12 +316,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
param.put("num",sceneNum);
|
|
|
fdKKClient.copyScene(param,"m_a_n_a_g_e");
|
|
|
|
|
|
-// if(scenePro !=null){ //v3场景复制
|
|
|
-// this.copyV3Scene(scenePro,newNum,detailEntity,camera.getSnCode());
|
|
|
-// }
|
|
|
-// if(scenePlus != null){ //v4场景复制
|
|
|
-// scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity,camera.getSnCode());
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -358,195 +341,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail,String snCode) throws Exception {
|
|
|
- SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
|
|
|
-
|
|
|
- String oldNum = oldScene.getNum();
|
|
|
- //复制数据库数据
|
|
|
- oldScene.setId(null);
|
|
|
- oldScene.setStatus(0);
|
|
|
- oldScene.setNum(newNum);
|
|
|
- oldScene.setSceneName(oldScene.getSceneName().concat("(copy)"));
|
|
|
- oldScene.setWebSite(oldScene.getWebSite().replace(oldScene.getNum(), newNum));
|
|
|
- oldScene.setThumb(oldScene.getThumb().replace(oldScene.getNum(), newNum));
|
|
|
- oldScene.setVideos(oldScene.getVideos().replace(oldNum,newNum));
|
|
|
- oldScene.setViewCount(0);
|
|
|
- String preDataSource = oldScene.getDataSource();
|
|
|
- String time = DateUtil.date2String(new Date(),DateUtil.YYYYMMDDHHMMSSSSS_DATA_FORMAT);
|
|
|
- oldScene.setDataSource(this.setDataSource(preDataSource,time));
|
|
|
-
|
|
|
- this.save(oldScene);
|
|
|
-
|
|
|
- sceneCopyLogService.saveByNum(oldNum,newNum,oldScene.getUserId());
|
|
|
- //复制完成更新相机容量
|
|
|
- cameraDetail.setUsedSpace(cameraDetail.getUsedSpace() + oldScene.getSpace());
|
|
|
- cameraDetailService.updateById(cameraDetail);
|
|
|
-
|
|
|
- oldEditScene.setId(null);
|
|
|
- oldEditScene.setProId(oldScene.getId());
|
|
|
- oldEditScene.setScreencapVoiceSrc(oldEditScene.getScreencapVoiceSrc() == null ? null : oldEditScene.getScreencapVoiceSrc().replace(oldNum, newNum));
|
|
|
- oldEditScene.setScreencapVoiceSound(oldEditScene.getScreencapVoiceSound() == null ? null : oldEditScene.getScreencapVoiceSound().replace(oldNum, newNum));
|
|
|
- oldEditScene.setScreencapVoiceSoundsync(oldEditScene.getScreencapVoiceSoundsync() == null ? null : oldEditScene.getScreencapVoiceSoundsync().replace(oldNum, newNum));
|
|
|
- oldEditScene.setPlayData(oldEditScene.getPlayData() == null ? null : oldEditScene.getPlayData().replace(oldNum, newNum));
|
|
|
- oldEditScene.setScreencapThumb(oldEditScene.getScreencapThumb() == null ? null : oldEditScene.getScreencapThumb().replace(oldNum, newNum));
|
|
|
- oldEditScene.setFloorPlanPng(oldEditScene.getFloorPlanPng() == null ? null : oldEditScene.getFloorPlanPng().replace(oldNum, newNum));
|
|
|
- sceneProEditService.save(oldEditScene);
|
|
|
-
|
|
|
- this.setQrCode(oldScene.getBuildType(), oldScene.getNum());
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- try {
|
|
|
- log.info("开始复制场景-{}", new Date());
|
|
|
-
|
|
|
- this.copyDataSource(oldScene.getDataSource(),preDataSource,oldScene.getSceneType(),time);
|
|
|
- //oss复制计算结果资源
|
|
|
- this.copyOssSource("v3",oldNum,newNum);
|
|
|
- this.copyLocalSource(oldNum,newNum);
|
|
|
-
|
|
|
- this.updateSceneJson("v3",oldScene.getVideos(),newNum,oldScene.getSceneName(),oldScene.getWebSite(),oldScene.getThumb(),oldScene.getId());
|
|
|
- //上传资源到oss
|
|
|
- this.uploadNewSceneToOss(newNum);
|
|
|
- oldScene.setStatus(-2);
|
|
|
- this.updateById(oldScene);
|
|
|
- log.info("复制场景结束-{}", new Date());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("复制场景异常", e);
|
|
|
- }
|
|
|
- });
|
|
|
- if(oldScene.getSceneType() == 4){ //深时场景
|
|
|
- laserService.copy(snCode,oldScene.getCreateTime(),newNum,oldScene.getStatus(),oldEditScene.getSceneKey(),oldScene.getSceneName(),oldScene.getUserId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateSceneJson(String type,String videos,String newNum,String sceneName,String webSite,String thumb,Long id) throws Exception {
|
|
|
- //更新video
|
|
|
- HashMap<String,Object> map = new HashMap<>();
|
|
|
- map.put("videos",videos);
|
|
|
- map.put("sceneName",sceneName);
|
|
|
- map.put("webSite",webSite);
|
|
|
- map.put("thumb",thumb);
|
|
|
- map.put("num",newNum);
|
|
|
- map.put("id",id);
|
|
|
- String uploadPath ;
|
|
|
- String localPath = ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json";
|
|
|
- if(type.equals("v3")){
|
|
|
- uploadPath = localPath.replace(ConstantFilePath.SCENE_PATH, "");
|
|
|
- }else {
|
|
|
- uploadPath =localPath.replace(ConstantFilePath.SCENE_V4_PATH, "");
|
|
|
- }
|
|
|
- FileUtils.writeJsonFile(localPath, map);
|
|
|
- mangeUploadToOssUtil.upload(localPath,uploadPath);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void uploadNewSceneToOss(String newNum) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- List<String> urlList = new ArrayList<>();
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "images/images" + newNum, urlList);
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "data/data" + newNum, urlList);
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "voice/voice" + newNum, urlList);
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "video/video" + newNum, urlList);
|
|
|
- for(String url : urlList){
|
|
|
- map.put(url, url.replace(ConstantFilePath.SCENE_PATH, ""));
|
|
|
- }
|
|
|
- mangeUploadToOssUtil.uploadMulFiles(map);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- 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 String.join("/", datasource);
|
|
|
- }
|
|
|
-
|
|
|
- @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);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @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) {
|
|
|
- mangeUploadToOssUtil.copyFiles(sourcePath,sourcePath.replaceAll(sceneNum,newNum));
|
|
|
- }
|
|
|
- }
|
|
|
- @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);
|
|
|
- }
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public Long getKkCount(List<String> asList, String startTime) {
|
|
|
LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.in(ScenePro::getSceneSource,asList);
|