|
@@ -80,24 +80,44 @@ public class InitServiceImpl implements InitService {
|
|
@Autowired
|
|
@Autowired
|
|
ConfigConstant configConstant;
|
|
ConfigConstant configConstant;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ MapService mapService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ RecountInfoService recountInfoService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* initDataStep1
|
|
* initDataStep1
|
|
* 有顺序分,不能乱
|
|
* 有顺序分,不能乱
|
|
* @param sceneCode
|
|
* @param sceneCode
|
|
* @param path
|
|
* @param path
|
|
|
|
+ * @param from:age 四维看看重算,其他:手动重算
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Result initData(String sceneCode, String path) {
|
|
|
|
|
|
+ public Result initData(String sceneCode, String path, String from) {
|
|
|
|
|
|
if (StrUtil.isAllEmpty(sceneCode) || StrUtil.isAllEmpty(path)) {
|
|
if (StrUtil.isAllEmpty(sceneCode) || StrUtil.isAllEmpty(path)) {
|
|
return Result.failure("场景码或路径不能为空");
|
|
return Result.failure("场景码或路径不能为空");
|
|
}
|
|
}
|
|
|
|
|
|
- path = "/laserData";
|
|
|
|
|
|
+ // 防止为四维看看重复调用重算
|
|
|
|
+ if ("age".equals(from)){
|
|
|
|
+ InitEntity init = this.findById(sceneCode);
|
|
|
|
+ if (init != null){
|
|
|
|
+ log.error("场景:[{}] 已存在,不需要重算", sceneCode);
|
|
|
|
+ return Result.success();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String laserDataPath = path + "/laserData";
|
|
|
|
+ log.info("laserDataPath: {}", laserDataPath);
|
|
|
|
|
|
// step1 创建t_route表
|
|
// step1 创建t_route表
|
|
- createRoute(sceneCode, path);
|
|
|
|
|
|
+ createRoute(sceneCode, laserDataPath);
|
|
|
|
|
|
// step3 创建poi表, 热点,默认没有
|
|
// step3 创建poi表, 热点,默认没有
|
|
createPoi(sceneCode);
|
|
createPoi(sceneCode);
|
|
@@ -115,7 +135,7 @@ public class InitServiceImpl implements InitService {
|
|
copyDefault(sceneCode);
|
|
copyDefault(sceneCode);
|
|
|
|
|
|
|
|
|
|
- // step8 替换index.html、/locat/addDataSet.html的场景码, @replace
|
|
|
|
|
|
+ //step8 替换index.html、/locat/addDataSet.html的场景码, @replace
|
|
replaceHtml(sceneCode);
|
|
replaceHtml(sceneCode);
|
|
|
|
|
|
|
|
|
|
@@ -136,6 +156,7 @@ public class InitServiceImpl implements InitService {
|
|
/**
|
|
/**
|
|
* 需要控制点,才能完成以下操作
|
|
* 需要控制点,才能完成以下操作
|
|
*
|
|
*
|
|
|
|
+ *
|
|
* @param sceneCode
|
|
* @param sceneCode
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@@ -148,15 +169,17 @@ public class InitServiceImpl implements InitService {
|
|
}
|
|
}
|
|
|
|
|
|
String path = init.getPath();
|
|
String path = init.getPath();
|
|
|
|
+ String laserDataPath = path + "/laserData";
|
|
|
|
+ log.info("laserDataPath: {}", laserDataPath);
|
|
|
|
|
|
// step:0 获取控制点
|
|
// step:0 获取控制点
|
|
ControlPointEntity controlPoint = getControlPoint(sceneCode);
|
|
ControlPointEntity controlPoint = getControlPoint(sceneCode);
|
|
|
|
|
|
- // step1: 处理vision.txt 创建filter表, 处理firstView
|
|
|
|
- createFilter(sceneCode, path, controlPoint);
|
|
|
|
|
|
+ // step1: 处理vision.txt 创建filter表, 处理特殊点:firstView
|
|
|
|
+ createFilter(sceneCode, laserDataPath, controlPoint);
|
|
|
|
|
|
// step2 处理could.js 创建site_model, 处理原点、中心点、最大点、最小点
|
|
// step2 处理could.js 创建site_model, 处理原点、中心点、最大点、最小点
|
|
- processCould(sceneCode, path, controlPoint);
|
|
|
|
|
|
+ processCould(sceneCode, laserDataPath, controlPoint);
|
|
|
|
|
|
// step6 创建t_configs表 , 需要firstView;
|
|
// step6 创建t_configs表 , 需要firstView;
|
|
createConfig(sceneCode);
|
|
createConfig(sceneCode);
|
|
@@ -166,7 +189,7 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
|
|
|
|
// step8 目录pano、pano_depth、webcloud上传oss,
|
|
// step8 目录pano、pano_depth、webcloud上传oss,
|
|
- ossUploadDir(sceneCode, path);
|
|
|
|
|
|
+ ossUploadDir(sceneCode, laserDataPath);
|
|
|
|
|
|
// 更新 initDataStep2 状态
|
|
// 更新 initDataStep2 状态
|
|
init.setUpdateTime(LocalDateTime.now());
|
|
init.setUpdateTime(LocalDateTime.now());
|
|
@@ -175,6 +198,44 @@ public class InitServiceImpl implements InitService {
|
|
log.info("initDataStep_2处理完成");
|
|
log.info("initDataStep_2处理完成");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 重算场景
|
|
|
|
+ * @param sceneCode
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Result initRecount(String sceneCode) {
|
|
|
|
+ InitEntity entity = this.findById(sceneCode);
|
|
|
|
+
|
|
|
|
+ // 删除旧数据
|
|
|
|
+ this.initRemove(sceneCode);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 重新初始化数据
|
|
|
|
+ // 处理一下地址
|
|
|
|
+ String path = entity.getPath();
|
|
|
|
+// path = path.replaceAll("/laserData", "");
|
|
|
|
+ log.info("path: {}", path);
|
|
|
|
+ this.initData(sceneCode, path, null);
|
|
|
|
+
|
|
|
|
+ // 更新重算
|
|
|
|
+ Integer recount = entity.getRecount();
|
|
|
|
+ recount = recount == null ? 1 : recount;
|
|
|
|
+ entity.setRecount(recount);
|
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ initMapper.save(entity);
|
|
|
|
+
|
|
|
|
+ // 记录重算日志
|
|
|
|
+ RecountInfoEntity infoEntity = new RecountInfoEntity();
|
|
|
|
+ infoEntity.setId(SnowFlakeUUidUtils.getUuid("RI"));
|
|
|
|
+ infoEntity.setSceneCode(sceneCode);
|
|
|
|
+ infoEntity.setCreateTime(LocalDateTime.now());
|
|
|
|
+ recountInfoService.save(infoEntity);
|
|
|
|
+
|
|
|
|
+ return Result.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 替换两个文件的c 换成场景码
|
|
* 替换两个文件的c 换成场景码
|
|
* index.html
|
|
* index.html
|
|
@@ -191,7 +252,9 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
String indexStr = cn.hutool.core.io.FileUtil.readUtf8String(indexPath);
|
|
String indexStr = cn.hutool.core.io.FileUtil.readUtf8String(indexPath);
|
|
String dataSetStr = cn.hutool.core.io.FileUtil.readUtf8String(addDateSetPath);
|
|
String dataSetStr = cn.hutool.core.io.FileUtil.readUtf8String(addDateSetPath);
|
|
-
|
|
|
|
|
|
+ if (!indexStr.contains("@replace")) {
|
|
|
|
+ throw new BaseRuntimeException(MsgCode.e3001, "index.html不包含默认值, 请查看default文件是否正确");
|
|
|
|
+ }
|
|
indexStr = indexStr.replaceAll("@replace", sceneCode);
|
|
indexStr = indexStr.replaceAll("@replace", sceneCode);
|
|
dataSetStr = dataSetStr.replaceAll("@replace", sceneCode);
|
|
dataSetStr = dataSetStr.replaceAll("@replace", sceneCode);
|
|
|
|
|
|
@@ -232,8 +295,39 @@ public class InitServiceImpl implements InitService {
|
|
return optional.get();
|
|
return optional.get();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void initRemove(String sceneCode) {
|
|
|
|
+ // 真删除数据初始化数据
|
|
|
|
+
|
|
|
|
+ filterService.remove(sceneCode);
|
|
|
|
+ poiService.remove(sceneCode);
|
|
|
|
+ poiTypeService.remove(sceneCode);
|
|
|
|
+ poiTypeGroupService.remove(sceneCode);
|
|
|
|
+ siteService.remove(sceneCode);
|
|
|
|
+ configService.remove(sceneCode);
|
|
|
|
+ controlPointService.remove(sceneCode);
|
|
|
|
+ dataSetService.remove(sceneCode);
|
|
|
|
+ mapService.remove(sceneCode);
|
|
|
|
+ routeService.remove(sceneCode);
|
|
|
|
+ specialPointService.remove(sceneCode);
|
|
|
|
+ log.info("删除初始化数据完成");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result testRemove(String sceneCode) {
|
|
|
|
+ this.initRemove(sceneCode);
|
|
|
|
+ return Result.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
private void createFilter(String sceneCode, String path, ControlPointEntity dto){
|
|
private void createFilter(String sceneCode, String path, ControlPointEntity dto){
|
|
path = path +"/vision.txt";
|
|
path = path +"/vision.txt";
|
|
|
|
+ if (!cn.hutool.core.io.FileUtil.isFile(path)){
|
|
|
|
+ throw new BaseRuntimeException(MsgCode.e3001, "vision.txt不存在");
|
|
|
|
+ }
|
|
JSONArray jsonArray = convertToPanoInfoFor4dkk.createFilter(sceneCode, path, dto);
|
|
JSONArray jsonArray = convertToPanoInfoFor4dkk.createFilter(sceneCode, path, dto);
|
|
FilterEntity entity = new FilterEntity();
|
|
FilterEntity entity = new FilterEntity();
|
|
entity.setId(sceneCode);
|
|
entity.setId(sceneCode);
|
|
@@ -345,8 +439,8 @@ public class InitServiceImpl implements InitService {
|
|
System.out.println();
|
|
System.out.println();
|
|
|
|
|
|
SiteModelEntity entity = new SiteModelEntity();
|
|
SiteModelEntity entity = new SiteModelEntity();
|
|
- entity.setId(SnowFlakeUUidUtils.getUuid("SM"));
|
|
|
|
- entity.setSceneCode(sceneCode);
|
|
|
|
|
|
+// entity.setId(SnowFlakeUUidUtils.getUuid("SM"));
|
|
|
|
+ entity.setId(sceneCode);
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
// 默认热点为空
|
|
// 默认热点为空
|
|
entity.setData(siteModels);
|
|
entity.setData(siteModels);
|
|
@@ -393,8 +487,8 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
private void createPoi(String sceneCode){
|
|
private void createPoi(String sceneCode){
|
|
PoiEntity entity = new PoiEntity();
|
|
PoiEntity entity = new PoiEntity();
|
|
- entity.setId(SnowFlakeUUidUtils.getUuid("PO"));
|
|
|
|
-// entity.setId(sceneCode);
|
|
|
|
|
|
+// entity.setId(SnowFlakeUUidUtils.getUuid("PO"));
|
|
|
|
+ entity.setId(sceneCode);
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
// 默认热点为空
|
|
// 默认热点为空
|
|
entity.setData(new ArrayList<>());
|
|
entity.setData(new ArrayList<>());
|
|
@@ -406,8 +500,8 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
private void createPoiType(String sceneCode){
|
|
private void createPoiType(String sceneCode){
|
|
PoiTypeEntity entity = new PoiTypeEntity();
|
|
PoiTypeEntity entity = new PoiTypeEntity();
|
|
- entity.setId(SnowFlakeUUidUtils.getUuid("PT"));
|
|
|
|
- entity.setSceneCode(sceneCode);
|
|
|
|
|
|
+// entity.setId(SnowFlakeUUidUtils.getUuid("PT"));
|
|
|
|
+ entity.setId(sceneCode);
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
// 读取初始文件
|
|
// 读取初始文件
|
|
String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
|
|
String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
|
|
@@ -419,8 +513,8 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
private void createPoiTypeGroup(String sceneCode){
|
|
private void createPoiTypeGroup(String sceneCode){
|
|
PoiTypeGroupEntity entity = new PoiTypeGroupEntity();
|
|
PoiTypeGroupEntity entity = new PoiTypeGroupEntity();
|
|
- entity.setId(SnowFlakeUUidUtils.getUuid("PG"));
|
|
|
|
- entity.setSceneCode(sceneCode);
|
|
|
|
|
|
+// entity.setId(SnowFlakeUUidUtils.getUuid("PG"));
|
|
|
|
+ entity.setId(sceneCode);
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
// 读取初始文件
|
|
// 读取初始文件
|
|
String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
|
|
String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
|
|
@@ -438,6 +532,9 @@ public class InitServiceImpl implements InitService {
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
// 设置原点坐标,通过场景码查询特殊点表的原点
|
|
// 设置原点坐标,通过场景码查询特殊点表的原点
|
|
SpecialPointEntity sp = specialPointService.findBySceneCodeAndPoiKey(sceneCode, TypeConstant.POI_ORIGIN);
|
|
SpecialPointEntity sp = specialPointService.findBySceneCodeAndPoiKey(sceneCode, TypeConstant.POI_ORIGIN);
|
|
|
|
+ if (sp == null) {
|
|
|
|
+ throw new BaseRuntimeException(MsgCode.e3001, "没有找到原点坐标");
|
|
|
|
+ }
|
|
Double[] poi = sp.getPoi();
|
|
Double[] poi = sp.getPoi();
|
|
// JSONObject dataSet = ModifyDataSets.createDataSet(poi);
|
|
// JSONObject dataSet = ModifyDataSets.createDataSet(poi);
|
|
DataSetPo po = ModifyDataSets.createDataSetPo(poi);
|
|
DataSetPo po = ModifyDataSets.createDataSetPo(poi);
|
|
@@ -471,8 +568,8 @@ public class InitServiceImpl implements InitService {
|
|
|
|
|
|
|
|
|
|
ConfigEntity entity = new ConfigEntity();
|
|
ConfigEntity entity = new ConfigEntity();
|
|
- entity.setId(SnowFlakeUUidUtils.getUuid("CF"));
|
|
|
|
- entity.setSceneCode(sceneCode);
|
|
|
|
|
|
+// entity.setId(SnowFlakeUUidUtils.getUuid("CF"));
|
|
|
|
+ entity.setId(sceneCode);
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setData(resData);
|
|
entity.setData(resData);
|
|
configService.save(entity);
|
|
configService.save(entity);
|
|
@@ -486,28 +583,30 @@ public class InitServiceImpl implements InitService {
|
|
*/
|
|
*/
|
|
private void createRoute(String sceneCode, String path){
|
|
private void createRoute(String sceneCode, String path){
|
|
List<String> list = new ArrayList<>();
|
|
List<String> list = new ArrayList<>();
|
|
- try {
|
|
|
|
|
|
+//
|
|
String routePath = path + "/final_freespace.csv";
|
|
String routePath = path + "/final_freespace.csv";
|
|
- if (!cn.hutool.core.io.FileUtil.exist(routePath)){
|
|
|
|
|
|
+ log.info("routePath: {}", routePath);
|
|
|
|
+ if (!cn.hutool.core.io.FileUtil.isFile(routePath)){
|
|
log.info("输入路径有误, path: {}", routePath);
|
|
log.info("输入路径有误, path: {}", routePath);
|
|
throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
|
|
throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
|
|
}
|
|
}
|
|
|
|
+ try {
|
|
list = FileUtil.readFileByLines2(routePath);
|
|
list = FileUtil.readFileByLines2(routePath);
|
|
-
|
|
|
|
RouteEntity entity = new RouteEntity();
|
|
RouteEntity entity = new RouteEntity();
|
|
-// entity.setId(SnowFlakeUUidUtils.getUuid("RT"));
|
|
|
|
entity.setId(sceneCode);
|
|
entity.setId(sceneCode);
|
|
-// entity.setSceneCode(sceneCode);
|
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
entity.setData(list);
|
|
entity.setData(list);
|
|
routeService.save(entity);
|
|
routeService.save(entity);
|
|
log.info(" Route数据初始化创建完成");
|
|
log.info(" Route数据初始化创建完成");
|
|
-
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+//
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private ControlPointEntity getControlPoint(String sceneCode){
|
|
private ControlPointEntity getControlPoint(String sceneCode){
|