Browse Source

Merge branch 'develop' of http://39.106.8.246:3003/BDTP/adm-middleware.git into develop

zhangqiankun 3 years ago
parent
commit
30e2a6d436

+ 5 - 1
src/main/java/com/persagy/proxy/adm/request/AdmDictQueryCriteria.java

@@ -1,6 +1,6 @@
 package com.persagy.proxy.adm.request;
 
-import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -20,4 +20,8 @@ public class AdmDictQueryCriteria extends AdmQueryCriteria {
 
     /** 信息点类型 */
     private String type;
+
+    /** 信息点类型 ,兼容拓扑图查询参数*/
+    @JsonProperty(value = "Type")
+    private String labslType;
 }

+ 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);
+    }
+
 }

+ 66 - 2
src/main/java/com/persagy/proxy/calculation/service/impl/AdmManualRelCalServiceImpl.java

@@ -1,8 +1,16 @@
 package com.persagy.proxy.calculation.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.dto.RequestData;
+import com.persagy.dmp.common.constant.ResponseCode;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.digital.client.DigitalObjectClient;
@@ -25,6 +33,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -316,10 +325,12 @@ public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
      */
     @Override
     public AdmResponse query(InstanceUrlParam context, AdmManualRelCalRequest admManualRelCalRequest) {
+        // 1.获取关系枚举类型映射
         Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
         if (!relationTypeMap.containsKey(admManualRelCalRequest.getRelType())){
-            return AdmManualRelCalResponse.failure("不存在的关系类型");
+            return AdmManualRelCalResponse.success(new ArrayList<>());
         }
+        // 2.构建查询参数
         AdmRelationTypeEnum relationTypeEnum = relationTypeMap.get(admManualRelCalRequest.getRelType());
         RequestData requestData = RequestData.builder()
                 .graphCode(relationTypeEnum.getGraphCode())
@@ -336,11 +347,64 @@ public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
         if (StrUtil.isNotBlank(admManualRelCalRequest.getVagueTo())){
             requestData.setSlaveContent(CollUtil.newHashSet(admManualRelCalRequest.getVagueTo()));
         }
+        // 3.查询参数
         CommonResult<List<ObjectDigital>> commonResult = digitalObjectClient
                 .queryObjectListByGraphCodeAndRelCode(context.getGroupCode(), context.getProjectId(),
                         context.getAppId(), "0", requestData);
+        // 4.处理参数
+        List<ObjectNode> result = new ArrayList<>();
+        ObjectMapper objectMapper = SpringUtil.getBean(ObjectMapper.class);
+        if (ResponseCode.A00000.getDesc().equals(commonResult.getResult())
+                && CollUtil.isNotEmpty(commonResult.getData())){
+            List<ObjectDigital> objectDigitals = commonResult.getData();
+            for (ObjectDigital objectDigital : objectDigitals) {
+                ObjectNode temp = objectMapper.createObjectNode();
+                createCommonResultObj(objectDigital,temp);
+                ArrayNode objectInfos = objectMapper.createArrayNode();
+                List<ObjectDigital> relObjs = objectDigital.getRelObjs();
+                if (CollUtil.isNotEmpty(relObjs)){
+                    for (ObjectDigital relObj : relObjs) {
+                        ObjectNode objectNode = objectMapper.createObjectNode();
+                        createCommonResultObj(relObj,objectNode);
+                        objectInfos.add(objectNode);
+                    }
+                }
+                temp.set("objectInfo",objectInfos);
+                result.add(temp);
+            }
+        }
         return new AdmManualRelCalResponse(commonResult.getResult(),commonResult.getMessage(),commonResult.getCount(),
                 admManualRelCalRequest.getPageNumber(),admManualRelCalRequest.getPageSize(),
-                commonResult.getData(),"Left");
+                result,"Left");
+    }
+    /***
+     * Description: 通用的创建结果对象
+     * @param objectDigital : 物理世界对象
+     * @param temp : 存储对象信息
+     * @return : void
+     * @author : lijie
+     * @date :2021/10/30 14:57
+     * Update By lijie 2021/10/30 14:57
+     */
+    private void createCommonResultObj(ObjectDigital objectDigital,ObjectNode temp) {
+        ObjectNode infos = objectDigital.getInfos();
+        temp.set("bimId",infos.get("bimId"));
+        temp.set("buildingId",infos.get("buildingId"));
+        temp.set("floorId",infos.get("floorId"));
+        temp.set("cadId",infos.get("cADID"));
+        temp.put("id",objectDigital.getId());
+        if (null!=objectDigital.getCreationTime()){
+            temp.put("createTime", DateUtil.format(objectDigital.getCreationTime().getDate(),"yyyy-MM-dd HH:mm:ss"));
+        }
+        if (null!=objectDigital.getModifiedTime()){
+            temp.put("lastUpdate", DateUtil.format(objectDigital.getModifiedTime().getDate(),"yyyy-MM-dd HH:mm:ss"));
+        }
+        temp.put("localId", objectDigital.getLocalId());
+        temp.put("localName", objectDigital.getLocalName());
+        temp.put("name", objectDigital.getName());
+        temp.put("objectType", objectDigital.getObjType());
+        temp.put("objectType", objectDigital.getObjType());
+        temp.put("projectId", objectDigital.getProjectId());
+        temp.putObject("statistics");
     }
 }

