Browse Source

fix bug:根据/object/building/query接口查询建筑楼层时楼层未按楼层序号排序返回的问题

lijie 3 years ago
parent
commit
0ab24eb939

+ 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);
     }