dengsixing 7 mesiacov pred
rodič
commit
ffee28eba7

+ 24 - 0
src/main/java/com/fdkankan/scene/service/impl/SceneDownloadLogServiceImpl.java

@@ -216,6 +216,7 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
         String num = param.getSceneCode();
 //        String lang = param.getLang();
         Map<String, Object> result = new HashMap<>();
+        result.put("rebuildOffline", true);
         SceneDownloadLog sceneDownloadLog = this.getOne(
                 new LambdaQueryWrapper<SceneDownloadLog>()
                 .eq(SceneDownloadLog::getSceneNum, num)
@@ -231,6 +232,9 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
         if(status == DownloadStatus.SUCCESS.code() || status == DownloadStatus.FAILD.code()){
             result.put("status", status);
             result.put("path", sceneDownloadLog.getDownloadUrl());
+            if(status == DownloadStatus.SUCCESS.code()){//如果是成功,需要匹配版本号,如果版本号不一致,需要返回需要重新生成表示
+                result.put("rebuildOffline", this.rebuildOffline(sceneDownloadLog));
+            }
             return result;
         }
         //下载中,从redis中获取下载进度,并根据状态更新数据库
@@ -252,6 +256,7 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
 //            downLoadProgressBean.setUrl(this.publicUrl+":"+fdkkLaserConfig.getLaserPort()+ "/" + scene.getMapping() +downLoadProgressBean.getUrl());
             result.put("status", DownloadStatus.SUCCESS.code());
             result.put("percent", 100);
+            result.put("rebuildOffline", this.rebuildOffline(sceneDownloadLog));
             return result;
         }
         if(downLoadProgressBean.getStatus()== 1003){//下载失败,更新数据库表
@@ -268,6 +273,25 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
         return result;
     }
 
+    private boolean rebuildOffline(SceneDownloadLog sceneDownloadLog){
+        String num = sceneDownloadLog.getSceneNum();
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+        if(Objects.isNull(scenePlus)){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+        }
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+        String bucket = scenePlusExt.getYunFileBucket();
+        String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH+"scene.json", num);
+        String sceneJson = ossUtil.getFileContent(bucket, sceneJsonPath);
+        SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
+        int version = sceneJsonBean.getVersion();
+
+        if(version != sceneDownloadLog.getSceneVersion()){
+            return true;
+        }
+        return false;
+    }
+
     @Override
     public ResultData downloadScene(SceneDownloadParamVO param) {