|
@@ -2,11 +2,14 @@ package com.persagy.adm.server.algorithm.controller;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
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.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.ModelFileVo;
|
|
import com.persagy.adm.server.algorithm.domain.QueryModelFileVo;
|
|
import com.persagy.adm.server.algorithm.domain.QueryModelFileVo;
|
|
import com.persagy.adm.server.algorithm.entity.AdmModelFile;
|
|
import com.persagy.adm.server.algorithm.entity.AdmModelFile;
|
|
import com.persagy.adm.server.algorithm.service.AdmModelService;
|
|
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.context.AppContext;
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
import com.persagy.dmp.common.utils.ResultHelper;
|
|
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.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
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;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -37,37 +38,67 @@ public class AdmModelController {
|
|
private final AdmModelService admModelService;
|
|
private final AdmModelService admModelService;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 010101-模型文件-根据建筑id查询模型文件列表
|
|
|
|
|
|
+ * 010101-模型文件-查询模型文件列表
|
|
* @param queryModelFileVo : 模型文件查询信息
|
|
* @param queryModelFileVo : 模型文件查询信息
|
|
* @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.adm.server.algorithm.entity.AdmModelFile>>
|
|
* @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.adm.server.algorithm.entity.AdmModelFile>>
|
|
* @author : lijie
|
|
* @author : lijie
|
|
* Update By 2022/1/12 16:32
|
|
* Update By 2022/1/12 16:32
|
|
* @undone
|
|
* @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查询建筑下的所有楼层
|
|
// 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<>());
|
|
return ResultHelper.multi(new ArrayList<>());
|
|
}
|
|
}
|
|
// 2.根据floorId查询最新的模型文件信息
|
|
// 2.根据floorId查询最新的模型文件信息
|
|
Map<String, AdmModelFile> modelFileMap = admModelService
|
|
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.组装返回值
|
|
// 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();
|
|
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){
|
|
if (null==admModelFile){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -80,7 +111,19 @@ public class AdmModelController {
|
|
vo.setUserId(admModelFile.getUserId());
|
|
vo.setUserId(admModelFile.getUserId());
|
|
vo.setUserName(admModelFile.getUserName());
|
|
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-模型文件-创建模型文件信息
|
|
* 010102-模型文件-创建模型文件信息
|