|
@@ -10,8 +10,7 @@ import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.fdkankan.common.constant.ModelingBuildStatus;
|
|
|
-import com.fdkankan.common.constant.SceneVersionType;
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
|
import com.fdkankan.contro.entity.ScenePlusExt;
|
|
@@ -82,6 +81,7 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
|
|
|
params.put("gps", gps);
|
|
|
params.put("totalTime", totalTime);
|
|
|
params.put("progress", 0);
|
|
|
+ params.put("status", CommonSuccessStatus.WAITING.code());
|
|
|
log.info("场景计算开始,发送进度请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
|
|
|
HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
|
|
|
|
|
@@ -96,95 +96,43 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
String finishStr = redisUtil.get(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, num));
|
|
|
- log.info("场景计算是否完成,num:{},是否完成:{}", num, StrUtil.isBlank(finishStr) ? false : true);
|
|
|
- //计算结果处理消费者消费完毕后,会发送一次进度为100的消息,这里就不需要再做任务操作,
|
|
|
- if(StrUtil.isNotEmpty(finishStr)){
|
|
|
- finish = true;
|
|
|
- }else{
|
|
|
- mainProgress += factor;
|
|
|
- log.info("mainProgress:{}", mainProgress);
|
|
|
- //如果预估的时间比实际的时间要慢,那么这里的进度条会草超过100,所以当超过100时,不需要再发送进度了,只需要等计算结果处理监听中的计算完毕去发送100即可
|
|
|
- if(mainProgress >= 100){
|
|
|
+ if(StrUtil.isEmpty(finishStr)){
|
|
|
+ finishStr = "0";
|
|
|
+ }
|
|
|
+ CommonSuccessStatus commonSuccessStatus = CommonSuccessStatus.get(Integer.valueOf(finishStr));
|
|
|
+ switch (commonSuccessStatus){
|
|
|
+ case SUCCESS:
|
|
|
+ //计算结果处理消费者消费完毕后,会发送一次进度为100的消息,这里就不需要再做任务操作,
|
|
|
+ finish = true;
|
|
|
+ break;
|
|
|
+ case FAIL:
|
|
|
finish = true;
|
|
|
- }else{
|
|
|
params.put("progress", mainProgress);
|
|
|
- log.info("场景计算进行中,发送进度请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
|
|
|
+ params.put("status", commonSuccessStatus.code());
|
|
|
+ log.info("场景计算失败,发送进度请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
|
|
|
HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
|
|
|
- }
|
|
|
+ break;
|
|
|
+ case WAITING:
|
|
|
+ mainProgress += factor;
|
|
|
+ log.info("mainProgress:{}", mainProgress);
|
|
|
+ //如果预估的时间比实际的时间要慢,那么这里的进度条会草超过100,所以当超过100时,不需要再发送进度了,只需要等计算结果处理监听中的计算完毕去发送100即可
|
|
|
+ if(mainProgress >= 100){
|
|
|
+ finish = true;
|
|
|
+ }else{
|
|
|
+ params.put("progress", mainProgress);
|
|
|
+ params.put("status", commonSuccessStatus.code());
|
|
|
+ log.info("场景计算进行中,发送进度请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
|
|
|
+ HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}while (!finish);
|
|
|
+
|
|
|
log.info("场景计算完成,删除计算完成redis记录,key:{}", String.format(RedisKey.SCENE_BUILD_FINISH_NUM, num));
|
|
|
redisUtil.del(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, num));
|
|
|
log.info("推送计算进度结束,num:{}", num);
|
|
|
});
|
|
|
|
|
|
-// String projectJsonPath = path.concat(File.separator).concat("project.json");
|
|
|
-// File file = FileUtil.file(projectJsonPath);
|
|
|
-// WatchMonitor watchMonitor = WatchMonitor.create(file);
|
|
|
-// watchMonitor.setWatcher(new Watcher() {
|
|
|
-//
|
|
|
-// boolean complete = false;
|
|
|
-// int mainProgress = 0;
|
|
|
-// Long totalTime = null;//
|
|
|
-//
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void onCreate(WatchEvent<?> event, Path currentPath) {
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void onModify(WatchEvent<?> event, Path currentPath) {
|
|
|
-// log.info("算法进度更新了.....");
|
|
|
-// String projectJsonStr = FileUtil.readUtf8String(file);
|
|
|
-// JSONObject projectJson = JSON.parseObject(projectJsonStr);
|
|
|
-// JSONObject state = projectJson.getJSONObject("state");
|
|
|
-// complete = state.getBoolean("done");
|
|
|
-// log.info("计算完成状态:{}", complete);
|
|
|
-// 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<>();
|
|
|
-// params.put("website", mainUrl.concat(website));
|
|
|
-// params.put("title", title);
|
|
|
-// params.put("customUserId", customUserId);
|
|
|
-// params.put("gps", gps);
|
|
|
-// params.put("totalTime", totalTime);
|
|
|
-// params.put("progress", mainProgress);
|
|
|
-// log.info("算法完成发送请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
|
|
|
-// HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
|
|
|
-// watchMonitor.interrupt();
|
|
|
-// } else {
|
|
|
-// int progress = 0;
|
|
|
-// progress = new BigDecimal(state.getDouble("progress")).multiply(new BigDecimal(100)).intValue();
|
|
|
-// log.info("当前进度为,progress:{}",progress);
|
|
|
-// if (progress - mainProgress >= 10) {
|
|
|
-// mainProgress = progress;
|
|
|
-// Map<String, Object> params = new HashMap<>();
|
|
|
-// params.put("website", mainUrl.concat(website));
|
|
|
-// params.put("title", title);
|
|
|
-// params.put("customUserId", customUserId);
|
|
|
-// params.put("gps", gps);
|
|
|
-// params.put("totalTime", totalTime);
|
|
|
-// params.put("progress", (progress/10)*10);
|
|
|
-// log.info("算法进行中发送请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
|
|
|
-// HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void onDelete(WatchEvent<?> event, Path currentPath) {
|
|
|
-// watchMonitor.interrupt();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void onOverflow(WatchEvent<?> event, Path currentPath) {
|
|
|
-// }
|
|
|
-// });
|
|
|
-// watchMonitor.start();
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
@@ -198,21 +146,6 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
|
|
|
|
|
|
@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);
|
|
|
|
|
|
}
|
|
|
|