Sfoglia il codice sorgente

添加系统服务于建筑、楼层‘、竖井的关系接口

luoguangyi 3 anni fa
parent
commit
b4c27bc8b2

+ 0 - 2
src/main/java/com/persagy/proxy/adm/controller/RelationSyForBdController.java

@@ -74,12 +74,10 @@ public class RelationSyForBdController {
      * 根据对象删除关系
      * 根据对象删除系统服务于建筑的关系,只针对一个对象
      * @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();

+ 196 - 0
src/main/java/com/persagy/proxy/adm/controller/RelationSyForFlController.java

@@ -0,0 +1,196 @@
+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.dmp.digital.entity.ObjectRelation;
+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.client.DmpRwdClient;
+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:027、关系-系统服务于楼层
+ * @author:lgy
+ * @data:2021/9/26 10:04
+ */
+@RestController
+@RequestMapping("/rel/sy-for-fl")
+public class RelationSyForFlController {
+
+    @Autowired
+    private IAdmRelationService service;
+    @Autowired
+    DmpRwdClient rwdClient;
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    /**
+     * 默认图类型
+     */
+    public static String DEFAULT_GRAPH_CODE = "MechForArch";
+    /**
+     * 默认边类型
+     */
+    public static String DEFAULT_REL_CODE = "Sy2Fl";
+
+
+    /**
+     * 创建系统服务于楼层关系
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = {"/link"})
+    public AdmResponse create(@RequestParam("projectId") String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        String sysId = param.getString("sysId");
+        String floorId = param.getString("floorId");
+        if(!StrUtil.isAllNotEmpty(floorId,sysId)) {
+            return AdmResponse.failure("必填项:SysId(系统id)、FloorId(楼层id)");
+        }
+        // 创建关系对象
+        List<RelationDTO> voList = new ArrayList<>();
+        voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, null, sysId , floorId));
+        // 组装上下文条件
+        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 sysId = param.getString("sysId");
+        String floorId = param.getString("floorId");
+        if(!StrUtil.isAllNotEmpty(floorId,sysId)) {
+            return AdmResponse.failure("必填项:SysId(系统id)、FloorId(楼层id)");
+        }
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("graphCode", DEFAULT_GRAPH_CODE);
+        node.put("relCode", DEFAULT_REL_CODE);
+        node.put("objFrom", sysId);
+        node.put("objTo",floorId);
+        criteria.setCriteria(node);
+        service.doDelete(context, criteria);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 创建系统服务于楼层,系统一对多
+     * @param   param
+     * @return                       创建的结果信息
+     */
+    @PostMapping("/link-fl")
+    public AdmResponse createBd(@RequestParam("projectId") String projectId,
+                                @RequestBody JSONObject param) throws Exception {
+        String sysId = param.getString("sysId");
+        JSONArray floorIdList = param.getJSONArray("floorIdList");
+        if(StrUtil.isBlank(sysId) || CollUtil.isEmpty(floorIdList)) {
+            return AdmResponse.failure("必填项:FloorIdList(楼层id列表)、SysId(系统id),测方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        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", sysId);
+        queryRequestTmp.setCriteria(nodeTmp);
+        //关系之前的关系,并且删除
+        List<ObjectRelation> objectRelations = service.queryByCondition(context, queryRequestTmp);
+        for (ObjectRelation objectRelation : objectRelations) {
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", objectRelation.getGraphCode());
+            node.put("relCode", objectRelation.getRelCode());
+            node.put("relValue", objectRelation.getRelValue());
+            node.put("objFrom", objectRelation.getObjFrom());
+            node.put("objTo", objectRelation.getObjTo());
+            queryRequest.setCriteria(node);
+            service.doDelete(context, queryRequest);
+        }
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < floorIdList.size();i++) {
+            String floorId = floorIdList.getString(i);
+            if(StrUtil.isBlank(floorId)) {
+                continue;
+            }
+            voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, null, sysId, floorId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 创建服务于楼层的系统,楼层一对多
+     * @param   param
+     * @return                       创建的结果信息
+     */
+    @PostMapping("/link-sy")
+    public AdmResponse createSy(@RequestParam("projectId") String projectId,
+                                @RequestBody JSONObject param) throws Exception {
+        String floorId = param.getString("floorId");
+        JSONArray sysIdList = param.getJSONArray("sysIdList");
+        if(StrUtil.isBlank(floorId) || CollUtil.isEmpty(sysIdList)) {
+            return AdmResponse.failure("必填项:FloorId(楼层id)、sysIdList(系统id列表),测方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        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("objTo", floorId);
+        queryRequestTmp.setCriteria(nodeTmp);
+        //关系之前的关系,并且删除
+        List<ObjectRelation> objectRelations = service.queryByCondition(context, queryRequestTmp);
+        for (ObjectRelation objectRelation : objectRelations) {
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", objectRelation.getGraphCode());
+            node.put("relCode", objectRelation.getRelCode());
+            node.put("relValue", objectRelation.getRelValue());
+            node.put("objFrom", objectRelation.getObjFrom());
+            node.put("objTo", objectRelation.getObjTo());
+            queryRequest.setCriteria(node);
+            service.doDelete(context, queryRequest);
+        }
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < sysIdList.size();i++) {
+            String sysId = sysIdList.getString(i);
+            if(StrUtil.isBlank(sysId)) {
+                continue;
+            }
+            voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, null, sysId, floorId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+}

+ 192 - 0
src/main/java/com/persagy/proxy/adm/controller/RelationSyForShController.java

@@ -0,0 +1,192 @@
+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.dmp.digital.entity.ObjectRelation;
+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.client.DmpRwdClient;
+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:028、关系-系统服务于竖井
+ * @author:lgy
+ * @data:2021/9/26 10:19
+ */
+@RestController
+@RequestMapping("/rel/sy-for-sh")
+public class RelationSyForShController {
+
+    @Autowired
+    private IAdmRelationService service;
+    @Autowired
+    DmpRwdClient rwdClient;
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    /**
+     * 默认图类型
+     */
+    public static String DEFAULT_GRAPH_CODE = "MechForArch";
+    /**
+     * 默认边类型
+     */
+    public static String DEFAULT_REL_CODE = "Sy2Sh";
+
+    /**
+     * 创建系统服务于竖井关系
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = {"/link"})
+    public AdmResponse create(@RequestParam("projectId") String projectId,
+                              @RequestBody JSONObject param) throws Exception {
+        String sysId = param.getString("sysId");
+        String shaftId = param.getString("shaftId");
+        if(!StrUtil.isAllNotEmpty(shaftId,sysId)) {
+            return AdmResponse.failure("必填项:SysId(系统id)、ShaftId(竖井id)");
+        }
+        // 创建关系对象
+        List<RelationDTO> voList = new ArrayList<>();
+        voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, null, sysId , 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 sysId = param.getString("sysId");
+        String shaftId = param.getString("shaftId");
+        if(!StrUtil.isAllNotEmpty(shaftId,sysId)) {
+            return AdmResponse.failure("必填项:SysId(系统id)、ShaftId(竖井id)");
+        }
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("graphCode", DEFAULT_GRAPH_CODE);
+        node.put("relCode", DEFAULT_REL_CODE);
+        node.put("objFrom", sysId);
+        node.put("objTo",shaftId);
+        criteria.setCriteria(node);
+        service.doDelete(context, criteria);
+        return AdmResponse.success();
+    }
+    /**
+     * 创建系统服务于楼层,系统一对多
+     * @param   param
+     * @return                       创建的结果信息
+     */
+    @PostMapping("/link-sh")
+    public AdmResponse createSh(@RequestParam("projectId") String projectId,
+                                @RequestBody JSONObject param) throws Exception {
+        String sysId = param.getString("sysId");
+        JSONArray shaftIdList = param.getJSONArray("shaftIdList");
+        if(StrUtil.isBlank(sysId) || CollUtil.isEmpty(shaftIdList)) {
+            return AdmResponse.failure("必填项:ShaftIdList(竖井id列表)、SysId(系统id),测方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        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", sysId);
+        queryRequestTmp.setCriteria(nodeTmp);
+        //关系之前的关系,并且删除
+        List<ObjectRelation> objectRelations = service.queryByCondition(context, queryRequestTmp);
+        for (ObjectRelation objectRelation : objectRelations) {
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", objectRelation.getGraphCode());
+            node.put("relCode", objectRelation.getRelCode());
+            node.put("relValue", objectRelation.getRelValue());
+            node.put("objFrom", objectRelation.getObjFrom());
+            node.put("objTo", objectRelation.getObjTo());
+            queryRequest.setCriteria(node);
+            service.doDelete(context, queryRequest);
+        }
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < shaftIdList.size();i++) {
+            String shaftId = shaftIdList.getString(i);
+            if(StrUtil.isBlank(shaftId)) {
+                continue;
+            }
+            voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, null, sysId, shaftId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+    /**
+     * 服务于竖井的系统,竖井一对多
+     * @param   param
+     * @return                       创建的结果信息
+     */
+    @PostMapping("/link-sy")
+    public AdmResponse createSy(@RequestParam("projectId") String projectId,
+                                @RequestBody JSONObject param) throws Exception {
+        String shaftId = param.getString("shaftId");
+        JSONArray sysIdList = param.getJSONArray("sysIdList");
+        if (StrUtil.isBlank(shaftId) || CollUtil.isEmpty(sysIdList)) {
+            return AdmResponse.failure("必填项:ShaftId(竖井id)、sysIdList(系统id列表),测方法会覆盖以前的记录");
+        }
+        // 创建关系对象.先删除,后添加
+        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("objTo", shaftId);
+        queryRequestTmp.setCriteria(nodeTmp);
+        //关系之前的关系,并且删除
+        List<ObjectRelation> objectRelations = service.queryByCondition(context, queryRequestTmp);
+        for (ObjectRelation objectRelation : objectRelations) {
+            QueryCriteria queryRequest = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", objectRelation.getGraphCode());
+            node.put("relCode", objectRelation.getRelCode());
+            node.put("relValue", objectRelation.getRelValue());
+            node.put("objFrom", objectRelation.getObjFrom());
+            node.put("objTo", objectRelation.getObjTo());
+            queryRequest.setCriteria(node);
+            service.doDelete(context, queryRequest);
+        }
+        List<RelationDTO> voList = new ArrayList<>();
+        for (int i = 0; i < sysIdList.size(); i++) {
+            String sysId = sysIdList.getString(i);
+            if (StrUtil.isBlank(sysId)) {
+                continue;
+            }
+            voList.add(new RelationDTO(null, DEFAULT_GRAPH_CODE, DEFAULT_REL_CODE, null, sysId, shaftId));
+        }
+        // 组装上下文条件
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+}