Browse Source

fix : 务空间台账(分区里有未关联的业务空间)--点击创建业务空间,平面图上选择元空间后,点击‘’从未关联平面图的业务空间选择“---关联业务空间和平面图后,报错,实际已经关联成功 FOV-106

lvxianyun 3 years ago
parent
commit
51fbcae58b

+ 25 - 0
src/main/java/com/persagy/proxy/adm/utils/GeoToolsUtil.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.utils;
 
+import cn.hutool.core.collection.CollUtil;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.geotools.geometry.jts.JTSFactoryFinder;
 import org.locationtech.jts.geom.*;
@@ -88,4 +89,28 @@ public class GeoToolsUtil {
        return flag;
    }
 
+
+    /**
+     * 点面包含关系判断
+     * 用途:判断一个面是否包含一个点,即一个点是否在一个面内
+     * @param fromOutLines: 轮廓坐标
+     * @param toOutLines: 轮廓坐标
+     * @return
+     */
+    public static Boolean isPolyInPoly(List<ObjectNode> fromOutLines,
+                                       List<ObjectNode> toOutLines) {
+        if (CollUtil.isEmpty(fromOutLines) || CollUtil.isEmpty(toOutLines)){
+            return false;
+        }
+        //创建点
+        Polygon fromPolygon = createPolygon(fromOutLines);
+        //创建面
+        Polygon toPolygon = createPolygon(toOutLines);
+        //判断面-面包含关系
+        return fromPolygon.contains(toPolygon)
+                || fromPolygon.equalsTopo(toPolygon)
+                || fromPolygon.overlaps(toPolygon)
+                || toPolygon.contains(fromPolygon);
+    }
+
 }

+ 2 - 1
src/main/java/com/persagy/proxy/relation/controller/RelationSpInSiController.java

