Browse Source

计算完成时间

lyhzzz 5 months ago
parent
commit
0448019f86
1 changed files with 20 additions and 6 deletions
  1. 20 6
      src/main/java/com/fdkankan/fusion/down/CaseDownService.java

+ 20 - 6
src/main/java/com/fdkankan/fusion/down/CaseDownService.java

@@ -370,15 +370,16 @@ public class CaseDownService {
 
    public void downSwkk(Integer caseId,String num,Integer type,String offPath){
 
-       String swkkPath = offPath+ "/www/swkk/"+num;
-       String swssPath = offPath + "/www/swss/"+num;
+       String swkkPath = offPath+ "/www/swkk";
+       String swssPath = offPath + "/www/swss";
 
        Boolean isLaser = false;
        if(type == 2 || type == 5){
            isLaser = true;
        }
-            Boolean wita = true;
+           Boolean wita = true;
            Long startTime = new Date().getTime();
+           Long outTime = new Date().getTime();
            Long wiatTime = 10000L;
 
            while (wita){
@@ -386,6 +387,9 @@ public class CaseDownService {
                if(nowTime - startTime < wiatTime){
                    continue;
                }
+               if(nowTime - outTime > 1000 * 60 * 60 * 24){ //下载单个场景超时时间
+                    break;
+               }
                startTime = nowTime;
                try {
                    FdkkResponse fdkkResponse = laserService.sceneLocInfo(num);
@@ -403,7 +407,7 @@ public class CaseDownService {
                    //1 生成成功,0:正在生成 1,初次生成  2,下载失败
                    Integer meshBuildOfflineStatus = jsonObject.getInteger("meshBuildOfflineStatus");
 
-                   wita = downSceneOffline(sceneId, isLaser,
+                   wita = downSceneOffline(num,sceneId, isLaser,
                            isLaser ? swssPath : swkkPath,
                            isLaser ? laserStatus : meshStatus,
                            isLaser ? laserOfflineFolder : meshOfflineFolder,
@@ -422,12 +426,21 @@ public class CaseDownService {
     /**
      * @param buildOfflineStatus   //1 生成成功,0:正在生成 1,初次生成  2,下载失败
      */
-    private Boolean downSceneOffline(Integer sceneId, Boolean isLaser, String offPath, Boolean rebuildOffline, String offlineFolder, Integer buildOfflineStatus) {
+    public static String buildSceneKey = "fusion:build:scene:";
+    private Boolean downSceneOffline(String num,Integer sceneId, Boolean isLaser, String offPath, Boolean rebuildOffline, String offlineFolder, Integer buildOfflineStatus) {
+        String redisKey = buildSceneKey + num;
+        redisUtil.set(redisKey,"0",60 * 60 * 24);
+        if(redisUtil.hasKey(redisKey) && Integer.parseInt(redisUtil.get(redisKey))>=2 ){
+            log.info("场景查询状态不对,跳出循环:{},{}",num,isLaser);
+            return false;
+        }
         if(rebuildOffline && buildOfflineStatus !=0){
+            redisUtil.set(buildSceneKey, String.valueOf(Integer.parseInt(redisUtil.get(redisKey)) +1),60 * 60 * 24);
             laserService.rebuildOffline(offPath,isLaser,sceneId);
             return true;
         }
         if(buildOfflineStatus == -1){
+            redisUtil.set(buildSceneKey, String.valueOf(Integer.parseInt(redisUtil.get(redisKey)) +1),60 * 60 * 24);
             laserService.rebuildOffline(offPath,isLaser,sceneId);
             return true;
         }
@@ -436,11 +449,12 @@ public class CaseDownService {
         }
         if(!rebuildOffline && buildOfflineStatus == 1){
             if(!new File(offlineFolder).exists()){
+                redisUtil.set(buildSceneKey, String.valueOf(Integer.parseInt(redisUtil.get(redisKey)) +1),60 * 60 * 24);
                 log.info("离线包文件不存在:{}",offlineFolder);
                 laserService.rebuildOffline(offPath,isLaser,sceneId);
                 return true;
             }
-            FileUtil.copyContent(new File(offlineFolder),new File(offPath),true);
+            FileUtil.copyContent(new File(offlineFolder),new File(offPath+File.separator+num),true);
             return false;
         }
         return true;