浏览代码

fix bug:修复会产生重复的关系

lijie 3 年之前
父节点
当前提交
6230514be6

+ 8 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/calstrategy/EqToSpCalculateServiceImpl.java

@@ -63,6 +63,8 @@ public class EqToSpCalculateServiceImpl implements CalculateService {
             return;
         }
         // 2.根据各个楼层分别进行关系计算
+        Set<String> ids = CollUtil.newHashSet();
+        String modeStr = "{}_{}_{}_{}_{}";
         for (ObjectDigital floor : floors) {
             // 2.1 根据项目id和楼层id查询设备列表
             List<ObjectDigital> equipments = objectDigitalMapper
@@ -79,6 +81,12 @@ public class EqToSpCalculateServiceImpl implements CalculateService {
             List<ObjectRelation> insertRels = new ArrayList<>();
             for (ObjectDigital equipment : equipments) {
                 for (ObjectDigital space : spaces) {
+                    String key = StrUtil.format(modeStr,calculatingDTO.getGroupCode(),calculatingDTO.getProjectId(),
+                            space.getClassCode(),equipment.getId(),space.getId());
+                    if (ids.contains(key)){
+                        continue;
+                    }
+                    ids.add(key);
                     if (GeoToolsUtil.isPointInPoly(equipment.getBimLocation(),space.getOutLines())){
                         ObjectRelation objectRelation = new ObjectRelation();
                         objectRelation.setGroupCode(calculatingDTO.getGroupCode());