@@ -82,7 +82,8 @@ public class RelationSpInSiController {
         List<String> ispaceIdList = siInSpBaseList.getIspaceIdList();
         String spaceId = siInSpBaseList.getSpaceId();
         if (StrUtil.isEmpty(spaceId) || CollectionUtils.isEmpty(ispaceIdList)) {
-            return AdmResponse.failure("必填项:ispaceIdList(元空间id)、spaceId(空间id)");
+           // return AdmResponse.failure("必填项:ispaceIdList(元空间id)、spaceId(空间id)");
+            return AdmResponse.success();
         }
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.SP2SI;

+ 51 - 38
src/main/java/com/persagy/proxy/report/controller/AdmSpaceInfoController.java

@@ -1,52 +1,32 @@
 package com.persagy.proxy.report.controller;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.QueryParam;
-
 import cn.hutool.core.collection.CollUtil;
-import com.persagy.dmp.basic.dto.RequestData;
-import com.persagy.dmp.digital.client.DigitalObjectFacade;
-import com.persagy.dmp.digital.entity.ObjectDigital;
-import com.persagy.proxy.object.model.AdmSpace;
-import com.persagy.proxy.object.service.IAdmSpaceService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Sets;
 import com.persagy.dmp.common.constant.ResponseCode;
-import com.persagy.dmp.common.context.AppContext;
-import com.persagy.dmp.common.helper.SpringHelper;
-import com.persagy.dmp.common.model.response.CommonResult;
-import com.persagy.dmp.digital.entity.ObjectRelation;
-import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.constant.GraphCodeEnum;
-import com.persagy.proxy.adm.constant.RelCodeEnum;
 import com.persagy.proxy.adm.request.AdmDCSQueryRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.adm.utils.GeoToolsUtil;
 import com.persagy.proxy.object.model.AdmEquipment;
+import com.persagy.proxy.object.model.AdmFloor;
 import com.persagy.proxy.object.model.AdmISpace;
 import com.persagy.proxy.object.model.AdmSystem;
-import com.persagy.proxy.object.service.IAdmEquipmentService;
-import com.persagy.proxy.object.service.IAdmISpaceService;
-import com.persagy.proxy.object.service.IAdmSystemService;
-
-import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.util.StrUtil;
+import com.persagy.proxy.object.service.*;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.QueryParam;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 
 /**
  *
@@ -61,6 +41,7 @@ import lombok.RequiredArgsConstructor;
 public class AdmSpaceInfoController {
 
 	private final IAdmISpaceService ispaceService;
+	private final IAdmFloorService floorService;
 	private final IAdmSystemService systemService;
 	private final IAdmEquipmentService equipmentService;
 	private final IAdmSpaceService spaceService;
@@ -150,22 +131,54 @@ public class AdmSpaceInfoController {
 	 */
 	@PostMapping("/unspace-ispace")
 	public AdmResponse unSpaceIspace(@QueryParam("objectType") String objectType, @RequestBody AdmDCSQueryRequest request) {
+		// 查询楼层信息 需要楼层信息中的outline modelId
+		AdmQueryCriteria admQueryCriteriaFl = new AdmQueryCriteria();
+		admQueryCriteriaFl.setName(AdmFloor.OBJ_TYPE);
+		admQueryCriteriaFl.setFilters(" id = '"+request.getFloorId()+"' ");
+		AdmResponse responseFl = floorService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteriaFl, AdmFloor.class);
+		if(CollUtil.isEmpty(responseFl.getContent())){
+			return AdmResponse.failure("flooId 为空");
+		}
+		AdmFloor floor = (AdmFloor) responseFl.getContent().get(0);
+
 		request.setName(AdmISpace.OBJ_TYPE);
 		// 设置关系条件
 		request.resetRelationCond(true, null, "Si2Sp", objectType, null, false);
 		StringBuilder sb = new StringBuilder();
 		// 补充filter条件
 		if(StrUtil.isNotBlank(request.getFilters())) {
-			sb.append(request.getFilters()).append(";");
+			sb.append(request.getFilters()).append("; ");
 		}
 		// 补充楼层条件
 		if(StrUtil.isNotBlank(request.getFloorId())) {
-			sb.append("floorId = '").append(request.getFloorId()).append("';");
+			sb.append("floorId = '").append(request.getFloorId()).append("'; ");
+		}
+		// 补充模型条件
+		if(StrUtil.isNotBlank(request.getFloorId())) {
+			sb.append("modelId = '").append(floor.getModelId()).append("'; ");
 		}
 		if(sb.length() > 0) {
 			request.setFilters(sb.substring(0, sb.length() - 1));
 		}
-		return ispaceService.doQuery(AdmContextUtil.toDmpContext(),request, AdmISpace.class);
+		AdmResponse responseIspace = ispaceService.doQuery(AdmContextUtil.toDmpContext(),request, AdmISpace.class);
+		// 按照楼层轮廓线计算出不在轮廓线内的空间
+		if(CollUtil.isNotEmpty(floor.getOutline())){
+			// 计算ispace.outLine 在floor.outLine 内的ispace
+			List<AdmISpace> iSpaceListTarget = new ArrayList<>(responseIspace.getTotal().intValue());
+			List<AdmISpace> iSpaceList = (List<AdmISpace>) responseIspace.getContent();
+			for(AdmISpace iSpace : iSpaceListTarget){
+				if(CollUtil.isEmpty(iSpace.getOutline())){
+					continue;
+				}
+				List<ObjectNode> ispaceOutLine = JSONArray.parseArray(iSpace.getOutline().toString(), ObjectNode.class);
+				if(GeoToolsUtil.isPolyInPoly(ispaceOutLine, floor.getOutline())){
+					iSpaceList.add(iSpace);
+				}
+			}
+			return AdmResponse.success(iSpaceList);
+		}else{
+			return responseIspace;
+		}
 	}
 
 	private AdmResponse unSpaceEq(String type, String spaceId, AdmQueryCriteria request, String graphCode) {