|
@@ -95,26 +95,28 @@ public class InitServiceImpl implements InitService {
|
|
|
@Override
|
|
|
public Result initData(String sceneCode, String path, String from) {
|
|
|
|
|
|
- if (StrUtil.isAllEmpty(sceneCode) || StrUtil.isAllEmpty(path)) {
|
|
|
- return Result.failure("场景码或路径不能为空");
|
|
|
+ if (StrUtil.isAllEmpty(sceneCode)) {
|
|
|
+ return Result.failure("场景码不能为空");
|
|
|
}
|
|
|
|
|
|
// 防止为四维看看重复调用重算
|
|
|
- InitEntity init = this.findById(sceneCode);
|
|
|
- if ("age".equals(from)){
|
|
|
- if (init != null){
|
|
|
+ InitEntity init = findById(sceneCode);
|
|
|
+ if (init != null) {
|
|
|
+ if ("age".equals(from)){
|
|
|
log.error("场景:[{}] 已存在,不需要重算", sceneCode);
|
|
|
- return Result.success();
|
|
|
+ return Result.failure(MsgCode.e3001, "场景已存在,不需要重算:" + sceneCode);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 重算
|
|
|
- if ("recount".equals(from)){
|
|
|
- path = init.getPath();
|
|
|
+ // 重算
|
|
|
+ if ("recount".equals(from)){
|
|
|
+ path = init.getPath();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ // 路径在这里检测
|
|
|
+ if (StrUtil.isAllEmpty(path)) {
|
|
|
+ return Result.failure("路径不能为空");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
String laserDataPath = path + "/laserData";
|
|
@@ -126,10 +128,10 @@ public class InitServiceImpl implements InitService {
|
|
|
// step3 创建poi表, 热点,默认没有
|
|
|
createPoi(sceneCode);
|
|
|
|
|
|
- // step4 创建poi_type表
|
|
|
+ // step4 创建poi_type表, 使用的是模板初始化
|
|
|
createPoiType(sceneCode);
|
|
|
|
|
|
- // step5 创建poi_type_group表
|
|
|
+ // step5 创建poi_type_group表, 使用的是模板初始化
|
|
|
createPoiTypeGroup(sceneCode);
|
|
|
|
|
|
// step7 复制静态资源
|
|
@@ -161,6 +163,7 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 这个方法可以本地调试
|
|
|
* 需要控制点,才能完成以下操作
|
|
|
* 重新输入控制点时, 把相应数据删除, 重新初始化
|
|
|
*
|
|
@@ -175,9 +178,6 @@ public class InitServiceImpl implements InitService {
|
|
|
throw new BaseRuntimeException(MsgCode.e3001,"此场景的数据初始化不存在");
|
|
|
}
|
|
|
InitEntity init = optional.get();
|
|
|
-// if (init.getStatus() !=0) {
|
|
|
-// throw new BaseRuntimeException("数据初始化失败");
|
|
|
-// }
|
|
|
|
|
|
// 输入控制点,需要删除旧数据,重新初始化
|
|
|
removeInitDataStep2(sceneCode);
|
|
@@ -192,13 +192,13 @@ public class InitServiceImpl implements InitService {
|
|
|
// step1: 处理vision.txt 创建filter表, 处理特殊点:firstView
|
|
|
createFilter(sceneCode, laserDataPath, controlPoint);
|
|
|
|
|
|
- // step2 处理could.js 创建site_model, 处理原点、中心点、最大点、最小点
|
|
|
+ // step2 处理could.js 使用的是代码初始化,创建site_model, 处理原点、中心点、最大点、最小点
|
|
|
processCould(sceneCode, laserDataPath, controlPoint);
|
|
|
|
|
|
- // step6 创建t_configs表 , 需要firstView;
|
|
|
+ // step6 创建t_configs表, 使用的是模板数据 , 需要firstView;
|
|
|
createConfig(sceneCode);
|
|
|
|
|
|
- // step7 创建t_datasets表, 需要处理原点之后执行
|
|
|
+ // step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行
|
|
|
createDataSet(sceneCode);
|
|
|
|
|
|
|
|
@@ -222,6 +222,9 @@ public class InitServiceImpl implements InitService {
|
|
|
specialPointService.remove(sceneCode);
|
|
|
configService.remove(sceneCode);
|
|
|
dataSetService.remove(sceneCode);
|
|
|
+ siteService.remove(sceneCode);
|
|
|
+
|
|
|
+
|
|
|
log.info("删除initDataStep2数据完成");
|
|
|
}
|
|
|
|
|
@@ -304,10 +307,7 @@ public class InitServiceImpl implements InitService {
|
|
|
@Override
|
|
|
public InitEntity findById(String id) {
|
|
|
Optional<InitEntity> optional = initMapper.findById(id);
|
|
|
- if (!optional.isPresent()){
|
|
|
- throw new BaseRuntimeException(MsgCode.e3001, "初始化数据不存在");
|
|
|
- }
|
|
|
- return optional.get();
|
|
|
+ return optional.orElse(null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -337,7 +337,50 @@ public class InitServiceImpl implements InitService {
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void testInitDataStep2(String sceneCode) {
|
|
|
+
|
|
|
+ Optional<InitEntity> optional = initMapper.findById(sceneCode);
|
|
|
+ if (!optional.isPresent()){
|
|
|
+ throw new BaseRuntimeException(MsgCode.e3001,"此场景的数据初始化不存在");
|
|
|
+ }
|
|
|
+ InitEntity init = optional.get();
|
|
|
+
|
|
|
+ // 输入控制点,需要删除旧数据,重新初始化
|
|
|
+ removeInitDataStep2(sceneCode);
|
|
|
+
|
|
|
+ String path = "F:\\test\\project\\age_laser";
|
|
|
+ String laserDataPath = path + "/laserData";
|
|
|
+ log.info("laserDataPath: {}", laserDataPath);
|
|
|
+
|
|
|
+ // step:0 获取控制点
|
|
|
+ ControlPointEntity controlPoint = getControlPoint(sceneCode);
|
|
|
+
|
|
|
+ // step1: 处理vision.txt 创建filter表, 处理特殊点:firstView
|
|
|
+ createFilter(sceneCode, laserDataPath, controlPoint);
|
|
|
|
|
|
+ // step2 处理could.js 使用的是代码初始化,创建site_model, 处理原点、中心点、最大点、最小点
|
|
|
+ processCould(sceneCode, laserDataPath, controlPoint);
|
|
|
+
|
|
|
+ // step6 创建t_configs表, 使用的是模板数据 , 需要firstView;
|
|
|
+ createConfig(sceneCode);
|
|
|
+
|
|
|
+ // step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行
|
|
|
+ createDataSet(sceneCode);
|
|
|
+
|
|
|
+
|
|
|
+ // step8 目录pano、pano_depth、webcloud上传oss,
|
|
|
+// ossUploadDir(sceneCode, laserDataPath);
|
|
|
+
|
|
|
+ // 更新 initDataStep2 状态
|
|
|
+ init.setUpdateTime(LocalDateTime.now());
|
|
|
+ init.setStatus(1);
|
|
|
+ initMapper.save(init);
|
|
|
+ log.info("initDataStep_2处理完成");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 这个不能本地调试
|
|
|
private void createFilter(String sceneCode, String path, ControlPointEntity dto){
|
|
|
path = path +"/vision.txt";
|
|
|
if (!cn.hutool.core.io.FileUtil.isFile(path)){
|
|
@@ -374,7 +417,7 @@ public class InitServiceImpl implements InitService {
|
|
|
JSONObject info = ModifyCloud.fixCloud(path);
|
|
|
|
|
|
cn.hutool.core.io.FileUtil.writeUtf8String(info.toString(), path);
|
|
|
- log.info("新的cloud.js写入完成:{}", path);
|
|
|
+ log.info("新的cloud.js写入服务器完成:{}", path);
|
|
|
|
|
|
/**
|
|
|
* 将boundingBox坐标转换成gis坐标, site_model需要
|
|
@@ -403,7 +446,7 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
Double[] gpsMax = getKey(resJson, "max");
|
|
|
Double[] gpsMin = getKey(resJson, "min");
|
|
|
- Double[] gpsCentre = getKey(resJson, "centre");
|
|
|
+ Double[] gpsCentre = getKeyZ(resJson, "centre");
|
|
|
|
|
|
// 将数据保存到db
|
|
|
saveSpecialPoint(sceneCode, TypeConstant.POI_BOUNDINGBOX_MAX, ageMax, gpsMax);
|
|
@@ -434,10 +477,10 @@ public class InitServiceImpl implements InitService {
|
|
|
Double[] peak_2 = {max[0],min[1]};
|
|
|
Double[] peak_3 = {min[0],min[1]};
|
|
|
Double[] peak_4 = {min[0],max[1]};
|
|
|
-// List<Double[]> doubles = Arrays.asList(peak_1, peak_2, peak_3, peak_4);
|
|
|
List<List<Double[]>> doubles = Arrays.asList(Arrays.asList(peak_1, peak_2, peak_3, peak_4));
|
|
|
|
|
|
// centre 替换BUILDING、FLOOR、ROOM 的center
|
|
|
+ log.info("中心点:{}, {}, {}", centre[0], centre[1], centre[2]);
|
|
|
siteModels.forEach(p -> {
|
|
|
// 第一层:BUILDING,处理centre、coordinates
|
|
|
p.setCenter(centre);
|
|
@@ -470,10 +513,8 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
});
|
|
|
|
|
|
- System.out.println();
|
|
|
-
|
|
|
+ log.info("更新后的siteModel值: {}", siteModels.toArray());
|
|
|
SiteModelEntity entity = new SiteModelEntity();
|
|
|
-// entity.setId(SnowFlakeUUidUtils.getUuid("SM"));
|
|
|
entity.setId(sceneCode);
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
// 默认热点为空
|
|
@@ -483,7 +524,7 @@ public class InitServiceImpl implements InitService {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void test(){
|
|
|
+ public void testSiteModel(){
|
|
|
String content = MyFileUtils.getResourceContent("data/site_model.json");
|
|
|
List<SiteDto> siteModels = JSON.parseArray(content, SiteDto.class);
|
|
|
|
|
@@ -492,6 +533,7 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 获取两个值的
|
|
|
* json数组转 double[]
|
|
|
* @param resJson
|
|
|
* @param key
|
|
@@ -503,6 +545,18 @@ public class InitServiceImpl implements InitService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取三个值的
|
|
|
+ * @param resJson
|
|
|
+ * @param key
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Double[] getKeyZ(JSONObject resJson , String key){
|
|
|
+ JSONArray array = resJson.getJSONArray(key);
|
|
|
+ Double[] res = {array.getDouble(0), array.getDouble(1), array.getDouble(2)};
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
/***
|
|
|
* 保存特质点
|
|
|
* @param sceneCode 场景码
|
|
@@ -522,7 +576,6 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
private void createPoi(String sceneCode){
|
|
|
PoiEntity entity = new PoiEntity();
|
|
|
-// entity.setId(SnowFlakeUUidUtils.getUuid("PO"));
|
|
|
entity.setId(sceneCode);
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
// 默认热点为空
|
|
@@ -535,7 +588,6 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
private void createPoiType(String sceneCode){
|
|
|
PoiTypeEntity entity = new PoiTypeEntity();
|
|
|
-// entity.setId(SnowFlakeUUidUtils.getUuid("PT"));
|
|
|
entity.setId(sceneCode);
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
// 读取初始文件
|
|
@@ -548,7 +600,6 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
private void createPoiTypeGroup(String sceneCode){
|
|
|
PoiTypeGroupEntity entity = new PoiTypeGroupEntity();
|
|
|
-// entity.setId(SnowFlakeUUidUtils.getUuid("PG"));
|
|
|
entity.setId(sceneCode);
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
// 读取初始文件
|
|
@@ -573,14 +624,12 @@ public class InitServiceImpl implements InitService {
|
|
|
entity.setId(sceneCode);
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
// 设置原点坐标,通过场景码查询特殊点表的原点
|
|
|
-// SpecialPointEntity sp = specialPointService.findBySceneCodeAndPoiKey(sceneCode, TypeConstant.POI_ORIGIN);
|
|
|
List<SpecialPointEntity> spList = specialPointService.findBySceneCode(sceneCode);
|
|
|
// 正常是5条记录: db.getCollection('t_special_point').find({"sceneCode":"t97"})
|
|
|
if (spList.size() != 5) {
|
|
|
throw new BaseRuntimeException(MsgCode.e3001, "特殊点表坐标异常");
|
|
|
}
|
|
|
|
|
|
-// List<String> poiKey = Arrays.asList(TypeConstant.POI_ORIGIN, TypeConstant.POI_BOUNDINGBOX_MAX, TypeConstant.POI_BOUNDINGBOX_MIN);
|
|
|
Map<String, Double[]> map = new HashMap<>();
|
|
|
for (SpecialPointEntity sp : spList) {
|
|
|
String key = sp.getPoiKey();
|