Explorar o código

新增分页查询

zhangqiankun %!s(int64=3) %!d(string=hai) anos
pai
achega
16b20fcb77

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

@@ -66,7 +66,7 @@ public class RelationReportHandler {
 		}
 				
 		// 2.获取所有的设备类定义的className
-		List<ObjectTypeDefine> classList = this.relationReportService.queryClassList(groupCode, projectId, null, equipment, null);
+		List<ObjectTypeDefine> classList = this.relationReportService.queryClassList(groupCode, projectId, null, Sets.newHashSet(equipment), null);
 		// key-classCode, value-className
 		Map<String, String> classDefine = new HashMap<String, String>();
 		for (ObjectTypeDefine objectTypeDefine : classList) {
@@ -109,17 +109,17 @@ public class RelationReportHandler {
 		}
 		
 		// 3.获取所有的设备、系统类定义信息
-		List<ObjectTypeDefine> equipClass = this.relationReportService.queryClassList(groupCode, projectId, null, equipment, null);
-		List<ObjectTypeDefine> systemClass = this.relationReportService.queryClassList(groupCode, projectId, null, AdmObjectType.SYSTEM.getIndex(), null);
+		List<ObjectTypeDefine> classInfo = this.relationReportService.queryClassList(groupCode, projectId, null, Sets.newHashSet(equipment, AdmObjectType.SYSTEM.getIndex()), null);
 		// key-equipCode, value-equipName
 		Map<String, String> equipTemp = new HashMap<String, String>();
-		for (ObjectTypeDefine equip : equipClass) {
-			equipTemp.put(equip.getCode(), equip.getName());
-		}
 		// key-systemCode, value-systemName
 		Map<String, String> systemTemp = new HashMap<String, String>();
-		for (ObjectTypeDefine system : systemClass) {
-			systemTemp.put(system.getCode(), system.getName());
+		for (ObjectTypeDefine info : classInfo) {
+			if (info.getCode().length() > 5) {
+				equipTemp.put(info.getCode(), info.getName());
+			} else {
+				systemTemp.put(info.getCode(), info.getName());
+			}
 		}
 		
 		// 4.获取所有的信息点

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

@@ -29,11 +29,11 @@ public interface IRelationReportService {
 	 * @param groupCode
 	 * @param projectId
 	 * @param classCode
-	 * @param objType
+	 * @param objTypes
 	 * @param ascOrder
 	 * @return
 	 */
-	List<ObjectTypeDefine> queryClassList(String groupCode, String projectId, String classCode, String objType, String ascOrder);
+	List<ObjectTypeDefine> queryClassList(String groupCode, String projectId, String classCode, Set<String> objTypes, String ascOrder);
 	
 	/**
 	 * 根据信息点统计对象个数

+ 82 - 11
src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java

@@ -67,7 +67,7 @@ public class RelationReportService implements IRelationReportService {
 	private String defaultCode;
 
 	@Override
-	public List<ObjectTypeDefine> queryClassList(String groupCode, String projectId, String classCode, String objType, String ascOrder) {
+	public List<ObjectTypeDefine> queryClassList(String groupCode, String projectId, String classCode, Set<String> objTypes, String ascOrder) {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
 		
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
@@ -76,15 +76,19 @@ public class RelationReportService implements IRelationReportService {
 		if (StrUtil.isNotBlank(classCode)) {
 			condition.put("code", classCode);
 		}
-		if (StrUtil.isNotBlank(objType)) {
-			condition.put("objType", objType);
+		if (CollectionUtil.isNotEmpty(objTypes)) {
+			JSONObject arrays = new JSONObject();
+			arrays.put("$in", objTypes);
+			condition.putPOJO("objType", objTypes);
 		}
 		classCriteria.setCriteria(condition);
 		if (StrUtil.isNotBlank(ascOrder)) {
 			classCriteria.setOrders(Collections.singletonList(OrderItem.asc(ascOrder)));
 		}
-		List<ObjectTypeDefine> objectNodes = DigitalDefineFacade.queryObjectType(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, classCriteria);
-		return CollectionUtil.isEmpty(objectNodes) ? Lists.newArrayList() : objectNodes;
+		classCriteria.setSize(500L);
+		List<ObjectTypeDefine> all = new ArrayList<ObjectTypeDefine>();
+		this.queryPageClass(all, classCriteria, groupCode, projectId, 1L);
+		return all;
 	}
 	
 	@Override
@@ -307,8 +311,11 @@ public class RelationReportService implements IRelationReportService {
 		criteria.put(key, value);
 		criteria.put("objType", objType);
 		queryCriteria.setCriteria(criteria);
-		List<ObjectNode> objectNodes = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
-		return objectNodes;
+		queryCriteria.setSize(500L);
+		
+		List<ObjectNode> all = new ArrayList<ObjectNode>();
+		this.queryPageObjects(all, queryCriteria, groupCode, projectId, 1L);
+		return all;
 	}
 	
 	@Override
@@ -352,12 +359,14 @@ public class RelationReportService implements IRelationReportService {
 		if (StrUtil.isNotBlank(objType)) {
 			object.put("objType", objType);
 		}
+		objectCriteria.setSize(500L);
 		objectCriteria.setCriteria(object);
 		if (StrUtil.isNotBlank(ascOrder)) {
 			objectCriteria.setOrders(Collections.singletonList(OrderItem.asc(ascOrder)));
 		}
-		List<ObjectNode> objectNodes = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, objectCriteria);
-		return CollectionUtil.isEmpty(objectNodes) ? Lists.newArrayList() : objectNodes;
+		List<ObjectNode> all = new ArrayList<ObjectNode>();
+		this.queryPageObjects(all, objectCriteria, groupCode, projectId, 1L);
+		return all;
 	}
 	
 	@Override
@@ -399,8 +408,10 @@ public class RelationReportService implements IRelationReportService {
 			condition.putPOJO("classCode", arrays);
 		}
 		queryCriteria.setCriteria(condition);
-		List<ObjectInfoDefine> infos = DigitalObjectInfoFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
-		return CollectionUtil.isEmpty(infos) ? Lists.newArrayList() : infos;
+		queryCriteria.setSize(500L);
+		List<ObjectInfoDefine> all = new ArrayList<ObjectInfoDefine>();
+		this.queryPageFunids(all, queryCriteria, groupCode, projectId, 1L);
+		return all;
 	}
 	
 	@Override
@@ -717,4 +728,64 @@ public class RelationReportService implements IRelationReportService {
 		return result;
 	}
 
+	
+	/***************************************************** 所有接口的额外分页查询 **********************************************/
+	
+	/**
+	 * 分页查询类定义数据
+	 * 
+	 * @param all
+	 * @param classCriteria
+	 * @param groupCode
+	 * @param projectId
+	 * @param page
+	 */
+	private void queryPageClass(List<ObjectTypeDefine> all, QueryCriteria classCriteria, String groupCode, String projectId, long page) {
+		classCriteria.setPage(page);
+		List<ObjectTypeDefine> objectNodes = DigitalDefineFacade.queryObjectType(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, classCriteria);
+		if (CollectionUtil.isEmpty(objectNodes)) {
+			return;
+		}
+		all.addAll(objectNodes);
+		this.queryPageClass(all, classCriteria, groupCode, projectId, ++page);
+	}
+	
+	/**
+	 * 分页查询对象数据
+	 * 
+	 * @param all
+	 * @param objectCriteria
+	 * @param groupCode
+	 * @param projectId
+	 * @param page
+	 */
+	private void queryPageObjects(List<ObjectNode> all, QueryCriteria objectCriteria, String groupCode, String projectId, long page) {
+		objectCriteria.setPage(page);
+		List<ObjectNode> objectNodes = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, objectCriteria);
+		if (CollectionUtil.isEmpty(objectNodes)) {
+			return;
+		}
+		all.addAll(objectNodes);
+		this.queryPageObjects(all, objectCriteria, groupCode, projectId, ++page);
+	}
+	
+	/**
+	 * 分页查询信息点定义数据
+	 * 
+	 * @param all
+	 * @param classCriteria
+	 * @param groupCode
+	 * @param projectId
+	 * @param page
+	 */
+	private void queryPageFunids(List<ObjectInfoDefine> all, QueryCriteria queryCriteria, String groupCode, String projectId, long page) {
+		queryCriteria.setPage(page);
+		List<ObjectInfoDefine> infos = DigitalObjectInfoFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
+		if (CollectionUtil.isEmpty(infos)) {
+			return;
+		}
+		all.addAll(infos);
+		this.queryPageFunids(all, queryCriteria, groupCode, projectId, ++page);
+	}
+	
 }