|
@@ -5,25 +5,28 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.persagy.dmp.basic.dto.RelationCalRuleDTO;
|
|
|
+import com.persagy.dmp.basic.dto.RequestData;
|
|
|
+import com.persagy.dmp.common.constant.CommonConstant;
|
|
|
+import com.persagy.dmp.define.entity.DigitalEquipClassRel;
|
|
|
import com.persagy.dmp.define.entity.RelationDefine;
|
|
|
-import com.persagy.dmp.digital.entity.ObjectDigital;
|
|
|
-import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
-import com.persagy.dmp.digital.entity.ObjectRelationProjectCal;
|
|
|
+import com.persagy.dmp.digital.entity.*;
|
|
|
import com.persagy.dmp.rwd.basic.constant.EquipmentTypeEnum;
|
|
|
+import com.persagy.dmp.rwd.define.service.DigitalEquipClassRelService;
|
|
|
import com.persagy.dmp.rwd.define.service.IRelationDefineService;
|
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectDigitalMapper;
|
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectRelationMapper;
|
|
|
import com.persagy.dmp.rwd.digital.domain.CalculatingDTO;
|
|
|
import com.persagy.dmp.rwd.digital.domain.FloorCalDTO;
|
|
|
-import com.persagy.dmp.rwd.digital.service.CalculateService;
|
|
|
-import com.persagy.dmp.rwd.digital.service.IObjectRelationService;
|
|
|
-import com.persagy.dmp.rwd.digital.service.RelationProjectCalService;
|
|
|
+import com.persagy.dmp.rwd.digital.service.*;
|
|
|
import com.persagy.dmp.rwd.digital.utils.ObjectDigitalCriteriaHelper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.locationtech.jts.math.Vector2D;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/***
|
|
|
* Description: 管网系统设备分块关系计算
|
|
@@ -41,6 +44,9 @@ public class SysBlockCalculateServiceImpl implements CalculateService {
|
|
|
private final ObjectDigitalMapper objectDigitalMapper;
|
|
|
private final RelationProjectCalService relationProjectCalService;
|
|
|
private final IRelationDefineService relationDefineService;
|
|
|
+ private final ConnectedBlockSourceService connectedBlockSourceService;
|
|
|
+ private final ConnectedBlockService connectedBlockService;
|
|
|
+ private final DigitalEquipClassRelService digitalEquipClassRelService;
|
|
|
|
|
|
|
|
|
/***
|
|
@@ -69,11 +75,159 @@ public class SysBlockCalculateServiceImpl implements CalculateService {
|
|
|
// 2.分块
|
|
|
relCalculateBlock(calRule,calculatingDTO,mepSystemTypes,defineName);
|
|
|
// 3.设置源
|
|
|
+ setSourceType(calRule,calculatingDTO,mepSystemTypes,defineName);
|
|
|
// 4.计算流向
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /***
|
|
|
+ * Description: 设置数据源
|
|
|
+ * @param calRule : 计算规则
|
|
|
+ * @param calculatingDTO : 请求参数
|
|
|
+ * @param mepSystemTypes : 构件用途类型
|
|
|
+ * @param defineName : 边类型名称
|
|
|
+ * @return : void
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/13 18:49
|
|
|
+ * Update By lijie 2021/10/13 18:49
|
|
|
+ */
|
|
|
+ private void setSourceType(RelationCalRuleDTO calRule, CalculatingDTO calculatingDTO,
|
|
|
+ Set<String> mepSystemTypes, String defineName) {
|
|
|
+ // 1.根据项目id和边类型编码名称查询项目边关系数据
|
|
|
+ List<DigitalEquipClassRel> objectRelationProjectCals =
|
|
|
+ queryObjectRelationProjectCalsByProjectIdAndRelName(calculatingDTO.getGroupCode(),
|
|
|
+ calculatingDTO.getProjectId(),defineName);
|
|
|
+ if (CollUtil.isEmpty(objectRelationProjectCals)){
|
|
|
+ // 2.没有指定源设备类型, 直接删除项目下所有源设备类型
|
|
|
+ deletePrevSource(calculatingDTO.getProjectId(), null, mepSystemTypes);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 3.根据设备类型查询设备数据
|
|
|
+ // 3.1 根据对象类型code查询对象数据
|
|
|
+ Set<String> equipClassCodes = objectRelationProjectCals
|
|
|
+ .stream()
|
|
|
+ .map(DigitalEquipClassRel::getSourceEquipCode)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ List<ObjectDigital> equipments = queryEquipmentsByClassCodes(equipClassCodes,calculatingDTO.getProjectId());
|
|
|
+ if (CollUtil.isEmpty(equipments)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<String> equipmentIds = equipments.stream().map(ObjectDigital::getId).collect(Collectors.toSet());
|
|
|
+ // 3.2 根据项目id和管道用途类型查询分块数据
|
|
|
+ List<ConnectedBlock> connectedBlocks =
|
|
|
+ queryConnectedBlockByProjectId(calculatingDTO.getGroupCode(), calculatingDTO.getProjectId(),mepSystemTypes);
|
|
|
+ if (CollUtil.isEmpty(connectedBlocks)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<ConnectedBlockSource> result = new ArrayList<>();
|
|
|
+ for (ConnectedBlock connectedBlock : connectedBlocks) {
|
|
|
+ if (!equipmentIds.contains(connectedBlock.getFirstId())
|
|
|
+ && !equipmentIds.contains(connectedBlock.getSecondId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ConnectedBlockSource connectedBlockSource = new ConnectedBlockSource();
|
|
|
+ connectedBlockSource.setProjectId(connectedBlock.getProjectId());
|
|
|
+ connectedBlockSource.setBlockId(connectedBlock.getBlockId());
|
|
|
+ connectedBlockSource.setDomain(connectedBlock.getDomain());
|
|
|
+ connectedBlockSource.setMepSystemType(connectedBlock.getMepSystemType());
|
|
|
+ connectedBlockSource.setBuildingId(connectedBlock.getBuildingId());
|
|
|
+ if (equipmentIds.contains(connectedBlock.getFirstId())){
|
|
|
+ connectedBlockSource.setSourceId(connectedBlock.getFirstId());
|
|
|
+ connectedBlockSource.setSourceType(connectedBlock.getFirstType());
|
|
|
+ connectedBlockSource.setSourceFlag(true);
|
|
|
+ }else {
|
|
|
+ connectedBlockSource.setSourceId(connectedBlock.getSecondId());
|
|
|
+ connectedBlockSource.setSourceType(connectedBlock.getSecondType());
|
|
|
+ connectedBlockSource.setSourceFlag(true);
|
|
|
+ }
|
|
|
+ result.add(connectedBlockSource);
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(result)){
|
|
|
+ deletePrevSource(calculatingDTO.getProjectId(),null,mepSystemTypes);
|
|
|
+ connectedBlockSourceService.saveBatch(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * Description: 根据项目id查询分块信息
|
|
|
+ * @param groupCode : 集团编码
|
|
|
+ * @param projectId : 项目id
|
|
|
+ * @param mepSystemTypes : 管道用途分类
|
|
|
+ * @return : java.util.List<com.persagy.dmp.digital.entity.ConnectedBlock>
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/13 22:21
|
|
|
+ * Update By lijie 2021/10/13 22:21
|
|
|
+ */
|
|
|
+ private List<ConnectedBlock> queryConnectedBlockByProjectId(String groupCode, String projectId,
|
|
|
+ Set<String> mepSystemTypes) {
|
|
|
+ LambdaQueryWrapper<ConnectedBlock> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ConnectedBlock::getGroupCode,groupCode);
|
|
|
+ queryWrapper.eq(ConnectedBlock::getProjectId,projectId);
|
|
|
+ queryWrapper.in(ConnectedBlock::getMepSystemType,mepSystemTypes);
|
|
|
+ queryWrapper.eq(ConnectedBlock::getValid,true);
|
|
|
+ return connectedBlockService.list(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * Description: 根据对象类型查询设备列表
|
|
|
+ * @param classCodes : 对象类型列表
|
|
|
+ * @param projectId: 项目id
|
|
|
+ * @return : java.util.List<com.persagy.dmp.digital.entity.ObjectDigital>
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/13 22:06
|
|
|
+ * Update By lijie 2021/10/13 22:06
|
|
|
+ */
|
|
|
+ private List<ObjectDigital> queryEquipmentsByClassCodes(Set<String> classCodes, String projectId) {
|
|
|
+ QueryWrapper<ObjectDigital> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in(ObjectDigital.CLASS_CODE,classCodes);
|
|
|
+ queryWrapper.eq(StrUtil.toUnderlineCase(CommonConstant.QUERY_PROJECTID),projectId);
|
|
|
+ queryWrapper.eq(ObjectDigital.PROP_VALID,true);
|
|
|
+ queryWrapper.isNotNull("JSON_UNQUOTE(JSON_EXTRACT(infos, '$.bimId'))");
|
|
|
+ return objectDigitalMapper.selectList(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * Description: 删除项目下所有源设备类型
|
|
|
+ * @param projectId : 项目id
|
|
|
+ * @param buildingId : 建筑id
|
|
|
+ * @param mepSystemTypes : 管道用途类型名称
|
|
|
+ * @return : void
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/13 20:06
|
|
|
+ * Update By lijie 2021/10/13 20:06
|
|
|
+ */
|
|
|
+ private void deletePrevSource(String projectId, String buildingId, Set<String> mepSystemTypes) {
|
|
|
+ LambdaQueryWrapper<ConnectedBlockSource> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ConnectedBlockSource::getProjectId,projectId);
|
|
|
+ queryWrapper.in(ConnectedBlockSource::getMepSystemType,mepSystemTypes);
|
|
|
+ if (StrUtil.isNotBlank(buildingId)){
|
|
|
+ queryWrapper.eq(ConnectedBlockSource::getBuildingId,buildingId);
|
|
|
+ }
|
|
|
+ connectedBlockSourceService.remove(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * Description: 根据项目id和边类型编码名称查询数据
|
|
|
+ *
|
|
|
+ * @param groupCode
|
|
|
+ * @param projectId : 项目id
|
|
|
+ * @param defineName : 边类型编码名称
|
|
|
+ * @return : java.util.List<com.persagy.dmp.digital.entity.ObjectRelationProjectCal>
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/13 20:00
|
|
|
+ * Update By lijie 2021/10/13 20:00
|
|
|
+ */
|
|
|
+ private List<DigitalEquipClassRel> queryObjectRelationProjectCalsByProjectIdAndRelName(String groupCode, String projectId,
|
|
|
+ String defineName) {
|
|
|
+ LambdaQueryWrapper<DigitalEquipClassRel> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(DigitalEquipClassRel::getGroupCode,groupCode);
|
|
|
+ queryWrapper.eq(DigitalEquipClassRel::getProjectId,projectId);
|
|
|
+ queryWrapper.eq(DigitalEquipClassRel::getRelCodeName,defineName);
|
|
|
+ queryWrapper.eq(DigitalEquipClassRel::getValid,true);
|
|
|
+ return digitalEquipClassRelService.list(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
/***
|
|
|
* Description: 分块
|
|
|
* @param calRule : 计算规则
|
|
@@ -101,6 +255,12 @@ public class SysBlockCalculateServiceImpl implements CalculateService {
|
|
|
if (CollUtil.isEmpty(connectors)){
|
|
|
continue;
|
|
|
}
|
|
|
+ // 2.1 对connectors进行排序
|
|
|
+ sortConnectorsAndSetUseState(connectors);
|
|
|
+ // 3.根据modelId查询其他构件
|
|
|
+ List<ObjectDigital> elements = objectDigitalMapper.queryModelElements(calculatingDTO.getGroupCode(),
|
|
|
+ calculatingDTO.getProjectId(),floor.getModelId());
|
|
|
+ // 4.获得一个楼层的分块
|
|
|
|
|
|
|
|
|
|
|
@@ -110,6 +270,38 @@ public class SysBlockCalculateServiceImpl implements CalculateService {
|
|
|
|
|
|
}
|
|
|
/***
|
|
|
+ * Description: 根据设备,部件,连接件,其他,水管,风管进行排序
|
|
|
+ * @param connectors : 设备连接件构件集合
|
|
|
+ * @return : void
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/13 16:40
|
|
|
+ * Update By lijie 2021/10/13 16:40
|
|
|
+ */
|
|
|
+ private void sortConnectorsAndSetUseState(List<ObjectDigital> connectors) {
|
|
|
+ Map<String,Integer> sortMap = new HashMap<>();
|
|
|
+ sortMap.put(EquipmentTypeEnum.OTMCEM.name(),0);
|
|
|
+ sortMap.put(EquipmentTypeEnum.OTMCCN.name(),1);
|
|
|
+ sortMap.put(EquipmentTypeEnum.OTMCJO.name(),2);
|
|
|
+ sortMap.put(EquipmentTypeEnum.OTMCOT.name(),2);
|
|
|
+ sortMap.put(EquipmentTypeEnum.OTMCPL.name(),3);
|
|
|
+ sortMap.put(EquipmentTypeEnum.OTMCDU.name(),4);
|
|
|
+ connectors.forEach(connector->{
|
|
|
+ if (null==connector.getInfos()
|
|
|
+ || !connector.getInfos().has("belongType")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String belongType = connector.getInfos().get("belongType").asText();
|
|
|
+ if (!sortMap.containsKey(belongType)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ connector.setSequenceId(sortMap.get(belongType));
|
|
|
+ connector.setUsedFlag(false);
|
|
|
+ });
|
|
|
+ // 根据sequenceId进行排序
|
|
|
+ connectors.sort(Comparator.comparing(ObjectDigital::getSequenceId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
* Description: 根据项目id查询楼层
|
|
|
* @param calculatingDTO : 请求参数
|
|
|
* @return : java.util.List<com.persagy.dmp.digital.entity.ObjectDigital>
|