|
@@ -4,16 +4,19 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.indoor.base.convert.DistanceUtil;
|
|
|
+import com.fdkankan.indoor.base.exception.BaseRuntimeException;
|
|
|
import com.fdkankan.indoor.base.util.GisUtils;
|
|
|
import com.fdkankan.indoor.base.util.Result;
|
|
|
+import com.fdkankan.indoor.core.entity.DataSetEntity;
|
|
|
+import com.fdkankan.indoor.core.entity.FilterEntity;
|
|
|
import com.fdkankan.indoor.core.entity.SiteModelEntity;
|
|
|
+import com.fdkankan.indoor.core.entity.dto.FilterHotDto;
|
|
|
import com.fdkankan.indoor.core.entity.dto.SiteDto;
|
|
|
import com.fdkankan.indoor.core.entity.dto.SiteModelSearchDto;
|
|
|
import com.fdkankan.indoor.core.entity.dto.SitePolygon;
|
|
|
+import com.fdkankan.indoor.core.entity.po.DataSetPo;
|
|
|
import com.fdkankan.indoor.core.mapper.SiteModelMapper;
|
|
|
-import com.fdkankan.indoor.core.service.ControlPointService;
|
|
|
-import com.fdkankan.indoor.core.service.InitService;
|
|
|
-import com.fdkankan.indoor.core.service.SiteModelService;
|
|
|
+import com.fdkankan.indoor.core.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -45,6 +48,14 @@ public class SiteModelServiceImpl implements SiteModelService {
|
|
|
@Autowired
|
|
|
InitService initService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DataSetService dataSetService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ FilterService filterService;
|
|
|
+
|
|
|
+
|
|
|
+ // updateSiteMode 只是这个方法用的
|
|
|
private Integer maxId;
|
|
|
|
|
|
@Override
|
|
@@ -272,13 +283,144 @@ public class SiteModelServiceImpl implements SiteModelService {
|
|
|
@Override
|
|
|
public Result initSiteModel(String sceneCode) {
|
|
|
|
|
|
- initService.initSiteModel(sceneCode);
|
|
|
- log.info("初始化siteModel完成: " + sceneCode);
|
|
|
+// initService.initSiteModel(sceneCode);
|
|
|
+// log.info("初始化siteModel完成: " + sceneCode);
|
|
|
+
|
|
|
+ SiteModelEntity entity = findById(sceneCode);
|
|
|
+ if (entity == null) {
|
|
|
+ String msg = "siteModel表数据不存在,请检查表数据, 场景码:" + sceneCode;
|
|
|
+ log.error(msg);
|
|
|
+ throw new BaseRuntimeException(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 去掉房间数据
|
|
|
+ List<SiteDto> data = entity.getData();
|
|
|
+ recursionRemoveRoom(data);
|
|
|
+
|
|
|
+ entity.setData(data);
|
|
|
+ this.save(entity);
|
|
|
+
|
|
|
+ // 更新dataSet.site_model_ids
|
|
|
+ executeDateSetBySetModelIds(sceneCode, data);
|
|
|
|
|
|
return Result.success(getDataBySceneCode(sceneCode));
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 2021-9-16
|
|
|
+ * 处理dataSet.site_model_ids, 是否在site_model.z_min,z_max范围内,且去掉房间ids
|
|
|
+ */
|
|
|
+ private void executeDateSetBySetModelIds(String sceneCode, List<SiteDto> data){
|
|
|
+ DataSetEntity dataSetEntity = dataSetService.findById(sceneCode);
|
|
|
+ if (dataSetEntity == null) {
|
|
|
+ String msg = "DataSet表数据不存在,请检查表数据, 场景码:" + sceneCode;
|
|
|
+ log.error(msg);
|
|
|
+ throw new BaseRuntimeException(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DataSetPo> dataSetPoList = dataSetEntity.getData();
|
|
|
+
|
|
|
+ List<DataSetPo> resDataSet = new ArrayList<>();
|
|
|
+ // dataSet
|
|
|
+ for (DataSetPo dataSetPo : dataSetPoList) {
|
|
|
+ Double[] location = dataSetPo.getLocation();
|
|
|
+ // 高度值
|
|
|
+ Double z = location[2];
|
|
|
+
|
|
|
+ List<Integer> siteModelIds = new ArrayList<>();
|
|
|
+ // siteModel
|
|
|
+ for (SiteDto dto : data) {
|
|
|
+ siteModelIds.add(dto.getId());
|
|
|
+ List<SiteDto> children = dto.getChildren();
|
|
|
+ if (children.size() > 0) {
|
|
|
+ // floor层
|
|
|
+ for (SiteDto childFloor : children) {
|
|
|
+ Double z_max = childFloor.getZ_max();
|
|
|
+ Double z_min = childFloor.getZ_min();
|
|
|
+ // 高度在该楼层范围之内
|
|
|
+ if (z_max > z && z > z_min) {
|
|
|
+ siteModelIds.add(childFloor.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataSetPo.setSite_model_entity_ids(siteModelIds.toArray(new Integer[0]));
|
|
|
+ resDataSet.add(dataSetPo);
|
|
|
+ }
|
|
|
+
|
|
|
+ dataSetEntity.setData(resDataSet);
|
|
|
+ dataSetService.save(dataSetEntity);
|
|
|
+
|
|
|
+ // 处理Filter.site_model_id
|
|
|
+ executeFilterBySetModelId(sceneCode, resDataSet);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2021-09-16
|
|
|
+ * @param sceneCode
|
|
|
+ * @param dataSets
|
|
|
+ */
|
|
|
+ private void executeFilterBySetModelId(String sceneCode, List<DataSetPo> dataSets){
|
|
|
+ FilterEntity filterEntity = filterService.findBySceneCode(sceneCode);
|
|
|
+ if (filterEntity == null) {
|
|
|
+ String msg = "filter表数据不存在,请检查表数据, 场景码:" + sceneCode;
|
|
|
+ log.error(msg);
|
|
|
+ throw new BaseRuntimeException(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FilterHotDto> filterDatas = filterEntity.getData();
|
|
|
+ boolean flag = false;
|
|
|
+ List<FilterHotDto> resFilter = new ArrayList<>();
|
|
|
+ for (FilterHotDto dto : filterDatas) {
|
|
|
+ Integer datasetId = dto.getDataset_id();
|
|
|
+ Integer filterSiteModelEntityId = dto.getSite_model_entity_id();
|
|
|
+ for (DataSetPo dataSet : dataSets) {
|
|
|
+ if (datasetId == dataSet.getId()) {
|
|
|
+ Integer[] ids = dataSet.getSite_model_entity_ids();
|
|
|
+ List<Integer> idsList = Arrays.asList(ids);
|
|
|
+ // 判断原filter.siteModelId是否包含在新的数组里, 包含则没变化,否则需要更新
|
|
|
+ if (!idsList.contains(filterSiteModelEntityId)) {
|
|
|
+ // 默认拿父级id
|
|
|
+ dto.setSite_model_entity_id(ids[0]);
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resFilter.add(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (flag) {
|
|
|
+ filterEntity.setData(resFilter);
|
|
|
+ filterService.save(filterEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2021-9-16
|
|
|
+ * 递归方法遍历, 删除房间
|
|
|
+ */
|
|
|
+ private void recursionRemoveRoom(List<SiteDto> param){
|
|
|
+ for (SiteDto dto : param) {
|
|
|
+ // 递归调用
|
|
|
+ List<SiteDto> children = dto.getChildren();
|
|
|
+ if ("FLOOR".equals(dto.getType())){
|
|
|
+ children = new ArrayList<>();
|
|
|
+ dto.setChildren(children);
|
|
|
+ }
|
|
|
+ if (children.size() > 0) {
|
|
|
+ recursionRemoveRoom(children);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 判断的坐标在那个空间位置
|
|
|
private boolean getSm(SiteDto model, Point2D.Double pointParam) {
|
|
|
if (CollectionUtils.isEmpty(model.getPolygon().getCoordinates())
|
|
@@ -411,7 +553,6 @@ public class SiteModelServiceImpl implements SiteModelService {
|
|
|
@Override
|
|
|
public SiteModelEntity findById(String sceneCode){
|
|
|
Optional<SiteModelEntity> optional = entityMapper.findById(sceneCode);
|
|
|
-
|
|
|
return optional.orElse(null);
|
|
|
}
|
|
|
|
|
@@ -499,6 +640,8 @@ public class SiteModelServiceImpl implements SiteModelService {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 2021-07-16
|
|
|
* 递归出每一个对象
|
|
@@ -532,7 +675,6 @@ public class SiteModelServiceImpl implements SiteModelService {
|
|
|
organizeModels2(child, models);
|
|
|
}
|
|
|
}
|
|
|
-// log.info("models.size: {}", models.size());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -545,7 +687,6 @@ public class SiteModelServiceImpl implements SiteModelService {
|
|
|
organizeModels3(child, models);
|
|
|
}
|
|
|
}
|
|
|
-// log.info("models.size: {}", models.size());
|
|
|
}
|
|
|
|
|
|
// 把当前节点的children 设为空数组
|