瀏覽代碼

增加计算进度通知

dsx 2 年之前
父節點
當前提交
2761b29aad
共有 1 個文件被更改,包括 21 次插入16 次删除
  1. 21 16
      src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneProgressServiceImpl.java

+ 21 - 16
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneProgressServiceImpl.java

@@ -26,6 +26,7 @@ import java.nio.file.Path;
 import java.nio.file.WatchEvent;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 @RefreshScope
 @Slf4j
@@ -63,25 +64,25 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
 
             boolean complete = false;
             int mainProgress = 0;
-            Long totalTime = buildProgressTime;
+            Long totalTime = null;//buildProgressTime
 
             @Override
             public void onCreate(WatchEvent<?> event, Path currentPath) {
-                log.info("project.json文件创建完毕");
-                String projectJsonStr = FileUtil.readUtf8String(file);
-                JSONObject projectJson = JSON.parseObject(projectJsonStr);
-                JSONObject state = projectJson.getJSONObject("state");
-                Long expectTime = state.getLong("expect_time");
-                totalTime += expectTime;
-                redisUtil.set(String.format(RedisKey.SCENE_BUILD_EXPECT_TOTAL_TIME_NUM, num), String.valueOf(totalTime), RedisKey.CAMERA_EXPIRE_7_TIME);
-                Map<String, Object> params = new HashMap<>();
-                params.put("website", website);
-                params.put("title", title);
-                params.put("customUserId",customUserId);
-                params.put("gps", gps);
-                params.put("totalTime", totalTime);
-                params.put("progress", mainProgress);
-                HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
+//                log.info("project.json文件创建完毕");
+//                String projectJsonStr = FileUtil.readUtf8String(file);
+//                JSONObject projectJson = JSON.parseObject(projectJsonStr);
+//                JSONObject state = projectJson.getJSONObject("state");
+//                Long expectTime = state.getLong("expect_time");
+//                totalTime += expectTime;
+//                redisUtil.set(String.format(RedisKey.SCENE_BUILD_EXPECT_TOTAL_TIME_NUM, num), String.valueOf(totalTime), RedisKey.CAMERA_EXPIRE_7_TIME);
+//                Map<String, Object> params = new HashMap<>();
+//                params.put("website", website);
+//                params.put("title", title);
+//                params.put("customUserId",customUserId);
+//                params.put("gps", gps);
+//                params.put("totalTime", totalTime);
+//                params.put("progress", mainProgress);
+//                HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
 
             }
 
@@ -92,6 +93,10 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
                 JSONObject projectJson = JSON.parseObject(projectJsonStr);
                 JSONObject state = projectJson.getJSONObject("state");
                 complete = state.getBoolean("done");
+                if(Objects.isNull(totalTime)){
+                    totalTime = state.getLong("expect_time") + buildProgressTime;
+                    redisUtil.set(String.format(RedisKey.SCENE_BUILD_EXPECT_TOTAL_TIME_NUM, num), String.valueOf(totalTime), RedisKey.CAMERA_EXPIRE_7_TIME);
+                }
                 if(complete){
                     mainProgress = 90;
                     Map<String, Object> params = new HashMap<>();