|
@@ -11,7 +11,6 @@ import com.persagy.dmp.basic.dto.RelationCalRuleDTO;
|
|
import com.persagy.dmp.common.helper.SpringHelper;
|
|
import com.persagy.dmp.common.helper.SpringHelper;
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
import com.persagy.dmp.rwd.basic.constant.EquipmentTypeEnum;
|
|
import com.persagy.dmp.rwd.basic.constant.EquipmentTypeEnum;
|
|
-import com.persagy.dmp.rwd.basic.utils.DigitalCommonUtils;
|
|
|
|
import com.persagy.dmp.rwd.basic.utils.GeoToolsUtil;
|
|
import com.persagy.dmp.rwd.basic.utils.GeoToolsUtil;
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectDigitalMapper;
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectDigitalMapper;
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectRelationMapper;
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectRelationMapper;
|
|
@@ -59,27 +58,27 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
@Override
|
|
@Override
|
|
public void calculateRelation(RelationCalRuleDTO calRule, CalculatingDTO calculatingDTO) {
|
|
public void calculateRelation(RelationCalRuleDTO calRule, CalculatingDTO calculatingDTO) {
|
|
// 1.获取有所在楼层的所有业务空间, 并按照所在楼层和业务空间类型排序
|
|
// 1.获取有所在楼层的所有业务空间, 并按照所在楼层和业务空间类型排序
|
|
- List<SpaceCalDTO> spaceCalDTOS = objectRelationMapper.querySpacesByProjectId(calculatingDTO);
|
|
|
|
- if (CollUtil.isEmpty(spaceCalDTOS)){
|
|
|
|
|
|
+ List<SpaceCalDTO> spaceCalDtoS = objectRelationMapper.querySpacesByProjectId(calculatingDTO);
|
|
|
|
+ if (CollUtil.isEmpty(spaceCalDtoS)){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// 1.1 获得[[space,space]]的二维数组
|
|
// 1.1 获得[[space,space]]的二维数组
|
|
- Map<String,List<SpaceCalDTO>> spaceMap = spaceCalDTOS.stream()
|
|
|
|
|
|
+ Map<String,List<SpaceCalDTO>> spaceMap = spaceCalDtoS.stream()
|
|
.collect(Collectors.groupingBy(spaceCalDTO -> spaceCalDTO.getFloorId()+StrUtil.UNDERLINE+spaceCalDTO.getClassCode()));
|
|
.collect(Collectors.groupingBy(spaceCalDTO -> spaceCalDTO.getFloorId()+StrUtil.UNDERLINE+spaceCalDTO.getClassCode()));
|
|
|
|
|
|
// 存储的关系列表
|
|
// 存储的关系列表
|
|
List<ObjectRelation> resultList = new ArrayList<>();
|
|
List<ObjectRelation> resultList = new ArrayList<>();
|
|
// 2.门的计算
|
|
// 2.门的计算
|
|
- calculateRelationInternal(resultList,spaceCalDTOS,calculatingDTO,spaceMap, EquipmentTypeEnum.CFBEDR.name(),
|
|
|
|
|
|
+ calculateRelationInternal(resultList,spaceCalDtoS,calculatingDTO,spaceMap, EquipmentTypeEnum.CFBEDR.name(),
|
|
calRule.getSpaceConnectionCal().getDoorCalFlag());
|
|
calRule.getSpaceConnectionCal().getDoorCalFlag());
|
|
// 3.窗的计算
|
|
// 3.窗的计算
|
|
- calculateRelationInternal(resultList,spaceCalDTOS,calculatingDTO,spaceMap,EquipmentTypeEnum.CFBEWN.name(),
|
|
|
|
|
|
+ calculateRelationInternal(resultList,spaceCalDtoS,calculatingDTO,spaceMap,EquipmentTypeEnum.CFBEWN.name(),
|
|
calRule.getSpaceConnectionCal().getWindowCalFlag());
|
|
calRule.getSpaceConnectionCal().getWindowCalFlag());
|
|
// 4.虚拟墙的计算(暂时没有虚拟墙的概念,先置为false)
|
|
// 4.虚拟墙的计算(暂时没有虚拟墙的概念,先置为false)
|
|
- calculateRelationInternal(resultList,spaceCalDTOS,calculatingDTO,spaceMap,EquipmentTypeEnum.CFBEXX.name(),
|
|
|
|
|
|
+ calculateRelationInternal(resultList,spaceCalDtoS,calculatingDTO,spaceMap,EquipmentTypeEnum.CFBEXX.name(),
|
|
calRule.getSpaceConnectionCal().getVirtualWindowCalFlag());
|
|
calRule.getSpaceConnectionCal().getVirtualWindowCalFlag());
|
|
// 5.元空间的计算
|
|
// 5.元空间的计算
|
|
- ispaceCalculateRelationInternal(resultList,spaceCalDTOS,calculatingDTO,spaceMap,
|
|
|
|
|
|
+ ispaceCalculateRelationInternal(resultList,spaceCalDtoS,calculatingDTO,spaceMap,
|
|
calRule.getSpaceConnectionCal().getIspaceCalFlag());
|
|
calRule.getSpaceConnectionCal().getIspaceCalFlag());
|
|
if (CollUtil.isNotEmpty(resultList)){
|
|
if (CollUtil.isNotEmpty(resultList)){
|
|
// 3.根据图类型编码,边类型编码,relValue,项目id,集团编码删除关系
|
|
// 3.根据图类型编码,边类型编码,relValue,项目id,集团编码删除关系
|
|
@@ -91,7 +90,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
/***
|
|
/***
|
|
* Description: 元空间的计算
|
|
* Description: 元空间的计算
|
|
* @param resultList : 结果集
|
|
* @param resultList : 结果集
|
|
- * @param spaceCalDTOS : 空间数据
|
|
|
|
|
|
+ * @param spaceCalDtoS : 空间数据
|
|
* @param calculatingDTO : 请求参数
|
|
* @param calculatingDTO : 请求参数
|
|
* @param spaceMap:{floorId_classCode:空间对象}
|
|
* @param spaceMap:{floorId_classCode:空间对象}
|
|
* @param calFlag : 是否计算的标记
|
|
* @param calFlag : 是否计算的标记
|
|
@@ -100,7 +99,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
* @date :2021/10/11 22:06
|
|
* @date :2021/10/11 22:06
|
|
* Update By lijie 2021/10/11 22:06
|
|
* Update By lijie 2021/10/11 22:06
|
|
*/
|
|
*/
|
|
- private void ispaceCalculateRelationInternal(List<ObjectRelation> resultList, List<SpaceCalDTO> spaceCalDTOS,
|
|
|
|
|
|
+ private void ispaceCalculateRelationInternal(List<ObjectRelation> resultList, List<SpaceCalDTO> spaceCalDtoS,
|
|
CalculatingDTO calculatingDTO,
|
|
CalculatingDTO calculatingDTO,
|
|
Map<String, List<SpaceCalDTO>> spaceMap,
|
|
Map<String, List<SpaceCalDTO>> spaceMap,
|
|
Boolean calFlag) {
|
|
Boolean calFlag) {
|
|
@@ -108,7 +107,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// 1.根据modelId批量查询门
|
|
// 1.根据modelId批量查询门
|
|
- List<SpaceCalDTO> ispaces = objectDigitalMapper.queryIspacesByModelIds(spaceCalDTOS.stream()
|
|
|
|
|
|
+ List<SpaceCalDTO> ispaces = objectDigitalMapper.queryIspacesByModelIds(spaceCalDtoS.stream()
|
|
.map(SpaceCalDTO::getFloorModelId).collect(Collectors.toSet()),calculatingDTO);
|
|
.map(SpaceCalDTO::getFloorModelId).collect(Collectors.toSet()),calculatingDTO);
|
|
if (CollUtil.isEmpty(ispaces)){
|
|
if (CollUtil.isEmpty(ispaces)){
|
|
return;
|
|
return;
|
|
@@ -155,7 +154,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
/***
|
|
/***
|
|
* Description: 通过门计算空间连通性
|
|
* Description: 通过门计算空间连通性
|
|
* @param resultList : 结果集
|
|
* @param resultList : 结果集
|
|
- * @param spaceCalDTOS : 空间数据
|
|
|
|
|
|
+ * @param spaceCalDtoS : 空间数据
|
|
* @param calculatingDTO : 请求参数
|
|
* @param calculatingDTO : 请求参数
|
|
* @param spaceMap:{floorId_classCode:空间对象}
|
|
* @param spaceMap:{floorId_classCode:空间对象}
|
|
* @return : void
|
|
* @return : void
|
|
@@ -164,7 +163,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
* Update By lijie 2021/10/11 17:44
|
|
* Update By lijie 2021/10/11 17:44
|
|
*/
|
|
*/
|
|
private void calculateRelationInternal(List<ObjectRelation> resultList,
|
|
private void calculateRelationInternal(List<ObjectRelation> resultList,
|
|
- List<SpaceCalDTO> spaceCalDTOS,
|
|
|
|
|
|
+ List<SpaceCalDTO> spaceCalDtoS,
|
|
CalculatingDTO calculatingDTO,
|
|
CalculatingDTO calculatingDTO,
|
|
Map<String, List<SpaceCalDTO>> spaceMap,
|
|
Map<String, List<SpaceCalDTO>> spaceMap,
|
|
String classCode,Boolean calFlag) {
|
|
String classCode,Boolean calFlag) {
|
|
@@ -172,7 +171,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// 1.根据modelId批量查询门
|
|
// 1.根据modelId批量查询门
|
|
- List<SpaceCalDTO> doors = objectDigitalMapper.queryEquipmentsByModelIds(spaceCalDTOS.stream()
|
|
|
|
|
|
+ List<SpaceCalDTO> doors = objectDigitalMapper.queryEquipmentsByModelIds(spaceCalDtoS.stream()
|
|
.map(SpaceCalDTO::getFloorModelId).collect(Collectors.toSet()),calculatingDTO,classCode);
|
|
.map(SpaceCalDTO::getFloorModelId).collect(Collectors.toSet()),calculatingDTO,classCode);
|
|
if (CollUtil.isEmpty(doors)){
|
|
if (CollUtil.isEmpty(doors)){
|
|
return;
|
|
return;
|
|
@@ -297,13 +296,13 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
double distance = getSegmentDistance(closedFirstX, closedFirstY, closedSecondX, closedSecondY);
|
|
double distance = getSegmentDistance(closedFirstX, closedFirstY, closedSecondX, closedSecondY);
|
|
// 2.计算该直线的斜率
|
|
// 2.计算该直线的斜率
|
|
Double k=null;
|
|
Double k=null;
|
|
- if(closedFirstX!=closedSecondX){
|
|
|
|
|
|
+ if(Double.compare(closedFirstX,closedSecondX)!=0){
|
|
k=(closedFirstY-closedSecondY)/(closedFirstX-closedSecondX);
|
|
k=(closedFirstY-closedSecondY)/(closedFirstX-closedSecondX);
|
|
}
|
|
}
|
|
// 2.1 获得垂直线的斜率
|
|
// 2.1 获得垂直线的斜率
|
|
Double verticalK = getVerticalK(k);
|
|
Double verticalK = getVerticalK(k);
|
|
// 2.2 获得当前直线的a
|
|
// 2.2 获得当前直线的a
|
|
- Double closedA = getAByPointAndK(closedFirstX,closedFirstY,k);
|
|
|
|
|
|
+ Double closedA = getAbyPointAndK(closedFirstX,closedFirstY,k);
|
|
List<OpenPointDTO> result = new ArrayList<>();
|
|
List<OpenPointDTO> result = new ArrayList<>();
|
|
if (distance>deltaDistance){
|
|
if (distance>deltaDistance){
|
|
// 距离大于delta_distance, 则足够开两个门
|
|
// 距离大于delta_distance, 则足够开两个门
|
|
@@ -311,8 +310,8 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
k,closedA,deltaDistance,closedSecondX,closedSecondY);
|
|
k,closedA,deltaDistance,closedSecondX,closedSecondY);
|
|
OpenPointDTO secondSegOpenPoint = getPointByDistanceOnSegment(closedSecondX,closedSecondY,
|
|
OpenPointDTO secondSegOpenPoint = getPointByDistanceOnSegment(closedSecondX,closedSecondY,
|
|
k,closedA,deltaDistance,closedFirstX,closedFirstY);
|
|
k,closedA,deltaDistance,closedFirstX,closedFirstY);
|
|
- Double firstA = getAByPointAndK(firstSegOpenPoint.getDestX(), firstSegOpenPoint.getDestY(), verticalK);
|
|
|
|
- Double secondA = getAByPointAndK(secondSegOpenPoint.getDestX(), secondSegOpenPoint.getDestY(), verticalK);
|
|
|
|
|
|
+ Double firstA = getAbyPointAndK(firstSegOpenPoint.getDestX(), firstSegOpenPoint.getDestY(), verticalK);
|
|
|
|
+ Double secondA = getAbyPointAndK(secondSegOpenPoint.getDestX(), secondSegOpenPoint.getDestY(), verticalK);
|
|
OpenPointDTO firstDistance = getPointByDistance(firstSegOpenPoint.getDestX(), firstSegOpenPoint.getDestY(), verticalK, firstA, doorLength);
|
|
OpenPointDTO firstDistance = getPointByDistance(firstSegOpenPoint.getDestX(), firstSegOpenPoint.getDestY(), verticalK, firstA, doorLength);
|
|
OpenPointDTO secondDistance = getPointByDistance(secondSegOpenPoint.getDestX(), secondSegOpenPoint.getDestY(), verticalK, secondA, doorLength);
|
|
OpenPointDTO secondDistance = getPointByDistance(secondSegOpenPoint.getDestX(), secondSegOpenPoint.getDestY(), verticalK, secondA, doorLength);
|
|
result.add(OpenPointDTO.builder().destX(firstDistance.getFirstX()).destY(firstDistance.getFirstY()).build());
|
|
result.add(OpenPointDTO.builder().destX(firstDistance.getFirstX()).destY(firstDistance.getFirstY()).build());
|
|
@@ -324,7 +323,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
// 中间开门
|
|
// 中间开门
|
|
OpenPointDTO openPoint = getPointByDistanceOnSegment(closedFirstX, closedFirstY,
|
|
OpenPointDTO openPoint = getPointByDistanceOnSegment(closedFirstX, closedFirstY,
|
|
k, closedA, distance / 2, closedSecondX, closedSecondY);
|
|
k, closedA, distance / 2, closedSecondX, closedSecondY);
|
|
- Double verticalA = getAByPointAndK(openPoint.getDestX(), openPoint.getDestY(), verticalK);
|
|
|
|
|
|
+ Double verticalA = getAbyPointAndK(openPoint.getDestX(), openPoint.getDestY(), verticalK);
|
|
OpenPointDTO firstDistance = getPointByDistance(openPoint.getDestX(), openPoint.getDestY(), verticalK, verticalA, doorLength);
|
|
OpenPointDTO firstDistance = getPointByDistance(openPoint.getDestX(), openPoint.getDestY(), verticalK, verticalA, doorLength);
|
|
result.add(OpenPointDTO.builder().destX(firstDistance.getFirstX()).destY(firstDistance.getFirstY()).build());
|
|
result.add(OpenPointDTO.builder().destX(firstDistance.getFirstX()).destY(firstDistance.getFirstY()).build());
|
|
result.add(OpenPointDTO.builder().destX(firstDistance.getSecondX()).destY(firstDistance.getSecondY()).build());
|
|
result.add(OpenPointDTO.builder().destX(firstDistance.getSecondX()).destY(firstDistance.getSecondY()).build());
|
|
@@ -398,7 +397,7 @@ public class SpaceConnectionRelCalculateServiceImpl implements CalculateService
|
|
* @date :2021/10/11 20:34
|
|
* @date :2021/10/11 20:34
|
|
* Update By lijie 2021/10/11 20:34
|
|
* Update By lijie 2021/10/11 20:34
|
|
*/
|
|
*/
|
|
- private Double getAByPointAndK(double x, double y, Double k) {
|
|
|
|
|
|
+ private Double getAbyPointAndK(double x, double y, Double k) {
|
|
if (null==k){
|
|
if (null==k){
|
|
return 0.0;
|
|
return 0.0;
|
|
}
|
|
}
|