|
@@ -95,25 +95,50 @@ public class InitServiceImpl implements InitService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Result initData(String sceneCode, String path, String from, String title) {
|
|
|
+ public Result initData(InitDto param) {
|
|
|
+ String from = param.getFrom();
|
|
|
+ log.info("来自【{}】 初始化", from);
|
|
|
|
|
|
+ String sceneCode = param.getSceneCode();
|
|
|
if (StrUtil.isAllEmpty(sceneCode)) {
|
|
|
return Result.failure("场景码不能为空");
|
|
|
}
|
|
|
|
|
|
+ String path = param.getPath();
|
|
|
+ String title = param.getTitle();
|
|
|
+
|
|
|
// 防止为四维看看重复调用重算
|
|
|
InitEntity init = findById(sceneCode);
|
|
|
if (init != null) {
|
|
|
+ log.info("初始化数据已存在: {}", sceneCode);
|
|
|
// if ("age".equals(from)){
|
|
|
// log.error("场景:[{}] 已存在,不需要重算", sceneCode);
|
|
|
// return Result.failure(MsgCode.e3001, "场景已存在,不需要重算:" + sceneCode);
|
|
|
// }
|
|
|
|
|
|
// 重算
|
|
|
+
|
|
|
if ("recount".equals(from)){
|
|
|
path = init.getPath();
|
|
|
title = init.getTitle();
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 新场景
|
|
|
+ init = new InitEntity();
|
|
|
+ init.setId(sceneCode);
|
|
|
+ init.setPath(path);
|
|
|
+ init.setCreateTime(LocalDateTime.now());
|
|
|
+ init.setTitle(title);
|
|
|
+ init.setChildName(param.getChildName());
|
|
|
+ init.setSnCode(param.getSnCode());
|
|
|
+ init.setShootTime(param.getCreateTime());
|
|
|
+ init.setStatus(0);
|
|
|
+ // https://testlaser.4dkankan.com/maxkk/ + 场景码
|
|
|
+ init.setWebSite(configConstant.webSitePath + sceneCode);
|
|
|
+ init.setUserId(param.getUserId());
|
|
|
+
|
|
|
+ initMapper.save(init);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 删除旧数据, 重算使用
|
|
@@ -154,6 +179,7 @@ public class InitServiceImpl implements InitService {
|
|
|
// step9 创建 t_measurement表, 测量表,空数据
|
|
|
createMeasurement(sceneCode);
|
|
|
|
|
|
+ log.info("================== 初始化第一步完成 ==================");
|
|
|
|
|
|
/**
|
|
|
* 这方法很重要, 会自动初始化initData2 的说有方法
|
|
@@ -172,81 +198,50 @@ public class InitServiceImpl implements InitService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ init.setUpdateTime(LocalDateTime.now());
|
|
|
+ init.setTitle(title);
|
|
|
+ Integer recount = init.getRecount();
|
|
|
+ recount = recount == null ? 1 : recount + 1;
|
|
|
+ init.setRecount(recount);
|
|
|
+
|
|
|
+// // 保存initDataStep1 状态
|
|
|
+// if (init == null) {
|
|
|
+// init = new InitEntity();
|
|
|
+// init.setId(sceneCode);
|
|
|
+// init.setPath(path);
|
|
|
+// init.setCreateTime(LocalDateTime.now());
|
|
|
+// init.setTitle(title);
|
|
|
+// init.setChildName(param.getChildName());
|
|
|
+// init.setSnCode(param.getSnCode());
|
|
|
+// init.setShootTime(param.getCreateTime());
|
|
|
+// // https://testlaser.4dkankan.com/maxkk/ + 场景码
|
|
|
+// init.setWebSite(configConstant.webSitePath + sceneCode);
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// init.setUpdateTime(LocalDateTime.now());
|
|
|
+// init.setTitle(title);
|
|
|
+// Integer recount = init.getRecount();
|
|
|
+// recount = recount == null ? 1 : recount + 1;
|
|
|
+// init.setRecount(recount);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
- // 保存initDataStep1 状态
|
|
|
- if (init == null) {
|
|
|
- init = new InitEntity();
|
|
|
- init.setId(sceneCode);
|
|
|
- init.setPath(path);
|
|
|
- init.setCreateTime(LocalDateTime.now());
|
|
|
- init.setTitle(title);
|
|
|
- } else {
|
|
|
- init.setUpdateTime(LocalDateTime.now());
|
|
|
- init.setTitle(title);
|
|
|
- Integer recount = init.getRecount();
|
|
|
- recount = recount == null ? 1 : recount + 1;
|
|
|
- init.setRecount(recount);
|
|
|
- }
|
|
|
|
|
|
- init.setStatus(0);
|
|
|
- initMapper.save(init);
|
|
|
|
|
|
if (flag){
|
|
|
+ init.setStatus(1);
|
|
|
log.info("完全初始化完成");
|
|
|
} else {
|
|
|
log.info("initDataStep_1处理完成");
|
|
|
+ init.setStatus(0);
|
|
|
}
|
|
|
|
|
|
+ initMapper.save(init);
|
|
|
+
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 初始化控制点
|
|
|
- * @param sceneCode
|
|
|
- * @param laserDataPath
|
|
|
- */
|
|
|
- private void createControlPoint(String sceneCode, String laserDataPath) {
|
|
|
- String path = laserDataPath + "/controlPoint.json";
|
|
|
- if (!cn.hutool.core.io.FileUtil.exist(path)){
|
|
|
- throw new BaseRuntimeException("控制点文件不存在: " + path);
|
|
|
- }
|
|
|
-
|
|
|
- String s = cn.hutool.core.io.FileUtil.readUtf8String(path);
|
|
|
- com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(s);
|
|
|
- com.alibaba.fastjson.JSONArray points = jsonObject.getJSONArray("points");
|
|
|
-
|
|
|
- com.alibaba.fastjson.JSONObject poi_1 = points.getJSONObject(0);
|
|
|
- com.alibaba.fastjson.JSONObject poi_2 = points.getJSONObject(1);
|
|
|
-
|
|
|
- // 第一个点 经度:lon:113, [0] 纬度:lat:22, [1]
|
|
|
- double gpsLon_1 = poi_1.getJSONObject("coordinate").getDouble("longitude");
|
|
|
- double gpsLat_1 = poi_1.getJSONObject("coordinate").getDouble("latitude");
|
|
|
- double ageX_1 = poi_1.getJSONObject("location").getDouble("x");
|
|
|
- double ageY_1 = poi_1.getJSONObject("location").getDouble("y");
|
|
|
-
|
|
|
- // 第二个点
|
|
|
- double gpsLon_2 = poi_2.getJSONObject("coordinate").getDouble("longitude");
|
|
|
- double gpsLat_2 = poi_2.getJSONObject("coordinate").getDouble("latitude");
|
|
|
- double ageX_2 = poi_2.getJSONObject("location").getDouble("x");
|
|
|
- double ageY_2 = poi_2.getJSONObject("location").getDouble("y");
|
|
|
-
|
|
|
- double[] gpsCoord1 = {gpsLon_1, gpsLat_1 };
|
|
|
- double[] gpsCoord2 = { gpsLon_2, gpsLat_2};
|
|
|
- double[] ageLocation1 = {ageX_1, ageY_1};
|
|
|
- double[] ageLocation2 = {ageX_2, ageY_2};
|
|
|
-
|
|
|
- ControlPointEntity entity = new ControlPointEntity();
|
|
|
- entity.setGpsControlCoordinate1(gpsCoord1);
|
|
|
- entity.setGpsControlCoordinate2(gpsCoord2);
|
|
|
- entity.setAgeControlLocation1(ageLocation1);
|
|
|
- entity.setAgeControlLocation2(ageLocation2);
|
|
|
|
|
|
- entity.setId(sceneCode);
|
|
|
- entity.setCreateTime(LocalDateTime.now());
|
|
|
- controlPointService.save(entity);
|
|
|
- log.info("controlPoint控制点初始化完成");
|
|
|
- }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -300,8 +295,26 @@ public class InitServiceImpl implements InitService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void initSiteModel(String sceneCode){
|
|
|
+ // step1: 获取控制点
|
|
|
+ ControlPointEntity controlPoint = getControlPoint(sceneCode);
|
|
|
+ if (controlPoint == null){
|
|
|
+ throw new BaseRuntimeException("控制点不存在:" + sceneCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ // step2: init数据路径
|
|
|
+ InitEntity initEntity = this.findById(sceneCode);
|
|
|
+ if (initEntity == null) {
|
|
|
+ throw new BaseRuntimeException("初始化数据不存在:" + sceneCode);
|
|
|
+ }
|
|
|
+ String path = initEntity.getPath();
|
|
|
+ path = path + "/laserData";
|
|
|
+
|
|
|
+ processCould(sceneCode, path, controlPoint);
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -315,7 +328,6 @@ public class InitServiceImpl implements InitService {
|
|
|
dataSetService.remove(sceneCode);
|
|
|
siteService.remove(sceneCode);
|
|
|
|
|
|
-
|
|
|
log.info("删除initDataStep2数据完成");
|
|
|
}
|
|
|
|
|
@@ -330,9 +342,13 @@ public class InitServiceImpl implements InitService {
|
|
|
// 删除旧数据
|
|
|
// this.initRemove(sceneCode);
|
|
|
|
|
|
-
|
|
|
+ log.info("执行手动重新:{}", sceneCode);
|
|
|
// 重新初始化数据, 地址在里面处理
|
|
|
- this.initData(sceneCode, null, "recount", null);
|
|
|
+ InitDto initDto = new InitDto();
|
|
|
+ initDto.setSceneCode(sceneCode);
|
|
|
+ initDto.setFrom("recount");
|
|
|
+// this.initData(sceneCode, null, "recount", null);
|
|
|
+ this.initData(initDto);
|
|
|
|
|
|
|
|
|
// 记录重算日志
|
|
@@ -341,7 +357,7 @@ public class InitServiceImpl implements InitService {
|
|
|
infoEntity.setSceneCode(sceneCode);
|
|
|
infoEntity.setCreateTime(LocalDateTime.now());
|
|
|
recountInfoService.save(infoEntity);
|
|
|
-
|
|
|
+ log.info("手动重新完成:{}", sceneCode);
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
@@ -381,6 +397,53 @@ public class InitServiceImpl implements InitService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 初始化控制点
|
|
|
+ * @param sceneCode
|
|
|
+ * @param laserDataPath
|
|
|
+ */
|
|
|
+ private void createControlPoint(String sceneCode, String laserDataPath) {
|
|
|
+ String path = laserDataPath + "/controlPoint.json";
|
|
|
+ if (!cn.hutool.core.io.FileUtil.exist(path)){
|
|
|
+ throw new BaseRuntimeException("控制点文件不存在: " + path);
|
|
|
+ }
|
|
|
+
|
|
|
+ String s = cn.hutool.core.io.FileUtil.readUtf8String(path);
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(s);
|
|
|
+ com.alibaba.fastjson.JSONArray points = jsonObject.getJSONArray("points");
|
|
|
+
|
|
|
+ com.alibaba.fastjson.JSONObject poi_1 = points.getJSONObject(0);
|
|
|
+ com.alibaba.fastjson.JSONObject poi_2 = points.getJSONObject(1);
|
|
|
+
|
|
|
+ // 第一个点 经度:lon:113, [0] 纬度:lat:22, [1]
|
|
|
+ double gpsLon_1 = poi_1.getJSONObject("coordinate").getDouble("longitude");
|
|
|
+ double gpsLat_1 = poi_1.getJSONObject("coordinate").getDouble("latitude");
|
|
|
+ double ageX_1 = poi_1.getJSONObject("location").getDouble("x");
|
|
|
+ double ageY_1 = poi_1.getJSONObject("location").getDouble("y");
|
|
|
+
|
|
|
+ // 第二个点
|
|
|
+ double gpsLon_2 = poi_2.getJSONObject("coordinate").getDouble("longitude");
|
|
|
+ double gpsLat_2 = poi_2.getJSONObject("coordinate").getDouble("latitude");
|
|
|
+ double ageX_2 = poi_2.getJSONObject("location").getDouble("x");
|
|
|
+ double ageY_2 = poi_2.getJSONObject("location").getDouble("y");
|
|
|
+
|
|
|
+ double[] gpsCoord1 = {gpsLon_1, gpsLat_1 };
|
|
|
+ double[] gpsCoord2 = { gpsLon_2, gpsLat_2};
|
|
|
+ double[] ageLocation1 = {ageX_1, ageY_1};
|
|
|
+ double[] ageLocation2 = {ageX_2, ageY_2};
|
|
|
+
|
|
|
+ ControlPointEntity entity = new ControlPointEntity();
|
|
|
+ entity.setGpsControlCoordinate1(gpsCoord1);
|
|
|
+ entity.setGpsControlCoordinate2(gpsCoord2);
|
|
|
+ entity.setAgeControlLocation1(ageLocation1);
|
|
|
+ entity.setAgeControlLocation2(ageLocation2);
|
|
|
+
|
|
|
+ entity.setId(sceneCode);
|
|
|
+ entity.setCreateTime(LocalDateTime.now());
|
|
|
+ controlPointService.save(entity);
|
|
|
+ log.info("controlPoint控制点初始化完成");
|
|
|
+ }
|
|
|
+
|
|
|
private void createMeasurement(String sceneCode) {
|
|
|
MeasurementEntity entity = new MeasurementEntity();
|
|
|
entity.setCreateTime(LocalDateTime.now());
|
|
@@ -625,10 +688,14 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
});
|
|
|
|
|
|
- log.info("更新后的siteModel值: {}", siteModels.toArray());
|
|
|
+// log.info("更新后的siteModel值: {}", siteModels.toArray());
|
|
|
+ SiteModelEntity modelEntity = siteService.findById(sceneCode);
|
|
|
+ if (modelEntity != null) {
|
|
|
+ siteService.remove(sceneCode);
|
|
|
+ }
|
|
|
SiteModelEntity entity = new SiteModelEntity();
|
|
|
entity.setId(sceneCode);
|
|
|
- entity.setUpdateTime(LocalDateTime.now());
|
|
|
+ entity.setCreateTime(LocalDateTime.now());
|
|
|
// 默认热点为空
|
|
|
entity.setData(siteModels);
|
|
|
siteService.save(entity);
|
|
@@ -769,6 +836,9 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
// 根据场景码查询特殊点
|
|
|
SpecialPointEntity sp = specialPointService.findBySceneCodeAndPoiKey(sceneCode, TypeConstant.POI_FIRST_VIEW);
|
|
|
+ if (sp == null) {
|
|
|
+ throw new BaseRuntimeException("firstView点不存在,请检查特殊点表或者检查createVisionToFilter方法初始化");
|
|
|
+ }
|
|
|
Double[] poi = sp.getPoi();
|
|
|
log.info("firstView: {}" , sp.getPoi());
|
|
|
|