|
@@ -1,24 +1,24 @@
|
|
|
package com.persagy.proxy.adm.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.text.TextSimilarity;
|
|
|
+import cn.hutool.core.util.BooleanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
+import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
import com.persagy.proxy.adm.model.*;
|
|
|
import com.persagy.proxy.adm.model.equip.ShaftSpaceVertical;
|
|
|
-import com.persagy.proxy.adm.model.equip.SpVerticalSp;
|
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
import com.persagy.proxy.adm.service.*;
|
|
|
import com.persagy.proxy.adm.utils.AdmContextUtil;
|
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.*;
|
|
@@ -35,332 +35,193 @@ public class AdmEquipShaftController {
|
|
|
|
|
|
@Autowired
|
|
|
private IAdmSystemService systemService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IAdmEquipmentService equipmentService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IAdmShaftService shaftService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IAdmBuildingService buildingService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IAdmSpVerticalSpService spVerticalSpService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IAdmSpaceService spaceService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IAdmRelationService relationService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IAdmFloorService floorService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IAdmDtRelationService dtRelationService;
|
|
|
-
|
|
|
- @Value("${middleware.group.code}")
|
|
|
- private String groupCode;
|
|
|
-
|
|
|
/**
|
|
|
* 查询没有和当前竖井绑定的系统
|
|
|
- *
|
|
|
- * @param param 竖井
|
|
|
+ * @param shaftId
|
|
|
+ * @param request
|
|
|
*/
|
|
|
@PostMapping("/unshaft-in-sys")
|
|
|
- public AdmResponse unShaftSys(@RequestBody JSONObject param) {
|
|
|
- //根据竖井Id,查询系统Id
|
|
|
- InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
- QueryCriteria queryRequest = new QueryCriteria();
|
|
|
- String shaftId = param.getString("shaftId");
|
|
|
- ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
|
|
|
- criteriaRel.put("graphCode", "MechInArch");
|
|
|
- criteriaRel.put("relCode", "Sy2Sh");
|
|
|
- criteriaRel.put("objTo", shaftId);
|
|
|
- queryRequest.setCriteria(criteriaRel);
|
|
|
- List<ObjectRelation> objectRelations = relationService.queryByCondition(context, queryRequest);
|
|
|
- List<String> sysIds = objectRelations.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toList());
|
|
|
-// String filter = "id = '" + shaftId + "'";
|
|
|
-// //根据竖井Id查询竖井
|
|
|
-// JSONObject request = param.getJSONObject("request");
|
|
|
-// AdmQueryCriteria criteria = JSONObject.toJavaObject(request, AdmQueryCriteria.class);
|
|
|
-// criteria.setFilters(filter);
|
|
|
-// AdmResponse admResponse = shaftService.doQuery(context, criteria, AdmShaft.class);
|
|
|
-// List<AdmShaft> admShafts = (List<AdmShaft>) admResponse.getContent();
|
|
|
-// List<String> sysIds = new ArrayList<>();
|
|
|
-// //获取竖井下的系统
|
|
|
-// for (AdmShaft admShaft : admShafts) {
|
|
|
-// List<AdmSystem> systemList = admShaft.getSystemList();
|
|
|
-// if (!CollectionUtils.isEmpty(systemList)) {
|
|
|
-// for (AdmSystem admSystem : systemList) {
|
|
|
-// sysIds.add(admSystem.getId());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
- JSONObject request = param.getJSONObject("request");
|
|
|
- AdmQueryCriteria criteria = JSONObject.toJavaObject(request, AdmQueryCriteria.class);
|
|
|
- //查询全量系统
|
|
|
- String filter = null;
|
|
|
- criteria.setFilters(filter);
|
|
|
- criteria.setName(AdmSystem.OBJ_TYPE);
|
|
|
- AdmResponse admResponse = systemService.doQuery(context, criteria, AdmSystem.class);
|
|
|
- List<AdmSystem> admSystems = (List<AdmSystem>) admResponse.getContent();
|
|
|
- Iterator<AdmSystem> iterator = admSystems.iterator();
|
|
|
- //去除竖井下的系统
|
|
|
- while (iterator.hasNext()) {
|
|
|
- AdmSystem next = iterator.next();
|
|
|
- if (sysIds.contains(next.getId())) {
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- }
|
|
|
- admResponse.setContent(admSystems);
|
|
|
- return admResponse;
|
|
|
+ public AdmResponse unShaftSys(@RequestParam String shaftId, @RequestBody AdmQueryCriteria request) {
|
|
|
+ request.setName(AdmSystem.OBJ_TYPE);
|
|
|
+ // 设置关系条件
|
|
|
+ request.resetRelationCond(true, "MechInArch", "Sy2Sh", shaftId, false);
|
|
|
+ return systemService.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询没有和当前竖井绑定的设备
|
|
|
*/
|
|
|
@PostMapping(value = "/unshaft-in-eq")
|
|
|
- public AdmResponse unShaftEq(@RequestBody JSONObject param) {
|
|
|
- String shaftId = param.getString("shaftId");
|
|
|
- InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
- QueryCriteria queryRequest = new QueryCriteria();
|
|
|
- ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
|
|
|
- criteriaRel.put("graphCode", "MechInArch");
|
|
|
- criteriaRel.put("relCode", "Eq2Sh");
|
|
|
- criteriaRel.put("objTo", shaftId);
|
|
|
- queryRequest.setCriteria(criteriaRel);
|
|
|
- List<ObjectRelation> objectRelations = relationService.queryByCondition(context, queryRequest);
|
|
|
- List<String> equipIds = objectRelations.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toList());
|
|
|
-
|
|
|
-// String filter = "id = '" + shaftId + "'";
|
|
|
-// //根据竖井Id查询
|
|
|
-// JSONObject request = param.getJSONObject("request");
|
|
|
-// AdmQueryCriteria criteria = JSONObject.toJavaObject(request, AdmQueryCriteria.class);
|
|
|
-// criteria.setFilters(filter);
|
|
|
-// AdmResponse admResponse = shaftService.doQuery(context, criteria, AdmShaft.class);
|
|
|
-// List<AdmShaft> admShafts = (List<AdmShaft>) admResponse.getContent();
|
|
|
-// List<String> equipIds = new ArrayList<>();
|
|
|
-// //获取竖井下的设备Id
|
|
|
-// for (AdmShaft admShaft : admShafts) {
|
|
|
-// List<AdmEquipment> equipmentList = admShaft.getEquipmentList();
|
|
|
-// if (!CollectionUtils.isEmpty(equipmentList)) {
|
|
|
-// for (AdmEquipment equipment : equipmentList) {
|
|
|
-// equipIds.add(equipment.getId());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
- //查询所有设备
|
|
|
- JSONObject request = param.getJSONObject("request");
|
|
|
- AdmQueryCriteria criteria = JSONObject.toJavaObject(request, AdmQueryCriteria.class);
|
|
|
- criteria.setFilters(null);
|
|
|
- criteria.setName(AdmEquipment.OBJ_TYPE);
|
|
|
- AdmResponse equipments = equipmentService.doQuery(context, criteria, AdmEquipment.class);
|
|
|
- List<AdmEquipment> admEquipments = (List<AdmEquipment>) equipments.getContent();
|
|
|
- //去除重复,竖井Id下的设备
|
|
|
- Iterator<AdmEquipment> iterator = admEquipments.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- AdmEquipment next = iterator.next();
|
|
|
- if (equipIds.contains(next.getId())) {
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- }
|
|
|
- equipments.setContent(admEquipments);
|
|
|
- return equipments;
|
|
|
+ public AdmResponse unShaftEq(@RequestParam String shaftId, @RequestBody AdmQueryCriteria request) {
|
|
|
+ request.setName(AdmEquipment.OBJ_TYPE);
|
|
|
+ // 设置关系条件
|
|
|
+ request.resetRelationCond(true, "MechInArch", "Eq2Sh", shaftId, false);
|
|
|
+ return equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询没有和当前竖井贯通的其它竖井
|
|
|
*/
|
|
|
@PostMapping(value = "/unshaft-through-shaft")
|
|
|
- public AdmResponse unShaftThroughShaft(@RequestBody JSONObject param) {
|
|
|
- InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
- String shaftId = param.getString("shaftId");
|
|
|
- JSONObject request = param.getJSONObject("request");
|
|
|
-
|
|
|
-// (graphCode = "ThroughRelationship", relCode = "Sh2Sh")
|
|
|
- QueryCriteria queryRequest = new QueryCriteria();
|
|
|
- ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
|
|
|
- criteriaRel.put("graphCode", "ThroughRelationship");
|
|
|
- criteriaRel.put("relCode", "Sh2Sh");
|
|
|
- criteriaRel.put("objTo", shaftId);
|
|
|
- queryRequest.setCriteria(criteriaRel);
|
|
|
- List<ObjectRelation> objectRelations = relationService.queryByCondition(context, queryRequest);
|
|
|
- List<String> shaftIds = objectRelations.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toList());
|
|
|
- queryRequest = new QueryCriteria();
|
|
|
- criteriaRel = JsonNodeFactory.instance.objectNode();
|
|
|
- criteriaRel.put("graphCode", "ThroughRelationship");
|
|
|
- criteriaRel.put("relCode", "Sh2Sh");
|
|
|
- criteriaRel.put("objFrom", shaftId);
|
|
|
- queryRequest.setCriteria(criteriaRel);
|
|
|
- List<ObjectRelation> objectRel = relationService.queryByCondition(context, queryRequest);
|
|
|
- List<String> shaftIdTos = objectRel.stream().map(ObjectRelation::getObjTo).collect(Collectors.toList());
|
|
|
- shaftIds.addAll(shaftIdTos);
|
|
|
- shaftIds.add(shaftId);
|
|
|
-
|
|
|
- AdmQueryCriteria criteria = JSONObject.toJavaObject(request, AdmQueryCriteria.class);
|
|
|
- criteria.setName(AdmShaft.OBJ_TYPE);
|
|
|
- AdmResponse admResponse = shaftService.doQuery(context, criteria, AdmShaft.class);
|
|
|
- List<AdmShaft> admShafts = (List<AdmShaft>) admResponse.getContent();
|
|
|
- Iterator<AdmShaft> iterator = admShafts.iterator();
|
|
|
- //去除竖井和竖井Id相同的竖井,一部分是关联数据
|
|
|
- while (iterator.hasNext()) {
|
|
|
- AdmShaft admShaft = iterator.next();
|
|
|
- List<AdmShaft> shaftThroughList = admShaft.getShaftThroughList();
|
|
|
- if (shaftIds.contains(admShaft.getId())) {
|
|
|
- iterator.remove();
|
|
|
- continue;
|
|
|
- }
|
|
|
-// for (AdmShaft shaft : shaftThroughList) {
|
|
|
-// if (shaft.getId().equals(shaftId)) {
|
|
|
-// iterator.remove();
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
- }
|
|
|
- admResponse.setContent(admShafts);
|
|
|
- return admResponse;
|
|
|
+ public AdmResponse unShaftThroughShaft(@RequestParam String shaftId, @RequestBody AdmQueryCriteria request) {
|
|
|
+ request.setName(AdmShaft.OBJ_TYPE);
|
|
|
+ // 设置关系条件
|
|
|
+ request.resetRelationCond(true, "ThroughRelationship", "Sh2Sh", shaftId, false);
|
|
|
+ return shaftService.doQuery(AdmContextUtil.toDmpContext(), request, AdmShaft.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询竖井关联的空间垂直交通关系
|
|
|
+ * @param shaftSpaceVertical
|
|
|
*/
|
|
|
@PostMapping("/shaft-vertical-space")
|
|
|
public AdmResponse shaftSpaceVertical(@RequestBody ShaftSpaceVertical shaftSpaceVertical) {
|
|
|
+ // 参数校验
|
|
|
String buildingId = shaftSpaceVertical.getBuildingId();
|
|
|
String shaftId = shaftSpaceVertical.getShaftId();
|
|
|
String objectType = shaftSpaceVertical.getObjectType();
|
|
|
Boolean aiSwitch = shaftSpaceVertical.getAiSwitch();
|
|
|
- if (StrUtil.isBlank(buildingId) || StrUtil.isBlank(shaftId)) {
|
|
|
- return AdmResponse.failure("必填项:buildingId(建筑id)、shaftId(竖井Id)");
|
|
|
+ if (StrUtil.isBlank(buildingId) || StrUtil.isBlank(objectType) || StrUtil.isBlank(shaftId)) {
|
|
|
+ return AdmResponse.failure("必填项:buildingId(建筑id)、shaftId(竖井Id)、objectType(空间类型)");
|
|
|
}
|
|
|
InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
- QueryCriteria queryRequest = new QueryCriteria();
|
|
|
- ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
|
|
|
- criteriaRel.put("graphCode", "ArchSubset");
|
|
|
- criteriaRel.put("relCode", "Bd2Fl");
|
|
|
- criteriaRel.put("objFrom", buildingId);
|
|
|
- queryRequest.setCriteria(criteriaRel);
|
|
|
- List<ObjectRelation> objectRelations = relationService.queryByCondition(context, queryRequest);
|
|
|
-// putString(criteria, "graphCode", anno.graphCode());
|
|
|
-// putString(criteria, "relCode", anno.relCode());
|
|
|
-// putString(criteria, "relValue", anno.relValue());
|
|
|
-// ArrayNode array = criteria.putObject(isSelectTo?"objFrom":"objTo").putArray("$in");
|
|
|
-// idList.forEach(id -> array.add(id));
|
|
|
- List<String> floorIds = objectRelations.stream().map(ObjectRelation::getObjTo).collect(Collectors.toList());
|
|
|
- AdmQueryCriteria criteria = new AdmQueryCriteria();
|
|
|
- String filter = " id in ('" + StrUtil.join("','", floorIds) + "') ";
|
|
|
- criteria.setFilters(filter);
|
|
|
- AdmResponse admBuild = floorService.doQuery(context, criteria, AdmFloor.class);
|
|
|
- List<AdmFloor> floor = (List<AdmFloor>) admBuild.getContent();
|
|
|
- //建筑下的楼层
|
|
|
- AdmResponse admResult = new AdmResponse();
|
|
|
- if (CollectionUtils.isEmpty(floor)) {
|
|
|
- return admResult;
|
|
|
+ // 查询建筑下的楼层
|
|
|
+ List<AdmFloor> floors = floorService.queryFloorInBuilding(context, buildingId);
|
|
|
+ AdmResponse response = AdmResponse.success(floors);
|
|
|
+ if(CollUtil.isEmpty(floors)) {
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ // 查询竖井下的空间
|
|
|
+ List<AdmSpace> spaces = spaceService.querySpaceInShaft(context, shaftId, objectType);
|
|
|
+ if(CollUtil.isEmpty(spaces)) {
|
|
|
+ return response;
|
|
|
}
|
|
|
- List<AdmSpace> spaceList = new ArrayList<>();
|
|
|
- //3 如果开关为true
|
|
|
- if (aiSwitch) {
|
|
|
- //1.查询竖井下的空间
|
|
|
-// and relValue = " + objectType + "
|
|
|
- filter = "graphCode = 'ArchSubset' and relCode = 'Sh2Sp' and projectId = " + context.getProjectId() + " and objFrom =" + shaftId + " and valid = 1";
|
|
|
- criteria.setFilters(filter);
|
|
|
- AdmResponse admResponse = dtRelationService.doQuery(context, criteria, AdmDtRelation.class);
|
|
|
- List<AdmDtRelation> dtRelations = (List<AdmDtRelation>) admResponse.getContent();
|
|
|
- List<String> spaceIdss = dtRelations.stream().map(AdmDtRelation::getObj_to).collect(Collectors.toList());
|
|
|
- filter = " id in ('" + StrUtil.join("','", spaceIdss) + "') ";
|
|
|
- criteria.setFilters(filter);
|
|
|
- admResponse= spaceService.doQuery(context,criteria,AdmSpace.class);
|
|
|
- spaceList = (List<AdmSpace>) admResponse.getContent();
|
|
|
- //2.排除不在buildingId下的
|
|
|
- Iterator<AdmSpace> iterator = spaceList.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- AdmSpace admSpace = iterator.next();
|
|
|
- if (!buildingId.equals(admSpace.getBuildingId())) {
|
|
|
- iterator.remove();
|
|
|
+ // 查询楼层下的空间
|
|
|
+ List<String> floorIds = CollUtil.getFieldValues(floors, BaseEntity.PROP_ID, String.class);
|
|
|
+ Map<String, List<String>> floorMap = spaceService.querySpaceMapInFloors(context, floorIds, objectType);
|
|
|
+ if(MapUtil.isEmpty(floorMap)) {
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ // 计算并收集垂直交通关系
|
|
|
+ groupSpaceToFloor(context, buildingId, floors, spaces, floorMap, objectType, aiSwitch);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按楼层汇总空间信息
|
|
|
+ * @param context
|
|
|
+ * @param buildingId
|
|
|
+ * @param floors
|
|
|
+ * @param spaces
|
|
|
+ * @param floorMap
|
|
|
+ * @param objectType
|
|
|
+ * @param aiSwitch
|
|
|
+ */
|
|
|
+ private void groupSpaceToFloor(InstanceUrlParam context, String buildingId, List<AdmFloor> floors, List<AdmSpace> spaces,
|
|
|
+ Map<String, List<String>> floorMap, String objectType, Boolean aiSwitch) {
|
|
|
+ Map<String, AdmSpace> spaceMap = spaces.stream().collect(Collectors.toMap(AdmSpace::getId, space -> space, (k1,k2)->k1));
|
|
|
+ Set<String> spaceIds = spaceMap.keySet();
|
|
|
+ // 如果需要AI:相似度匹配
|
|
|
+ Map<String, List<AdmSpace>> aiSpaceMap = new HashMap<>();
|
|
|
+ Set<String> allIds = CollUtil.newHashSet(spaceIds);
|
|
|
+ if(BooleanUtil.isTrue(aiSwitch)) {
|
|
|
+ // 匹配结果
|
|
|
+ aiSpaceMap = matchingSpaces(context, buildingId, spaces, spaceIds, objectType);
|
|
|
+ // 收集id
|
|
|
+ for(String key:aiSpaceMap.keySet()) {
|
|
|
+ List<AdmSpace> aiSpaces = aiSpaceMap.get(key);
|
|
|
+ if(CollUtil.isEmpty(aiSpaces)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
+ Set<String> aiSpaceIds = aiSpaces.stream().map(AdmSpace::getId).collect(Collectors.toSet());
|
|
|
+ allIds.addAll(aiSpaceIds);
|
|
|
}
|
|
|
- List<AdmSpace> copy = spaceList.stream().collect(Collectors.toList());
|
|
|
-
|
|
|
- List<String> classCodes = spaceList.stream().map(AdmSpace::getClassCode).collect(Collectors.toList());
|
|
|
- //查询建筑下所有指定类型空间
|
|
|
- String classCodeStr = "('" + StrUtil.join("','", classCodes) + "') ";
|
|
|
- //查询空间对象
|
|
|
- filter = "projectId = " + context.getProjectId() + " and buildingId = " + buildingId + " and classCode in " + classCodeStr + " and valid = 1";
|
|
|
- criteria.setFilters(filter);
|
|
|
- AdmResponse admSpaceRes = spaceService.doQuery(context, criteria, AdmSpace.class);
|
|
|
- List<AdmSpace> spaces = (List<AdmSpace>) admSpaceRes.getContent();
|
|
|
- for (AdmSpace space : spaces) {
|
|
|
- boolean flag = false;
|
|
|
- String localId = space.getLocalId();
|
|
|
- String localName = space.getLocalName();
|
|
|
- if (StrUtil.isBlank(localId) || StrUtil.isBlank(localName)) {
|
|
|
- for (AdmSpace admSpace : copy) {
|
|
|
- admSpace.getLocalId();
|
|
|
- admSpace.getLocalName();
|
|
|
- //如果名称或id匹配的大于90%
|
|
|
- if (TextSimilarity.similar(admSpace.getLocalId(), localId) > 0.9 || TextSimilarity.similar(admSpace.getLocalName(), localName) > 0.9) {
|
|
|
- flag = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (flag) {
|
|
|
- spaceList.add(space);
|
|
|
+ }
|
|
|
+ // 查询有垂直交通关系的空间
|
|
|
+ Map<String, Set<String>> trafficMap = spaceService.queryTrafficSpaceMap(context, allIds, objectType);
|
|
|
+ // 组装到Floor中
|
|
|
+ for(AdmFloor floor:floors) {
|
|
|
+ // 获取楼层下的空间
|
|
|
+ List<String> spInFls = floorMap.get(floor.getId());
|
|
|
+ if(CollUtil.isEmpty(spInFls)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Set<AdmSpace> spaceList = new HashSet<>();
|
|
|
+ for(String spInFlId:spInFls) {
|
|
|
+ // 取竖井中在本楼层的空间
|
|
|
+ AdmSpace spInSh = spaceMap.get(spInFlId);
|
|
|
+ if(spInSh == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 设置垂直交通关系
|
|
|
+ spInSh.setSpaceIdList(trafficMap.get(spInFlId));
|
|
|
+ spaceList.add(spInSh);
|
|
|
+ // 获取此空间匹配的空间
|
|
|
+ List<AdmSpace> matchSpaces = aiSpaceMap.get(spInFlId);
|
|
|
+ if(CollUtil.isEmpty(matchSpaces)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(AdmSpace matchSpace:matchSpaces) {
|
|
|
+ if(spaceList.add(matchSpace)) {
|
|
|
+ // 设置垂直交通关系
|
|
|
+ matchSpace.setSpaceIdList(trafficMap.get(matchSpace.getId()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //4 查询交通关系
|
|
|
- classCodes = spaceList.stream().map(AdmSpace::getClassCode).collect(Collectors.toList());
|
|
|
- classCodeStr = "('" + StrUtil.join("','", classCodes) + "') ";
|
|
|
- filter = "graphCode = TrafficNetwork and projectId = " + context.getProjectId() + " and (objFrom in " + classCodeStr + " or objTo in " + classCodeStr + ") and valid = 1";
|
|
|
- criteria.setFilters(filter);
|
|
|
- AdmResponse admSp = spVerticalSpService.doQuery(context, criteria, SpVerticalSp.class);
|
|
|
- List<SpVerticalSp> spVerticalSps = (List<SpVerticalSp>) admSp.getContent();
|
|
|
- List<String> spaceIds = spVerticalSps.stream().map(SpVerticalSp::getSpaceId).collect(Collectors.toList());
|
|
|
- String id = " id in ('" + StrUtil.join("','", spaceIds) + "') ";
|
|
|
- criteria.setFilters(id);
|
|
|
- admSpaceRes = spaceService.doQuery(context, criteria, AdmSpace.class);
|
|
|
- spaces = (List<AdmSpace>) admSpaceRes.getContent();
|
|
|
- spaceList.addAll(spaces);
|
|
|
- Set<String> ids = new HashSet<>();
|
|
|
- Iterator<AdmSpace> iter = spaceList.iterator();
|
|
|
- while (iter.hasNext()) {
|
|
|
- AdmSpace next = iter.next();
|
|
|
- //去除重复
|
|
|
- if (ids.contains(next.getId())) {
|
|
|
- iter.remove();
|
|
|
- }
|
|
|
- ids.add(next.getId());
|
|
|
+ if(CollUtil.isEmpty(spaceList)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
+ floor.setSpaceList(CollUtil.newArrayList(spaceList));
|
|
|
}
|
|
|
- //6将spaceList按照floor分组返回floor对象
|
|
|
- if (!CollectionUtils.isEmpty(spaceList)) {
|
|
|
- Map<String, List<AdmSpace>> map = new HashMap<>();
|
|
|
- for (AdmSpace admSpace : spaceList) {
|
|
|
- String floorId = admSpace.getFloorId();
|
|
|
- List<AdmSpace> spaces = new ArrayList<>();
|
|
|
- if (map.containsKey(floorId)) {
|
|
|
- spaces = map.get(floorId);
|
|
|
- }
|
|
|
- spaces.add(admSpace);
|
|
|
- map.put(floorId, spaces);
|
|
|
- }
|
|
|
- Iterator<AdmFloor> iterator = floor.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- AdmFloor admFloor = iterator.next();
|
|
|
- String id = admFloor.getId();
|
|
|
- List<AdmSpace> spaces = map.get(id);
|
|
|
- if (CollectionUtils.isEmpty(spaces)) {
|
|
|
- iterator.remove();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据相似度匹配空间
|
|
|
+ * @param context
|
|
|
+ * @param buildingId 匹配此建筑下的空间
|
|
|
+ * @param spaces 按这些空间匹配
|
|
|
+ * @param spaceIds
|
|
|
+ * @param objectType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, List<AdmSpace>> matchingSpaces(InstanceUrlParam context, String buildingId, List<AdmSpace> spaces,
|
|
|
+ Set<String> spaceIds, String objectType) {
|
|
|
+ final double matchingPercent = 0.9;
|
|
|
+ Map<String, List<AdmSpace>> aiSpaceMap = new HashMap<>();
|
|
|
+ // 查询建筑下的空间
|
|
|
+ List<AdmSpace> spInBds = spaceService.querySpaceInBuilding(context, buildingId, objectType);
|
|
|
+ // 按竖井下的空间,逐个计算每个空间匹配的空间
|
|
|
+ for(AdmSpace space:spaces) {
|
|
|
+ for(AdmSpace spInBd:spInBds) {
|
|
|
+ // 已在竖井下的不用再匹配
|
|
|
+ if (spaceIds.contains(spInBd)) {
|
|
|
continue;
|
|
|
}
|
|
|
- admFloor.setSpaceList(spaces);
|
|
|
+ // 字符串匹配度大于0.9的保留
|
|
|
+ if (TextSimilarity.similar(space.getLocalId(), spInBd.getLocalId()) > matchingPercent
|
|
|
+ || TextSimilarity.similar(space.getLocalName(), spInBd.getLocalName()) > matchingPercent) {
|
|
|
+ List<AdmSpace> ais = aiSpaceMap.get(space.getId());
|
|
|
+ if (CollUtil.isEmpty(ais)) {
|
|
|
+ ais = new ArrayList<>();
|
|
|
+ aiSpaceMap.put(space.getId(), ais);
|
|
|
+ }
|
|
|
+ spInBd.setIsAi(true);
|
|
|
+ ais.add(spInBd);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- admResult.setContent(floor);
|
|
|
- return admResult;
|
|
|
+ return aiSpaceMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -368,22 +229,30 @@ public class AdmEquipShaftController {
|
|
|
*/
|
|
|
@PostMapping("/vertical-space")
|
|
|
public AdmResponse shaftVerticalSp(@RequestBody ShaftSpaceVertical shaftSpaceVertical) {
|
|
|
- String buildingId = shaftSpaceVertical.getBuildingId();
|
|
|
+ String buildingId = shaftSpaceVertical.getBuildingId();
|
|
|
String shaftId = shaftSpaceVertical.getShaftId();
|
|
|
String objectType = shaftSpaceVertical.getObjectType();
|
|
|
if (StrUtil.isBlank(buildingId) || StrUtil.isBlank(shaftId) || StrUtil.isBlank(objectType)) {
|
|
|
return AdmResponse.failure("必填项:buildingId(建筑id)、shaftId(竖井Id),objectType(空间类型)");
|
|
|
}
|
|
|
+ // 查询竖井下的空间
|
|
|
InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
- AdmQueryCriteria criteria = new AdmQueryCriteria();
|
|
|
- String filter = "graphCode = 'ArchSubset' and relCode = 'Sh2Sp' and projectId = " + context.getProjectId() + " and objFrom =" + shaftId + " and valid = 1";
|
|
|
- criteria.setFilters(filter);
|
|
|
- AdmResponse admResponse = dtRelationService.doQuery(context, criteria, AdmDtRelation.class);
|
|
|
- List<AdmDtRelation> dtRelations = (List<AdmDtRelation>) admResponse.getContent();
|
|
|
- List<String> spaceIdss = dtRelations.stream().map(AdmDtRelation::getObj_to).collect(Collectors.toList());
|
|
|
- filter = " id in ('" + StrUtil.join("','", spaceIdss) + "') ";
|
|
|
- criteria.setFilters(filter);
|
|
|
- return spaceService.doQuery(context,criteria,AdmSpace.class);
|
|
|
+ QueryCriteria queryRequest = new QueryCriteria();
|
|
|
+ ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
|
|
|
+ criteriaRel.put("graphCode", "ArchSubset");
|
|
|
+ criteriaRel.put("relCode", "Sh2Sp");
|
|
|
+ criteriaRel.put("refValue", objectType);
|
|
|
+ criteriaRel.put("objFrom", shaftId);
|
|
|
+ queryRequest.setCriteria(criteriaRel);
|
|
|
+ List<ObjectRelation> relations = relationService.queryByCondition(context, queryRequest);
|
|
|
+ if(CollUtil.isEmpty(relations)) {
|
|
|
+ return AdmResponse.success();
|
|
|
+ }
|
|
|
+ // 收集空间ID
|
|
|
+ List<String> spaceIds = relations.stream().map(ObjectRelation::getObjTo).collect(Collectors.toList());
|
|
|
+ // TODO 异步调用垂直关系计算 public.is_vertically_overlap(#{projectId},#{buildingId},#{zoneType},ARRAY)
|
|
|
+
|
|
|
+ return AdmResponse.success();
|
|
|
}
|
|
|
|
|
|
}
|