Browse Source

Merge remote-tracking branch 'origin/develop' into develop

lijie 3 years ago
parent
commit
654e226990

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

@@ -29,10 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.ws.rs.QueryParam;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Adm 空间 API
@@ -151,7 +148,7 @@ public class AdmSpaceController {
                         if(flowBuild.startsWith("Bd")){
                             admSpace.setBuildingId(flowBuild);
                             Map<String, Object> infos = new HashMap<String,Object>(16);
-                            infos.put("$remove","['floorId']");
+                            infos.put("$remove", Arrays.asList("floorId"));
                             admSpace.setInfos(infos);
                         }
                     }else {
@@ -164,9 +161,10 @@ public class AdmSpaceController {
                             admSpace.setFloorId(str[0]);
                         }
                     }
+                    admSpace.setFlowBuild(null);
                 }else{
                     Map<String, Object> infos = new HashMap<String,Object>(16);
-                    infos.put("$remove","['floorId','buildingId']");
+                    infos.put("$remove",Arrays.asList("floorId","buildingId"));
                     admSpace.setInfos(infos);
                 }
             });

+ 21 - 45
src/main/java/com/persagy/proxy/report/controller/AdmSpaceInfoController.java

@@ -1,22 +1,19 @@
 package com.persagy.proxy.report.controller;
 
 import cn.hutool.core.util.StrUtil;
-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 com.persagy.proxy.object.service.IAdmEquipmentService;
+import com.persagy.proxy.object.service.IAdmISpaceService;
+import com.persagy.proxy.object.service.IAdmSystemService;
 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;
@@ -26,7 +23,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.QueryParam;
 
 /**
- * 
+ *
  * @version 1.0.0
  * @company persagy
  * @author zhangqiankun
@@ -37,32 +34,20 @@ 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;
 	/**
 	 * 统计 属于多建筑楼层的空间
-	 * 
+	 *
 	 * @param request
 	 * @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;
@@ -78,14 +63,9 @@ public class AdmSpaceInfoController {
 	 */
 	@RequestMapping("/unspace-in-sys")
 	public AdmResponse unSpaceSys(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request){
-		//sy2sp
-		ObjectNode relationFrom = JsonNodeFactory.instance.objectNode();
-		relationFrom.put("relCode", "Sy2Sp");
-		relationFrom.put("graphCode", "MechInArch");
-		relationFrom.put("objTo", spaceId);
-		relationFrom.put("$bindFlag",false);
-		request.setRelationFrom(relationFrom);
 		request.setName(AdmSystem.OBJ_TYPE);
+		// 设置关系条件
+		request.resetRelationCond(true, "MechInArch", "Sy2Sp", spaceId, false);
 		return systemService.doQuery(AdmContextUtil.toDmpContext(),request, AdmSystem.class);
 	}
 
@@ -131,20 +111,20 @@ public class AdmSpaceInfoController {
 	 */
 	@PostMapping("/unspace-ispace")
 	public AdmResponse unSpaceIspace(@QueryParam("objectType") String objectType, @RequestBody AdmDCSQueryRequest request) {
-		//si2sp
-		ObjectNode relationFrom = JsonNodeFactory.instance.objectNode();
-		relationFrom.put("relCode", "Si2Sp");
-		relationFrom.put("$bindFlag",false);
-		request.setRelationFrom(relationFrom);
 		request.setName(AdmISpace.OBJ_TYPE);
-		String floorFilter = "floorId = '" + request.getFloorId()+"'";
-		if(StrUtil.isNotEmpty(request.getFilters())){
-			request.setFilters(request.getFilters()+";"+floorFilter);
-		}else{
-			request.setFilters(floorFilter);
+		// 设置关系条件
+		request.resetRelationCond(true, null, "Si2Sp", objectType, null, false);
+		StringBuilder sb = new StringBuilder();
+		// 补充filter条件
+		if(StrUtil.isNotBlank(request.getFilters())) {
+			sb.append(request.getFilters() + ";");
+		}
+		// 补充楼层条件
+		if(StrUtil.isNotBlank(request.getFloorId())) {
+			sb.append("floorId = '" + request.getFloorId()+"';");
 		}
-		if(StrUtil.isNotEmpty(objectType)){
-			request.setFilters(request.getFilters()+"; classCode='"+objectType+"'");
+		if(sb.length() > 0) {
+			request.setFilters(sb.substring(0, sb.length() - 1));
 		}
 		return ispaceService.doQuery(AdmContextUtil.toDmpContext(),request, AdmISpace.class);
 	}
@@ -154,12 +134,8 @@ public class AdmSpaceInfoController {
 			return AdmResponse.failure(ResponseCode.A0400.getDesc() + "空间id为空");
 		}
 		request.setName(AdmEquipment.OBJ_TYPE);
-		ObjectNode relationFrom = JsonNodeFactory.instance.objectNode();
-		relationFrom.put("relCode", "Eq2Sp");
-		relationFrom.put("graphCode", graphCode);
-		relationFrom.put("objTo", spaceId);
-		relationFrom.put("$bindFlag", false);
-		request.setRelationFrom(relationFrom);
+		// 设置关系条件
+		request.resetRelationCond(true, graphCode, "Eq2Sp", type, spaceId, false);
 		return equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
 	}
 }