+ 8 - 10
src/main/java/com/persagy/proxy/dictionary/controller/AdmDictController.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.dictionary.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.persagy.dmp.define.entity.ObjectInfoCollect;
 import com.persagy.proxy.adm.constant.AdmDictConstant;
 import com.persagy.proxy.adm.constant.AdmDictCategoryEnum;
@@ -41,7 +42,6 @@ public class AdmDictController {
 
     /**
      * 字典类型查询:所有设备类型、部件类型、系统类型、专业类型
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -59,7 +59,6 @@ public class AdmDictController {
 
     /**
      * 批量处理字典信息操作:方案设定(BDTP暂不支持)
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -75,7 +74,6 @@ public class AdmDictController {
 
     /**
      * 查询项目下类型的信息点
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -84,13 +82,18 @@ public class AdmDictController {
     public AdmResponse query(@RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
-        request.setName(request.getType());
+        if(StringUtils.isNotEmpty(request.getLabslType())){
+            request.setName(request.getLabslType());
+        }
+        if(StringUtils.isNotEmpty(request.getType())){
+            request.setName(request.getType());
+        }
         return service.query(context, request, AdmDictConstant.CLASS_CODE, AdmObjectInfo.class);
     }
 
+
     /**
      * 查询设备对应的设备族(废弃)
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -105,7 +108,6 @@ public class AdmDictController {
 
     /**
      * 重置项目下所有得定制信息点
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -120,7 +122,6 @@ public class AdmDictController {
 
     /**
      * 根据类型,项目id重置信息点
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -138,7 +139,6 @@ public class AdmDictController {
 
     /**
      * 设置-项目定制化字典
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -152,7 +152,6 @@ public class AdmDictController {
 
     /**
      * 查询项目下已有的设备类型带系统
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -168,7 +167,6 @@ public class AdmDictController {
 
     /**
      * 查询类型下所有字典信息 M 和 L 类型,包括自定义信息点
-     * @param projectId
      * @param dictTypeList
      * @return
      * @throws Exception

+ 29 - 1
src/main/java/com/persagy/proxy/object/controller/AdmEquipmentController.java

@@ -6,22 +6,26 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Sets;
+import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.basic.utils.JsonNodeUtils;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.exception.BusinessException;
 import com.persagy.dmp.common.helper.SpringHelper;
 import com.persagy.dmp.common.model.entity.BaseEntity;
+import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.define.client.DigitalDefineFacade;
 import com.persagy.dmp.define.entity.ObjectInfoDefine;
 import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
 import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.constant.AdmDictCategoryEnum;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
@@ -237,7 +241,31 @@ public class AdmEquipmentController {
 	public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
 		// 组装上下文条件
 		request.setName(AdmEquipment.OBJ_TYPE);
-		return service.query(request);
+		if(CollUtil.isEmpty(request.getCascade()) && CollUtil.isNotEmpty(request.getProjection()) && request.getDistinct() && request.getProjection().size() == 1 && request.getProjection().get(0).equals("classCode")) {
+			/** 特殊处理
+			 * distinct: true
+			 * pageNumber: 1
+			 * pageSize: 1000
+			 * projection: ["classCode"]
+			 * 0: "classCode"
+			 */
+			RequestData requestData = new RequestData();
+			requestData.setProjection(request.getProjection());
+			requestData.setObjType(AdmEquipment.OBJ_TYPE);
+			requestData.setPage(request.getPageNumber().longValue());
+			requestData.setSize(request.getPageSize().longValue());
+			CommonResult<List<ObjectNode>> result = DigitalObjectSimpleFacade.queryObjListByConditions(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, requestData);
+			if (result == null || CollUtil.isEmpty(result.getData())) {
+				return AdmResponse.success();
+			}else{
+				List<AdmEquipment> admEquipments = JSONUtil.toList(result.getData().toString(), AdmEquipment.class);
+				service.ensureSpecialValues(AdmContextUtil.toDmpContext(), admEquipments);
+				return AdmResponse.success(admEquipments);
+			}
+		}else{
+			return service.query(request);
+		}
+
 	}
 
 	/**

+ 0 - 1
src/main/java/com/persagy/proxy/object/controller/AdmSpaceController.java

@@ -183,7 +183,6 @@ public class AdmSpaceController {
                     relationDTOList.add(relationFl);
                 }
             });
-
             if (CollUtil.isNotEmpty(relationDTOList)) {
                 relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOList);
             }

+ 2 - 3
src/main/java/com/persagy/proxy/object/controller/AdmSystemController.java

@@ -218,14 +218,13 @@ public class AdmSystemController {
     @PostMapping("/query")
     public AdmResponse query(@RequestBody AdmQueryCriteria request) {
         request.setName(AdmSystem.OBJ_TYPE);
-
-        if(CollUtil.isNotEmpty(request.getProjection()) && request.getDistinct() && !request.getProjection().contains(BaseEntity.PROP_ID)){
+        if(CollUtil.isEmpty(request.getCascade()) && CollUtil.isNotEmpty(request.getProjection()) && request.getDistinct() && !request.getProjection().contains(BaseEntity.PROP_ID)){
             RequestData requestData = new RequestData();
             requestData.setProjection(request.getProjection());
             requestData.setObjType(AdmSystem.OBJ_TYPE);
             requestData.setPage(request.getPageNumber().longValue());
             requestData.setSize(request.getPageSize().longValue());
-            CommonResult<List<ObjectNode>> result = DigitalObjectSimpleFacade.querySystemListByConditions(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, requestData);
+            CommonResult<List<ObjectNode>> result = DigitalObjectSimpleFacade.queryObjListByConditions(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, requestData);
             if(result == null || CollUtil.isEmpty(result.getData())){
                 return AdmResponse.success();
             }

+ 1 - 1
src/main/java/com/persagy/proxy/object/model/AdmSpace.java

@@ -44,7 +44,7 @@ public class AdmSpace extends AdmBaseEntity<AdmSpace> {
     /** 图片 - 信息点里已存在的信息点不应在实体中重复定义为其他格式 */
     private ArrayNode pic;
     /** 空间是否受影响 */
