zhangqiankun 3 years ago
parent
commit
68fb2f0f43

+ 3 - 1
src/main/java/com/persagy/proxy/adm/controller/AdmSpaceController.java

@@ -30,6 +30,7 @@ import com.persagy.proxy.adm.service.IAdmFloorService;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.service.IAdmSpaceService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
 import com.persagy.proxy.common.entity.RelationDTO;
 
@@ -144,7 +145,8 @@ public class AdmSpaceController {
             objectNode.put("zoneType", request.getZoneType());
         }
         return objectNode;*/
-    	return this.spaceRelationInfoHandler.querySpaceInfo(request);
+    	ObjectNode criteria = AdmQueryCriteriaHelper.toCriteria(null, request.getFilters());
+    	return this.spaceRelationInfoHandler.querySpaceInfo(request, criteria);
     }
 
     /**

+ 5 - 5
src/main/java/com/persagy/proxy/adm/handler/RelationReportHandler.java

@@ -62,7 +62,7 @@ public class RelationReportHandler {
 		HashSet<String> equipments = Sets.newHashSet(equipment);
 		
 		// 1.获取所有的设备对象数据
-		List<ObjectNode> equipList = this.relationReportService.queryObjects(groupCode, projectId, null, null, equipments, Sets.newHashSet("classCode"), null);
+		List<ObjectNode> equipList = this.relationReportService.queryObjects(null, groupCode, projectId, null, null, equipments, Sets.newHashSet("classCode"), null);
 		if (CollectionUtil.isEmpty(equipList)) {
 			return Lists.newArrayList();
 		}
@@ -98,14 +98,14 @@ public class RelationReportHandler {
 		String equipment = AdmObjectType.EQUIPMENT.getIndex();
 		
 		// 1.获取项目名称
-		List<ObjectNode> projects = this.relationReportService.queryObjects(groupCode, projectId, Sets.newHashSet(projectId), Sets.newHashSet(AdmObjectType.PROJECT.getIndex()), null, null, null);
+		List<ObjectNode> projects = this.relationReportService.queryObjects(null, groupCode, projectId, Sets.newHashSet(projectId), Sets.newHashSet(AdmObjectType.PROJECT.getIndex()), null, null, null);
 		if (CollectionUtil.isEmpty(projects)) {
 			return Lists.newArrayList();
 		}
 		String projectName = projects.get(0).has("localName") ? projects.get(0).get("localName").asText() : null;
 		
 		// 2.获取所有的设备对象数据
-		List<ObjectNode> equipList = this.relationReportService.queryObjects(groupCode, projectId, null, null, Sets.newHashSet(equipment), Sets.newHashSet("classCode"), null);
+		List<ObjectNode> equipList = this.relationReportService.queryObjects(null, groupCode, projectId, null, null, Sets.newHashSet(equipment), Sets.newHashSet("classCode"), null);
 		if (CollectionUtil.isEmpty(equipList)) {
 			return Lists.newArrayList();
 		}
@@ -141,14 +141,14 @@ public class RelationReportHandler {
 		String equipment = AdmObjectType.EQUIPMENT.getIndex();
 		
 		// 1.获取项目名称
-		List<ObjectNode> projects = this.relationReportService.queryObjects(groupCode, projectId, Sets.newHashSet(projectId), Sets.newHashSet(AdmObjectType.PROJECT.getIndex()), null, null, null);
+		List<ObjectNode> projects = this.relationReportService.queryObjects(null, groupCode, projectId, Sets.newHashSet(projectId), Sets.newHashSet(AdmObjectType.PROJECT.getIndex()), null, null, null);
 		if (CollectionUtil.isEmpty(projects)) {
 			return Lists.newArrayList();
 		}
 		String projectName = projects.get(0).has("localName") ? projects.get(0).get("localName").asText() : null;
 		
 		// 2.获取所有的设备对象数据
-		List<ObjectNode> equipList = this.relationReportService.queryObjects(groupCode, projectId, null, null, Sets.newHashSet(equipment), Sets.newHashSet("classCode"), null);
+		List<ObjectNode> equipList = this.relationReportService.queryObjects(null, groupCode, projectId, null, null, Sets.newHashSet(equipment), Sets.newHashSet("classCode"), null);
 		if (CollectionUtil.isEmpty(equipList)) {
 			return Lists.newArrayList();
 		}

+ 7 - 7
src/main/java/com/persagy/proxy/adm/handler/SpaceRelationInfoHandler.java

@@ -55,7 +55,7 @@ public class SpaceRelationInfoHandler {
 	 * @return
 	 * @throws Exception
 	 */
