|
@@ -3,30 +3,23 @@ package com.fdkankan.indoor.core.service.impl;
|
|
|
import com.fdkankan.indoor.base.constant.MsgCode;
|
|
|
import com.fdkankan.indoor.base.constant.TypeConstant;
|
|
|
import com.fdkankan.indoor.base.convert.FixRouteMap;
|
|
|
+import com.fdkankan.indoor.base.convert.MergeRouteMap;
|
|
|
import com.fdkankan.indoor.base.exception.BaseRuntimeException;
|
|
|
import com.fdkankan.indoor.base.util.Result;
|
|
|
-import com.fdkankan.indoor.core.entity.ControlPointEntity;
|
|
|
-import com.fdkankan.indoor.core.entity.DataSetEntity;
|
|
|
-import com.fdkankan.indoor.core.entity.InitEntity;
|
|
|
-import com.fdkankan.indoor.core.entity.RouteEntity;
|
|
|
+import com.fdkankan.indoor.core.entity.*;
|
|
|
import com.fdkankan.indoor.core.entity.dto.FilterHotDto;
|
|
|
import com.fdkankan.indoor.core.entity.dto.PoiHotDto;
|
|
|
import com.fdkankan.indoor.core.entity.dto.SecurityDto;
|
|
|
import com.fdkankan.indoor.core.entity.po.DataSetPo;
|
|
|
import com.fdkankan.indoor.core.mapper.DataSetMapper;
|
|
|
-import com.fdkankan.indoor.core.service.ControlPointService;
|
|
|
-import com.fdkankan.indoor.core.service.DataSetService;
|
|
|
-import com.fdkankan.indoor.core.service.InitService;
|
|
|
-import com.fdkankan.indoor.core.service.RouteService;
|
|
|
+import com.fdkankan.indoor.core.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -49,6 +42,8 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
|
|
|
@Autowired
|
|
|
RouteService routeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ MergeInfoService mergeInfoService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -119,17 +114,19 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
|
|
|
dataSetMapper.save(entity);
|
|
|
log.info("更新dataSet数据完成");
|
|
|
|
|
|
- // 更新RouteMap并存入数据库
|
|
|
- try {
|
|
|
- fixRouteMap(location, orientation, sceneCode);
|
|
|
-// return Result.success(auth(sceneCode).getData());
|
|
|
- // 返回修改的数组
|
|
|
- return Result.success(getDataBySceneCodeAndDataSetId(sceneCode, newIds));
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ return Result.success(getDataBySceneCodeAndDataSetId(sceneCode, newIds));
|
|
|
|
|
|
- return null;
|
|
|
+ // 2021-08-31 不需处理更新RouteMap并存入数据库
|
|
|
+// try {
|
|
|
+// fixRouteMap(location, orientation, sceneCode);
|
|
|
+//// return Result.success(auth(sceneCode).getData());
|
|
|
+// // 返回修改的数组
|
|
|
+// return Result.success(getDataBySceneCodeAndDataSetId(sceneCode, newIds));
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// return null;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -140,39 +137,136 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
|
|
|
* @param sceneCode
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- private void fixRouteMap(Double[] location, Double orientation, String sceneCode) throws Exception {
|
|
|
- String initKey = TypeConstant.REDIS_INIT_PATH + sceneCode;
|
|
|
- log.info("initKey: {}", initKey);
|
|
|
-// String initPath = redisTemplate.opsForValue().get(initKey);
|
|
|
-// if (initPath == null) {
|
|
|
-// InitEntity initEntity = initService.findById(sceneCode);
|
|
|
-// if (initEntity == null) {
|
|
|
-// throw new BaseRuntimeException("init初始化数据不存: {}" +sceneCode);
|
|
|
-// }
|
|
|
-// initPath = initEntity.getPath();
|
|
|
-// redisTemplate.opsForValue().set(initKey, initPath, 24, TimeUnit.HOURS);
|
|
|
+// private void fixRouteMap(Double[] location, Double orientation, String sceneCode) throws Exception {
|
|
|
+// String initKey = TypeConstant.REDIS_INIT_PATH + sceneCode;
|
|
|
+// log.info("initKey: {}", initKey);
|
|
|
+// String initPath = redisPath(sceneCode);
|
|
|
+//
|
|
|
+// initPath = initPath + "/laserData";
|
|
|
+// log.info("initPath: {}", initPath);
|
|
|
+//
|
|
|
+// ControlPointEntity controlPointEntity = controlPointService.findById(sceneCode);
|
|
|
+// if (controlPointEntity == null) {
|
|
|
+// throw new BaseRuntimeException("控制点数据不存: {}" +sceneCode);
|
|
|
// }
|
|
|
- String initPath = redisPath(sceneCode);
|
|
|
+// log.info("有控制点");
|
|
|
+// double[] gpsLocation = {location[0], location[1], location[2]};
|
|
|
+// List<String> routeMap = FixRouteMap.updateRouteMap(orientation, gpsLocation, controlPointEntity, initPath);
|
|
|
+//
|
|
|
+// RouteEntity routeEntity = routeService.findBySceneCode(sceneCode);
|
|
|
+// routeEntity.setData(routeMap);
|
|
|
+// routeEntity.setUpdateTime(LocalDateTime.now());
|
|
|
+// routeService.save(routeEntity);
|
|
|
+// log.info("更新Route数据完成");
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 本地测试:需要把t_merge_info的合并路径改为本地路径(windows)
|
|
|
+ * F:\\test\\ngin\\age_laser_data\\w-50\\results\\laserData
|
|
|
+ * @param sceneCode
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result reposes(String sceneCode) {
|
|
|
|
|
|
- initPath = initPath + "/laserData";
|
|
|
- log.info("initPath: {}", initPath);
|
|
|
+ List<DataSetPo> data = getDataBySceneCode(sceneCode);
|
|
|
+ // 1个数据集, 不需要处理, 两个或以上需要处理
|
|
|
+ if (data.size() <= 1) {
|
|
|
+ log.info("数据集数量为1,不需要合并");
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
|
|
|
- ControlPointEntity controlPointEntity = controlPointService.findById(sceneCode);
|
|
|
- if (controlPointEntity == null) {
|
|
|
- throw new BaseRuntimeException("控制点数据不存: {}" +sceneCode);
|
|
|
+
|
|
|
+ // 获取控制点
|
|
|
+ ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
|
|
|
+ // 原场景码地址
|
|
|
+ String sceneCodePath = redisPath(sceneCode) + "/laserData";
|
|
|
+ if ("dev".equals(configConstant.active)) {
|
|
|
+ sceneCodePath = "F:\\test\\ngin\\age_laser_data\\" + sceneCode + "\\results\\laserData";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<List<JSONObject>> routeList= new ArrayList<>();
|
|
|
+ for (DataSetPo po : data) {
|
|
|
+ Double orientation = po.getOrientation();
|
|
|
+ if (orientation == null) {
|
|
|
+ throw new BaseRuntimeException("dataSet.orientation不能为空");
|
|
|
+ }
|
|
|
+ Double[] location = po.getLocation();
|
|
|
+ Integer dataSetId = po.getId();
|
|
|
+ double[] gpsLocation = {location[0], location[1], location[2]};
|
|
|
+ List<JSONObject> route ;
|
|
|
+ // 原数据集
|
|
|
+ if (dataSetId == 1) {
|
|
|
+ route = FixRouteMap.getRotate(orientation, gpsLocation, controlPoint, sceneCodePath);
|
|
|
+ } else {
|
|
|
+ // 合并数据集
|
|
|
+ MergeInfoEntity mergeInfoEntity = mergeInfoService.findBySceneCodeAndDataSetId(sceneCode, dataSetId);
|
|
|
+ if (mergeInfoEntity == null) {
|
|
|
+ throw new BaseRuntimeException("合并信息数据不存在");
|
|
|
+ }
|
|
|
+ route = FixRouteMap.getRotate(orientation, gpsLocation, controlPoint, mergeInfoEntity.getPath());
|
|
|
+ }
|
|
|
+ routeList.add(route);
|
|
|
}
|
|
|
- log.info("有控制点");
|
|
|
- double[] gpsLocation = {location[0], location[1], location[2]};
|
|
|
- List<String> routeMap = FixRouteMap.updateRouteMap(orientation, gpsLocation, controlPointEntity, initPath);
|
|
|
+
|
|
|
+ // 合并
|
|
|
+ recursion(routeList);
|
|
|
+ log.info("route递归合并完成");
|
|
|
+
|
|
|
+ // 合并结果
|
|
|
+ List<JSONObject> mergeRoute = routeList.get(0);
|
|
|
+ // 信息写入数据库
|
|
|
+ List<String> resultStr = convertToString(mergeRoute);
|
|
|
|
|
|
RouteEntity routeEntity = routeService.findBySceneCode(sceneCode);
|
|
|
- routeEntity.setData(routeMap);
|
|
|
+ routeEntity.setData(resultStr);
|
|
|
routeEntity.setUpdateTime(LocalDateTime.now());
|
|
|
routeService.save(routeEntity);
|
|
|
log.info("更新Route数据完成");
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
}
|
|
|
|
|
|
+ private static List<String> convertToString(List<JSONObject> param){
|
|
|
+ List<String> mergeResult = new ArrayList<>();
|
|
|
+ for (JSONObject jon : param) {
|
|
|
+ StringBuilder strBuilder = new StringBuilder();
|
|
|
+ strBuilder.append(jon.getString("x")).append(" ");
|
|
|
+ strBuilder.append(jon.getString("y")).append(" ");
|
|
|
+ strBuilder.append(jon.getString("z")).append(" ");
|
|
|
+ strBuilder.append(jon.getString("k")).append(" ");
|
|
|
+ strBuilder.append(jon.getString("linkedIds"));
|
|
|
+
|
|
|
+ mergeResult.add(strBuilder.toString());
|
|
|
+ }
|
|
|
+ log.info("json数据转换String完成");
|
|
|
+ return mergeResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归合并
|
|
|
+ */
|
|
|
+ private void recursion(List<List<JSONObject>> param){
|
|
|
+ log.info("需要合并的数据量:{}", param.size());
|
|
|
+ if (param.size() >= 2) {
|
|
|
+ List<JSONObject> mergeRoute = MergeRouteMap.mergeRoute(param.get(0), param.get(1));
|
|
|
+ param.set(0, mergeRoute);
|
|
|
+ param.remove(1);
|
|
|
+
|
|
|
+ // 递归调用
|
|
|
+ recursion(param);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void remove(String sceneCode) {
|
|
|
dataSetMapper.deleteById(sceneCode);
|
|
@@ -235,6 +329,7 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
private List<DataSetPo> changeSecurityUnLoginList(List<DataSetPo> param){
|
|
|
List<DataSetPo> result = new ArrayList<>();
|
|
|
for (DataSetPo dto : param) {
|