-    private String state;
+    private Integer state;
     /** 空间常驻人数 */
     private Integer permanentPeopleNum;
 

+ 0 - 1
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -138,7 +138,6 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
             relationTo.put("graphCode", "ArchSubset");
             relationTo.put("objFrom", request.getFloorId());
             request.setRelationTo(relationTo);
-
         }else if(StrUtil.isNotEmpty(request.getBuildingId()) && StrUtil.isNotEmpty(request.getFloorId()) && request.getFloorId().equals("isnull")){
             //明确建筑,不明确楼层
             //查询建筑下的楼层

+ 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;

+ 86 - 81
src/main/java/com/persagy/proxy/report/controller/AdmReportEquipController.java

@@ -43,13 +43,12 @@ import org.springframework.web.bind.annotation.*;
 import javax.ws.rs.QueryParam;
 import java.lang.reflect.Field;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
-*  设备报表API
-* @author lvxy
-* @date 2021/9/18
-*/
+ *  设备报表API
+ * @author lvxy
+ * @date 2021/9/18
+ */
 @RestController
 @RequestMapping("/equip-query")
 public class AdmReportEquipController {
@@ -171,7 +170,7 @@ public class AdmReportEquipController {
      */
     @GetMapping("/equip-compon")
     public AdmResponse getEquipCompon(@QueryParam("id") String id, @QueryParam("category") String category){
-        //return  rEquipComponService.getEquipCompon(id,category)        
+        //return  rEquipComponService.getEquipCompon(id,category)
         RequestData requestData = new RequestData();
         if(StrUtil.isNotEmpty(id)){
             requestData.setEquipmentId(id);
@@ -284,7 +283,7 @@ public class AdmReportEquipController {
             request.setName(AdmComponent.OBJ_TYPE);
             return pageQuery(request);
         }
-       return null;
+        return null;
     }
 
     /**
@@ -435,7 +434,7 @@ public class AdmReportEquipController {
         if(JSONUtil.isNull(equipUpDateEnclosureRequest)){
             return AdmResponse.failure(ResponseCode.A0400.getDesc()+",不能为空");
         }
-        
+
         List<EquipUpDateEnclosure> equipUpDateEnclosure = JSONUtil.toList(equipUpDateEnclosureRequest.get("content").toString(), EquipUpDateEnclosure.class);
         if(CollUtil.isNotEmpty(equipUpDateEnclosure)){
             Map<String, EquipUpDateEnclosure> equipUpDateEnclosureMap = CollUtil.fieldValueMap(equipUpDateEnclosure, BaseEntity.PROP_ID);
@@ -491,30 +490,39 @@ public class AdmReportEquipController {
         ObjectNode criteriaEquip = JsonNodeFactory.instance.objectNode();
         criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
         criteriaEquip.put("taskState",-1);
-        ArrayNode array = criteriaEquip.putObject("modelId").putArray("$in");
-        equipComDelList.stream().forEach(nodeObj -> {
-            if(StrUtil.isNotEmpty(nodeObj.get("modelId").textValue())) {
-                array.add(nodeObj.get("modelId").textValue());
+        ArrayNode idList = criteriaEquip.putObject("modelId").putArray("$in");
+        // 组装结果Map 并 设置modelId数组
+        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
+        for (ObjectNode equipComDel : equipComDelList) {
+            // 取id
+            JsonNode idNode = equipComDel.get("modelId");
+            if(idNode == null || !idNode.isTextual()) {
+                continue;
             }
-        });
+            // 设置默认count
+            JsonNode countNode = equipComDel.get("count");
+            if(countNode == null || !countNode.isIntegralNumber()) {
+                // 没有count,则设置为0
+                equipComDel.put("count", 0);
+            }
+            idList.add(idNode.textValue());
+            equipDelMap.put(idNode.textValue(), equipComDel);
+        }
         queryCriteriaEuip.setCriteria(criteriaEquip);
         List<ObjectNode> equipList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
         if(CollUtil.isEmpty(equipList)){
             return AdmResponse.success(equipComDelList);
         }
-        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
-        for (ObjectNode equipComDel : equipComDelList) {
-            String modelIdObj = equipComDel.get("modelId").toString();
-            equipDelMap.put(modelIdObj, equipComDel);
-        }
-        equipList.stream().forEach(euip -> {
-            String modelIdEq = euip.get("modelId").textValue();
-            if(equipDelMap.containsKey(modelIdEq)){
-                Integer count = Integer.parseInt(equipDelMap.get(modelIdEq).get("count").textValue()) + 1;
-                equipDelMap.get(modelIdEq).put("count", count);
+        // 按查询到的设备计数
+        equipList.stream().forEach(eq -> {
+            String modelId = eq.get("modelId").textValue();
+            if(equipDelMap.containsKey(modelId)){
+                ObjectNode delCounter = equipDelMap.get(modelId);
+                int count = delCounter.get("count").intValue() + 1;
+                delCounter.put("count", count);
             }
         });
-        return AdmResponse.success(equipDelMap.values().stream().collect(Collectors.toList()));
+        return AdmResponse.success(equipComDelList);
     }
 
 
@@ -527,8 +535,6 @@ public class AdmReportEquipController {
      */
     @PostMapping("/equip-supply")
     public AdmResponse equipPropertySupply(@RequestBody List<ObjectNode> equipComDelList){
-        //return EquipmentService.equipPropertySupplys(equipComDelList)
-        //
         if(CollUtil.isEmpty(equipComDelList)){
             return AdmResponse.success();
         }
@@ -536,14 +542,28 @@ public class AdmReportEquipController {
         QueryCriteria queryCriteria = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         criteria.put("objType", AdmFloor.OBJ_TYPE);
-        ArrayNode arrayNode = criteria.putObject("modelId").putArray("$in");
-        equipComDelList.stream().forEach(node -> {
-            arrayNode.add(node.get("modelId").textValue());
-        });
+        ArrayNode idList = criteria.putObject("modelId").putArray("$in");
+        // 组装结果Map 并 设置modelId数组
+        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
+        for (ObjectNode equipComDel : equipComDelList) {
+            // 取id
+            JsonNode idNode = equipComDel.get("modelId");
+            if(idNode == null || !idNode.isTextual()) {
+                continue;
+            }
+            // 设置默认count
+            JsonNode countNode = equipComDel.get("count");
+            if(countNode == null || !countNode.isIntegralNumber()) {
+                // 没有count,则设置为0
+                equipComDel.put("count", 0);
+            }
+            idList.add(idNode.textValue());
+            equipDelMap.put(idNode.textValue(), equipComDel);
+        }
         queryCriteria.setCriteria(criteria);
         List<ObjectNode> floorList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
         if(CollUtil.isEmpty(floorList)){
-            return AdmResponse.success();
+            return AdmResponse.success(equipComDelList);
         }
         List<AdmFloor> admFloorList = JSONUtil.toList(floorList.toString(), AdmFloor.class);
         Map<String, AdmFloor> admFloorMap = CollUtil.fieldValueMap(admFloorList, BaseEntity.PROP_ID);
@@ -553,46 +573,33 @@ public class AdmReportEquipController {
         criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
         ArrayNode array = criteriaEquip.putObject("floorId").putArray("$in");
         admFloorMap.keySet().stream().forEach(id -> array.add(id));
-
-        JSONObject bimId = new JSONObject();
-        bimId.put("$null", true);
-        criteria.putPOJO("bimId", bimId);
-
-        JSONObject bimLocation = new JSONObject();
-        bimId.put("$null", false);
-        criteriaEquip.putPOJO("bimLocation", bimLocation);
-
-        JSONObject modelId = new JSONObject();
-        modelId.put("$null", true);
-        criteriaEquip.putPOJO("modelId", modelId);
-
+        criteria.putObject("bimId").put("$null", true);
+        criteria.putObject("bimLocation").put("$null", false);
+        criteria.putObject("modelId").put("$null", true);
         queryCriteriaEuip.setCriteria(criteriaEquip);
         List<ObjectNode> equipList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
         if(CollUtil.isEmpty(equipList)){
             return AdmResponse.success(equipComDelList);
         }
+        // 按楼层统计设备数量
         equipList.stream().forEach(equip -> {
-            String floolId = equip.get("floorId").textValue();
-            if(admFloorMap.containsKey(floolId)){
-                Integer count = Integer.parseInt(admFloorMap.get(floolId).getCount()) + 1;
-                admFloorMap.get(floolId).setCount(count.toString());
+            String floorId = equip.get("floorId").textValue();
+            if(admFloorMap.containsKey(floorId)){
+                AdmFloor floor = admFloorMap.get(floorId);
+                Integer count = floor.getCount() == null ? 0 : Integer.parseInt(floor.getCount());
+                floor.setCount(String.valueOf(count+1));
             }
         });
-
         // 3 根据floorId,modelId 汇总
-        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
-        for (ObjectNode equipComDel : equipComDelList) {
-           String modelIdObj = equipComDel.get("modelId").toString();
-           equipDelMap.put(modelIdObj, equipComDel);
-        }
         admFloorMap.values().stream().forEach(floor -> {
-            String modelIdFl = floor.getModelId();
-            if(equipDelMap.containsKey(modelIdFl)){
-                Integer count = Integer.parseInt(equipDelMap.get(modelIdFl).get("count").textValue()) + Integer.parseInt(floor.getCount());
-                equipDelMap.get(modelIdFl).put("count", count);
+            String modelId = floor.getModelId();
+            if(equipDelMap.containsKey(modelId)){
+                ObjectNode delCounter = equipDelMap.get(modelId);
+                int count = delCounter.get("count").intValue() + Integer.parseInt(floor.getCount());
+                delCounter.put("count", count);
             }
         });
-        return AdmResponse.success(equipDelMap.values().stream().collect(Collectors.toList()));
+        return AdmResponse.success(equipComDelList);
     }
 
     /**
@@ -624,7 +631,7 @@ public class AdmReportEquipController {
      */
     @PostMapping("/property-equip-supp")
     public AdmResponse propertyEquip(@RequestBody AdmQueryCriteria request){
-        
+
         //return EquipmentService.equipPropertySupp(sQueryRequest)
         //equipment.bim_id IS NULL
         //  AND equipment.model_id IS NULL
@@ -669,23 +676,23 @@ public class AdmReportEquipController {
             filter =  filter + ";id in "+arrayNode.toString();
             request.setFilters(filter);
 
-           AdmResponse admResponse = equipmentService.query(request);
-           if(CollUtil.isNotEmpty(admResponse.getContent())){
-               //处理数据
-               List<ObjectNode> objectNodeList = (List<ObjectNode>) admResponse.getContent();
-               objectNodeList.stream().forEach(equip ->{
-                   JsonNode building = equip.get("building");
-                   JsonNode floor = equip.get("floor");
-                   if(!JSONUtil.isNull(building)){
-                       equip.put("buildingName", building.get("localName").textValue());
-                   }
-                   if(!JSONUtil.isNull(floor)){
-                       equip.put("floorName", floor.get("localName").textValue());
-                       equip.put("modelId", floor.get("modelId").textValue());
-                   }
-               });
-           }
-           return admResponse;
+            AdmResponse admResponse = equipmentService.query(request);
+            if(CollUtil.isNotEmpty(admResponse.getContent())){
+                //处理数据
+                List<ObjectNode> objectNodeList = (List<ObjectNode>) admResponse.getContent();
+                objectNodeList.stream().forEach(equip ->{
+                    JsonNode building = equip.get("building");
+                    JsonNode floor = equip.get("floor");
+                    if(!JSONUtil.isNull(building)){
+                        equip.put("buildingName", building.get("localName").textValue());
+                    }
+                    if(!JSONUtil.isNull(floor)){
+                        equip.put("floorName", floor.get("localName").textValue());
+                        equip.put("modelId", floor.get("modelId").textValue());
+                    }
+                });
+            }
+            return admResponse;
         }else{
             return AdmResponse.success();
         }
@@ -814,7 +821,7 @@ public class AdmReportEquipController {
         AdmGatherInfoPoint gatherInfoPoint = new AdmGatherInfoPoint();
 
         Integer controlInfoCounts = controlInfoCounts(AdmEquipment.OBJ_TYPE);
-       // 根据objType获取定义 获取采集的设备的classcode
+        // 根据objType获取定义 获取采集的设备的classcode
         Set<String> objTypes = new HashSet<>(1);
         objTypes.add(AdmEquipment.OBJ_TYPE);
         List<Map<String, Object>> codes = DigitalObjectSimpleFacade.queryDefineInfoByObjType(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null, RequestData.builder().objTypes(objTypes).build());
@@ -935,7 +942,7 @@ public class AdmReportEquipController {
         queryCriteria.setOnlyCount(true);
         List<ObjectNode> euipCom = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
         if(CollUtil.isNotEmpty(euipCom)){
-           return AdmResponse.success(euipCom);
+            return AdmResponse.success(euipCom);
         }else{
             return AdmResponse.success();
         }
@@ -1165,6 +1172,4 @@ public class AdmReportEquipController {
             infos.put(attribute, upTarget);
         }
     }
-
-
 }

+ 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) {