Browse Source

平面图接口开发

linhuili 3 years ago
parent
commit
04e905de4e

+ 98 - 0
src/main/java/com/persagy/proxy/adm/controller/AdmLabslController.java

@@ -0,0 +1,98 @@
+package com.persagy.proxy.adm.controller;
+
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmObjectInfo;
+import com.persagy.proxy.adm.model.AdmObjectType;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmLabslService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+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.ws.rs.QueryParam;
+import java.util.List;
+
+/**
+ * @ClassName AdmLabslController
+ * @Description: 蜡笔森林定制接口
+ * @Author linhuili
+ * @Date 2021/9/17 20:01
+ * @Version V1.0
+ **/
+@RestController
+@RequestMapping("/labsl")
+@Slf4j
+public class AdmLabslController {
+
+
+    @Autowired
+    private IAdmLabslService service;
+
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    /**
+     * 查询项目下的设备类型
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/category")
+    public AdmResponse queryCategory() throws Exception {
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, AdmCommonConstant.PROJECTID, AdmCommonConstant.APP_ID);
+        return service.queryCategory(context, AdmObjectInfo.class);
+    }
+
+
+    /**
+     * 查询项目下的空间类型
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/zone/type")
+    public AdmResponse queryZoneType() throws Exception {
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, AdmCommonConstant.PROJECTID, AdmCommonConstant.APP_ID);
+        return service.queryZoneType(context, AdmObjectInfo.class);
+    }
+
+    /**
+     * 查询项目下的建筑楼层
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/building/floor")
+    public AdmResponse queryBuildFloor(@QueryParam("projectId") String projectId) throws Exception {
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        return service.queryBuildFloor(context, AdmObjectInfo.class);
+    }
+
+
+    /**
+     * 查询设备包含设备类型
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/query/equip")
+    public AdmResponse queryEquipType(@QueryParam("projectId") String projectId) throws Exception {
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        return service.queryBuildFloor(context, AdmObjectInfo.class);
+    }
+
+
+    /**
+     * 根据设备id统计设备所属的专业
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/major/category")
+    public AdmResponse queryMajorCategory(@QueryParam("projectId") String projectId,
+                                          @RequestBody List<String> ids) throws Exception {
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        return service.queryMajorCategory(context, ids , AdmObjectType.class);
+    }
+
+}

+ 28 - 6
src/main/java/com/persagy/proxy/adm/controller/AdmPlanarController.java

@@ -1,8 +1,10 @@
 package com.persagy.proxy.adm.controller;
 
+import cn.hutool.core.collection.CollUtil;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.model.AdmObjectType;
+import com.persagy.proxy.adm.model.*;
 import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmPlanarService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,16 +33,36 @@ public class AdmPlanarController {
     @Value("${middleware.group.code}")
     private String groupCode;
 
+    @Autowired
+    private IAdmPlanarService service;
+
     /**
-     * 查询设备信息
+     * 查询平面图设备信息
      * @return
      * @throws Exception
      */
     @PostMapping("/equip")
-    public AdmResponse queryEquip(@QueryParam("projectId") String projectId,
-                                          @RequestBody List<String> ids) throws Exception {
+    public AdmResponse queryPlanarEquip(@QueryParam("projectId") String projectId,
+                                          @RequestBody AdmPlanarEquipRequests requests) throws Exception {
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        if(requests == null){
+            throw new Exception("请求参数不能为空");
+        }
+        return service.queryPlanarEquip(context,requests, AdmEquipment.class);
+    }
+
+    /**
+     * 查询平面图空间信息
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/space")
+    public AdmResponse queryPlanarSpace(@QueryParam("projectId") String projectId,
+                                  @RequestBody AdmPlanarEquipRequests requests) throws Exception {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        //
-        return AdmResponse.success(new ArrayList<>());
+        if(requests == null){
+            throw new Exception("请求参数不能为空");
+        }
+        return service.queryPlanarSpace(context,requests, AdmSpace.class);
     }
 }

+ 36 - 0
src/main/java/com/persagy/proxy/adm/model/AdmPlanarEquipRequests.java

@@ -0,0 +1,36 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName AdmPlanarEquipRequests
+ * @Description: 平面图设备查询请求参数
+ * @Author linhuili
+ * @Date 2021/9/22 14:15
+ * @Version V1.0
+ **/
+@Data
+public class AdmPlanarEquipRequests {
+
+    /** 设备类型 */
+    private List<String> equipTypes;
+
+    /** 空间类型 */
+    private List<String> zoneTypes;
+
+    /** 空间 id */
+    private List<String> spaceIds;
+
+    /** 空间功能区类型 */
+    private List<String> funcTypes;
+
+    /** 楼层 id */
+    private String floorId;
+
+    /** 建筑 id */
+    private String buildingId;
+
+}

+ 8 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmBaseService.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.service;
 
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -45,4 +46,11 @@ public interface IAdmBaseService<T> {
      * @return
      */
     void doDelete(InstanceUrlParam context, List<T> voList);
+
+    /**
+     * 根据物理世界对象查询条件查询
+     * @param request
+     * @return
+     */
+    AdmResponse doQuery(InstanceUrlParam context, QueryCriteria request, Class<T> clazz);
 }

+ 32 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmPlanarService.java

@@ -0,0 +1,32 @@
+package com.persagy.proxy.adm.service;
+
+import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmPlanarEquipRequests;
+import com.persagy.proxy.adm.model.AdmSpace;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+public interface IAdmPlanarService {
+
+
+    /**
+     * 查询平面图设备信息
+     * @param context
+     * @param requests
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    AdmResponse queryPlanarEquip(InstanceUrlParam context , AdmPlanarEquipRequests requests,Class<AdmEquipment> clazz) throws Exception;
+
+    /**
+     * 查询平面图空间信息
+     * @param context
+     * @param requests
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    AdmResponse queryPlanarSpace(InstanceUrlParam context , AdmPlanarEquipRequests requests,Class<AdmSpace> clazz) throws Exception;
+
+}

+ 28 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -370,4 +370,32 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
             throw new RuntimeException("调用中台查询接口出错:" + response.getMessage());
         }
     }
+
+    /**
+     * 根据物理世界查询条件查询对象信息
+     * @param context
+     * @param dmpRequest
+     * @param clazz
+     * @return
+     */
+    @Override
+    public AdmResponse doQuery(InstanceUrlParam context, QueryCriteria dmpRequest, Class<T> clazz) {
+        // 转换参数
+        JSONObject para = null;
+        try {
+            para = JsonHelper.toJSONObject(dmpRequest);
+        } catch (IOException e) {
+            log.error(e.getMessage(), e);
+            return null;
+        }
+        // 调用中台查询
+        DmpResult<JSONArray> dmpResult = rwdClient.queryObject(context, para);
+       // List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.getData(), null, clazz);
+        // 设置返回值
+        AdmResponse response = AdmResponse.success((List<T>)dmpResult.getData());
+        Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
+        response.setTotal(total);
+        return response;
+    }
+
 }

+ 213 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AdmLabslServiceImpl.java

@@ -0,0 +1,213 @@
+package com.persagy.proxy.adm.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
+import com.persagy.proxy.adm.model.*;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.*;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @ClassName AdmLabslServiceImpl
+ * @Description: 蜡笔森林定制接口
+ * @Author linhuili
+ * @Date 2021/9/17 20:01
+ * @Version V1.0
+ **/
+@Slf4j
+@Service
+public class AdmLabslServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> implements IAdmLabslService<T>{
+
+    @Autowired
+    private IAdmBuildingService buildingService;
+
+    @Autowired
+    private IAdmEquipmentService equipmentService;
+
+    /**
+     * 查询项目下的设备类型
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public AdmResponse queryCategory(InstanceUrlParam context , Class<T> clazz) throws Exception {
+
+        List<AdmObjectInfo> result = new ArrayList<>();
+        QueryCriteria criteria = new QueryCriteria();
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        //查询所有的专业
+        node.put("type",AdmDictCategoryEnum.MAJOR.getValue());
+        criteria.setCriteria(node);
+        AdmResponse majorResonse = doQueryDictData(context, criteria, clazz);
+
+        if(CollUtil.isNotEmpty(majorResonse.getContent())){
+            List<AdmObjectInfo> content = (List<AdmObjectInfo>) majorResonse.getContent();
+            result.addAll(content);
+        }
+
+        //查询所有的系统,设备类
+        List<String> objTypes = new ArrayList<>();
+        objTypes.add(AdmDictCategoryEnum.SYSTEM.getValue());
+        objTypes.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
+        node.put("objType",objTypes.toString());
+        criteria.setCriteria(node);
+        AdmResponse equipResponse = doQueryObjectType(context, criteria, clazz);
+
+        if(CollUtil.isNotEmpty(equipResponse.getContent())){
+            List<AdmObjectInfo> content = (List<AdmObjectInfo>) equipResponse.getContent();
+            result.addAll(content);
+        }
+        return AdmResponse.success(result);
+    }
+
+    /**
+     * 查询项目下的空间类型
+     * @param context
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public AdmResponse queryZoneType(InstanceUrlParam context, Class<T> clazz) throws Exception {
+        QueryCriteria criteria = new QueryCriteria();
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+
+        //查询所有的空间类型
+        List<String> objTypes = new ArrayList<>();
+        objTypes.add(AdmDictCategoryEnum.SPACE.getValue());
+        node.put("objType",objTypes.toString());
+        criteria.setCriteria(node);
+        AdmResponse response = doQueryObjectType(context, criteria, clazz);
+
+        List<AdmObjectInfo> content = (List<AdmObjectInfo>) response.getContent();
+        return AdmResponse.success(content);
+    }
+
+    /**
+     * 查询项目下的建筑楼层
+     * @param context
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public AdmResponse queryBuildFloor(InstanceUrlParam context, Class<T> clazz) throws Exception {
+        List<AdmBuilding> admBuildings = new ArrayList<>();
+        //添加未明确建筑
+        AdmBuilding admBuilding = new AdmBuilding();
+        admBuilding.setId("fisnull");
+        admBuilding.setName("未明确建筑");
+        admBuilding.setLocalName("未明确建筑");
+
+        //添加未明确楼层
+        ArrayList<AdmFloor> admFloors = new ArrayList<>();
+        AdmFloor admFloor = new AdmFloor();
+        admFloor.setId("fisnull");
+        admFloor.setName("未明确楼层");
+        admFloor.setLocalName("未明确楼层");
+        admFloors.add(admFloor);
+
+        //获取项目下的建筑,建筑下的楼层
+        AdmQueryCriteria request = new AdmQueryCriteria();
+        request.setName(AdmBuilding.OBJ_TYPE);
+
+        //设置建筑->楼层级联查询参数
+        AdmQueryCriteria cascade = new AdmQueryCriteria();
+        cascade.setName(AdmFloor.OBJ_TYPE);
+        List<AdmQueryCriteria> cascadeList = new ArrayList<>();
+        cascadeList.add(cascade);
+        request.setCascade(cascadeList);
+
+        AdmResponse buildResponse = buildingService.doQuery(context, request, AdmBuilding.class);
+        if(CollUtil.isEmpty(buildResponse.getContent())){
+            admBuildings.add(admBuilding);
+            return AdmResponse.success((List<JSONObject>)admBuilding);
+        }
+
+        //建筑下的楼层添加默认"未明确楼层"
+        List<AdmBuilding> buildContent = (List<AdmBuilding>)buildResponse.getContent();
+        buildContent.add(admBuilding);
+        for (AdmBuilding building : buildContent) {
+            List<AdmFloor> floor = building.getFloor();
+            floor.add(admFloor);
+        }
+        return AdmResponse.success(buildContent);
+    }
+
+    /**
+     * 根据设备id统计设备所属的专业
+     * @param context
+     * @param ids
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public AdmResponse queryMajorCategory(InstanceUrlParam context, List<String> ids, Class<T> clazz) throws Exception {
+
+        //根据id查询对应的设备类型
+        AdmQueryCriteria request = new AdmQueryCriteria();
+        request.setName(AdmEquipment.OBJ_TYPE);
+        request.setFilters("id in " + ids);
+        AdmResponse equipResponse = equipmentService.doQuery(context, request, AdmEquipment.class);
+        if(CollUtil.isEmpty(equipResponse.getContent())){
+            throw new Exception("设备不存在");
+        }
+        List<AdmEquipment> equipments = (List<AdmEquipment>)equipResponse.getContent();
+        Set<String> classCodes = equipments.stream().map(k -> k.getClassCode()).collect(Collectors.toSet());
+
+        //根据设备类型查询设备所属专业
+        QueryCriteria dictCriteria = new QueryCriteria();
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("code",classCodes.toString());
+        dictCriteria.setCriteria(node);
+        AdmResponse dictResponse = doQueryObjectType(context, dictCriteria, clazz);
+        if(CollUtil.isEmpty(dictResponse.getContent())){
+            throw new Exception("项目下没有设备类型");
+        }
+
+        //获取设备类对应的专业编码
+        List<AdmObjectType> classCodeList = (List<AdmObjectType>)dictResponse.getContent();
+        Map<String, List<AdmObjectType>> classCodeMap = classCodeList.stream().collect(Collectors.groupingBy(k->k.getMajorCode()));
+
+        Set<String> majors = classCodeList.stream().map(k -> k.getMajorCode()).collect(Collectors.toSet());
+        if(CollUtil.isEmpty(majors)){
+            return AdmResponse.success(new ArrayList<>());
+        }
+
+        //查询字典中的专业
+        QueryCriteria criteria = new QueryCriteria();
+        ObjectNode majorNode = JsonNodeFactory.instance.objectNode();
+        majorNode.put("type",AdmDictCategoryEnum.MAJOR.getValue());
+        criteria.setCriteria(majorNode);
+        AdmResponse majorResonse = doQueryDictData(context, criteria, clazz);
+        List<AdmObjectType> dictMajorList = (List<AdmObjectType>)majorResonse.getContent();
+        Map<String, List<AdmObjectType>> dictMajorMap = dictMajorList.stream().collect(Collectors.groupingBy(k->k.getCode()));
+
+        List<AdmObjectType> result = new ArrayList<>();
+        //组装成专业-设备类返回结果
+        for (String major : majors) {
+            List<AdmObjectType> objectTypes = dictMajorMap.get(major);
+            if(CollUtil.isNotEmpty(objectTypes)){
+                AdmObjectType objectType = objectTypes.get(0);
+                objectType.setChildren(classCodeMap.get(major));
+                result.add(objectType);
+            }
+        }
+        return AdmResponse.success(result);
+    }
+
+}

+ 219 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AdmPlanarServiceImpl.java

@@ -0,0 +1,219 @@
+package com.persagy.proxy.adm.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmPlanarEquipRequests;
+import com.persagy.proxy.adm.model.AdmSpace;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmEquipmentService;
+import com.persagy.proxy.adm.service.IAdmPlanarService;
+import com.persagy.proxy.adm.service.IAdmSpaceService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+/**
+ * @ClassName AdmPlanarServiceImpl
+ * @Description: 平面图接口
+ * @Author linhuili
+ * @Date 2021/9/22 14:17
+ * @Version V1.0
+ **/
+@Service
+public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implements IAdmPlanarService {
+
+    @Autowired
+    private IAdmSpaceService spaceService;
+
+    @Autowired
+    private IAdmEquipmentService equipmentService;
+    
+    /**
+     * 查询平面图设备信息
+     * @param context
+     * @param requests
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public AdmResponse queryPlanarEquip(InstanceUrlParam context, AdmPlanarEquipRequests requests, Class<AdmEquipment> clazz) throws Exception {
+        List<AdmSpace> spaces = new ArrayList<>();
+        //获取空间信息
+        if(CollUtil.isEmpty(requests.getSpaceIds())){
+            //查询建筑/楼层下的空间信息
+            spaces = querySpInFl(context, requests, AdmSpace.class);
+        }else{
+            //根据空间功能类型等过滤空间信息
+            spaces = queryDmpSpace(context, requests, AdmSpace.class);
+        }
+        if(CollUtil.isEmpty(spaces)){
+            return AdmResponse.success(new ArrayList<>());
+        }
+        List<String> spaceIds = spaces.stream().map(k -> k.getId()).collect(Collectors.toList());
+        requests.setSpaceIds(spaceIds);
+        //查询空间下的设备
+        List<AdmEquipment> result = queryEqInSp(context, requests, AdmEquipment.class);
+        AdmResponse response = AdmResponse.success(result);
+        response.setTotal(result == null ? 0 : Long.valueOf(result.size()));
+        return response;
+    }
+
+    /**
+     * 查询平面图空间
+     * @param context
+     * @param requests
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public AdmResponse queryPlanarSpace(InstanceUrlParam context, AdmPlanarEquipRequests requests, Class<AdmSpace> clazz) throws Exception {
+        List<AdmSpace> spaces = new ArrayList<>();
+        //获取空间信息
+        if(CollUtil.isEmpty(requests.getSpaceIds())){
+            //查询建筑/楼层下的空间信息
+            spaces = querySpInFl(context, requests, AdmSpace.class);
+        }else{
+            //根据空间功能类型等过滤空间信息
+            spaces = queryDmpSpace(context, requests, AdmSpace.class);
+        }
+        AdmResponse response = AdmResponse.success(spaces);
+        response.setTotal(spaces == null ? 0 : Long.valueOf(spaces.size()));
+        return response;
+    }
+
+    /**
+     * 查询楼层下的空间
+     * @param context
+     * @param requests
+     * @return
+     */
+    private List<AdmSpace> querySpInFl(InstanceUrlParam context, AdmPlanarEquipRequests requests, Class<AdmSpace> clazz){
+
+        //设置空间基础查询条件
+        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+        if(CollUtil.isNotEmpty(requests.getZoneTypes())){
+            ArrayNode array = criteria.putObject("objType").putArray("$in");
+            requests.getZoneTypes().forEach(code -> array.add(code));
+        }
+
+        if(CollUtil.isNotEmpty(requests.getFuncTypes())){
+            ArrayNode array = criteria.putObject("roomFuncType").putArray("$in");
+            requests.getFuncTypes().forEach(code -> array.add(code));
+        }
+        if(CollUtil.isNotEmpty(requests.getEquipTypes())){
+            ArrayNode array = criteria.putObject("classCode").putArray("$in");
+            requests.getEquipTypes().forEach(code -> array.add(code));
+        }
+
+        //设置空间关系查询条件
+        QueryCriteria dmpRequest = new QueryCriteria();
+        if(StringUtils.isEmpty(requests.getFloorId())){
+            dmpRequest = transDmpRelationCriteria(criteria,"ArchSubset", "Bd2Sp", requests.getBuildingId(), 0);
+        }else{
+            dmpRequest = transDmpRelationCriteria(criteria,"ArchSubset", "Fl2Sp", requests.getFloorId(), 0);
+        }
+
+        //查询物理世界空间信息
+        AdmResponse response = spaceService.doQuery(context, dmpRequest, clazz);
+        return (List<AdmSpace>)response.getContent();
+    }
+
+    /**
+     * 查询空间下的设备
+     * @param context
+     * @param requests
+     * @param clazz
+     * @return
+     */
+    private List<AdmEquipment> queryEqInSp(InstanceUrlParam context,AdmPlanarEquipRequests requests,Class<AdmEquipment> clazz){
+        List<String> spaceIds = requests.getSpaceIds();
+        if(CollUtil.isEmpty(spaceIds)){
+            return new ArrayList<>();
+        }
+        //默认业务空间数量不会太多,若多的话后期进行优化
+        List<AdmEquipment> result = new ArrayList<>();
+        for (String spaceId : spaceIds) {
+            ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+            //设置设备关系查询条件
+            QueryCriteria dmpRequest = transDmpRelationCriteria(criteria,"MechInArch", "Eq2Sp", spaceId, 1);
+            //查询物理世界对象信息
+            AdmResponse response = equipmentService.doQuery(context, dmpRequest, clazz);
+            List<AdmEquipment> content = (List<AdmEquipment>) response.getContent();
+            if(CollUtil.isNotEmpty(content)){
+                result.addAll(content);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 查询中台空间信息
+     * @param context
+     * @param requests
+     * @return
+     */
+    private List<AdmSpace> queryDmpSpace(InstanceUrlParam context, AdmPlanarEquipRequests requests, Class<AdmSpace> clazz){
+        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+        if(CollUtil.isNotEmpty(requests.getSpaceIds())){
+            ArrayNode array = criteria.putObject("id").putArray("$in");
+            requests.getZoneTypes().forEach(code -> array.add(code));
+        }
+        if(CollUtil.isNotEmpty(requests.getFuncTypes())){
+            ArrayNode array = criteria.putObject("roomFuncType").putArray("$in");
+            requests.getFuncTypes().forEach(code -> array.add(code));
+        }
+        if(CollUtil.isNotEmpty(requests.getZoneTypes())){
+            ArrayNode array = criteria.putObject("objType").putArray("$in");
+            requests.getZoneTypes().forEach(code -> array.add(code));
+        }
+        if(CollUtil.isNotEmpty(requests.getEquipTypes())){
+            ArrayNode array = criteria.putObject("classCode").putArray("$in");
+            requests.getEquipTypes().forEach(code -> array.add(code));
+        }
+        QueryCriteria dmpRequest = new QueryCriteria();
+        dmpRequest.setCriteria(criteria);
+
+        //查询物理世界空间信息
+        AdmResponse response = spaceService.doQuery(context, dmpRequest, clazz);
+        return (List<AdmSpace>)response.getContent();
+    }
+
+    /**
+     * 获取关系查询条件
+     * @param graphCode
+     * @param relCode
+     * @param id (fromID/targetID)
+     * @param direct  0 正向 1反向
+     * @return
+     */
+    public static QueryCriteria transDmpRelationCriteria(ObjectNode objectNode,String graphCode, String relCode, String id, Integer direct){
+        QueryCriteria queryCriteria = new QueryCriteria();
+
+        ObjectNode object = JsonNodeFactory.instance.objectNode();
+        object.put("graphCode", graphCode);
+        object.put("relCode", relCode);
+        if(direct == 0){
+            //正向查询 objFrom->objTo
+            object.put("objFrom", id);
+            objectNode.put("relationTo",object);
+        }else{
+            //反向查询 objTo->objFrom
+            object.put("objTo", id);
+            objectNode.put("relationFrom",object);
+        }
+        queryCriteria.setCriteria(objectNode);
+        return queryCriteria;
+    }
+
+}