Просмотр исходного кода

v4.9.0 定时任务删除相机原始目录增加原始资源目录正确性校验

dsx 2 лет назад
Родитель
Сommit
ebef2e82a3

+ 12 - 8
src/main/java/com/fdkankan/scene/service/impl/SceneCleanOrigServiceImpl.java

@@ -87,16 +87,20 @@ public class SceneCleanOrigServiceImpl extends ServiceImpl<ISceneCleanOrigMapper
                 String homePath = dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, ConstantFilePath.OSS_PREFIX);
                 //由于国内测试和生产用的bucket是同一个,这里需要做一个安全校验,保证不会删错
                 String fileContent = fYunFileService.getFileContent(homePath.concat("/").concat("data.fdage"));
-                JSONObject jsonObject = JSON.parseObject(fileContent);
-                String snCode = jsonObject.getJSONObject("cam").getString("uuid");
-                String uuidTime = jsonObject.getString("jsonObject");
-                if(!homePath.contains(snCode) || !homePath.contains(snCode.concat("_").concat(uuidTime))){
-                    this.saveLog(scene.getNum(), CommonSuccessStatus.FAIL.code(), "原始资源路径不正确");
-                    return;
+                if(StrUtil.isNotBlank(fileContent)){
+                    JSONObject jsonObject = JSON.parseObject(fileContent);
+                    String snCode = jsonObject.getJSONObject("cam").getString("uuid");
+                    String uuidTime = jsonObject.getString("jsonObject");
+                    if(!homePath.contains(snCode) || !homePath.contains(snCode.concat("_").concat(uuidTime))){
+                        this.saveLog(scene.getNum(), CommonSuccessStatus.FAIL.code(), "原始资源路径不正确");
+                        return;
+                    }
+                    fYunFileService.deleteFolder(homePath);
+                    this.saveLog(scene.getNum(), CommonSuccessStatus.SUCCESS.code(), null);
+                }else {
+                    this.saveLog(scene.getNum(), CommonSuccessStatus.FAIL.code(), "oss资源不存在");
                 }
-                fYunFileService.deleteFolder(homePath);
             }
-            this.saveLog(scene.getNum(), CommonSuccessStatus.SUCCESS.code(), null);
         }catch (Exception e){
             log.error("删除原始资源失败,num : " + scene.getNum(), e);
             this.saveLog(scene.getNum(), CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000));