Browse Source

Merge branch 'develop' of http://39.106.8.246:3003/BDTP/adm-middleware into develop

lvxianyun 3 years ago
parent
commit
2bd2442f85

+ 38 - 16
src/main/java/com/persagy/proxy/object/controller/AdmShaftController.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.object.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.comparator.CompareUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -312,8 +313,8 @@ public class AdmShaftController {
      * @throws Exception
      */
     @GetMapping("/shaft-zoneSpaceBaseTable-building")
-    public AdmResponse queryZoneSpBd(@QueryParam("shaftId") String shaftId,
-                                     @QueryParam("objectType") String objectType) throws Exception {
+    public AdmResponse queryZoneSpBd(@RequestParam("shaftId") String shaftId,
+                                     @RequestParam(value = "objectType",required = false) String objectType) throws Exception {
         if(!StrUtil.isAllNotEmpty(shaftId,AdmContextUtil.toDmpContext().getProjectId())) {
             return AdmResponse.failure("必填项:shaftId(竖井id)、projectId(项目id)");
         }
@@ -335,7 +336,7 @@ public class AdmShaftController {
         //1.1 空间级联楼层
         AdmQueryCriteria cascadeSpFl = new AdmQueryCriteria();
         cascadeSpFl.setName("floorList");
-        cascadeSpFl.setProjection(Arrays.asList("id","name","localName"));
+        cascadeSpFl.setProjection(Arrays.asList("id","name","localName","floorSequenceID"));
         cascadeSpFl.setOrders("floorSequenceId desc");
         cascadeSp2BdFl.add(cascadeSpFl);
 
@@ -348,22 +349,43 @@ public class AdmShaftController {
         admQueryCriteriaSpace.setCascade(cascadeSp2BdFl);
 
         AdmResponse admResponseSp = spaceService.query(admQueryCriteriaSpace);
-        if(CollUtil.isNotEmpty(admResponseSp.getContent())){
-            //处理建筑下的楼层不是和空间关联的信息
-            List<AdmSpace> spaces = (List<AdmSpace>) admResponseSp.getContent();
-            List<AdmBuilding> admBuildingList = new ArrayList<>();
-            for(AdmSpace space : spaces){
-                AdmBuilding building = space.getBuilding();
-                List<AdmFloor> floorList = space.getFloorList();
-                if(building != null && CollUtil.isNotEmpty(floorList)){
-                    building.setFloor(floorList);
-                    admBuildingList.add(building);
+        if (CollUtil.isEmpty(admResponseSp.getContent())){
+            return AdmResponse.success();
+        }
+        //处理建筑下的楼层不是和空间关联的信息
+        List<AdmSpace> spaces = (List<AdmSpace>) admResponseSp.getContent();
+        List<AdmBuilding> admBuildingList = new ArrayList<>();
+        Map<String,List<AdmFloor>> buildingMap = new HashMap<>();
+        Set<String> floorIds = new HashSet<>();
+        for(AdmSpace space : spaces){
+            AdmBuilding building = space.getBuilding();
+            List<AdmFloor> floorList = space.getFloorList();
+            if(null == building){
+                continue;
+            }
+            List<AdmFloor> floors = buildingMap.getOrDefault(building.getId(), new ArrayList<>());
+            if(CollUtil.isNotEmpty(floorList)){
+                for (AdmFloor admFloor : floorList) {
+                    if (floorIds.contains(admFloor.getId())){
+                        continue;
+                    }
+                    floors.add(admFloor);
+                    floorIds.add(admFloor.getId());
                 }
             }
-            return AdmResponse.success(admBuildingList);
-        }else{
-            return AdmResponse.success();
+            if (buildingMap.containsKey(building.getId())){
+                continue;
+            }
+            buildingMap.put(building.getId(),floors);
+            admBuildingList.add(building);
+        }
+        for (AdmBuilding building : admBuildingList) {
+            List<AdmFloor> floors = buildingMap.getOrDefault(building.getId(), new ArrayList<>());
+            building.setFloor(floors.stream()
+                    .sorted((f1,f2)-> CompareUtil.compare(f2.getFloorSequenceID(),f1.getFloorSequenceID(),false))
+                    .collect(Collectors.toList()));
         }
+        return AdmResponse.success(admBuildingList);
     }
 
     /*@GetMapping("/shaft-zoneSpaceBaseTable-building")