|
@@ -1,410 +0,0 @@
|
|
|
-//package com.fdkankan.indoor.core.service.impl;
|
|
|
-//
|
|
|
-//import com.alibaba.fastjson.JSON;
|
|
|
-//import com.alibaba.fastjson.JSONObject;
|
|
|
-//import com.fdkankan.indoor.base.util.GisUtils;
|
|
|
-//import com.fdkankan.indoor.base.util.JsonUtil;
|
|
|
-//import com.fdkankan.indoor.base.util.Result;
|
|
|
-//import com.fdkankan.indoor.core.entity.dto.SiteModelSearchDto;
|
|
|
-//import com.fdkankan.indoor.core.entity.SiteModelEntity;
|
|
|
-//import com.fdkankan.indoor.core.entity.siteModel.Polygon;
|
|
|
-//import com.fdkankan.indoor.core.entity.siteModel.SiteModel;
|
|
|
-//import com.fdkankan.indoor.core.mapper.SiteModelMapper;
|
|
|
-//import com.fdkankan.indoor.core.service.SiteModelService;
|
|
|
-//import com.fdkankan.indoor.core.entity.vo.BaseVo;
|
|
|
-//import lombok.AllArgsConstructor;
|
|
|
-//import lombok.extern.slf4j.Slf4j;
|
|
|
-//import org.springframework.beans.BeanUtils;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
-//import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
-//import org.springframework.data.mongodb.core.query.Query;
|
|
|
-//import org.springframework.stereotype.Service;
|
|
|
-//import org.springframework.util.CollectionUtils;
|
|
|
-//
|
|
|
-//import java.awt.geom.Point2D;
|
|
|
-//import java.util.ArrayList;
|
|
|
-//import java.util.HashSet;
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.Set;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * @author Admin
|
|
|
-// */
|
|
|
-//@Service
|
|
|
-//@Slf4j
|
|
|
-//@AllArgsConstructor
|
|
|
-//public class SiteModelServiceImpl implements SiteModelService {
|
|
|
-//
|
|
|
-// private final MongoTemplate mongoTemplate;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// SiteModelMapper entityMapper;
|
|
|
-//
|
|
|
-// private SiteModelEntity findBySceneCode_5(String sceneCode){
|
|
|
-// Query query = new Query();
|
|
|
-// query.addCriteria(Criteria.where("sceneCode").is(sceneCode));
|
|
|
-// SiteModelEntity vo = mongoTemplate.findOne(query, SiteModelEntity.class, "t_site_model");
|
|
|
-// return vo;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Result withinType_5(String code, Double[] location, String type) {
|
|
|
-//
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void save(SiteModelEntity entity) {
|
|
|
-// entityMapper.insert(entity);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**************************************************************************************************/
|
|
|
-//
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Result withinType(String code, Double[] location, String type) {
|
|
|
-// log.info("code: {}", code);
|
|
|
-// log.info("location: {}", location);
|
|
|
-// log.info("code: {}", type);
|
|
|
-//
|
|
|
-// // 总对象
|
|
|
-// List<SiteModel> models = new ArrayList<>();
|
|
|
-//
|
|
|
-// SiteModel siteModel = findBySceneCode(code);
|
|
|
-// // copy实体对象
|
|
|
-// SiteModel newSiteModel = copyModelNotContainChildren(siteModel);
|
|
|
-// // 做为父节点的低一条
|
|
|
-// models.add(newSiteModel);
|
|
|
-// if (!CollectionUtils.isEmpty(siteModel.getChildren())) {
|
|
|
-// organizeModels2(siteModel, models);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// // 按type封装成对象数组
|
|
|
-// List<SiteModel> resultList = new ArrayList<>();
|
|
|
-// SiteModel result = null;
|
|
|
-//
|
|
|
-// Point2D.Double pointParam = new Point2D.Double(location[0], location[1]);
|
|
|
-// log.info("pointParam: {}", pointParam);
|
|
|
-// if ("BUILDING".equals(type)) {
|
|
|
-// resultList = models.stream().filter(data -> "BUILDING".equals(data.getType())).collect(Collectors.toList());
|
|
|
-// result = resultList.stream().filter(sm -> getSm(sm, pointParam)).findAny()
|
|
|
-// .orElseThrow(() -> new RuntimeException("没有找到符合多边形的点"));
|
|
|
-// } else if ("FLOOR".equals(type)) {
|
|
|
-// resultList = models.stream().filter(data -> "FLOOR".equals(data.getType())).collect(Collectors.toList());
|
|
|
-// log.info("resultList.size: {}", resultList.size());
|
|
|
-//
|
|
|
-// result = resultList.stream().filter(sm -> getSmByFloor(sm, pointParam)).findAny().orElseThrow(() -> new RuntimeException("没有找到符合多边形的点"));
|
|
|
-// } else if ("ROOM".equals(type)) {
|
|
|
-// resultList = models.stream().filter(data -> "ROOM".equals(data.getType())).collect(Collectors.toList());
|
|
|
-// result = resultList.stream().filter(sm -> getSm(sm, pointParam)).findAny()
|
|
|
-// .orElseThrow(() -> new RuntimeException("没有找到符合多边形的点"));
|
|
|
-// // type为空,返回全部数据
|
|
|
-// } else {
|
|
|
-// resultList = models.stream().filter(data -> "ROOM".equals(data.getType())).collect(Collectors.toList());
|
|
|
-// result = resultList.stream().filter(sm -> getSm(sm, pointParam)).findAny()
|
|
|
-// .orElseThrow(() -> new RuntimeException("没有找到符合多边形的点"));
|
|
|
-//
|
|
|
-// List<SiteModel> roomChildren = new ArrayList<>();
|
|
|
-// roomChildren.add(result);
|
|
|
-// siteModel.setChildren(roomChildren);
|
|
|
-// result = siteModel;
|
|
|
-// }
|
|
|
-//
|
|
|
-// log.info("result: {}", result);
|
|
|
-// ArrayList<Object> list = new ArrayList<>();
|
|
|
-// list.add(result);
|
|
|
-// return Result.success(list);
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 2021-07-20
|
|
|
-// * 根据场景码查询对象
|
|
|
-// *
|
|
|
-// * 2021-07-28 目前表存的数据结构是对象, 正确应该是数组
|
|
|
-// * 返回结果对象也是一个数组
|
|
|
-// * @param sceneCode
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// private SiteModel findBySceneCode(String sceneCode){
|
|
|
-// Query query = new Query();
|
|
|
-// query.addCriteria(Criteria.where("sceneCode").is(sceneCode));
|
|
|
-// BaseVo vo = mongoTemplate.findOne(query, BaseVo.class, "t_site_model");
|
|
|
-// log.info("vo: {}", vo);
|
|
|
-// Object data = vo.getData();
|
|
|
-// String s = JSON.toJSONString(data);
|
|
|
-// SiteModel siteModel = JSONObject.parseObject(s, SiteModel.class);
|
|
|
-// return siteModel;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public SiteModel findById(Long id, String code) {
|
|
|
-//
|
|
|
-// SiteModel siteModel = findBySceneCode(code);
|
|
|
-// return siteModel;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Result getData(JSONObject param, String code) {
|
|
|
-// String type = param.getString("type");
|
|
|
-// if (!"BUILDING".equals(type)) {
|
|
|
-// throw new RuntimeException("非BUILDING类型");
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// SiteModel siteModel = findBySceneCode(code);
|
|
|
-//
|
|
|
-// if (siteModel != null) {
|
|
|
-// siteModel.setChildren(new ArrayList<>());
|
|
|
-// return Result.success(siteModel);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Result search(String sceneCode, SiteModelSearchDto searchDto) {
|
|
|
-// SiteModel siteModel = findBySceneCode(sceneCode);
|
|
|
-//
|
|
|
-// List<SiteModel> loopModel = getLoopModel(siteModel);
|
|
|
-// String searchKey = searchDto.getQuery();
|
|
|
-// Integer size = searchDto.getSize();
|
|
|
-// size = size==null?10: size;
|
|
|
-// List<SiteModel> collect = loopModel.stream().filter(p -> getContent(p, searchKey)).limit(size).collect(Collectors.toList());
|
|
|
-// log.info("返回collect数量: {}", collect.size());
|
|
|
-//
|
|
|
-// // 映射实体名称
|
|
|
-// List<Object> result = ormSiteModel(collect);
|
|
|
-//
|
|
|
-// return Result.success(result);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Result latest(String sceneCode, Double[] location, Double radius) {
|
|
|
-// SiteModel siteModel = findBySceneCode(sceneCode);
|
|
|
-//
|
|
|
-// // 递归为对象
|
|
|
-// List<SiteModel> loopModel = getLoopModel(siteModel);
|
|
|
-//
|
|
|
-// // 获取点在多边形的集合
|
|
|
-// List<SiteModel> result = loopModel.stream().filter(p -> pointIsArea(location, p)).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// log.info("没有父级的数量:{}", result.size());
|
|
|
-// // 将父级有parenId的对象添加到result
|
|
|
-// addSiteMode(loopModel, result);
|
|
|
-// log.info("添加父级后的数量:{}", result.size());
|
|
|
-//
|
|
|
-//
|
|
|
-// return Result.success(loopModel);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Result testData(String sceneCode) {
|
|
|
-// SiteModel SiteModel = findBySceneCode(sceneCode);
|
|
|
-// return Result.success(SiteModel);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 将父节点添加到结果集
|
|
|
-// * @param loopModel
|
|
|
-// * @param result
|
|
|
-// */
|
|
|
-// private void addSiteMode(List<SiteModel> loopModel, List<SiteModel> result) {
|
|
|
-// Set<SiteModel> parentSiteModel = getParentSiteModel(loopModel, result);
|
|
|
-// for (SiteModel siteModel : parentSiteModel) {
|
|
|
-// result.add(siteModel);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 获取父节点
|
|
|
-// * @param loopModel
|
|
|
-// * @param result
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// private Set<SiteModel> getParentSiteModel(List<SiteModel> loopModel, List<SiteModel> result){
|
|
|
-// Set<SiteModel> parent = new HashSet<>();
|
|
|
-// for (SiteModel siteModel : loopModel) {
|
|
|
-// for (SiteModel model : result) {
|
|
|
-// if (model.getParentId() == siteModel.getId()) {
|
|
|
-// parent.add(siteModel);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return parent;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 输入点是否在多边形内
|
|
|
-// * @param point
|
|
|
-// * @param param
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// private boolean pointIsArea(Double[] point, SiteModel param){
|
|
|
-// // 获取多边行点
|
|
|
-// Polygon polygon = param.getPolygon();
|
|
|
-// if (polygon == null) {
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// List<List<List<Double>>> coordinates = polygon.getCoordinates();
|
|
|
-// if (CollectionUtils.isEmpty(coordinates)){
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// List<List<Double>> lists = coordinates.get(0);
|
|
|
-// if (CollectionUtils.isEmpty(lists)){
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-//
|
|
|
-// Point2D.Double pointDouble = new Point2D.Double();
|
|
|
-// pointDouble.setLocation(point[0], point[1]);
|
|
|
-//
|
|
|
-//
|
|
|
-// List<Point2D.Double> allPoints = lists.stream()
|
|
|
-// .map(points -> new Point2D.Double(points.get(0), points.get(1))).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// Boolean inArea = GisUtils.rayCasting(allPoints, pointDouble);
|
|
|
-// log.info("是否在多边型内: {}", inArea);
|
|
|
-//
|
|
|
-// return inArea;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// // 前端需要, 映射实体
|
|
|
-// private List<Object> ormSiteModel(List<SiteModel> collect){
|
|
|
-// List<Object> list = new ArrayList<>();
|
|
|
-// for (SiteModel siteModel : collect) {
|
|
|
-// JSONObject jsonObject = new JSONObject();
|
|
|
-// jsonObject.put("id", siteModel.getId());
|
|
|
-// jsonObject.put("title", siteModel.getName());
|
|
|
-// jsonObject.put("matching_title", siteModel.getName());
|
|
|
-// jsonObject.put("matching_description", null);
|
|
|
-// list.add(jsonObject);
|
|
|
-// }
|
|
|
-// return list;
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 模糊匹配
|
|
|
-// private Boolean getContent(SiteModel p, String searchKey){
|
|
|
-// String name = p.getName();
|
|
|
-// log.info("name: {}, 配备结果:{}", name, name.contains(searchKey));
|
|
|
-// return name.contains(searchKey);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// // 判断的坐标在那个空间位置
|
|
|
-// private boolean getSm(SiteModel model, Point2D.Double pointParam) {
|
|
|
-// if (CollectionUtils.isEmpty(model.getPolygon().getCoordinates())
|
|
|
-// || CollectionUtils.isEmpty(model.getPolygon().getCoordinates().get(0))
|
|
|
-// || CollectionUtils.isEmpty(model.getPolygon().getCoordinates().get(0).get(0))) {
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<Point2D.Double> allPoints = model.getPolygon().getCoordinates().get(0).stream()
|
|
|
-// .map(points -> new Point2D.Double(points.get(0), points.get(1))).collect(Collectors.toList());
|
|
|
-// if (JsonUtil.IsPtInPoly(pointParam, allPoints)) {
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * type=FLOOR 时,polygon=null
|
|
|
-// * @param model
|
|
|
-// * @param pointParam
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// private boolean getSmByFloor(SiteModel model, Point2D.Double pointParam) {
|
|
|
-// Polygon polygon = model.getPolygon();
|
|
|
-// if (polygon == null) {
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<Point2D.Double> allPoints = model.getPolygon().getCoordinates().get(0).stream()
|
|
|
-// .map(points -> new Point2D.Double(points.get(0), points.get(1))).collect(Collectors.toList());
|
|
|
-// if (JsonUtil.IsPtInPoly(pointParam, allPoints)) {
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// // 把当前节点的children 设为空数组
|
|
|
-// private SiteModel copyModelNotContainChildren(SiteModel siteModel) {
|
|
|
-// SiteModel newSiteModel = new SiteModel();
|
|
|
-// BeanUtils.copyProperties(siteModel, newSiteModel);
|
|
|
-// // 设置空数组
|
|
|
-// newSiteModel.setChildren(new ArrayList<>());
|
|
|
-// return newSiteModel;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 2021-07-14
|
|
|
-// * 获取原来的对象test1 一共是17条
|
|
|
-// * @param siteModel
|
|
|
-// * @param models 数量回保存到原来的数据
|
|
|
-// */
|
|
|
-// private void organizeModels2(SiteModel siteModel, List<SiteModel> models) {
|
|
|
-// for (SiteModel child : siteModel.getChildren()) {
|
|
|
-// models.add(copyModelNotContainChildren(child));
|
|
|
-// if (!CollectionUtils.isEmpty(child.getChildren())) {
|
|
|
-// organizeModels2(child, models);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//// log.info("models.size: {}", models.size());
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// private void organizeModels3(SiteModel siteModel, List<SiteModel> models) {
|
|
|
-// for (SiteModel child : siteModel.getChildren()) {
|
|
|
-// Integer id = siteModel.getId();
|
|
|
-// child.setParentId(id);
|
|
|
-// models.add(copyModelNotContainChildren(child));
|
|
|
-// if (!CollectionUtils.isEmpty(child.getChildren())) {
|
|
|
-// organizeModels3(child, models);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//// log.info("models.size: {}", models.size());
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 2021-07-16
|
|
|
-// * 递归出每一个对象
|
|
|
-// * @param siteModel
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// private List<SiteModel> getLoopModel(SiteModel siteModel){
|
|
|
-// List<SiteModel> models = new ArrayList<>();
|
|
|
-// // copy实体对象
|
|
|
-// SiteModel newSiteModel = copyModelNotContainChildren(siteModel);
|
|
|
-// // 做为父节点的低一条
|
|
|
-// models.add(newSiteModel);
|
|
|
-// if (!CollectionUtils.isEmpty(siteModel.getChildren())) {
|
|
|
-//// organizeModels2(siteModel, models);
|
|
|
-// organizeModels3(siteModel, models);
|
|
|
-// }
|
|
|
-// log.info("models.size: {}", models.size());
|
|
|
-// return models;
|
|
|
-//
|
|
|
-// }
|
|
|
-//}
|