Browse Source

query-new 系统查询 返回结果展示格式化

lvxianyun 3 years ago
parent
commit
cd93242fe5

+ 19 - 17
src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java

@@ -35,6 +35,7 @@ import javax.json.JsonObject;
 import javax.validation.constraints.NotNull;
 import javax.ws.rs.QueryParam;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -246,24 +247,24 @@ public class AdmSystemController {
             if(CollUtil.isNotEmpty(syses.getContent())){
                 admSystemList = (List<AdmSystem>) syses.getContent();
                 admSystemList.stream().forEach(admSystem -> {
-                    List<AdmBuildingFloorInfo> buildingFloorInfoList = new ArrayList<>();
+                    List<ObjectNode> buildingFloorInfoList = new ArrayList<>();
                     List<AdmBuilding> buildingList = admSystem.getBuildingList();
                     if(CollUtil.isNotEmpty(buildingList)){
                         buildingList.stream().forEach(admBuilding -> {
                             List<AdmFloor> admFloorList = admBuilding.getFloor();
                             if(CollUtil.isNotEmpty(admFloorList)){
                                 admFloorList.stream().forEach(floor -> {
-                                    AdmBuildingFloorInfo info = new AdmBuildingFloorInfo();
-                                    info.setBuildID(admBuilding.getId());
-                                    info.setBuildName(admBuilding.getLocalName());
-                                    info.setFloorID(floor.getId());
-                                    info.setFloorName(floor.getLocalName());
+                                    ObjectNode info = JsonNodeFactory.instance.objectNode();
+                                    info.put("BuildID",admBuilding.getId());
+                                    info.put("BuildName",admBuilding.getLocalName());
+                                    info.put("FloorID",floor.getId());
+                                    info.put("FloorName",floor.getLocalName());
                                     buildingFloorInfoList.add(info);
                                 });
                             }else{
-                                AdmBuildingFloorInfo info = new AdmBuildingFloorInfo();
-                                info.setBuildID(admBuilding.getId());
-                                info.setBuildName(admBuilding.getLocalName());
+                                ObjectNode info = JsonNodeFactory.instance.objectNode();
+                                info.put("BuildID",admBuilding.getId());
+                                info.put("BuildName",admBuilding.getLocalName());
                                 buildingFloorInfoList.add(info);
                             }
                         });
@@ -378,7 +379,7 @@ public class AdmSystemController {
             return null;
         }
         if(StrUtil.isEmpty(buildingId)){//处理成adm目标格式
-            List<AdmBuildingFloorInfo> nullList = new ArrayList<>(0);
+            List<ObjectNode> nullList = new ArrayList<>(0);
             admSystemList.stream().forEach(admSystem -> {
                 admSystem.setBuildingFloorInfoList(nullList);
             });
@@ -394,19 +395,20 @@ public class AdmSystemController {
             AdmQueryCriteria admQueryCriteria = getAdmQueryCriteria(AdmFloor.OBJ_TYPE, floorId);
             floors = floorService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmFloor.class);
         }
-        AdmBuildingFloorInfo buildingFloorInfo = new AdmBuildingFloorInfo();
+
+        ObjectNode buildingFloorInfo = JsonNodeFactory.instance.objectNode();
         if (CollUtil.isNotEmpty(buildings.getContent())) {
-            AdmBuilding building = (AdmBuilding) buildings.getContent().get(0);
-            buildingFloorInfo.setBuildName(building.getLocalName());
-            buildingFloorInfo.setBuildID(buildingId);
+            AdmBuilding admBuilding = (AdmBuilding) buildings.getContent().get(0);
+            buildingFloorInfo.put("BuildID",admBuilding.getId());
+            buildingFloorInfo.put("BuildName",admBuilding.getLocalName());
         }
         if (null!=floors && CollUtil.isNotEmpty(floors.getContent())) {
             AdmFloor floor = (AdmFloor) floors.getContent().get(0);
-            buildingFloorInfo.setFloorName(floor.getLocalName());
-            buildingFloorInfo.setFloorID(floorId);
+            buildingFloorInfo.put("FloorID",floor.getId());
+            buildingFloorInfo.put("FloorName",floor.getLocalName());
         }
         admSystemList.stream().forEach(admSystem -> {
-            admSystem.setBuildingFloorInfoList(CollUtil.newArrayList(buildingFloorInfo));
+            admSystem.setBuildingFloorInfoList(Arrays.asList(buildingFloorInfo));
         });
         return admSystemList;
     }

+ 0 - 48
src/main/java/com/persagy/proxy/adm/model/AdmBuildingFloorInfo.java

@@ -1,48 +0,0 @@
-package com.persagy.proxy.adm.model;
-
-import com.alibaba.fastjson.annotation.JSONField;
-import lombok.Data;
-
-/**
- *  建筑楼层信息
- * @author lvxy
- * @date 2021/8/17
- */
-@Data
-public class AdmBuildingFloorInfo {
-    /** 建筑体ID */
-    @JSONField(name = "BuildID")
-    private String buildID;
-
-    /** 建筑体名称 */
-    @JSONField(name = "BuildName")
-    private String buildName;
-
-    /** 楼层ID */
-    @JSONField(name = "FloorID")
-    private String floorID;
-
-    /** 楼层名称 */
-    @JSONField(name = "FloorName")
-    private String floorName;
-
-    @JSONField(name = "BuildName")
-    public String getBuildName() {
-        return buildName;
-    }
-
-    @JSONField(name = "FloorID")
-    public String getFloorID() {
-        return floorID;
-    }
-
-    @JSONField(name = "FloorName")
-    public String getFloorName() {
-        return floorName;
-    }
-
-    @JSONField(name = "BuildID")
-    public String getBuildID() {
-        return buildID;
-    }
-}

+ 2 - 1
src/main/java/com/persagy/proxy/adm/model/AdmSystem.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -58,7 +59,7 @@ public class AdmSystem extends AdmSBaseEntity<AdmSystem> {
     @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Bd")
     private List<AdmBuilding> buildingList;
     /** 建筑楼层 */
-    private List<AdmBuildingFloorInfo> buildingFloorInfoList;
+    private List<ObjectNode> buildingFloorInfoList;
 
     /** 供展示使用,并非实体中的字段 **/
     /** 设备id*/