Selaa lähdekoodia

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

linhuili 3 vuotta sitten
vanhempi
commit
95bc3c6833

+ 7 - 2
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -8,7 +8,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 
+import cn.hutool.core.bean.BeanUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import com.alibaba.fastjson.JSONArray;
@@ -284,8 +286,11 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
             if(isList) {
                 // 取出对应的对象集合
                 Map<String, V> currVOMap = MapUtil.filter(subVOMap, subIdList.toArray(new String[0]));
-                List<V> voList = CollUtil.newArrayList(currVOMap.values());
-                ReflectUtil.setFieldValue(mainVO, casField, voList);
+                // 2021年11月11日17:30:04,by lijie.解决级联查询已经排好序的列表错乱问题
+                List<V> currList = vos.stream().filter(vo -> currVOMap.containsKey(BeanUtil.getFieldValue(vo, BaseEntity.PROP_ID)))
+                        .collect(Collectors.toList());
+                // List<V> voList = CollUtil.newArrayList(currVOMap.values());
+                ReflectUtil.setFieldValue(mainVO, casField, currList);
             } else {
                 // 非集合取第一个即可
                 String subId = subIdList.get(0);

+ 1 - 0
src/main/java/com/persagy/proxy/object/controller/AdmBuildingController.java

@@ -155,6 +155,7 @@ public class AdmBuildingController {
     public AdmResponse query(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmBuilding.OBJ_TYPE);
+
         return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmBuilding.class);
     }
 

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

@@ -235,13 +235,14 @@ public class AdmSpaceController {
         criteriaSpace.setFilters("state = 1");
 
         criteriaFloor.setCascade(CollUtil.newArrayList(criteriaSpace));
+        criteriaFloor.setOrders("floorSequenceID desc");
         request.setCascade(CollUtil.newArrayList(criteriaFloor));
-        AdmResponse response = buildingService.doQueryBuildingFloor( AdmContextUtil.toDmpContext(), request);
+        AdmResponse response = buildingService.doQueryBuildingFloor(AdmContextUtil.toDmpContext(), request);
         List<AdmBuilding> buildings = (List<AdmBuilding>) response.getContent();
-        buildings.stream().forEach(building -> {
+        buildings.forEach(building -> {
             if(CollUtil.isNotEmpty(building.getFloor())){
                 List<AdmFloor> floors = building.getFloor();
-                floors.stream().forEach(floor -> {
+                floors.forEach(floor -> {
                     if(CollUtil.isNotEmpty(floor.getSpaceList())){
                         floor.setCount(String.valueOf(floor.getSpaceList().size()));
                         floor.setSpaceList(null);

+ 36 - 9
src/main/java/com/persagy/proxy/report/service/impl/RelationReportService.java

@@ -211,26 +211,20 @@ public class RelationReportService implements IRelationReportService {
 		List<JSONObject> resultList = new ArrayList<>();
 		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP;
 		Map<String, RelationDefine> relationDefineMap = queryAllRelationDefineMap(groupCode, projectId);
+		Map<String, Integer> relCountMap = queryAllRelationCountMap(groupCode,projectId);
+		Map<String,List<ObjectNode>> graphCodeMap = queryAllProjectCalMap(groupCode,projectId);
 		for (GraphDefine graphDefine : secondList) {
 			String graphCode = graphDefine.getCode();
 			JSONObject graphObject = this.transfer(graphDefine);
 
 			// 查询出对应项目关系计算数据
-			QueryCriteria projectCriteria = new QueryCriteria();
-			ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
-			ObjectNode criteria = objectMapper.createObjectNode();
-			criteria.put("projectId", projectId);
-			criteria.put("graphCode", graphCode);
-			criteria.put("valid", 1);
-			projectCriteria.setCriteria(criteria);
-			List<ObjectNode> projectList = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
+			List<ObjectNode> projectList = graphCodeMap.getOrDefault(graphCode,new ArrayList<>());
 			if (CollectionUtil.isEmpty(projectList)) {
 				graphObject.put("relationTypeProjectList", Lists.newArrayList());
 				continue;
 			}
 			// 再根据图类型、边类型,统计此类型下的数量
 			List<JSONObject> tempList = new ArrayList<>();
-			Map<String, Integer> relCountMap = queryAllRelationCountMap(groupCode,projectId);
 			for (ObjectNode objectNode : projectList) {
 				String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
 				tempList.add(this.fillRelationProjectCal(objectNode, graphDefine.getCode(), relCode, graphRelTypeMap,relationDefineMap,relCountMap));
@@ -241,6 +235,39 @@ public class RelationReportService implements IRelationReportService {
 
 		return resultList;
 	}
+	/***
+	 * Description: 查询项目的图类型映射
+	 * @param groupCode : 集团编码
+ 	 * @param projectId : 项目id
+	 * @return : java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.node.ObjectNode>>
+	 * @author : lijie
+	 * @date :2021/11/11 16:03
+	 * Update By lijie 2021/11/11 16:03
+	 */
+	private Map<String, List<ObjectNode>> queryAllProjectCalMap(String groupCode, String projectId) {
+		Map<String, List<ObjectNode>> result = new HashMap<>();
+		// 查询出对应项目关系计算数据
+		QueryCriteria projectCriteria = new QueryCriteria();
+		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+		ObjectNode criteria = objectMapper.createObjectNode();
+		criteria.put("projectId", projectId);
+		criteria.put("valid", 1);
+		projectCriteria.setCriteria(criteria);
+		List<ObjectNode> projectList = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
+		if (CollUtil.isEmpty(projectList)){
+			return new HashMap<>();
+		}
+		for (ObjectNode objectNode : projectList) {
+			if (!objectNode.has("graphCode")
+					|| StrUtil.isBlank(objectNode.get("graphCode").asText())){
+				continue;
+			}
+			List<ObjectNode> projectCals = result.getOrDefault(objectNode.get("graphCode").asText(), new ArrayList<>());
+			projectCals.add(objectNode);
+			result.put(objectNode.get("graphCode").asText(),projectCals);
+		}
+		return result;
+	}
 
 	@Override
 	public JSONObject getRelationProjectCal(String groupCode, String projectId, String relType) {