ソースを参照

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

liyang 2 年 前
コミット
6c43955ac3

+ 4 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/constant/AdmServerConstant.java

@@ -7,6 +7,10 @@ package com.persagy.adm.server.algorithm.constant;
 public interface AdmServerConstant {
     /**楼层顺序码的信息点key值*/
     String FLOOR_SEQUENCE_ID="floorSequenceID";
+    /**建筑顺序码的信息点key值*/
+    String BUILD_SEQUENCE_ID="buildSequenceID";
+    /**建筑id的信息点key值*/
+    String BUILDING_ID="buildingId";
 
 
 }

+ 0 - 3
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/controller/AdmModelBackController.java

@@ -1,14 +1,11 @@
 package com.persagy.adm.server.algorithm.controller;
 
 
-import com.persagy.adm.server.algorithm.domain.ModelFileVo;
-import com.persagy.adm.server.algorithm.domain.QueryModelFileVo;
 import com.persagy.adm.server.algorithm.service.AdmModelBackService;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 

+ 64 - 21
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/controller/AdmModelController.java

@@ -2,11 +2,14 @@ package com.persagy.adm.server.algorithm.controller;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.persagy.adm.server.algorithm.constant.AdmServerConstant;
+import com.persagy.adm.server.algorithm.domain.BuildingVo;
 import com.persagy.adm.server.algorithm.domain.ModelFileVo;
 import com.persagy.adm.server.algorithm.domain.QueryModelFileVo;
 import com.persagy.adm.server.algorithm.entity.AdmModelFile;
 import com.persagy.adm.server.algorithm.service.AdmModelService;
