|
@@ -1,5 +1,6 @@
|
|
|
package com.fdkankan.indoor.core.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fdkankan.indoor.base.constant.CmdConstant;
|
|
@@ -22,7 +23,9 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import net.sf.json.JSONArray;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.junit.Test;
|
|
|
+import org.slf4j.MDC;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
@@ -129,11 +132,28 @@ public class InitServiceImpl implements InitService {
|
|
|
}
|
|
|
} else {
|
|
|
// 新场景
|
|
|
+
|
|
|
+ // 路径在这里检测
|
|
|
+ String path = param.getPath();
|
|
|
+ if (StrUtil.isBlank(path)) {
|
|
|
+ throw new BaseRuntimeException("init.path路径不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String title = param.getTitle();
|
|
|
+ if (StrUtil.isBlank(title)) {
|
|
|
+ throw new BaseRuntimeException("标题不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String phone = param.getPhone();
|
|
|
+ if (StrUtil.isBlank(phone)) {
|
|
|
+ throw new BaseRuntimeException("用户名称不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
init = new InitEntity();
|
|
|
init.setId(sceneCode);
|
|
|
- init.setPath(param.getPath());
|
|
|
+ init.setPath(path);
|
|
|
init.setCreateTime(LocalDateTime.now());
|
|
|
- init.setTitle(param.getTitle());
|
|
|
+ init.setTitle(title);
|
|
|
init.setChildName(param.getChildName());
|
|
|
init.setSnCode(param.getSnCode());
|
|
|
init.setShootTime(param.getCreateTime());
|
|
@@ -142,30 +162,108 @@ public class InitServiceImpl implements InitService {
|
|
|
// https://testlaser.4dkankan.com/maxkk/ + 场景码
|
|
|
init.setWebSite(configConstant.webSitePath + sceneCode);
|
|
|
init.setUserId(param.getUserId());
|
|
|
- init.setUserName(param.getPhone());
|
|
|
+ init.setUserName(phone);
|
|
|
|
|
|
initMapper.save(init);
|
|
|
|
|
|
}
|
|
|
|
|
|
- // 删除旧数据, 重算使用
|
|
|
- initRemove(sceneCode);
|
|
|
|
|
|
- String path = init.getPath();
|
|
|
- String title = init.getTitle();
|
|
|
- // 路径在这里检测
|
|
|
- if (StrUtil.isBlank(path)) {
|
|
|
- throw new BaseRuntimeException("init.path路径不能为空");
|
|
|
- }
|
|
|
+ InitEntity finalInit = init;
|
|
|
+ String traceId = MDC.get("TRACE_ID");
|
|
|
+ log.info("链路id: {}", traceId);
|
|
|
+ ThreadUtil.execAsync(() -> initDataStep1(finalInit, traceId));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- if (StrUtil.isBlank(title)) {
|
|
|
- throw new BaseRuntimeException("标题不能为空");
|
|
|
- }
|
|
|
|
|
|
|
|
|
// String laserDataPath = path + "/laserData";
|
|
|
- String laserDataPath = path ;
|
|
|
- log.info("laserDataPath: {}", laserDataPath);
|
|
|
+// String laserDataPath = path ;
|
|
|
+// log.info("laserDataPath: {}", laserDataPath);
|
|
|
+//
|
|
|
+// // step1 创建t_route表(路径规划)
|
|
|
+// createRoute(sceneCode, laserDataPath);
|
|
|
+//
|
|
|
+// // step3 创建poi表, 热点,默认没有
|
|
|
+// createPoi(sceneCode);
|
|
|
+//
|
|
|
+// // step4 创建poi_type表, 使用的是模板初始化
|
|
|
+// createPoiType(sceneCode);
|
|
|
+//
|
|
|
+// // step5 创建poi_type_group表, 使用的是模板初始化
|
|
|
+// createPoiTypeGroup(sceneCode);
|
|
|
+//
|
|
|
+// // step7 复制静态资源
|
|
|
+// copyDefault(sceneCode);
|
|
|
+//
|
|
|
+//
|
|
|
+// //step8 替换index.html、/locat/addDataSet.html的场景码, @replace, @title
|
|
|
+// replaceHtml(sceneCode, title);
|
|
|
+//
|
|
|
+// // step9 创建 t_measurement表, 测量表,空数据
|
|
|
+// createMeasurement(sceneCode);
|
|
|
+
|
|
|
+
|
|
|
+// log.info("================== 初始化第一步完成 ==================");
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 这方法很重要, 会自动初始化initData2 的说有方法
|
|
|
+// * step10 创建控制点表 t_controlPoint, 读取服务器controlPoint.json文件
|
|
|
+// */
|
|
|
+//
|
|
|
+// String controlPointPath = laserDataPath + "/controlPoint.json";
|
|
|
+// log.info("控制点文件路径:{}", controlPointPath);
|
|
|
+// boolean flag = false;
|
|
|
+// if (cn.hutool.core.io.FileUtil.exist(controlPointPath)) {
|
|
|
+// log.info("处理控制点逻辑");
|
|
|
+// createControlPoint(sceneCode, laserDataPath);
|
|
|
+// flag = true;
|
|
|
+// } else {
|
|
|
+// log.info("控制点文件不存在:{}", controlPointPath);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ // 2021-09-23 地址需要更新
|
|
|
+// init.setUpdateTime(LocalDateTime.now());
|
|
|
+// Integer recount = init.getRecount();
|
|
|
+// recount = recount == null ? 1 : recount + 1;
|
|
|
+// init.setRecount(recount);
|
|
|
+
|
|
|
+
|
|
|
+// if (flag) {
|
|
|
+// init.setStatus(1);
|
|
|
+// log.info("完全初始化完成");
|
|
|
+// } else {
|
|
|
+// log.info("initDataStep_1处理完成");
|
|
|
+// init.setStatus(0);
|
|
|
+// }
|
|
|
+//
|
|
|
+// initMapper.save(init);
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化数据第一步
|
|
|
+ * @param initParam
|
|
|
+ */
|
|
|
+ public void initDataStep1(InitEntity initParam, String traceId){
|
|
|
+ log.info("异步初始化数据开始");
|
|
|
+ // 链路id
|
|
|
+ MDC.put("TRACE_ID", traceId);
|
|
|
+
|
|
|
+ String sceneCode = initParam.getId();
|
|
|
+ String laserDataPath = initParam.getPath();
|
|
|
+ String title = initParam.getTitle();
|
|
|
+
|
|
|
+
|
|
|
+ // 删除旧数据, 重算使用
|
|
|
+ initRemove(sceneCode);
|
|
|
+
|
|
|
|
|
|
// step1 创建t_route表(路径规划)
|
|
|
createRoute(sceneCode, laserDataPath);
|
|
@@ -189,7 +287,6 @@ public class InitServiceImpl implements InitService {
|
|
|
// step9 创建 t_measurement表, 测量表,空数据
|
|
|
createMeasurement(sceneCode);
|
|
|
|
|
|
-
|
|
|
log.info("================== 初始化第一步完成 ==================");
|
|
|
|
|
|
/**
|
|
@@ -208,25 +305,24 @@ public class InitServiceImpl implements InitService {
|
|
|
log.info("控制点文件不存在:{}", controlPointPath);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // 2021-09-23 地址需要更新
|
|
|
- init.setUpdateTime(LocalDateTime.now());
|
|
|
- Integer recount = init.getRecount();
|
|
|
- recount = recount == null ? 1 : recount + 1;
|
|
|
- init.setRecount(recount);
|
|
|
-
|
|
|
-
|
|
|
if (flag) {
|
|
|
- init.setStatus(1);
|
|
|
+ initParam.setStatus(1);
|
|
|
log.info("完全初始化完成");
|
|
|
} else {
|
|
|
log.info("initDataStep_1处理完成");
|
|
|
- init.setStatus(0);
|
|
|
+ initParam.setStatus(0);
|
|
|
}
|
|
|
|
|
|
- initMapper.save(init);
|
|
|
+ // 2021-09-23 地址需要更新
|
|
|
+ initParam.setUpdateTime(LocalDateTime.now());
|
|
|
+ Integer recount = initParam.getRecount();
|
|
|
+ recount = recount == null ? 1 : recount + 1;
|
|
|
+ initParam.setRecount(recount);
|
|
|
+
|
|
|
+ initMapper.save(initParam);
|
|
|
+
|
|
|
+ log.info("异步初始化数据结束");
|
|
|
|
|
|
- return Result.success();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -276,7 +372,7 @@ public class InitServiceImpl implements InitService {
|
|
|
// step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行
|
|
|
DataSetPo dataSet = createDataSet(sceneCode, laserDataPath, calculateEntity.getRotation2(), from);
|
|
|
|
|
|
- // step 10 创建 t_tiled_map表, 需要用到dataSet数据
|
|
|
+ // step 10 创建平面图 t_tiled_map表, 需要用到dataSet数据
|
|
|
tiledMapService.init(sceneCode, from);
|
|
|
|
|
|
|
|
@@ -305,7 +401,6 @@ public class InitServiceImpl implements InitService {
|
|
|
throw new BaseRuntimeException("初始化数据不存在:" + sceneCode);
|
|
|
}
|
|
|
String path = initEntity.getPath();
|
|
|
-// path = path + "/laserData";
|
|
|
|
|
|
processCould(sceneCode, path, controlPoint);
|
|
|
|