-	public JSONObject querySpaceInfo(AdmDCSQueryRequest request) throws Exception {
+	public JSONObject querySpaceInfo(AdmDCSQueryRequest request, ObjectNode criteria) throws Exception {
 		List<ObjectNode> resultList = null;
 		String groupCode = AppContext.getContext().getGroupCode();
 		String projectId = AppContext.getContext().getProjectId();
@@ -103,11 +103,11 @@ public class SpaceRelationInfoHandler {
 			}
 			
 		} else if (StrUtil.isNotBlank(buildingId) && StrUtil.isBlank(floorId) && "isnull".equals(buildingId)) {
-			resultList = this.querySpaceInfo(request, groupCode, projectId, zoneTypeList, ascOrder, descOrder);
+			resultList = this.querySpaceInfo(request, criteria, groupCode, projectId, zoneTypeList, ascOrder, descOrder);
 			
 		} else if (StrUtil.isBlank(buildingId) && StrUtil.isBlank(floorId)) {
 			// 直接获取所有的空间数据
-			List<ObjectNode> spacelist = this.relationReportService.queryObjects(groupCode, projectId, null, zoneTypeList, 
+			List<ObjectNode> spacelist = this.relationReportService.queryObjects(criteria, groupCode, projectId, null, zoneTypeList, 
 					Sets.newHashSet(AdmObjectType.SPACE.getIndex()), ascOrder, descOrder);
 			resultList = this.fillSpaceInfo(spacelist, null, null);
 		}
@@ -127,11 +127,11 @@ public class SpaceRelationInfoHandler {
 	 * @param projectId
 	 * @return
 	 */
-	private List<ObjectNode> querySpaceInfo(AdmDCSQueryRequest request, String groupCode, String projectId, Set<String> zoneTypeList, 
+	private List<ObjectNode> querySpaceInfo(AdmDCSQueryRequest request, ObjectNode criteria, String groupCode, String projectId, Set<String> zoneTypeList, 
 			Set<String> ascOrder, Set<String> descOrder) {
 		List<ObjectNode> resultList = null;
 		// 获取所有的建筑ID集合
-		List<ObjectNode> buildList = this.relationReportService.queryObjects(groupCode, projectId, null, null, 
+		List<ObjectNode> buildList = this.relationReportService.queryObjects(null, groupCode, projectId, null, null, 
 				Sets.newHashSet(AdmObjectType.BUILDING.getIndex()), null, null);
 		if (CollectionUtil.isNotEmpty(buildList)) {
 			for (ObjectNode objectNode : buildList) {
@@ -146,7 +146,7 @@ public class SpaceRelationInfoHandler {
 			}
 		} else {
 			// 获取所有的空间数据
-			List<ObjectNode> spacelist = this.relationReportService.queryObjects(groupCode, projectId, null, zoneTypeList, 
+			List<ObjectNode> spacelist = this.relationReportService.queryObjects(criteria, groupCode, projectId, null, zoneTypeList, 
 					Sets.newHashSet(AdmObjectType.SPACE.getIndex()), ascOrder, descOrder);
 			resultList = this.fillSpaceInfo(spacelist, null, null);
 		}
@@ -240,7 +240,7 @@ public class SpaceRelationInfoHandler {
 			
 			if (CollectionUtil.isNotEmpty(notBuildSpace)){
 				// 获取所有的对象数据
-				resultList = this.relationReportService.queryObjects(groupCode, projectId, notBuildSpace, zoneTypeList, 
+				resultList = this.relationReportService.queryObjects(null, groupCode, projectId, notBuildSpace, zoneTypeList, 
     					Sets.newHashSet(AdmObjectType.SPACE.getIndex()), ascOrder, descOrder);
     			this.fillSpaceInfo(resultList, buildingId, null);
             }

+ 3 - 2
src/main/java/com/persagy/proxy/adm/service/IRelationReportService.java

@@ -168,6 +168,7 @@ public interface IRelationReportService {
 	/**
 	 * 获取原始的对象数据
 	 * 
+	 * @param criteria 条件参数
 	 * @param groupCode
 	 * @param projectId
 	 * @param ids
@@ -177,8 +178,8 @@ public interface IRelationReportService {
 	 * @param descOrder
 	 * @return
 	 */
-	List<ObjectNode> queryObjects(String groupCode, String projectId, Set<String> ids, Set<String> classCodes, Set<String> objTypes, 
-			Set<String> ascOrder, Set<String> descOrder);
+	List<ObjectNode> queryObjects(ObjectNode criteria, String groupCode, String projectId, Set<String> ids, Set<String> classCodes, 
+			Set<String> objTypes, Set<String> ascOrder, Set<String> descOrder);
 	
 	/**
 	 * 获取原始的对象关系数据

+ 9 - 7
src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java

@@ -347,31 +347,33 @@ public class RelationReportService implements IRelationReportService {
 	}
 
 	@Override
-	public List<ObjectNode> queryObjects(String groupCode, String projectId, Set<String> ids, Set<String> classCodes, Set<String> objTypes, 
-			Set<String> ascOrder, Set<String> descOrder) {
+	public List<ObjectNode> queryObjects(ObjectNode criteria, String groupCode, String projectId, Set<String> ids, 
+			Set<String> classCodes, Set<String> objTypes, Set<String> ascOrder, Set<String> descOrder) {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
 		
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
 		QueryCriteria objectCriteria = new QueryCriteria();
-		ObjectNode object = objectMapper.createObjectNode();
+		if (criteria == null) {
+			criteria = objectMapper.createObjectNode();
+		}
 		if (CollectionUtil.isNotEmpty(ids)) {
 			JSONObject arrays = new JSONObject();
 			arrays.put("$in", ids);
-			object.putPOJO("id", ids);
+			criteria.putPOJO("id", ids);
 		}
 		if (CollectionUtil.isNotEmpty(classCodes)) {
 			JSONObject arrays = new JSONObject();
 			arrays.put("$in", classCodes);
-			object.putPOJO("classCode", classCodes);
+			criteria.putPOJO("classCode", classCodes);
 		}
 		if (CollectionUtil.isNotEmpty(objTypes)) {
 			JSONObject arrays = new JSONObject();
 			arrays.put("$in", objTypes);
-			object.putPOJO("objType", objTypes);
+			criteria.putPOJO("objType", objTypes);
 		}
 		objectCriteria.setPage(1L);
 		objectCriteria.setSize(500L);
-		objectCriteria.setCriteria(object);
+		objectCriteria.setCriteria(criteria);
 		if (CollectionUtil.isNotEmpty(ascOrder)) {
 			objectCriteria.setOrders(OrderItem.ascs(ascOrder.toArray(new String[ascOrder.size()])));
 		}