Bladeren bron

复制v3场景nas,Host.json

lyhzzz 2 jaren geleden
bovenliggende
commit
ee5e3b7232

+ 18 - 13
src/main/java/com/fdkankan/ucenter/service/impl/SceneCommonService.java

@@ -108,10 +108,10 @@ public class SceneCommonService {
     }
 
 
-    public void updateNasSceneJson(String targetPath, String oldNum, String newNum,String newSceneName,String sceneVersion) {
+    public void updateNasSceneJson(String targetPath, String oldNum, String newNum,String newSceneName,String sceneVersion,String fileName) {
         String fileContent = null;
         if("v3".equals(sceneVersion)){
-            String localPath = SceneResourcePath.nasBasePath + targetPath + "/" + "scene.json";
+            String localPath = SceneResourcePath.nasBasePath + targetPath + "/" + fileName;
             File file = new File(localPath);
             if(!file.exists()){
                 log.error("sceneCopy-error--localFileExist:localPath:{},oldNum:{},newNum:{}",localPath,oldNum,newNum);
@@ -120,7 +120,7 @@ public class SceneCommonService {
             fileContent = FileUtil.readUtf8String(file);
         }
         if("v4".equals(sceneVersion)){
-            String ossStatusJsonPath =  targetPath + "/" + "scene.json";
+            String ossStatusJsonPath =  targetPath + "/" + fileName
             if(!fYunFileServiceInterface.fileExist(ossStatusJsonPath)){
                 log.error("sceneCopy-error--ossFileExist:targetPath:{},oldNum:{},newNum:{}",ossStatusJsonPath,oldNum,newNum);
                 return;
@@ -130,7 +130,7 @@ public class SceneCommonService {
 
         if(StringUtils.isNotBlank(fileContent)){
             //v3编辑器使用
-            String localPath = SceneResourcePath.nasBasePath + targetPath +"/scene.json";
+            String localPath = SceneResourcePath.nasBasePath + targetPath +"/" + fileName;
             File file = new File(localPath);
             if(!file.getParentFile().exists()){
                 file.getParentFile().mkdirs();
@@ -139,27 +139,32 @@ public class SceneCommonService {
             JSONObject jsonObject = JSONObject.parseObject(newJson);
             try {
                 if("v3".equals(sceneVersion)){
-                    jsonObject.put("sceneName",newSceneName);
+                    if(fileName.contains("scene.json")){
+                        jsonObject.put("sceneName",newSceneName);
+                    }
                     com.fdkankan.ucenter.util.FileUtil.writeFile(localPath,jsonObject.toJSONString());
 
-                    String sceneJsonPath = String.format(SceneResourcePath.dataPath+"/scene.json", newNum);
-                    fYunFileServiceInterface.uploadFile(localPath, sceneJsonPath);
+                    if(fileName.contains("scene.json")){
+                        String sceneJsonPath = String.format(SceneResourcePath.dataPath+"/"+fileName, newNum);
+                        fYunFileServiceInterface.uploadFile(localPath, sceneJsonPath);
+                    }
+
                 }
                 if("v4".equals(sceneVersion)){
                     jsonObject.put("title",newSceneName);
                     com.fdkankan.ucenter.util.FileUtil.writeFile(localPath,jsonObject.toJSONString());
 
-                    String sceneJsonPath = String.format(SceneResourcePath.DATA_VIEW_PATH+"/scene.json", newNum);
+                    String sceneJsonPath = String.format(SceneResourcePath.DATA_VIEW_PATH+"/" + fileName, newNum);
                     fYunFileServiceInterface.uploadFile(localPath, sceneJsonPath);
 
                     //修改图片名称
                     String filePath = String.format(SceneResourcePath.USER_VIEW_PATH, newNum) ;
                     List<String> files = fYunFileServiceInterface.listRemoteFiles(filePath);
-                    for (String fileName : files) {
-                        if(fileName.contains(oldNum)){
-                            String oldName = fileName;
-                            fileName = fileName.replace(oldNum,newNum);
-                            fYunFileServiceInterface.copyFileInBucket(oldName,fileName);
+                    for (String ossFilePath : files) {
+                        if(ossFilePath.contains(oldNum)){
+                            String oldName = ossFilePath;
+                            ossFilePath = ossFilePath.replace(oldNum,newNum);
+                            fYunFileServiceInterface.copyFileInBucket(oldName,ossFilePath);
                             fYunFileServiceInterface.deleteFile(oldName);
                         }
                     }

+ 1 - 1
src/main/java/com/fdkankan/ucenter/service/impl/ScenePlusServiceImpl.java

@@ -258,7 +258,7 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
                 String targetData = String.format(SceneResourcePath.DATA_VIEW_PATH,newNum);
                 sceneCommonService.updateOssJson(targetData,oldNum,newNum,"status.json");
 
-                sceneCommonService.updateNasSceneJson(targetData,oldNum,newNum,scenePlus.getTitle(),"v4");
+                sceneCommonService.updateNasSceneJson(targetData,oldNum,newNum,scenePlus.getTitle(),"v4","scene.json");
 
                 if(scenePlus.getSceneSource() == 4){  //深时复制
                     String laserPath = laserService.copyDataSource(oldDataSource,plusExt.getDataSource());

+ 2 - 1
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -796,7 +796,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
                 //修改 oss status.json ,nas scene.json
                 sceneCommonService.updateOssJson(targetData,oldNum,newNum,"status.json");
                 sceneCommonService.updateOssJson(targetData,oldNum,newNum,"hot.json");
-                sceneCommonService.updateNasSceneJson(targetData,oldNum,newNum,scenePro.getSceneName(),"v3");
+                sceneCommonService.updateNasSceneJson(targetData,oldNum,newNum,scenePro.getSceneName(),"v3","scene.json");
+                sceneCommonService.updateNasSceneJson(targetData,oldNum,newNum,scenePro.getSceneName(),"v3","hot.json");
 
                 String sourceImages = String.format(SceneResourcePath.imagesPath, oldNum);
                 String targetImages = String.format(SceneResourcePath.imagesPath, scenePro.getNum());