|
@@ -2,9 +2,11 @@ package com.fdkankan.indoor.core.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.fdkankan.indoor.base.constant.ConfigConstant;
|
|
|
import com.fdkankan.indoor.base.constant.TypeConstant;
|
|
|
import com.fdkankan.indoor.base.convert.*;
|
|
|
import com.fdkankan.indoor.base.exception.BaseRuntimeException;
|
|
|
+import com.fdkankan.indoor.base.util.CmdUtils;
|
|
|
import com.fdkankan.indoor.base.util.FileUtils;
|
|
|
import com.fdkankan.indoor.base.util.Result;
|
|
|
import com.fdkankan.indoor.base.util.SnowFlakeUUidUtils;
|
|
@@ -69,6 +71,9 @@ public class InitServiceImpl implements InitService {
|
|
|
@Autowired
|
|
|
ControlPointService controlPointService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ConfigConstant configConstant;
|
|
|
+
|
|
|
/**
|
|
|
* initDataStep1
|
|
|
* 有顺序分,不能乱
|
|
@@ -92,10 +97,19 @@ public class InitServiceImpl implements InitService {
|
|
|
// step5 创建poi_type_group表
|
|
|
createPoiTypeGroup(sceneCode);
|
|
|
|
|
|
- // step8 创建t_route表
|
|
|
+ // step6 创建t_route表
|
|
|
createRoute(sceneCode, path);
|
|
|
|
|
|
|
|
|
+ // step7 复制静态资源
|
|
|
+ copyDefault(sceneCode);
|
|
|
+
|
|
|
+
|
|
|
+ // step8 替换index.html、/locat/addDataSet.html的场景码, @replace
|
|
|
+ replaceHtml(sceneCode);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 保存initDataStep1 状态
|
|
|
InitEntity entity = new InitEntity();
|
|
|
entity.setId(sceneCode);
|
|
@@ -103,10 +117,51 @@ public class InitServiceImpl implements InitService {
|
|
|
entity.setCreateTime(LocalDateTime.now());
|
|
|
entity.setStatus(0);
|
|
|
initMapper.save(entity);
|
|
|
+ log.info("initDataStep_1处理完成");
|
|
|
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 替换两个文件的c 换成场景码
|
|
|
+ * index.html
|
|
|
+ * /locat/addDataSet.html
|
|
|
+ * @param sceneCode
|
|
|
+ */
|
|
|
+ private void replaceHtml(String sceneCode) {
|
|
|
+ String indexName = "index.html";
|
|
|
+ String addDataSetName = "addDataSet.html";
|
|
|
+
|
|
|
+ String basePath = configConstant.serverBasePath + "/" + sceneCode + "/" ;
|
|
|
+ String indexPath = basePath + indexName;
|
|
|
+ String addDateSetPath = basePath + "locat/" + addDataSetName;
|
|
|
+
|
|
|
+ String indexStr = cn.hutool.core.io.FileUtil.readUtf8String(indexPath);
|
|
|
+ String dataSetStr = cn.hutool.core.io.FileUtil.readUtf8String(addDateSetPath);
|
|
|
+
|
|
|
+ indexStr = indexStr.replaceAll("@replace", sceneCode);
|
|
|
+ dataSetStr = dataSetStr.replaceAll("@replace", sceneCode);
|
|
|
+
|
|
|
+ cn.hutool.core.io.FileUtil.writeUtf8String(indexStr, indexPath);
|
|
|
+ cn.hutool.core.io.FileUtil.writeUtf8String(dataSetStr, addDateSetPath);
|
|
|
+ log.info("html文件替完成");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制静态资源
|
|
|
+ * @param sceneCode
|
|
|
+ */
|
|
|
+ private void copyDefault(String sceneCode) {
|
|
|
+ // /. 是复制该目录下所有文件
|
|
|
+ String source = configConstant.serverBasePath + "/default/.";
|
|
|
+ String target = configConstant.serverBasePath + "/" + sceneCode;
|
|
|
+ String cmd = "cp -r " + source + " " + target;
|
|
|
+ CmdUtils.callLine(cmd);
|
|
|
+ log.info("复制default目录完成");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 需要控制点,才能完成以下操作
|
|
@@ -139,10 +194,26 @@ public class InitServiceImpl implements InitService {
|
|
|
// step7 创建t_datasets表, 需要处理原点之后执行
|
|
|
createDataSet(sceneCode);
|
|
|
|
|
|
+
|
|
|
+ // step8 目录pano、pano_depth、webcloud上传oss,
|
|
|
+ ossUploadDir(sceneCode, path);
|
|
|
+
|
|
|
// 更新 initDataStep2 状态
|
|
|
init.setUpdateTime(LocalDateTime.now());
|
|
|
init.setStatus(1);
|
|
|
initMapper.save(init);
|
|
|
+ log.info("initDataStep_2处理完成");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<InitEntity> findByStatus(Integer status) {
|
|
|
+ return initMapper.findByStatus(status);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public InitEntity findById(String id) {
|
|
|
+ Optional<InitEntity> optional = initMapper.findById(id);
|
|
|
+ return optional.get();
|
|
|
}
|
|
|
|
|
|
private void createFilter(String sceneCode, String path, ControlPointEntity dto){
|
|
@@ -156,6 +227,7 @@ public class InitServiceImpl implements InitService {
|
|
|
List<FilterHotDto> list = JSONArray.toList(jsonArray, FilterHotDto.class);
|
|
|
entity.setData(list);
|
|
|
filterService.save(entity);
|
|
|
+ log.info("filter数据初始化创建完成");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -164,7 +236,7 @@ public class InitServiceImpl implements InitService {
|
|
|
* @param path
|
|
|
*/
|
|
|
private void processCould(String sceneCode, String path, ControlPointEntity dto){
|
|
|
- path = path + "/cloud.js";
|
|
|
+ path = path + "/webcloud/cloud.js";
|
|
|
// 处理原点,将原点坐标转为坐标
|
|
|
double[] doubles = ModifyCloud.convertFromOrigin(dto);
|
|
|
Double[] origin = {doubles[0] ,doubles[1]};
|
|
@@ -175,6 +247,10 @@ public class InitServiceImpl implements InitService {
|
|
|
try {
|
|
|
// 修改cloud.js文件
|
|
|
JSONObject info = ModifyCloud.fixCloud(path);
|
|
|
+
|
|
|
+ cn.hutool.core.io.FileUtil.writeUtf8String(info.toString(), path);
|
|
|
+ log.info("新的cloud.js写入完成:{}", path);
|
|
|
+
|
|
|
// 将boundingbox坐标转换成gis坐标, site_model需要
|
|
|
JSONObject boundingBox = ModifyCloud.getBoundingBox(info);
|
|
|
Double minZ = boundingBox.getDouble("minZ");
|
|
@@ -260,6 +336,7 @@ public class InitServiceImpl implements InitService {
|
|
|
// 默认热点为空
|
|
|
entity.setData(siteModels);
|
|
|
siteModelService.save(entity);
|
|
|
+ log.info("siteModel数据初始化创建完成");
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -307,6 +384,8 @@ public class InitServiceImpl implements InitService {
|
|
|
// 默认热点为空
|
|
|
entity.setData(new ArrayList<>());
|
|
|
poiService.save(entity);
|
|
|
+ log.info("Poi数据初始化创建完成");
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -320,6 +399,7 @@ public class InitServiceImpl implements InitService {
|
|
|
List<PoiTypeDto> dtoList = com.alibaba.fastjson.JSONArray.parseArray(resourceContent, PoiTypeDto.class);
|
|
|
entity.setData(dtoList);
|
|
|
poiTypeService.save(entity);
|
|
|
+ log.info("poiType数据初始化创建完成");
|
|
|
}
|
|
|
|
|
|
private void createPoiTypeGroup(String sceneCode){
|
|
@@ -332,6 +412,7 @@ public class InitServiceImpl implements InitService {
|
|
|
List<PoiTypeGroupDto> dtoList = com.alibaba.fastjson.JSONArray.parseArray(resourceContent, PoiTypeGroupDto.class);
|
|
|
entity.setData(dtoList);
|
|
|
poiTypeGroupService.save(entity);
|
|
|
+ log.info("PoiTypeGroup数据初始化创建完成");
|
|
|
|
|
|
}
|
|
|
|
|
@@ -348,6 +429,7 @@ public class InitServiceImpl implements InitService {
|
|
|
JSONObject dataSet = ModifyDataSets.createDataSet(poi);
|
|
|
entity.setData(dataSet);
|
|
|
dataSetService.save(entity);
|
|
|
+ log.info("DataSet数据初始化创建完成");
|
|
|
}
|
|
|
|
|
|
private void createConfig(String sceneCode){
|
|
@@ -380,6 +462,7 @@ public class InitServiceImpl implements InitService {
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
entity.setData(resData);
|
|
|
configService.save(entity);
|
|
|
+ log.info(" Config数据初始化创建完成");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -390,7 +473,9 @@ public class InitServiceImpl implements InitService {
|
|
|
private void createRoute(String sceneCode, String path){
|
|
|
List<String> list = new ArrayList<>();
|
|
|
try {
|
|
|
- list = FileUtil.readFileByLines2(path + "/routeMap.txt");
|
|
|
+// list = FileUtil.readFileByLines2(path + "/routeMap.txt");
|
|
|
+ list = FileUtil.readFileByLines2(path + "/final_freespace.csv");
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -400,6 +485,7 @@ public class InitServiceImpl implements InitService {
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
entity.setData(list);
|
|
|
routeService.save(entity);
|
|
|
+ log.info(" Route数据初始化创建完成");
|
|
|
|
|
|
}
|
|
|
|
|
@@ -407,4 +493,17 @@ public class InitServiceImpl implements InitService {
|
|
|
return controlPointService.findById(sceneCode);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void ossUploadDir(String sceneCode, String path){
|
|
|
+ String panoPath = path + "/pano";
|
|
|
+ String panoDepthPath = path + "/pano_depth";
|
|
|
+ String webCloudPath = path + "/webcloud";
|
|
|
+ CmdUtils.ossUploadDir(sceneCode, panoPath, "pano");
|
|
|
+ log.info("pano目录上传oss完成");
|
|
|
+ CmdUtils.ossUploadDir(sceneCode, panoDepthPath, "pano_depth");
|
|
|
+ log.info("pano_depth目录上传oss完成");
|
|
|
+ CmdUtils.ossUploadDir(sceneCode, webCloudPath,"webcloud");
|
|
|
+ log.info("webcloud目录上传oss完成");
|
|
|
+ }
|
|
|
+
|
|
|
}
|