浏览代码

修改data.fdage

lyhzzz 2 年之前
父节点
当前提交
f79b332c64

+ 1 - 0
src/main/java/com/fdkankan/manage/common/OssPath.java

@@ -6,6 +6,7 @@ public class OssPath {
     public final static String v3_statusPath = "data/data%s/status.json";
     public final static String v4_statusPath = "scene_view_data/%s/data/status.json";
     public final static String localStatusPath = System.getProperty("java.io.tmpdir") +"status.json";   //获取临时文件目录
+    public final static String localFdagePath = System.getProperty("java.io.tmpdir") +"data.fdage";   //获取临时文件目录
 
     public final static String default_head ="manage/user/newHead.png";
 

+ 13 - 0
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -17,6 +17,7 @@ import com.fdkankan.manage.httpClient.service.LaserService;
 import com.fdkankan.manage.entity.*;
 import com.fdkankan.manage.mapper.ISceneProMapper;
 import com.fdkankan.manage.service.*;
+import com.fdkankan.manage.util.Dateutils;
 import com.fdkankan.manage.util.SceneStatusUtil;
 import com.fdkankan.manage.vo.request.SceneParam;
 import com.fdkankan.manage.vo.response.CameraDataVo;
@@ -359,9 +360,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
         Long sceneCameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
         Long space = scenePro == null ? 0 :scenePro.getSpace();
+        String dataSource = scenePro == null ? null :scenePro.getDataSource();
         if(scenePlus !=null){
             ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
             space = scenePlusExt.getSpace();
+            dataSource = scenePlusExt.getDataSource();
         }
         space = space == null ? 0 :space;
         Long newUseSpace = space + cameraDetail.getUsedSpace();
@@ -437,7 +440,17 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         if(cameraDetail.getType() == 10){       //深时场景
             laserService.move(param.getNum(),oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId());
         }
+        updateFdage(oldCamera.getSnCode(),param.getSnCode(),dataSource);
+    }
 
+    private void updateFdage(String oldSnCode,String newSnCode,String dataSource) {
+        String fdagePaht =  dataSource.replace("/mnt/data","home") +"/data.fdage";
+        String fileContent = fYunFileServiceInterface.getFileContent(fdagePaht);
+        String newJson = fileContent.replaceAll(oldSnCode,newSnCode);
+        FileUtils.writeFile(OssPath.localFdagePath ,newJson);
+        log.info("updateFdage--localPath:{},ossPath:{}",OssPath.localFdagePath,fdagePaht);
+        fYunFileServiceInterface.copyFileInBucket(fdagePaht, Dateutils.getDate(new Date()) +fdagePaht+".back");
+        fYunFileServiceInterface.uploadFile(OssPath.localFdagePath,fdagePaht);
     }
 
     @Override

+ 19 - 1
src/main/java/com/fdkankan/manage/test/TestController.java

@@ -1,6 +1,10 @@
 package com.fdkankan.manage.test;
 
 import cn.hutool.core.io.FileUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.manage.common.OssPath;
 import com.fdkankan.manage.common.ResultCode;
 import com.fdkankan.manage.common.ResultData;
 import com.fdkankan.common.util.SecurityUtil;
@@ -25,9 +29,23 @@ import java.util.*;
 @RequestMapping("/test")
 public class TestController {
 
+    @Autowired
+    FYunFileServiceInterface fYunFileServiceInterface;
+
     @RequestMapping("/test")
     public ResultData test(){
-        return ResultData.ok();
+        JSONObject jsonObject = updateFdage("A0EOIX083", "A0EOIX084", "/mnt/data/a0eoix083/1070024800111427584/a0eoix083_202301311641102900");
+        return ResultData.ok(jsonObject);
+    }
+    private JSONObject updateFdage(String oldSnCode, String newSnCode, String dataSource) {
+        JSONObject jsonObject = new JSONObject();
+        String fdagePaht =  dataSource.replace("/mnt/data","home") +"/data.fdage";
+        String fileContent = fYunFileServiceInterface.getFileContent(fdagePaht);
+        jsonObject.put("old",JSONObject.parse(fileContent));
+        String newJson = fileContent.replaceAll("(?i)"+oldSnCode,newSnCode);
+        jsonObject.put("new",JSONObject.parse(newJson));
+
+        return jsonObject;
     }
 
     /**