|
@@ -1,14 +1,19 @@
|
|
|
package com.fdkankan.indoor.core.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.fdkankan.indoor.base.constant.MsgCode;
|
|
|
import com.fdkankan.indoor.base.convert.DistanceUtil;
|
|
|
+import com.fdkankan.indoor.base.exception.BaseRuntimeException;
|
|
|
import com.fdkankan.indoor.base.util.*;
|
|
|
import com.fdkankan.indoor.core.entity.dto.*;
|
|
|
import com.fdkankan.indoor.core.entity.FilterEntity;
|
|
|
import com.fdkankan.indoor.core.entity.po.DataSetPo;
|
|
|
+import com.fdkankan.indoor.core.entity.vo.FilterDataSetHotVo;
|
|
|
import com.fdkankan.indoor.core.mapper.FilterMapper;
|
|
|
import com.fdkankan.indoor.core.service.FilterService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.Test;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -42,7 +47,7 @@ public class FilterServiceImpl implements FilterService {
|
|
|
|
|
|
private FilterEntity findBySceneCode(String sceneCode){
|
|
|
Optional<FilterEntity> optional = filterMapper.findById(sceneCode);
|
|
|
- return optional.get();
|
|
|
+ return optional.orElse(null);
|
|
|
}
|
|
|
|
|
|
private List<FilterHotDto> getDataBySceneCode(String sceneCode){
|
|
@@ -164,6 +169,7 @@ public class FilterServiceImpl implements FilterService {
|
|
|
List<FilterHotDto> data = entity.getData();
|
|
|
log.info("db数据量: {}", data.size());
|
|
|
|
|
|
+
|
|
|
Integer maxId = 0;
|
|
|
if (data.size() != 0){
|
|
|
// 将热点id提取出来做过滤条件
|
|
@@ -189,6 +195,14 @@ public class FilterServiceImpl implements FilterService {
|
|
|
dto.setId(maxId);
|
|
|
}
|
|
|
|
|
|
+ // 处理file_path: 默认取最后一个data后缀
|
|
|
+ String filePath = dto.getFile_path();
|
|
|
+ if (StrUtil.isNotBlank(filePath)){
|
|
|
+ filePath = StrUtil.subAfter(filePath, "data/", true);
|
|
|
+ filePath = "data/" + filePath;
|
|
|
+ dto.setFile_path(filePath);
|
|
|
+ }
|
|
|
+
|
|
|
data.add(dto);
|
|
|
}
|
|
|
|
|
@@ -207,6 +221,77 @@ public class FilterServiceImpl implements FilterService {
|
|
|
filterMapper.deleteById(sceneCode);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result editDatasetOrientation(String sceneCode, Double[] orientation) {
|
|
|
+ FilterEntity entity = findBySceneCode(sceneCode);
|
|
|
+ List<FilterHotDto> data = entity.getData();
|
|
|
+
|
|
|
+ List<FilterHotDto> result = new ArrayList<>();
|
|
|
+ for (FilterHotDto dto : data) {
|
|
|
+ dto.setDataset_orientation(orientation);
|
|
|
+ dto.setDataset_floor_orientation(orientation);
|
|
|
+ result.add(dto);
|
|
|
+ }
|
|
|
+ entity.setData(result);
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
+ save(entity);
|
|
|
+
|
|
|
+ return Result.success(getDataBySceneCode(sceneCode));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result findByDataSetId(String code, Integer dataset_id) {
|
|
|
+ if (dataset_id == null) {
|
|
|
+ throw new BaseRuntimeException(MsgCode.e3001, "dataset_id不能为空");
|
|
|
+ }
|
|
|
+ List<FilterHotDto> data = getDataBySceneCode(code);
|
|
|
+ data = data.stream().filter(p -> dataset_id.equals(p.getDataset_id())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<FilterDataSetHotVo> result = new ArrayList<>();
|
|
|
+ for (FilterHotDto hot : data) {
|
|
|
+ FilterDataSetHotVo vo = new FilterDataSetHotVo();
|
|
|
+ BeanUtils.copyProperties(hot, vo);
|
|
|
+ vo.setLast_modified(System.currentTimeMillis());
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result updateDataSet(String sceneCode, List<FilterDataSetPutDto> param) {
|
|
|
+
|
|
|
+ FilterEntity entity = findBySceneCode(sceneCode);
|
|
|
+ if (entity == null){
|
|
|
+ throw new BaseRuntimeException(MsgCode.e3001, "此场景不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FilterHotDto> data = entity.getData();
|
|
|
+ log.info("元数据数量:{}", data.size());
|
|
|
+ log.info("参数数量:{}", param.size());
|
|
|
+
|
|
|
+ if (data.size() > 0) {
|
|
|
+ // 复制参数到原数组
|
|
|
+ data.forEach(p -> {
|
|
|
+ Integer id = p.getId();
|
|
|
+ param.forEach(d -> {
|
|
|
+ Integer dId = d.getId();
|
|
|
+ if (dId.equals(id)){
|
|
|
+ // 参数复制
|
|
|
+ BeanUtils.copyProperties(d, p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setData(data);
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
+ this.save(entity);
|
|
|
+
|
|
|
+ return Result.success(this.getDataBySceneCode(sceneCode));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 处理step step的值会有影响
|
|
@@ -258,17 +343,13 @@ public class FilterServiceImpl implements FilterService {
|
|
|
// 计算距离后的结果集
|
|
|
Map<Double, FilterHotDto> calResultMap = new HashMap<>();
|
|
|
for (FilterHotDto jsonData : jsonDataList) {
|
|
|
-// Double[] coordinates1 = new Double[3];
|
|
|
-// coordinates1[0] = queryJsonData.getLon();
|
|
|
-// coordinates1[1] = queryJsonData.getLat();
|
|
|
-// coordinates1[2] = queryJsonData.getZ();
|
|
|
+
|
|
|
|
|
|
Double[] coordinates2 = new Double[3];
|
|
|
coordinates2[0] = jsonData.getLocation()[0];
|
|
|
coordinates2[1] = jsonData.getLocation()[1];
|
|
|
coordinates2[2] = jsonData.getLocation()[2];
|
|
|
|
|
|
-// Double distance = DistanceUtil.distance(coordinates1, coordinates2, new Options().setUnits("miles"));
|
|
|
Double distance = DistanceUtil.distance3(coordinates1, coordinates2);
|
|
|
// log.info("计算出的距离:{}", distance);
|
|
|
|
|
@@ -322,17 +403,13 @@ public class FilterServiceImpl implements FilterService {
|
|
|
int i = 1;
|
|
|
Double min = null;
|
|
|
for (FilterHotDto jsonData : jsonDataList) {
|
|
|
-// Double[] coordinates1 = new Double[2];
|
|
|
-// coordinates1[0] = queryJsonData.getLon();
|
|
|
-// coordinates1[1] = queryJsonData.getLat();
|
|
|
-// coordinates1[2] = queryJsonData.getZ();
|
|
|
+
|
|
|
|
|
|
Double[] coordinates2 = new Double[3];
|
|
|
coordinates2[0] = jsonData.getLocation()[0];
|
|
|
coordinates2[1] = jsonData.getLocation()[1];
|
|
|
coordinates2[2] = jsonData.getLocation()[2];
|
|
|
|
|
|
-// Double distance = DistanceUtil.distance(coordinates1, coordinates2, new Options().setUnits("miles"));
|
|
|
Double distance = DistanceUtil.distance3(coordinates1, coordinates2);
|
|
|
// log.info("计算出的距离:{}", distance);
|
|
|
// 默认取第一值
|
|
@@ -359,9 +436,8 @@ public class FilterServiceImpl implements FilterService {
|
|
|
|
|
|
@Test
|
|
|
public void test(){
|
|
|
- double a= 8.346455383936777E-4;
|
|
|
- double b= 0.001518440040006915;
|
|
|
- System.out.println( a < b);
|
|
|
+ String path = "data/aa/ldata/bbb/data/cc";
|
|
|
+ System.out.println(StrUtil.subAfter(path, "/data/", true));
|
|
|
}
|
|
|
|
|
|
|