Explorar o código

迁移修改data.fdage

lyhzzz %!s(int64=2) %!d(string=hai) anos
pai
achega
03c33ac27d

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

@@ -5,8 +5,8 @@ public class OssPath {
     public final static String invoiceOssDir = "manage/invoice/";
     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 localStatusPath = "/home/backend/4dkankan_v4/manage/%s";   //获取临时文件目录
+    public final static String localFdagePath = "/home/backend/4dkankan_v4/manage/%s";   //获取临时文件目录
 
     public final static String default_head ="manage/user/newHead.png";
 

+ 4 - 1
src/main/java/com/fdkankan/manage/service/ISceneProService.java

@@ -47,4 +47,7 @@ public interface ISceneProService extends IService<ScenePro> {
     Long getSsObjCount(List<String> asList, String startTime);
 
     HashMap<String, String> getSnCodeByNumList(Set<String> numList);
-}
+
+    void updateFdage(String oldSnCode,String newSnCode,String dataSource);
+
+    }

+ 22 - 12
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -281,6 +281,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
      * 从oss中获取文件,并重写,上传替换
      */
     private void updateOssStatus(String path,Integer payStatus) {
+        String localPath = String.format(OssPath.localStatusPath, path);
         try {
             if(!fYunFileServiceInterface.fileExist(path)){
                 return;
@@ -292,13 +293,13 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             JSONObject jsonObject = JSONObject.parseObject(data);
             jsonObject.put("payStatus",payStatus);
             String json = JSONUtil.toJsonStr(jsonObject);
-            FileUtils.writeFile(OssPath.localStatusPath ,json);
-            log.info("updateOssStatus--localPath:{},ossPath:{}",OssPath.localStatusPath,path);
-            fYunFileServiceInterface.uploadFile(OssPath.localStatusPath,path);
+            FileUtils.writeFile(localPath,json);
+            log.info("updateOssStatus--localPath:{},ossPath:{}",localPath,path);
+            fYunFileServiceInterface.uploadFile(localPath,path);
         }catch (Exception e){
             e.printStackTrace();
         }finally {
-            FileUtil.del(OssPath.localStatusPath);
+            FileUtil.del(localPath);
         }
     }
 
@@ -443,14 +444,23 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         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
+    public void updateFdage(String oldSnCode,String newSnCode,String dataSource) {
+        String localPath = String.format(OssPath.localFdagePath,dataSource);
+        try {
+            String fdagePaht =  dataSource.replace("/mnt/data","home") +"/data.fdage";
+            String fileContent = fYunFileServiceInterface.getFileContent(fdagePaht);
+            String newJson = fileContent.replaceAll(oldSnCode,newSnCode);
+            FileUtils.writeFile(localPath ,newJson);
+            log.info("updateFdage--localPath:{},ossPath:{}",localPath,fdagePaht);
+            fYunFileServiceInterface.copyFileInBucket(fdagePaht, fdagePaht+".back");
+            fYunFileServiceInterface.uploadFile(localPath,fdagePaht);
+        }catch (Exception e){
+            log.error("updateFdage-error:oldSnCode:{},newSnCode:{},dataSource:{}",oldSnCode,newSnCode,dataSource);
+            log.error("updateFdage-error:",e);
+        }finally {
+            FileUtil.del(localPath);
+        }
     }
 
     @Override

+ 7 - 14
src/main/java/com/fdkankan/manage/test/TestController.java

@@ -11,6 +11,7 @@ import com.fdkankan.common.util.SecurityUtil;
 import com.fdkankan.manage.common.FilePath;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.httpClient.service.LaserService;
+import com.fdkankan.manage.service.ISceneProService;
 import com.fdkankan.manage.util.Dateutils;
 import com.fdkankan.manage.util.ExcelUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -30,22 +31,14 @@ import java.util.*;
 public class TestController {
 
     @Autowired
-    FYunFileServiceInterface fYunFileServiceInterface;
+    ISceneProService sceneProService;
 
     @RequestMapping("/test")
-    public ResultData test(){
-        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;
+    public ResultData test(@RequestParam(required = false) String oldSnCode,
+                           @RequestParam(required = false)String newSnCode,
+                           @RequestParam(required = false)String dataSource){
+       sceneProService.updateFdage(oldSnCode, newSnCode, dataSource);
+        return ResultData.ok();
     }
 
     /**