Browse Source

fix:FOV-202 (提出人:赵强)空间台账---批量关联空间---空间名称显示错误,不是准确的空间名称
删除空间接口:增加删除 空间与元空间的关系

lvxianyun 3 years ago
parent
commit
eaa92e86b7

+ 12 - 6
src/main/java/com/persagy/proxy/object/controller/AdmSpaceController.java

@@ -104,8 +104,9 @@ public class AdmSpaceController {
         QueryCriteria queryCriteria = new QueryCriteria();
         vos.forEach(vo -> {
             /** 清除空间和建筑楼层的的数据 */
-            dealRelation(vo.getId(), queryCriteria,"Bd2Sp");
-            dealRelation(vo.getId(), queryCriteria,"Fl2Sp");
+            dealRelation(vo.getId(), queryCriteria,"Bd2Sp", false);
+            dealRelation(vo.getId(), queryCriteria,"Fl2Sp", false);
+            dealRelation(vo.getId(), queryCriteria,"Sp2Si", true);
         });
         return AdmResponse.success();
     }
@@ -275,8 +276,8 @@ public class AdmSpaceController {
             String type = requestData.getType();//classCode
 
             /** 清除空间和建筑楼层的的数据 */
-            dealRelation(spaceId, queryCriteria,"Bd2Sp");
-            dealRelation(spaceId, queryCriteria,"Fl2Sp");
+            dealRelation(spaceId, queryCriteria,"Bd2Sp", false);
+            dealRelation(spaceId, queryCriteria,"Fl2Sp", false);
 
             if(StrUtil.isNotEmpty(id)){
                 if(id.startsWith("Fl") && StrUtil.isNotEmpty(spaceId)){
@@ -446,9 +447,14 @@ public class AdmSpaceController {
     }
 
 
-    private void dealRelation(String spaceId, QueryCriteria queryCriteria, String relCode){
+    private void dealRelation(String spaceId, QueryCriteria queryCriteria, String relCode, Boolean isObjFrom){
         ObjectNode rBd = JsonNodeFactory.instance.objectNode();
-        rBd.put("objTo",spaceId);
+        if(isObjFrom){
+            rBd.put("objFrom",spaceId);
+        }else{
+            rBd.put("objTo",spaceId);
+        }
+
         rBd.put("relCode",relCode);
         queryCriteria.setCriteria(rBd);
         relationService.doDelete( AdmContextUtil.toDmpContext(), queryCriteria);

+ 9 - 7
src/main/java/com/persagy/proxy/relation/controller/RelationSpInSiController.java

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
+import com.persagy.proxy.adm.request.AdmCreateResponse;
 import com.persagy.proxy.relation.model.SiInSpBase;
 import com.persagy.proxy.relation.model.SiInSpBaseList;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
@@ -81,26 +82,26 @@ public class RelationSpInSiController {
      * @return 创建的结果信息
      */
     @PostMapping("/link-sp")
-    public AdmResponse createSp(@RequestParam(value = "type", required = false) String type,
-                                @RequestBody SiInSpBaseList siInSpBaseList) {
+    public AdmCreateResponse createSp(@RequestParam(value = "type", required = false) String type,
+                                      @RequestBody SiInSpBaseList siInSpBaseList) {
         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.success();
+            return AdmCreateResponse.success();
         }
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.SP2SI;
         String graphCode = typeEnum.getGraphCode();
         String relCode = typeEnum.getRelCode();
-        deleteBySpaceId(spaceId, context, typeEnum);
+        deleteBySpaceId(spaceId, context, typeEnum, type);
         List<RelationDTO> voList = new ArrayList<>();
         for (String ispaceId : ispaceIdList) {
-            RelationDTO relation = new RelationDTO(null, graphCode, relCode, siInSpBaseList.getZoneType(), spaceId, ispaceId);
+            RelationDTO relation = new RelationDTO(null, graphCode, relCode, type, spaceId, ispaceId);
             voList.add(relation);
         }
         service.doSave(context, voList);
-        return AdmResponse.success();
+        return AdmCreateResponse.success(voList);
     }
 
     /**
@@ -110,12 +111,13 @@ public class RelationSpInSiController {
      * @param context
      * @param typeEnum
      */
-    private void deleteBySpaceId(String spaceId, InstanceUrlParam context, AdmRelationTypeEnum typeEnum) {
+    private void deleteBySpaceId(String spaceId, InstanceUrlParam context, AdmRelationTypeEnum typeEnum, String zoneType) {
         QueryCriteria criteria = new QueryCriteria();
         ObjectNode node = JsonNodeFactory.instance.objectNode();
         node.put("graphCode", typeEnum.getGraphCode());
         node.put("relCode", typeEnum.getRelCode());
         node.put("objFrom", spaceId);
+        node.put("relValue", zoneType);
         criteria.setCriteria(node);
         service.doDelete(context, criteria);
     }

+ 4 - 10
src/main/java/com/persagy/proxy/report/controller/AdmSpaceInfoController.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.common.constant.ResponseCode;
+import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.adm.request.AdmDCSQueryRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
@@ -142,18 +143,11 @@ public class AdmSpaceInfoController {
 
 		request.setName(AdmISpace.OBJ_TYPE);
 		// 设置关系条件
-		request.resetRelationCond(false, null, "Sp2Si", objectType, null, false);
-		StringBuilder sb = new StringBuilder();
-		// 补充filter条件
-		if(StrUtil.isNotBlank(request.getFilters())) {
-			sb.append(request.getFilters()).append("; ");
-		}
+        AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.SP2SI;
+		request.resetRelationCond(false, null, typeEnum.getRelCode(), objectType, null, false);
 		// 补充楼层条件
 		if(StrUtil.isNotBlank(request.getFloorId())) {
-			sb.append("bimId startwith '").append(floor.getBimIdPre()).append("'; ");
-		}
-		if(sb.length() > 0) {
-			request.setFilters(sb.substring(0, sb.length() - 1));
+            request.addFilters("bimId startwith '"+floor.getBimIdPre()+"' ");
 		}
 		AdmResponse responseIspace = ispaceService.doQuery(AdmContextUtil.toDmpContext(),request, AdmISpace.class);
 		// 按照楼层轮廓线计算出不在轮廓线内的空间