Browse Source

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

lvxianyun 3 years ago
parent
commit
dd8e1ebb90

+ 28 - 2
src/main/java/com/persagy/proxy/relation/controller/RelationShInBdController.java

@@ -1,5 +1,12 @@
 package com.persagy.proxy.relation.controller;
 
+import cn.hutool.core.collection.CollUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.basic.utils.QueryCriteriaHelper;
+import com.persagy.dmp.common.helper.SpringHelper;
+import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.relation.model.ShInBdList;
 import com.persagy.proxy.adm.request.AdmResponse;
@@ -15,8 +22,11 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * 关系-竖井所在建筑
@@ -36,19 +46,35 @@ public class RelationShInBdController {
      * @return
      */
     @PostMapping("link-bd")
-    public AdmResponse createBd(@RequestBody ShInBdList shInBdList){
+    public AdmResponse createBd(@RequestBody ShInBdList shInBdList) throws IOException {
         log.info("创建系统所在建筑关系link-bd");
         List<String> buildingIdList = shInBdList.getBuildingIdList();
         String shaftId = shInBdList.getShaftId();
-        //检验输入参数
+        // 1.检验输入参数
         if(CollectionUtils.isEmpty(buildingIdList)|| StringUtils.isEmpty(shaftId)){
             return AdmResponse.failure("必填项:shaftId(竖井id)、BuildingIdList(建筑id列表)");
         }
         List<RelationDTO> voList = new ArrayList<>();
         String graphCode = AdmRelationTypeEnum.BD2SH_ARCHSUBSET.getGraphCode();
         String relCode = AdmRelationTypeEnum.BD2SH_ARCHSUBSET.getRelCode();
+        // 2.根据图类型,边类型,建筑id数组,竖井id数组查询关系
+        QueryCriteria criteria = new QueryCriteria();
+        ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+        ObjectNode queryObj = objectMapper.createObjectNode();
+        queryObj.set("objFrom",objectMapper.readTree(objectMapper.writeValueAsString(buildingIdList)));
+        queryObj.put("objTo",shaftId);
+        queryObj.put("graphCode",graphCode);
+        queryObj.put("relCode",relCode);
+        queryObj.put("valid",Boolean.TRUE);
+        criteria.setCriteria(queryObj);
+        List<ObjectRelation> relations = service.queryByCondition(AdmContextUtil.toDmpContext(), criteria);
+        Set<String> havedBuildIds = CollUtil.newHashSet(CollUtil.isNotEmpty(relations),
+                relations.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toSet()));
         // 组装关系
         for (String buildingId : buildingIdList) {
+            if (havedBuildIds.contains(buildingId)){
+                continue;
+            }
             RelationDTO relation = RelationDTO.builder().graphCode(graphCode).relCode(relCode)
                     .objFrom(buildingId).objTo(shaftId).build();
             voList.add(relation);

+ 23 - 27
src/main/java/com/persagy/proxy/report/controller/AdmSpaceInfoController.java

@@ -1,29 +1,32 @@
 package com.persagy.proxy.report.controller;
 
-import cn.hutool.core.util.StrUtil;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.QueryParam;
+
+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 com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.common.constant.ResponseCode;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 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.service.IAdmRelationService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.object.model.AdmEquipment;
 import com.persagy.proxy.object.model.AdmISpace;
 import com.persagy.proxy.object.model.AdmSystem;
-import com.persagy.proxy.object.service.*;
-import lombok.RequiredArgsConstructor;
-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 com.persagy.proxy.object.service.IAdmEquipmentService;
+import com.persagy.proxy.object.service.IAdmISpaceService;
+import com.persagy.proxy.object.service.IAdmSystemService;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.QueryParam;
+import cn.hutool.core.util.StrUtil;
+import lombok.RequiredArgsConstructor;
 
 /**
  * 
@@ -37,22 +40,15 @@ import javax.ws.rs.QueryParam;
 @RequestMapping("/space")
 public class AdmSpaceInfoController {
 
-	public static final String EXPORT_SHEET_NAME = "关系维护";
-
 	@Value("${middleware.group.code}")
 	private String defaultCode;
 	@Autowired
-	private IAdmSpaceService spaceService;
-	@Autowired
 	private IAdmISpaceService ispaceService;
 	@Autowired
 	private IAdmSystemService systemService;
 	@Autowired
 	private IAdmEquipmentService equipmentService;
-	@Autowired
-	private IAdmRelationService relationService;
-	@Autowired
-	private IAdmFloorService floorService;
+	
 	/**
 	 * 统计 属于多建筑楼层的空间
 	 * 
@@ -60,12 +56,12 @@ public class AdmSpaceInfoController {
 	 * @return
 	 */
 	@RequestMapping("/space-bd-fl")
-	public AdmResponse queryCount(HttpServletRequest request) {
-		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
-		String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
-		AdmResponse response = AdmResponse.success();
-		response.setCount(0L);
-		return response;
+	public JSONObject queryCount(HttpServletRequest request) {
+		JSONObject result = new JSONObject();
+		result.put("count", 0);
+		result.put("message", "");
+		result.put("result", "success");
+		return result;
 	}
 
 	/**