+import com.persagy.dmp.common.constant.DigitalObjectType;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
@@ -18,9 +21,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -37,37 +38,67 @@ public class AdmModelController {
     private final AdmModelService admModelService;
 
     /**
-     * 010101-模型文件-根据建筑id查询模型文件列表
+     * 010101-模型文件-查询模型文件列表
      * @param queryModelFileVo : 模型文件查询信息
      * @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.adm.server.algorithm.entity.AdmModelFile>>
      * @author : lijie
      * Update By 2022/1/12 16:32
      * @undone
      */
-    @PostMapping(value = "/queryModelFilesByBuildingId")
-    public CommonResult<List<ModelFileVo>> queryFloorsByBuildingId(@RequestBody QueryModelFileVo queryModelFileVo) {
+    @PostMapping(value = "/queryModelFilesByProjectId")
+    public CommonResult<List<BuildingVo>> queryModelFilesByProjectId(@RequestBody QueryModelFileVo queryModelFileVo) {
         // 1.根据建筑id查询建筑下的所有楼层
-        List<ObjectDigital> allFloors = admModelService.queryFloorsByBuildingId(queryModelFileVo.getBuildingId());
-        if (CollUtil.isEmpty(allFloors)){
+        List<ObjectDigital> allBuildFloors = admModelService.queryBuildFloorsByProjectId();
+        if (CollUtil.isEmpty(allBuildFloors)){
             return ResultHelper.multi(new ArrayList<>());
         }
         // 2.根据floorId查询最新的模型文件信息
         Map<String, AdmModelFile> modelFileMap = admModelService
-                .queryCurrentModelFileByFloorIds(allFloors.stream().map(ObjectDigital::getId).collect(Collectors.toList()));
+                .queryCurrentModelFileByFloorIds(allBuildFloors.stream()
+                        .filter(objectDigital -> DigitalObjectType.FLOOR.getIndex().equals(objectDigital.getObjType()))
+                        .map(ObjectDigital::getId).collect(Collectors.toList()));
         // 3.组装返回值
-        List<ModelFileVo> result = new ArrayList<>(allFloors.size());
-        for (ObjectDigital floor : allFloors) {
+        Map<String, BuildingVo> buildingVoMap = new HashMap<>(allBuildFloors.size());
+        for (ObjectDigital digital : allBuildFloors) {
+            if (DigitalObjectType.BUILDING.getIndex().equals(digital.getObjType())){
+                // 处理建筑数据
+                BuildingVo buildingVo = buildingVoMap.getOrDefault(digital.getId(),new BuildingVo());
+                buildingVo.setBuildingId(digital.getId());
+                buildingVo.setBuildingName(digital.getLocalName());
+                if (null!=digital.getInfos()
+                        && digital.getInfos().has(AdmServerConstant.BUILD_SEQUENCE_ID)
+                        && digital.getInfos().get(AdmServerConstant.BUILD_SEQUENCE_ID).isIntegralNumber()){
+                    buildingVo.setBuildSequenceId(digital.getInfos().get(AdmServerConstant.BUILD_SEQUENCE_ID).asInt());
+                }
+                if (null!=digital.getInfos()
+                        && digital.getInfos().has(AdmServerConstant.BUILD_SEQUENCE_ID)
+                        && digital.getInfos().get(AdmServerConstant.BUILD_SEQUENCE_ID).isTextual()){
+                    buildingVo.setBuildSequenceId(Integer.parseInt(digital.getInfos().get(AdmServerConstant.BUILD_SEQUENCE_ID).asText()));
+                }
+                buildingVoMap.put(digital.getId(),buildingVo);
+                continue;
+            }
+            if (null==digital.getInfos()
+                    || !digital.getInfos().has(AdmServerConstant.BUILDING_ID)
+                    || !digital.getInfos().get(AdmServerConstant.BUILDING_ID).isTextual()){
+                continue;
+            }
+            String buildingId = digital.getInfos().get(AdmServerConstant.BUILDING_ID).asText();
+            BuildingVo buildingVo = buildingVoMap.getOrDefault(buildingId, new BuildingVo());
+            buildingVoMap.put(buildingId,buildingVo);
+            List<ModelFileVo> modelFileVos = CollUtil.defaultIfEmpty(buildingVo.getModelFiles(), CollUtil.newArrayList());
+            buildingVo.setModelFiles(modelFileVos);
             ModelFileVo vo = new ModelFileVo();
-            result.add(vo);
-            vo.setFloorId(floor.getId());
-            vo.setBuildingId(queryModelFileVo.getBuildingId());
-            vo.setFloorName(floor.getLocalName());
-            if (null!=floor.getInfos()
-                    && floor.getInfos().has(AdmServerConstant.FLOOR_SEQUENCE_ID)
-                    && floor.getInfos().get(AdmServerConstant.FLOOR_SEQUENCE_ID).isIntegralNumber()){
-                vo.setFloorSequenceId(floor.getInfos().get(AdmServerConstant.FLOOR_SEQUENCE_ID).asInt());
+            modelFileVos.add(vo);
+            vo.setFloorId(digital.getId());
+            vo.setBuildingId(buildingId);
+            vo.setFloorName(digital.getLocalName());
+            if (null!=digital.getInfos()
+                    && digital.getInfos().has(AdmServerConstant.FLOOR_SEQUENCE_ID)
+                    && digital.getInfos().get(AdmServerConstant.FLOOR_SEQUENCE_ID).isIntegralNumber()){
+                vo.setFloorSequenceId(digital.getInfos().get(AdmServerConstant.FLOOR_SEQUENCE_ID).asInt());
             }
-            AdmModelFile admModelFile = modelFileMap.get(floor.getId());
+            AdmModelFile admModelFile = modelFileMap.get(digital.getId());
             if (null==admModelFile){
                 continue;
             }
@@ -80,7 +111,19 @@ public class AdmModelController {
             vo.setUserId(admModelFile.getUserId());
             vo.setUserName(admModelFile.getUserName());
         }
-        return ResultHelper.multi(result);
+        // 4.处理一下排序
+        List<BuildingVo> buildingVos = CollUtil.newArrayList(buildingVoMap.values()).stream()
+                .filter(buildingVo -> CollUtil.isEmpty(queryModelFileVo.getBuildingIds())
+                        || queryModelFileVo.getBuildingIds().contains(buildingVo.getBuildingId()))
+                .filter(buildingVo -> StrUtil.isNotBlank(buildingVo.getBuildingId())).collect(Collectors.toList());
+        for (BuildingVo buildingVo : buildingVos) {
+            if(CollUtil.isEmpty(buildingVo.getModelFiles())){
+                continue;
+            }
+            buildingVo.getModelFiles().sort(Comparator.comparing(ModelFileVo::getFloorSequenceId));
+        }
+        buildingVos.sort(Comparator.comparing(BuildingVo::getBuildSequenceId));
+        return ResultHelper.multi(buildingVos);
     }
     /**
      * 010102-模型文件-创建模型文件信息

+ 22 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/domain/BuildingVo.java

@@ -0,0 +1,22 @@
+package com.persagy.adm.server.algorithm.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 建筑实体VO类
+ * @author : lijie
+ * Update By 2022/1/20 13:36
+ */
+@Data
+public class BuildingVo {
+    /**建筑id*/
+    private String buildingId;
+    /**建筑本地名称*/
+    private String buildingName;
+    /**建筑顺序码*/
+    private Integer buildSequenceId;
+    /**建筑下的模型文件信息*/
+    private List<ModelFileVo> modelFiles;
+}

+ 3 - 3
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/domain/QueryModelFileVo.java

@@ -3,6 +3,7 @@ package com.persagy.adm.server.algorithm.domain;
 import lombok.Data;
 
 import javax.validation.constraints.NotBlank;
+import java.util.Set;
 
 /**
  * 查询模型文件的VO类
@@ -11,8 +12,7 @@ import javax.validation.constraints.NotBlank;
  */
 @Data
 public class QueryModelFileVo {
-    /**建筑id*/
-    @NotBlank
-    private String buildingId;
+    /**建筑id列表:用于过滤,为空时返回项目下所有建筑*/
+    private Set<String> buildingIds;
 
 }

+ 3 - 3
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/AdmModelService.java

@@ -6,6 +6,7 @@ import com.persagy.dmp.digital.entity.ObjectDigital;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 模型文件的逻辑处理接口
@@ -14,13 +15,12 @@ import java.util.Map;
  */
 public interface AdmModelService {
     /**
-     * 根据建筑id查询建筑下的所有楼层
-     * @param buildingId : 建筑id
+     * 查询项目下的所有建筑楼层
      * @return : java.util.List<com.persagy.dmp.digital.entity.ObjectDigital>
      * @author : lijie
      * Update By 2022/1/19 10:04
      */
-    List<ObjectDigital> queryFloorsByBuildingId(String buildingId);
+    List<ObjectDigital> queryBuildFloorsByProjectId();
     /**
      * 根据楼层id集合查询当前的模型文件信息
      * @param floorIds : 楼层id集合

+ 8 - 11
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/impl/AdmModelServiceImpl.java

@@ -12,6 +12,7 @@ import com.persagy.adm.server.algorithm.entity.AdmModelFile;
 import com.persagy.adm.server.algorithm.service.AdmModelService;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.common.constant.CommonConstant;
+import com.persagy.dmp.common.constant.DigitalObjectType;
 import com.persagy.dmp.common.constant.GraphCodeEnum;
 import com.persagy.dmp.common.constant.RelCodeEnum;
 import com.persagy.dmp.common.context.AppContext;
@@ -28,6 +29,7 @@ import org.springframework.stereotype.Service;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -44,25 +46,20 @@ public class AdmModelServiceImpl implements AdmModelService {
 
     /**
      * 根据建筑id查询建筑下的所有楼层
-     * @param buildingId : 建筑id
      * @return : java.util.List<com.persagy.dmp.digital.entity.ObjectDigital>
      * @author : lijie
      * Update By 2022/1/19 10:04
      */
     @Override
-    public List<ObjectDigital> queryFloorsByBuildingId(String buildingId) {
-        if (StrUtil.isBlank(buildingId)){
-            return new ArrayList<>();
-        }
+    public List<ObjectDigital> queryBuildFloorsByProjectId() {
         // 构建查询参数,valid为true,并且是该建筑下的.且按floorSequenceID正序排序
         QueryCriteria queryCriteria = new QueryCriteria();
         ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
         ObjectNode objectNode = objectMapper.createObjectNode();
         objectNode.put(ObjectDigital.PROP_VALID,Boolean.TRUE);
-        objectNode.putPOJO(ObjectRelation.RELATION_TO_HUM,createRelationQueryNode(objectMapper, GraphCodeEnum.ArchSubset.name(),
-                RelCodeEnum.Bd2Fl.name(),buildingId));
+        objectNode.putPOJO(ObjectDigital.OBJ_TYPE_HUM, CollUtil.newArrayList(DigitalObjectType.FLOOR.getIndex(),
+                DigitalObjectType.BUILDING.getIndex()));
         queryCriteria.setCriteria(objectNode);
-        queryCriteria.setOrders(CollUtil.newArrayList(OrderItem.asc(AdmServerConstant.FLOOR_SEQUENCE_ID)));
         CommonResult<List<ObjectDigital>> commonResult = DigitalObjectFacade.queryObject(AppContext.getContext().getGroupCode(),
                 AppContext.getContext().getProjectId(), AppContext.getContext().getAppId(),
                 AppContext.getContext().getAccountId(), queryCriteria);
@@ -110,17 +107,17 @@ public class AdmModelServiceImpl implements AdmModelService {
      * @param objectMapper : objectMapper
      * @param graphCode : 图类型编码
      * @param relCode : 边类型编码
-     * @param buildingId : 建筑id
+     * @param buildingIds : 建筑id
      * @return : com.fasterxml.jackson.databind.node.ObjectNode
      * @author : lijie
      * Update By 2022/1/19 14:18
      */
     private ObjectNode createRelationQueryNode(ObjectMapper objectMapper, String graphCode, String relCode,
-                                               String buildingId) {
+                                               Set<String> buildingIds) {
         ObjectNode objectNode = objectMapper.createObjectNode();
         objectNode.put(ObjectRelation.GRAPH_CODE_HUM,graphCode);
         objectNode.put(ObjectRelation.REL_CODE_HUM,relCode);
-        objectNode.put(ObjectRelation.OBJ_FROM_HUM,buildingId);
+        objectNode.putPOJO(ObjectRelation.OBJ_FROM_HUM,buildingIds);
         return objectNode;
     }
 }