ソースを参照

添加部分关系接口

luoguangyi 3 年 前
コミット
b5c0795edf

+ 160 - 0
src/main/java/com/persagy/proxy/adm/controller/RelationEqInShController.java

@@ -0,0 +1,160 @@
+package com.persagy.proxy.adm.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+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.AdmCommonConstant;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.common.entity.RelationDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description:020、关系-设备所在竖井
+ * @author:lgy
+ * @data:2021/9/13 10:00
+ */
+@RequestMapping("/rel/eq-in-sh")
+@RestController
+public class RelationEqInShController {
+    @Autowired
+    private IAdmRelationService service;
+    @Value("${middleware.group.code}")
+    private String groupCode;
+    /**
+     * 创建设备所在竖井关系,累计添加不会覆盖以前记录
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = {"/link"})
+    public AdmResponse create(@RequestParam("projectId") String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        String equipId = param.getString("equipId");
+        String shaftId = param.getString("shaftId");
+        if(!StrUtil.isAllNotEmpty(equipId,shaftId)) {
+            return AdmResponse.failure("必填项:EquipId(设备id)、ShaftId(竖井id)");
+        }
+        // 创建关系对象  EquipinShaft
+        List<RelationDTO> voList = new ArrayList<>();
+        voList.add(new RelationDTO(null, "MechInArch", "Eq2Sh", null, equipId , shaftId));
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+    /**
+     * 根据对象删除设备所在竖井关系,只针对一个对象
+     * @param   param      对象
+     * @return             删除的结果信息
+     */
+
+    @PostMapping("/unlink")
+    public AdmResponse delete(@RequestParam String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        if(CollUtil.isEmpty(param)) {
+            return AdmResponse.success();
+        }
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 组装条件
+        QueryCriteria criteria = new QueryCriteria();
+        String equipId = param.getString("equipId");
+        String shaftId = param.getString("shaftId");
+        if(!StrUtil.isAllNotEmpty(equipId,shaftId)) {
+            return AdmResponse.failure("必填项:EquipId(设备id)、shaftId(竖井id)");
+        }
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("graphCode", "MechInArch");
+        node.put("relCode", "Eq2Sh");
+        node.put("objFrom", equipId);
+        node.put("objTo",shaftId);
+        criteria.setCriteria(node);
+        service.doDelete(context, criteria);
+        return AdmResponse.success();
+    }
+    /**
+     * 设备所在竖井,设备一对多,此方法会覆盖以前的记录
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/link-sh")
+    public AdmResponse createSh(@RequestParam("projectId") String projectId,
+                                @RequestBody JSONObject param) throws Exception {
+        String equipId = param.getString("equipId");
+        JSONArray shaftIdList = param.getJSONArray("shaftIdList");
+        if(StrUtil.isBlank(equipId) || CollUtil.isEmpty(shaftIdList)) {
+            return AdmResponse.failure("必填项:EquipId(设备id)、ShaftIdList(竖井id列表),此方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < shaftIdList.size();i++) {
+            String shaftId = shaftIdList.getString(i);
+            if(StrUtil.isBlank(shaftId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", "MechInArch");
+            node.put("relCode", "Eq2Sh");
+            node.put("objFrom", equipId);
+            node.put("objTo", shaftId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "MechInArch", "Eq2Sh", null, equipId, shaftId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+    /**
+     * 所在竖井的设备,竖井一对多,此方法会覆盖以前的记录
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = {"/link-eq","/link-eq-sh"})
+    public AdmResponse createEq(@RequestParam("projectId") String projectId,
+                                @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        JSONArray equipIdList = param.getJSONArray("shaftIdList");
+        if(StrUtil.isBlank(shaftId) || CollUtil.isEmpty(equipIdList)) {
+            return AdmResponse.failure("必填项:EquipIdList(设备id列表)、ShaftId(竖井id),此方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < equipIdList.size();i++) {
+            String equipId = equipIdList.getString(i);
+            if(StrUtil.isBlank(shaftId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", "MechInArch");
+            node.put("relCode", "Eq2Sh");
+            node.put("objFrom", equipId);
+            node.put("objTo", shaftId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "MechInArch", "Eq2Sh", null, equipId, shaftId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+}

+ 164 - 0
src/main/java/com/persagy/proxy/adm/controller/RelationFlThroughFlController.java

@@ -0,0 +1,164 @@
+package com.persagy.proxy.adm.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+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.AdmCommonConstant;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.common.entity.RelationDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description: 021关系-楼层的贯通
+ * @author:lgy
+ * @data:2021/9/13 11:02
+ */
+@RestController
+@RequestMapping("/rel/fl-through-fl")
+public class RelationFlThroughFlController {
+    @Autowired
+    private IAdmRelationService service;
+    @Value("${middleware.group.code}")
+    private String groupCode;
+    /**
+     * 创建楼层的贯通关系
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = {"/link"})
+    public AdmResponse create(@RequestParam("projectId") String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        String floorId = param.getString("floorId");
+        String floorOtherId = param.getString("floorOtherId");
+        if(!StrUtil.isAllNotEmpty(floorId,floorOtherId)) {
+            return AdmResponse.failure("必填项:FloorId(楼层id)、FloorOtherId(其他楼层id)");
+        }
+        // 创建关系对象
+        List<RelationDTO> voList = new ArrayList<>();
+        voList.add(new RelationDTO(null, "ThroughRelationship", "Fl2Fl", null, floorId , floorOtherId));
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+    /**
+     * 根据对象删除关系
+     * 根据对象删除楼层的贯通关系,只针对一个对象
+     * @param   param      对象
+     * @return             删除的结果信息
+     */
+
+    @PostMapping("/unlink")
+    public AdmResponse delete(@RequestParam String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        if(CollUtil.isEmpty(param)) {
+            return AdmResponse.success();
+        }
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 组装条件
+        QueryCriteria criteria = new QueryCriteria();
+        String floorId = param.getString("floorId");
+        String floorOtherId = param.getString("floorOtherId");
+        if(!StrUtil.isAllNotEmpty(floorId,floorOtherId)) {
+            return AdmResponse.failure("必填项:FloorId(楼层id)、FloorOtherId(其他楼层id)");
+        }
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("graphCode", "ThroughRelationship");
+        node.put("relCode", "Fl2Fl");
+        node.put("objFrom", floorId);
+        node.put("objTo",floorOtherId);
+        criteria.setCriteria(node);
+        service.doDelete(context, criteria);
+        return AdmResponse.success();
+    }
+    /**
+     * 创建楼层的贯通关系
+     * 楼层的贯通,楼层一对多
+     * @param param 楼层和其他楼层列表关系对象r
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/link-or")
+    public AdmResponse createFloorOtherIdList(@RequestParam("projectId") String projectId,
+                                @RequestBody JSONObject param) throws Exception {
+        String floorId = param.getString("floorId");
+        JSONArray floorOtherIdList = param.getJSONArray("floorOtherIdList");
+        if(StrUtil.isBlank(floorId) || CollUtil.isEmpty(floorOtherIdList)) {
+            return AdmResponse.failure("必填项:FloorId(楼层id)、FloorOtherIdList(其他楼层id列表),测方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < floorOtherIdList.size();i++) {
+            String floorOtherId = floorOtherIdList.getString(i);
+            if(StrUtil.isBlank(floorOtherId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", "ThroughRelationship");
+            node.put("relCode", "Fl2Fl");
+            node.put("objFrom", floorId);
+            node.put("objTo", floorOtherId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "ThroughRelationship", "Fl2Fl", null, floorId, floorOtherId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 楼层的贯通,其他楼层一对多
+     * @param param 楼层和其他楼层列表关系对象r
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/link-fl")
+    public AdmResponse createFloorIdList(@RequestParam("projectId") String projectId,
+                                              @RequestBody JSONObject param) throws Exception {
+        String floorOtherId = param.getString("floorOtherId");
+        JSONArray floorIdList = param.getJSONArray("floorIdList");
+        if(StrUtil.isBlank(floorOtherId) || CollUtil.isEmpty(floorIdList)) {
+            return AdmResponse.failure("必填项:FloorIdList(楼层id列表)、FloorOtherId(其他楼层id),测方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < floorIdList.size();i++) {
+            String floorId = floorIdList.getString(i);
+            if(StrUtil.isBlank(floorId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", "ThroughRelationship");
+            node.put("relCode", "Fl2Fl");
+            node.put("objFrom", floorId);
+            node.put("objTo", floorOtherId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "ThroughRelationship", "Fl2Fl", null, floorId, floorOtherId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+}

+ 317 - 0
src/main/java/com/persagy/proxy/adm/controller/RelationShContainSpBaseController.java

@@ -0,0 +1,317 @@
+package com.persagy.proxy.adm.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+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.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.dto.RequestData;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.helper.SpringHelper;
+import com.persagy.dmp.digital.client.DigitalObjectFacade;
+import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.constant.AdmObjectType;
+import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmDictService;
+import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.common.client.DmpRwdClient;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.common.entity.RelationDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @description:023、关系-竖井下的业务空间
+ * @author:lgy
+ * @data:2021/9/13 14:49
+ */
+@RestController
+@RequestMapping("/rel/sh-contain-sp-base")
+public class RelationShContainSpBaseController {
+
+    @Autowired
+    private IAdmRelationService service;
+    @Autowired
+    DmpRwdClient rwdClient;
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    /**
+     * 默认图类型
+     */
+    public static String DEFAULT_GRAPH_CODE = "ArchSubset";
+    /**
+     * 默认边类型
+     */
+    public static String DEFAULT_REL_CODE = "Sh2Sp";
+
+    /**
+     * 创建竖井下的业务空间关系
+     * @param param 竖井和业务空间的关系对象
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = {"/link"})
+    public AdmResponse create(@RequestParam("projectId") String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        String spaceId = param.getString("spaceId");
+        String type = param.getString("objectType");
+        if(!StrUtil.isAllNotEmpty(shaftId,spaceId)) {
+            return AdmResponse.failure("必填项:ShaftID(竖井id)、SpaceID(业务空间id)");
+        }
+        // 创建关系对象
+        List<RelationDTO> voList = new ArrayList<>();
+        voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, type, shaftId , spaceId));
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 根据对象删除关系
+     *根据对象删除竖井下的业务空间关系,只针对一个对象
+     * @param    param    对象
+     * @param   type                 空间类型
+     * @return                       删除的结果信息
+     */
+    @PostMapping("/unlink")
+    public AdmResponse delete(@RequestParam String projectId,
+                              @RequestParam(value = "type", required = false) String type,
+                              @RequestBody JSONObject param) throws Exception {
+        if(CollUtil.isEmpty(param)) {
+            return AdmResponse.success();
+        }
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 组装条件
+        QueryCriteria criteria = new QueryCriteria();
+        String shaftId = param.getString("shaftId");
+        String spaceId = param.getString("spaceId");
+        if(!StrUtil.isAllNotEmpty(shaftId,spaceId)) {
+            return AdmResponse.failure("必填项:ShaftID(竖井id)、SpaceID(业务空间id)");
+        }
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("graphCode", DEFAULT_GRAPH_CODE);
+        node.put("relCode", DEFAULT_REL_CODE);
+        node.put("relValue", type);
+        node.put("objFrom", shaftId);
+        node.put("objTo",spaceId);
+        criteria.setCriteria(node);
+        service.doDelete(context, criteria);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 创建竖井下的业务空间关系
+     *
+     * @param   param     竖井和业务空间的关系对象
+     * @param   type                 空间类型
+     * @return                       创建的结果信息
+     */
+    @PostMapping("/link-shsps")
+    public AdmResponse createShsps(@RequestParam("projectId") String projectId,
+                                @RequestParam(value = "type", required = false) String type,
+                                @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        JSONArray spaceIdList = param.getJSONArray("spaceIdList");
+        if(StrUtil.isBlank(shaftId) || CollUtil.isEmpty(spaceIdList)) {
+            return AdmResponse.failure("必填项:SpaceIdList(业务空间id列表)、ShaftID(竖井id),此方法不会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < spaceIdList.size();i++) {
+            String spaceId = spaceIdList.getString(i);
+            if(StrUtil.isBlank(spaceId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", DEFAULT_GRAPH_CODE);
+            node.put("relCode", DEFAULT_REL_CODE);
+            node.put("relValue", type);
+            node.put("objFrom", shaftId);
+            node.put("objTo", spaceId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, type, shaftId, spaceId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 竖井下的业务空间,空间一对多
+     *
+     * @param   param     竖井和业务空间的关系对象
+     * @param   type                 空间类型
+     * @return                       创建的结果信息
+     */
+    @PostMapping("/link-spshs")
+    public AdmResponse createSpshs(@RequestParam("projectId") String projectId,
+                                   @RequestParam(value = "type", required = false) String type,
+                                   @RequestBody JSONObject param) throws Exception {
+        String spaceId = param.getString("spaceId");
+        JSONArray shaftIdList = param.getJSONArray("shaftIdList");
+        if(StrUtil.isBlank(spaceId) || CollUtil.isEmpty(shaftIdList)) {
+            return AdmResponse.failure("必填项:SpaceId(业务空间id)、ShaftIDList(竖井id列表)");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < shaftIdList.size();i++) {
+            String shaftId = shaftIdList.getString(i);
+            if(StrUtil.isBlank(shaftId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", DEFAULT_GRAPH_CODE);
+            node.put("relCode", DEFAULT_REL_CODE);
+            node.put("relValue", type);
+            node.put("objFrom", shaftId);
+            node.put("objTo", spaceId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, type, shaftId, spaceId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 创建竖井下的业务空间,竖井一对多,此方法会覆盖以前的记录
+     *
+     * @param   param     竖井和业务空间的关系对象
+     * @param   type                 空间类型
+     * @return                       创建的结果信息
+     */
+    @PostMapping("/link-shsps-replace")
+    public AdmResponse createShSpsReplace(@RequestParam("projectId") String projectId,
+                                   @RequestParam(value = "Type", required = false) String type,
+                                   @RequestParam(value = "BuildingId", required = false) String buildingId,
+                                   @RequestParam(value = "FloorId", required = false) String floorId,
+                                   @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        JSONArray spaceIdList = param.getJSONArray("spaceIdList");
+        if(StrUtil.isBlank(shaftId) || CollUtil.isEmpty(spaceIdList)) {
+            return AdmResponse.failure("必填项:SpaceIdList(业务空间id列表)、ShaftID(竖井id),此方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        RequestData requestData = RequestData.builder().buildingId(buildingId).classCode(type).floorId(floorId).projectId(projectId).objType(AdmDictCategoryEnum.SPACE.getValue()).build();
+        QueryCriteria queryRequestTmp = new QueryCriteria();
+        ObjectNode nodeTmp = JsonNodeFactory.instance.objectNode();
+        nodeTmp.put("graphCode", DEFAULT_GRAPH_CODE);
+        nodeTmp.put("relCode", DEFAULT_REL_CODE);
+        nodeTmp.put("relValue", type);
+        nodeTmp.put("objFrom", shaftId);
+        queryRequestTmp.setCriteria(nodeTmp);
+        //关系查询空间id
+        Set<String> oldSpaceIds = service.queryByCondition(context,queryRequestTmp).stream().map(ObjectRelation::getObjTo).collect(Collectors.toSet());
+        List<ObjectDigital> objectDigitals = DigitalObjectFacade.queryObjectListSuperiorId(groupCode, projectId, AdmCommonConstant.APP_ID, null, requestData);
+        //楼层、建筑、对象类查询的空间id
+        Set<String> spaceIdSet = objectDigitals.stream().map(ObjectDigital::getId).collect(Collectors.toSet());
+        //空间id取交集
+        if(ObjectUtil.isNotEmpty(oldSpaceIds)){
+            spaceIdSet.retainAll(oldSpaceIds);
+        }
+        //删除空间关系
+        for (String oldSpaceId : spaceIdSet) {
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", DEFAULT_GRAPH_CODE);
+            node.put("relCode", DEFAULT_REL_CODE);
+            node.put("relValue", type);
+            node.put("objFrom", shaftId);
+            node.put("objTo", oldSpaceId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+        }
+        //替换空间关系
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < spaceIdList.size();i++) {
+            String spaceId = spaceIdList.getString(i);
+            if(StrUtil.isBlank(spaceId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", DEFAULT_GRAPH_CODE);
+            node.put("relCode", DEFAULT_REL_CODE);
+            node.put("relValue", type);
+            node.put("objFrom", shaftId);
+            node.put("objTo", spaceId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, type, shaftId, spaceId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 查询空间类型和名称
+     * @param projectId projectId
+     * @param shaftId shaftId 竖井id
+     * @param param param
+     * @return {@link AdmResponse}
+     * @author lgy
+     * @date 2021/9/23 18:37
+     */
+    @PostMapping("/space-type-query")
+    public AdmResponse spaceTypeQuery(@RequestParam String projectId,
+                              @RequestParam(value = "shaftId", required = false) String shaftId,
+                              @RequestBody JSONObject param) throws Exception {
+
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 组装条件
+        QueryCriteria queryRequestTmp = new QueryCriteria();
+        ObjectNode nodeTmp = JsonNodeFactory.instance.objectNode();
+        nodeTmp.put("graphCode", DEFAULT_GRAPH_CODE);
+        nodeTmp.put("relCode", DEFAULT_REL_CODE);
+        nodeTmp.put("objFrom", shaftId);
+        queryRequestTmp.setCriteria(nodeTmp);
+        //关系查询空间id
+        Set<String> relValue = service.queryByCondition(context,queryRequestTmp).stream().map(ObjectRelation::getRelValue).collect(Collectors.toSet());
+        JSONObject queryCriteria = new JSONObject();
+        JSONObject criteria = new JSONObject();
+        criteria.put("code",relValue);
+        queryCriteria.put("criteria",criteria);
+        JSONArray dmpResult = rwdClient.queryDefClass(context, queryCriteria).getData(JSONArray.class);
+        JSONArray result = new JSONArray();
+        for (int i = 0; i < dmpResult.size(); i++) {
+            JSONObject defClass = dmpResult.getJSONObject(i);
+            JSONObject temp = new JSONObject();
+            temp.put("objectType",defClass.getString("code"));
+            temp.put("objectTypeName",defClass.getString("name"));
+            result.add(temp);
+        }
+        return AdmResponse.success(result);
+    }
+}

+ 163 - 0
src/main/java/com/persagy/proxy/adm/controller/RelationShaftThroughShaftController.java

@@ -0,0 +1,163 @@
+package com.persagy.proxy.adm.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+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.AdmCommonConstant;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.common.entity.RelationDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description:022、关系-竖井的贯通关系
+ * @author:lgy
+ * @data:2021/9/13 13:06
+ */
+@RestController
+@RequestMapping("/rel/sh-through-sh")
+public class RelationShaftThroughShaftController {
+    @Autowired
+    private IAdmRelationService service;
+    @Value("${middleware.group.code}")
+    private String groupCode;
+    /**
+     * 创建竖井的贯通关系
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = {"/link"})
+    public AdmResponse create(@RequestParam("projectId") String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        String shaftOtherId = param.getString("shaftOtherId");
+        if(!StrUtil.isAllNotEmpty(shaftId,shaftOtherId)) {
+            return AdmResponse.failure("必填项:ShaftId(竖井id)、ShaftOtherId(其他竖井id)");
+        }
+        // 创建关系对象
+        List<RelationDTO> voList = new ArrayList<>();
+        voList.add(new RelationDTO(null, "ThroughRelationship", "Sh2Sh", null, shaftId , shaftOtherId));
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+    /**
+     * 根据对象删除关系
+     * 根据对象删除竖井的贯通关系,只针对一个对象
+     * @param   param      对象
+     * @return             删除的结果信息
+     */
+
+    @PostMapping("/unlink")
+    public AdmResponse delete(@RequestParam String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        if(CollUtil.isEmpty(param)) {
+            return AdmResponse.success();
+        }
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 组装条件
+        QueryCriteria criteria = new QueryCriteria();
+        String shaftId = param.getString("shaftId");
+        String shaftOtherId = param.getString("shaftOtherId");
+        if(!StrUtil.isAllNotEmpty(shaftId,shaftOtherId)) {
+            return AdmResponse.failure("必填项:ShaftId(竖井id)、ShaftOtherId(其他数据竖井id)");
+        }
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("graphCode", "ThroughRelationship");
+        node.put("relCode", "Sh2Sh");
+        node.put("objFrom", shaftId);
+        node.put("objTo",shaftOtherId);
+        criteria.setCriteria(node);
+        service.doDelete(context, criteria);
+        return AdmResponse.success();
+    }
+    /**
+     * 创建竖井的贯通关系
+     * 竖井的贯通,竖井一对多,此方法会覆盖以前的记录
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/link-or")
+    public AdmResponse createFloorOtherIdList(@RequestParam("projectId") String projectId,
+                                              @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        JSONArray shaftOtherIdList = param.getJSONArray("shaftOtherIdList");
+        if(StrUtil.isBlank(shaftId) || CollUtil.isEmpty(shaftOtherIdList)) {
+            return AdmResponse.failure("必填项:ShaftId(竖井id)、ShaftOtherIdList(其他竖井id列表),此方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < shaftOtherIdList.size();i++) {
+            String shaftOtherId = shaftOtherIdList.getString(i);
+            if(StrUtil.isBlank(shaftOtherId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", "ThroughRelationship");
+            node.put("relCode", "Sh2Sh");
+            node.put("objFrom", shaftId);
+            node.put("objTo", shaftOtherId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "ThroughRelationship", "Sh2Sh", null, shaftId, shaftOtherId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 创建竖井的贯通关系
+     * 竖井的贯通,竖井一对多,此方法会覆盖以前的记录
+     * @param param 竖井和其他竖井列表关系对象r
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/link-shaft")
+    public AdmResponse createFloorIdList(@RequestParam("projectId") String projectId,
+                                         @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        JSONArray shaftOtherIdList = param.getJSONArray("shaftOtherIdList");
+        if(StrUtil.isBlank(shaftId) || CollUtil.isEmpty(shaftOtherIdList)) {
+            return AdmResponse.failure("必填项:ShaftId(竖井id)、ShaftOtherIdList(其他竖井id列表)");
+        }
+        // 创建关系对象.先删除,后添加
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < shaftOtherIdList.size();i++) {
+            String shaftOtherId = shaftOtherIdList.getString(i);
+            if(StrUtil.isBlank(shaftOtherId)) {
+                continue;
+            }
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", "ThroughRelationship");
+            node.put("relCode", "Sh2Sh");
+            node.put("objFrom", shaftId);
+            node.put("objTo", shaftOtherId);
+            queryRequest.setCriteria(node);
+            service.doDelete(context,queryRequest);
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "ThroughRelationship", "Sh2Sh", null, shaftId, shaftOtherId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+}