Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java
lvxianyun 3 gadi atpakaļ
vecāks
revīzija
83ecb8d6cd

+ 11 - 13
src/main/java/com/persagy/proxy/adm/controller/AdmRelCalController.java

@@ -53,7 +53,7 @@ public class AdmRelCalController {
                                               HttpServletRequest request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        admRelCalService.calcRelation(context,CollUtil.newArrayList(getAdmRelationTypeEnum(request)),objectTypeStr,relationTypeStr);
+        admRelCalService.calcRelation(context,CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
         return AdmResponse.success(new ArrayList<>());
     }
 
@@ -82,7 +82,7 @@ public class AdmRelCalController {
                                               HttpServletRequest request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        admRelCalService.calcRelation(context, CollUtil.newArrayList(getAdmRelationTypeEnum(request)),objectTypeStr,relationTypeStr);
+        admRelCalService.calcRelation(context, CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
         return AdmResponse.success(new ArrayList<>());
     }
 
@@ -168,10 +168,6 @@ public class AdmRelCalController {
     }
     /***
      * Description: 添加关系(图类型关系为SensorRelationship)
-     * @param relType : 关系类型
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
-     *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
-     *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
      * eq2sp_SensorRelationship_ss2sp:传感器测量空间关系
      * @return : com.persagy.proxy.adm.request.AdmCreateResponse
      * @author : lijie
@@ -179,14 +175,16 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"eq2sp_SensorRelationship_ss2sp"})
-    public AdmResponse sensorRelationshipCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse sensorRelationshipCalcRelation(@RequestParam("projectId") String projectId,
+                                                      @RequestParam("groupCode") String groupCode,
+                                                      @RequestParam("appId") String appId,
+                                                      @RequestParam("userId") String userId) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
+        admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.EQ2SP_SENSORRELATIONSHIP_SS2SP),"AirConditioningZone");
         return AdmResponse.success(new ArrayList<>());
     }
     /***
@@ -284,7 +282,7 @@ public class AdmRelCalController {
         }
         ArrayList<AdmRelationTypeEnum> admRelationTypeEnums =
                 CollUtil.newArrayList(relationTypeMap.get("eq2bd"), relationTypeMap.get("sy2bd"));
-        admRelCalService.calcRelation(context,admRelationTypeEnums,objectTypeStr,relationTypeStr);
+        admRelCalService.calcRelation(context,admRelationTypeEnums,null);
         return AdmResponse.success(new ArrayList<>());
     }
     /***

+ 26 - 3
src/main/java/com/persagy/proxy/adm/controller/ComponentBuildingController.java

@@ -7,12 +7,15 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.dto.RequestData;
@@ -44,6 +47,9 @@ import cn.hutool.core.util.StrUtil;
 @RestController
 public class ComponentBuildingController {
 
+	@Value("${middleware.group.code}")
+	private String defaultCode;
+	
 	@Autowired
 	private RelationObjectContext relationObjectContext;
 	
@@ -56,18 +62,35 @@ public class ComponentBuildingController {
 	@RequestMapping("/building/query")
 	public AdmResponse queryBuilding(@RequestBody AdmQueryCriteria queryCriteria, HttpServletRequest request) {
 		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
 		String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
 		
 		// 查询出所有的建筑对象
+		String orders = queryCriteria.getOrders();
 		RequestData requestData = new RequestData();
+		
+		List<OrderItem> orderItems = null;
+		if (StringUtils.isNotBlank(orders)) {
+			orderItems = new ArrayList<OrderItem>();
+			
+			String[] split = orders.split(",");
+			for (String column : split) {
+				if (StringUtils.isNotBlank(column)) {
+					orderItems.add(column.endsWith("asc") ? OrderItem.asc(column.split(" ")[0]) : OrderItem.desc(column.split(" ")[0]));
+				}
+			}
+		}
+		if (CollectionUtil.isNotEmpty(orderItems)) {
+			requestData.setOrders(orderItems);
+		}
 		requestData.setGraphCode(GraphCodeEnum.ArchSubset.name());
 		requestData.setRelCode(RelCodeEnum.Bd2Fl.name());
-		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setPage(queryCriteria.getPageNumber() == null ? 1L : queryCriteria.getPageNumber());
+		requestData.setSize(queryCriteria.getPageSize() == null ? 500L : queryCriteria.getPageSize());
 		
 		List<ObjectDigital> masterObjs = this.relationObjectContext.queryPageObjectInfo(requestData, groupCode, projectId, AdmRelationType.ARCHSUBSET_BD2FL);
 		this.handleMasterObjs(masterObjs, groupCode, projectId);
-		return AdmResponse.success();
+		return AdmResponse.success(masterObjs);
 	}
 
 	/**

+ 7 - 2
src/main/java/com/persagy/proxy/adm/controller/RelationReportController.java

@@ -19,6 +19,7 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.ResourceUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -30,7 +31,6 @@ import com.alibaba.excel.ExcelWriter;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Lists;
-import com.persagy.dmp.define.client.DigitalGraphDefineFacade;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmRelationObject;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
@@ -56,6 +56,9 @@ public class RelationReportController {
 
 	public static final String EXPORT_SHEET_NAME = "关系维护";
 	
+	@Value("${middleware.group.code}")
+	private String defaultCode;
+	
 	@Autowired
 	private RelationObjectContext relationObjectContext;
 	
@@ -269,6 +272,7 @@ public class RelationReportController {
 		ExcelWriter excelWriter = null;
 		try {
 			String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
+			groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
 			code = StrUtil.isBlank(code) ? "对象ID" : code;
 			
 			response.setContentType("application/vnd.ms-excel");
@@ -276,7 +280,8 @@ public class RelationReportController {
 			response.setCharacterEncoding(encode);
 			response.setHeader("Content-disposition", "attachment;filename=relation-template.xlsx");
 			
-			List<AdmRelationObject> relationObjects = this.relationReportService.reportRelationObject(groupCode, projectId, relType, code, zoneType);
+			log.info("下载报表: groupCode[{}], projectId[{}], relType[{}], code[{}]", groupCode, projectId, relType, code);
+			List<AdmRelationObject> relationObjects = this.relationObjectContext.findRelationObject(groupCode, projectId, relType);
 			
 			File templateFile = this.getTemplateFile("relation-template.xlsx");
 			EasyExcel.write(response.getOutputStream()).withTemplate(templateFile).sheet(EXPORT_SHEET_NAME).needHead(false).doWrite(relationObjects);

+ 1 - 1
src/main/java/com/persagy/proxy/adm/controller/RelationSpInBdOrFlController.java

@@ -101,7 +101,7 @@ public class RelationSpInBdOrFlController {
      * @param    requestParam    对象
      * @return                       删除的结果信息
      */
-    @PostMapping("/bd-del-1")
+    @PostMapping("/bd-update")
     public AdmResponse delete(@RequestParam String projectId,
                               @RequestBody JSONObject requestParam) throws Exception {
         JSONArray content = requestParam.getJSONArray("content");

+ 9 - 0
src/main/java/com/persagy/proxy/adm/dto/TwicePointDTO.java

@@ -1,11 +1,20 @@
 package com.persagy.proxy.adm.dto;
 
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
 /***
  * Description: 记录两组坐标的DTO类
  * @author : lijie
  * @date :2021/10/8 10:01
  * Update By lijie 2021/10/8 10:01
  */
+@Builder
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
 public class TwicePointDTO {
 
     private Double x1;

+ 3 - 3
src/main/java/com/persagy/proxy/adm/service/AdmRelCalService.java

@@ -18,14 +18,14 @@ public interface AdmRelCalService {
      * Description: 计算关系
      * @param context : 请求参数
      * @param admRelationTypeEnums : 关系类型集合
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型)
-     * @param relationTypeStr : 关系类型
+     //* @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型)
+     //* @param relationTypeStr : 关系类型
      * @return : void
      * @author : lijie
      * @date :2021/9/11 20:35
      * Update By lijie 2021/9/11 20:35
      */
-    void calcRelation(InstanceUrlParam context, List<AdmRelationTypeEnum> admRelationTypeEnums, String objectTypeStr, String relationTypeStr);
+    void calcRelation(InstanceUrlParam context, List<AdmRelationTypeEnum> admRelationTypeEnums, String relValue);
     /***
      * Description: 计算空间服务于空间的关系
      * @param context : 通用参数

+ 1 - 2
src/main/java/com/persagy/proxy/adm/service/IRelationReportService.java

@@ -8,7 +8,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.define.entity.GraphDefine;
 import com.persagy.dmp.define.entity.RelationDefine;
 import com.persagy.dmp.digital.entity.ObjectRelation;
-import com.persagy.proxy.adm.model.AdmRelationObject;
 
 /**
  * 报表/模板下载
@@ -152,6 +151,6 @@ public interface IRelationReportService {
 	 * @param zoneType
 	 * @return 可以被直接导出的数据集
 	 */
-	List<AdmRelationObject> reportRelationObject(String groupCode, String projectId, String relType, String code, String zoneType);
+	//List<AdmRelationObject> reportRelationObject(String groupCode, String projectId, String relType, String code, String zoneType);
 
 }

+ 246 - 56
src/main/java/com/persagy/proxy/adm/service/impl/AdmRelCalServiceImpl.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.adm.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.math.MathUtil;
 import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -14,7 +15,9 @@ import com.persagy.dmp.common.helper.SpringHelper;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
 import com.persagy.dmp.digital.client.DigitalRelationCaclFacade;
+import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
 import com.persagy.proxy.adm.constant.AdmObjectType;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
@@ -22,14 +25,14 @@ import com.persagy.proxy.adm.constant.ObjTypeMapping;
 import com.persagy.proxy.adm.dto.TwicePointDTO;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.AdmRelCalService;
+import com.persagy.proxy.adm.utils.GeoToolsUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.Data;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 @Service
 @Slf4j
@@ -40,24 +43,27 @@ public class AdmRelCalServiceImpl implements AdmRelCalService {
      * Description: 计算关系
      * @param context : 请求参数
      * @param admRelationTypeEnums : 关系类型集合
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型)
-     * @param relationTypeStr : 关系类型
+     //* @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型)
+     //* @param relationTypeStr : 关系类型
      * return : void
      * @author : lijie
      * date :2021/9/11 20:35
      * Update By lijie 2021/9/11 20:35
      */
     @Override
-    public void calcRelation(InstanceUrlParam context, List<AdmRelationTypeEnum> admRelationTypeEnums, String objectTypeStr,
-                             String relationTypeStr) {
+    public void calcRelation(InstanceUrlParam context, List<AdmRelationTypeEnum> admRelationTypeEnums,String relValue) {
         for (AdmRelationTypeEnum admRelationTypeEnum : admRelationTypeEnums) {
+            RequestData requestData = RequestData.builder()
+                    .graphCode(admRelationTypeEnum.getGraphCode())
+                    .relCode(admRelationTypeEnum.getRelCode())
+                    .calBeforeRelFlag(true)
+                    .build();
+            if (StrUtil.isNotBlank(relValue)){
+                requestData.setRelValue(relValue);
+            }
             // 调用中台的计算逻辑
             DigitalRelationCaclFacade.calculatingObjRelationPrototype(context.getGroupCode(),context.getProjectId(),
-                    context.getAppId(), CommonConstant.DEFAULT_ID, RequestData.builder()
-                            .graphCode(admRelationTypeEnum.getGraphCode())
-                            .relCode(admRelationTypeEnum.getRelCode())
-                            .calBeforeRelFlag(true)
-                            .build());
+                    context.getAppId(), CommonConstant.DEFAULT_ID, requestData);
         }
     }
     /***
@@ -75,50 +81,59 @@ public class AdmRelCalServiceImpl implements AdmRelCalService {
     @Override
     public AdmResponse calcRelationForArchForArchSpToSp(InstanceUrlParam context, String buildingId, String objectType,
                                                         String type, AdmRelationTypeEnum relationTypeEnum) {
-        double distance = 100.00;
         if (StrUtil.isBlank(buildingId)){
             return AdmResponse.success(new ArrayList<>());
         }
+        RequestData requestData = RequestData
+                .builder()
+                .buildingId(buildingId)
+                .objTypes(CollUtil.newHashSet(AdmObjectType.FLOOR.getIndex()))
+                .build();
         // 1.根据建筑id查询建筑下的所有楼层
         CommonResult<List<ObjectDigital>> commonResult = DigitalObjectFacade
                 .queryObjectListSuperiorIdPrototype(context.getGroupCode(), context.getProjectId(),
-                context.getAppId(), context.getUserId(), RequestData
-                        .builder()
-                        .buildingId(buildingId)
-                        .objTypes(CollUtil.newHashSet(AdmObjectType.FLOOR.getIndex()))
-                        .build());
+                context.getAppId(), context.getUserId(), requestData);
         if (!"success".equals(commonResult.getResult())){
             return AdmResponse.failure(commonResult.getMessage());
         }
         Long count = commonResult.getCount();
         List<ObjectDigital> data = commonResult.getData();
-        handleFloorRelationCalc(data,context);
-
-        long skip = data.size();
-        while (skip<count){
-            // 有未处理完的楼层
-
-
-
+        handleFloorRelationCalc(data,context,objectType,relationTypeEnum);
+        if (data.size() == count){
+            // 不需要分页查询
+            return AdmResponse.success();
         }
-
-
-        return null;
-
+        // 有结果集未查完
+        long page = (count % CommonConstant.QUERY_DEFAULT_PAGE_SIZE) == 0
+                ? (count / CommonConstant.QUERY_DEFAULT_PAGE_SIZE) : (count / CommonConstant.QUERY_DEFAULT_PAGE_SIZE + 1);
+        for (long i = 1; i < page; i++) {
+            requestData.setPage(i);
+            requestData.setSize(CommonConstant.QUERY_DEFAULT_PAGE_SIZE);
+            List<ObjectDigital> pageFloors = DigitalObjectFacade
+                    .queryObjectListSuperiorId(context.getGroupCode(),
+                            context.getProjectId(), context.getAppId(), context.getUserId(), requestData);
+            handleFloorRelationCalc(pageFloors,context,objectType,relationTypeEnum);
+        }
+        return AdmResponse.success();
     }
     /***
      * Description: 处理楼层下的关系计算(BDTP平台已经限制查询数据量)
      * @param data : 楼层数据
-     * @param context: 请求参数
+     * @param context : 请求参数
+     * @param classCode : 对象类型code
+     * @param relationTypeEnum: 图类型对象
      * @return : void
      * @author : lijie
      * @date :2021/9/30 16:46
      * Update By lijie 2021/9/30 16:46
      */
-    private void handleFloorRelationCalc(List<ObjectDigital> data, InstanceUrlParam context) {
+    private void handleFloorRelationCalc(List<ObjectDigital> data, InstanceUrlParam context, String classCode,
+                                         AdmRelationTypeEnum relationTypeEnum) {
         if (CollUtil.isEmpty(data)){
             return;
         }
+        ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+        List<ObjectNode> relations = new ArrayList<>();
         // 2.循环所有楼层
         for (ObjectDigital floor : data) {
             if (!floor.getInfos().has(AdmObjectInfoConstant.MODEL_ID)
@@ -131,21 +146,139 @@ public class AdmRelCalServiceImpl implements AdmRelCalService {
                             .getInfos()
                             .get(AdmObjectInfoConstant.MODEL_ID)
                             .asText(),context);
-            // 2.1 根据楼层id和classCode查询所有的空间
-
-
+            if (CollUtil.isEmpty(pointDTOS)){
+                continue;
+            }
+            // 2.2 根据楼层id和classCode查询所有的空间
+            List<ObjectDigital> spaces = queryAllSpacesByFloorIdAndClassCode(floor.getId(),
+                    classCode,floor.getProjectId(),context);
+            if (CollUtil.isEmpty(spaces)){
+                continue;
+            }
             // 2.3 遍历所有的门,得到门拥有的两组x,y坐标
-            // 2.4 遍历坐标组,与空间进行对比,得到所有符合的空间id数组
+            Map<Integer,List<String>> spaceIndexMap = new HashMap<>();
+            for (int i = 0; i < pointDTOS.size(); i++) {
+                TwicePointDTO pointDTO = pointDTOS.get(i);
+                ObjectNode point1 = objectMapper
+                        .createObjectNode()
+                        .put("x", pointDTO.getX1())
+                        .put("y", pointDTO.getY1())
+                        .put("z", 0.00);
+                ObjectNode point2 = objectMapper
+                        .createObjectNode()
+                        .put("x", pointDTO.getX2())
+                        .put("y", pointDTO.getY2())
+                        .put("z", 0.00);
+                // 2.4 遍历坐标组,与空间进行对比,得到所有符合的空间id数组
+                for (ObjectDigital space : spaces) {
+                    if (null==space.getInfos()){
+                        continue;
+                    }
+                    if (!space.getInfos().has("outline")
+                            || !(space.getInfos().get("outline").size()>0)
+                            || !(space.getInfos().get("outline").get(0).size()>0)){
+                        continue;
+                    }
+                    // 空间的第一个数组
+                    JsonNode jsonNode = space.getInfos().get("outline").get(0).get(0);
+                    if (jsonNode==null || !jsonNode.isArray()){
+                        continue;
+                    }
+                    ArrayNode jsonNodes = (ArrayNode) jsonNode;
+                    List<ObjectNode> temp = new ArrayList<>();
+                    jsonNodes.forEach(node->temp.add((ObjectNode) node));
+                    if (GeoToolsUtil.isPointInPoly(point1,temp) || GeoToolsUtil.isPointInPoly(point2,temp)){
+                        List<String> spaceIds = spaceIndexMap.getOrDefault(i, new ArrayList<>());
+                        spaceIds.add(space.getId());
+                        spaceIndexMap.put(i,spaceIds);
+                    }
+                }
+            }
             // 2.5 创建空间服务关系的关系数据
-
-
+            Set<Map.Entry<Integer, List<String>>> entries = spaceIndexMap.entrySet();
+
+            for (Map.Entry<Integer, List<String>> entry : entries) {
+                List<String> list = entry.getValue();
+                if(CollUtil.isEmpty(list) || list.size()<2){
+                    continue;
+                }
+                String oneSpaceId = list.get(0);
+                for (int i = 1; i < list.size(); i++) {
+                    String otherSpaceId = list.get(i);
+                    ObjectNode objectNode = objectMapper.createObjectNode()
+                            .put("graphCode", relationTypeEnum.getGraphCode())
+                            .put("relCode", relationTypeEnum.getRelCode())
+                            .put("graphId", StrUtil.format(CommonConstant.DEFAULT_GRAPH_ID_FORMAT, relationTypeEnum.getGraphCode()))
+                            .put("projectId", floor.getProjectId())
+                            .put("objTo", otherSpaceId)
+                            .put("objFrom", oneSpaceId)
+                            .put("valid", 1)
+                            .put("createApp", context.getAppId())
+                            .put("updateApp", context.getAppId())
+                            .put("groupCode", context.getGroupCode())
+                            .put("creator", context.getUserId())
+                            .put("modifier", context.getUserId());
+                    if (StrUtil.isNotBlank(classCode)){
+                        objectNode.put("relValue",classCode);
+                    }
+                    relations.add(objectNode);
+                }
+            }
         }
-
-
-
-
-
+        if (CollUtil.isNotEmpty(relations)){
+            DigitalRelationFacade.create(context.getGroupCode(),context.getProjectId(),context.getAppId(),context.getUserId(),relations);
+        }
+    }
+    /***
+     * Description: 查询楼层下的所有空间
+     * @param floorId : 楼层id
+     * @param classCode : 对象类型code
+     * @param projectId : 项目id
+     * @param context: 内容上下文
+     * @return : java.util.List<com.persagy.dmp.digital.entity.ObjectDigital>
+     * @author : lijie
+     * @date :2021/10/8 14:47
+     * Update By lijie 2021/10/8 14:47
+     */
+    private List<ObjectDigital> queryAllSpacesByFloorIdAndClassCode(String floorId, String classCode,
+                                                                    String projectId, InstanceUrlParam context) {
+        RequestData requestData = RequestData
+                .builder()
+                .projectId(projectId)
+                .floorId(floorId)
+                .objTypes(CollUtil.newHashSet(AdmObjectType.SPACE.getIndex()))
+                .classCodes(CollUtil.newHashSet(classCode))
+                .build();
+        // 1.查询通用结果集
+        CommonResult<List<ObjectDigital>> commonResult = DigitalObjectFacade
+                .queryObjectListSuperiorIdPrototype(context.getGroupCode(),
+                        context.getProjectId(), context.getAppId(), context.getUserId(), requestData);
+        List<ObjectDigital> spaces = commonResult.getData();
+        if (CollUtil.isEmpty(spaces)){
+            return new ArrayList<>();
+        }
+        Long count = commonResult.getCount();
+        if (spaces.size() == count){
+            // 不需要分页查询
+            return spaces;
+        }
+        // 有结果集未查完
+        long page = (count % CommonConstant.QUERY_DEFAULT_PAGE_SIZE) == 0
+                ? (count / CommonConstant.QUERY_DEFAULT_PAGE_SIZE) : (count / CommonConstant.QUERY_DEFAULT_PAGE_SIZE + 1);
+        for (long i = 1; i < page; i++) {
+            requestData.setPage(i);
+            requestData.setSize(CommonConstant.QUERY_DEFAULT_PAGE_SIZE);
+            List<ObjectDigital> pageSpaces = DigitalObjectFacade
+                    .queryObjectListSuperiorId(context.getGroupCode(),
+                            context.getProjectId(), context.getAppId(), context.getUserId(), requestData);
+            if (CollUtil.isEmpty(pageSpaces)){
+                continue;
+            }
+            spaces.addAll(pageSpaces);
+        }
+        return spaces;
     }
+
     /***
      * Description: 根据楼层模型id查询所有门数据(BDTP限制了查询条数,需要做分页查询)
      * @param floorModelId : 楼层模型id
@@ -156,18 +289,50 @@ public class AdmRelCalServiceImpl implements AdmRelCalService {
      * Update By lijie 2021/10/8 10:02
      */
     private List<TwicePointDTO> queryAllDoorByFloorModelId(String floorModelId, InstanceUrlParam context) {
+
         // 门的classCode:CFBEDR,obj_type为equipment
         QueryCriteria queryCriteria = new QueryCriteria();
         queryCriteria.getCriteria().put("classCode","CFBEDR")
                 .put("objType",AdmObjectType.EQUIPMENT.getIndex())
                 .put("modelId",floorModelId);
-        List<ObjectNode> objectNodes = DigitalObjectFacade
-                .query(context.getGroupCode(), context.getProjectId(), context.getAppId(),
+        CommonResult<List<ObjectNode>> commonResult = DigitalObjectFacade
+                .queryPrototype(context.getGroupCode(), context.getProjectId(), context.getAppId(),
                         context.getUserId(), queryCriteria);
+        List<TwicePointDTO> result = new ArrayList<>();
+        List<ObjectNode> objectNodes = commonResult.getData();
+        Long count = commonResult.getCount();
+        analysisDoorResultData(result,objectNodes);
+        if (objectNodes.size()==count){
+            // 查询结果集小于BDTP默认分页条数
+            return result;
+        }
+        // 有结果集未查完
+        long page = (count % CommonConstant.QUERY_DEFAULT_PAGE_SIZE) == 0
+                ? (count / CommonConstant.QUERY_DEFAULT_PAGE_SIZE) : (count / CommonConstant.QUERY_DEFAULT_PAGE_SIZE + 1);
+        for (long i = 1; i < page; i++) {
+            queryCriteria.setPage(i);
+            queryCriteria.setSize(CommonConstant.QUERY_DEFAULT_PAGE_SIZE);
+            analysisDoorResultData(result,DigitalObjectFacade
+                    .query(context.getGroupCode(), context.getProjectId(), context.getAppId(),
+                            context.getUserId(), queryCriteria));
+        }
+        return result;
+    }
+
+    /***
+     * Description: 解析门查询结果集
+     * @param result : 存储结果集
+     * @param objectNodes : 对象结果集
+     * @return : void
+     * @author : lijie
+     * @date :2021/10/8 14:26
+     * Update By lijie 2021/10/8 14:26
+     */
+    private void analysisDoorResultData(List<TwicePointDTO> result, List<ObjectNode> objectNodes) {
+        double distance = 100.00;
         if (CollUtil.isEmpty(objectNodes)){
-            return new ArrayList<>();
+            return;
         }
-        List<TwicePointDTO> result = new ArrayList<>();
         for (ObjectNode objectNode : objectNodes) {
             // 1.获得outline
             if (!objectNode.has("outline")
@@ -186,19 +351,44 @@ public class AdmRelCalServiceImpl implements AdmRelCalService {
             ArrayNode points = (ArrayNode) objectNode.get("outline").get(0);
             JsonNode firstPoint = points.get(0);
             JsonNode secondPoint = points.get(1);
-
-
-
-
-
+            Double k=getPoints(firstPoint.get("x").asDouble(),firstPoint.get("y").asDouble(),
+                    secondPoint.get("x").asDouble(),secondPoint.get("y").asDouble());
+            if (null==k){
+                result.add(TwicePointDTO
+                        .builder()
+                        .x1(point.get("x").asDouble())
+                        .y1(point.get("y").asDouble()+distance)
+                        .x2(point.get("x").asDouble())
+                        .y2(point.get("y").asDouble()-distance)
+                        .build());
+                continue;
+            }
+            result.add(getPointByDistance(point.get("x").asDouble(),point.get("y").asDouble(),k,distance*2));
         }
+    }
 
-
-        return null;
-
-
-
+    /***
+     * Description: 计算两点之间的距离(我不太明白这个算法是怎么算的)
+     * @param baseX : 坐标点1的x值
+     * @param baseY : 坐标点1的y值
+     * @param k : 坐标点2的x值
+     * @param distance : 坐标点2的y值
+     * @return : java.lang.Double
+     * @author : lijie
+     * @date :2021/10/8 11:31
+     * Update By lijie 2021/10/8 11:31
+     */
+    private TwicePointDTO getPointByDistance(Double baseX,Double baseY,Double k,Double distance){
+        if (null==k){
+            return TwicePointDTO.builder().x1(baseX).y1(baseY+distance).x2(baseX).y2(baseY-distance).build();
+        }
+        double vectorX1 = Math.sqrt(distance * distance / (1 + k * k));
+        double vectorX2 = -vectorX1;
+        double vectorY1 = k*vectorX1;
+        double vectorY2 = k*vectorX2;
+        return TwicePointDTO.builder().x1(baseX+vectorX1).y1(baseY+vectorY1).x2(baseX+vectorX2).y2(baseY+vectorY2).build();
     }
+
     /***
      * Description: 计算两点之间的距离(我不太明白这个算法是怎么算的)
      * @param x1 : 坐标点1的x值

+ 10 - 24
src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java

@@ -1,7 +1,12 @@
 package com.persagy.proxy.adm.service.impl;
 
-import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.util.StrUtil;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Lists;
@@ -21,19 +26,12 @@ import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.adm.constant.ObjTypeMapping;
-import com.persagy.proxy.adm.model.AdmRelationObject;
 import com.persagy.proxy.adm.service.IRelationReportService;
-import com.persagy.proxy.adm.strategy.RelationObjectContext;
 import com.persagy.proxy.adm.strategy.relationdata.RelationObjectStrategy;
-import lombok.extern.slf4j.Slf4j;
-import net.minidev.json.JSONObject;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+import net.minidev.json.JSONObject;
 
 /**
  * 报表/模板下载
@@ -43,16 +41,12 @@ import java.util.Set;
  * @author zhangqiankun
  * @date 2021年8月31日 下午4:43:15
  */
-@Slf4j
 @Service
 public class RelationReportService implements IRelationReportService {
 
 	@Value("${middleware.group.code}")
 	private String defaultCode;
 
-	@Autowired
-	private RelationObjectContext relationObjectContext;
-
 	@Override
 	public List<Map<String, Object>> queryObjectCountByObjInfos(String groupCode, Set<String> classCodes, Set<String> objTypes, List<String> groups) {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
@@ -265,12 +259,4 @@ public class RelationReportService implements IRelationReportService {
 		return CollectionUtil.isEmpty(objectRelations) ? Lists.newArrayList() : objectRelations;
 	}
 	
-	
-	@Override
-	public List<AdmRelationObject> reportRelationObject(String groupCode, String projectId, String relType, String code, String zoneType) {
-		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
-		log.info("下载报表: groupCode[{}], projectId[{}], relType[{}], code[{}]", groupCode, projectId, relType, code);
-		return this.relationObjectContext.findRelationObject(groupCode, projectId, relType);
-	}
-
 }

+ 4 - 6
src/main/java/com/persagy/proxy/adm/strategy/RelationObjectContext.java

@@ -34,8 +34,6 @@ public class RelationObjectContext {
 	private Map<String, RelationObjectStrategy> relationObjectStrategyMap;
 	
 	/**
-	 * 自动注入 byName
-	 * 
 	 * @param relationObjectStrategyMap
 	 */
 	@Resource
@@ -135,16 +133,16 @@ public class RelationObjectContext {
 	 * @param requestData 请求参数
 	 * @param groupCode 集团编码
 	 * @param projectId 项目ID
-	 * @param relType 
+	 * @param relType  graphCode_relCode;
 	 */
 	public List<ObjectDigital> queryPageObjectInfo(RequestData requestData, String groupCode, String projectId, String relType) {
 		List<ObjectDigital> masterObjs = new ArrayList<ObjectDigital>();
-		AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
+		/*AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
 		if (relationTypeEnum == null) {
 			return masterObjs;
 		}
-		String className = relationTypeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + relationTypeEnum.getRelCode();
-		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(className);
+		String className = relationTypeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + relationTypeEnum.getRelCode();*/
+		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
 		if (strategy == null) {
 			return masterObjs;
 		}