Browse Source

Merge remote-tracking branch 'origin/develop' into develop

lijie 3 years ago
parent
commit
2b09cefc33

+ 2 - 2
src/main/java/com/persagy/proxy/adm/model/AdmBaseEntity.java

@@ -4,8 +4,8 @@ import com.persagy.dmp.common.model.entity.BaseEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
-import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @author lvxy
@@ -21,6 +21,6 @@ public abstract class AdmBaseEntity<T> extends BaseEntity {
     /** 集团编码 */
     private String groupCode;
     /** 需要删除的对象 */
-    private List<String> nullList;
+    private Set<String> nullList;
 
 }

+ 1 - 1
src/main/java/com/persagy/proxy/dictionary/service/impl/AdmModelRelServiceImpl.java

@@ -195,7 +195,7 @@ public class AdmModelRelServiceImpl extends AbstractAdmBaseServiceImpl<AdmModelR
         if(CollUtil.isEmpty(content)) {
             return;
         }
-        List<String> nullList = CollUtil.newArrayList("buildingId", "floorId");
+        Set<String> nullList = CollUtil.newHashSet("buildingId", "floorId");
         for (AdmISpace iSpace : content) {
             if(deleteFlag) {
                 iSpace.setBuildingId(null);

+ 14 - 0
src/main/java/com/persagy/proxy/object/controller/AdmEquipmentController.java

@@ -185,6 +185,20 @@ public class AdmEquipmentController {
 		if(CollUtil.isEmpty(vos)) {
 			return AdmResponse.success(vos);
 		}
+		for(AdmEquipment vo:vos) {
+			if(StrUtil.isNotBlank(vo.getFlowBuild())) {
+				// 处理建筑-楼层信息点
+				List<String> flows = StrUtil.splitTrim(vo.getFlowBuild(), "-");
+				for(String flow:flows) {
+					if(StrUtil.startWith(flow, "Bd")) {
+						vo.setBuildingId(flow);
+					} else if(StrUtil.startWith(flow, "fl")) {
+						vo.setFloorId(flow);
+					}
+				}
+				vo.setFlowBuild(null);
+			}
+		}
 		vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
 		return AdmResponse.success(vos);
 	}

+ 2 - 76
src/main/java/com/persagy/proxy/object/controller/AdmSpaceController.java

@@ -7,8 +7,6 @@ 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.basic.utils.JsonNodeUtils;
-import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
-import com.persagy.proxy.adm.handler.SpaceRelationInfoHandler;
 import com.persagy.proxy.adm.request.*;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
@@ -47,8 +45,7 @@ public class AdmSpaceController {
     private IAdmRelationService relationService;
     @Autowired
     private IAdmFloorService floorService;
-    @Autowired
-    private SpaceRelationInfoHandler spaceRelationInfoHandler;
+
 
 
     /**
@@ -122,78 +119,7 @@ public class AdmSpaceController {
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmSpace> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         List<AdmSpace> vos = CollUtil.newArrayList(createRequest.getContent());
-        if(CollUtil.isNotEmpty(vos)) {
-            AdmRelationTypeEnum typeEnumBd = AdmRelationTypeEnum.BD2SP;
-            AdmRelationTypeEnum typeEnumFl = AdmRelationTypeEnum.FL2SP;
-            QueryCriteria criteria = new QueryCriteria();
-            ObjectNode node = JsonNodeFactory.instance.objectNode();
-
-            List<RelationDTO> relationDTOList = new ArrayList<>(vos.size());
-            vos.forEach(admSpace -> {
-                //处理建筑 楼层信息点
-                int removeflBd = 0 ;//关系处理 0 不删除 1 删除bd 2 删除fl 3 都删除
-                if(StrUtil.isNotEmpty(admSpace.getFlowBuild())){
-                    String flowBuild = admSpace.getFlowBuild();
-                    if(!flowBuild.contains("-")){
-                        if(flowBuild.startsWith("Bd")){
-                            admSpace.setBuildingId(flowBuild);
-                            if(StrUtil.isNotEmpty(admSpace.getFloorId())){
-                                Map<String, Object> infos = new HashMap<String,Object>(16);
-                                infos.put("$remove", Arrays.asList("floorId"));
-                                admSpace.setInfos(infos);
-                                removeflBd = 2;
-                            }
-                        }
-                    }else {
-                        String[] str = flowBuild.split("-");
-                        if(str[0].startsWith("Bd")){
-                            admSpace.setBuildingId(str[0]);
-                            admSpace.setFloorId(str[1]);
-                        }else{
-                            admSpace.setBuildingId(str[1]);
-                            admSpace.setFloorId(str[0]);
-                        }
-                        removeflBd = 3;
-                    }
-                    admSpace.setFlowBuild(null);
-                }else{
-                    Map<String, Object> infos = new HashMap<String,Object>(16);
-                    infos.put("$remove",Arrays.asList("floorId","buildingId"));
-                    admSpace.setInfos(infos);
-                    removeflBd = 3;
-                }
-                //删除关系 然后重建
-                if(removeflBd == 3 || removeflBd == 2){
-                    node.put("relCode", typeEnumFl.getRelCode());
-                    node.put("objTo",  admSpace.getId());
-                    node.put("graphCode", typeEnumFl.getGraphCode());
-                    criteria.setCriteria(node);
-                    relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
-                }
-                if(removeflBd == 3 || removeflBd == 1){
-                    node.put("relCode", typeEnumBd.getRelCode());
-                    node.put("objTo", admSpace.getId());
-                    node.put("graphCode", typeEnumBd.getGraphCode());
-                    criteria.setCriteria(node);
-                    relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
-                }
-            });
-            vos.stream().forEach(space -> {
-                if (StrUtil.isNotEmpty(space.getBuildingId())) {
-                    RelationDTO relationBd = new RelationDTO(null, typeEnumBd.getGraphCode(), typeEnumBd.getRelCode(), null, space.getBuildingId(), space.getId());
-                    relationDTOList.add(relationBd);
-                }
-                if (StrUtil.isNotEmpty(space.getFloorId())) {
-                    RelationDTO relationFl = new RelationDTO(null, typeEnumFl.getGraphCode(), typeEnumFl.getRelCode(), null, space.getFloorId(), space.getId());
-                    relationDTOList.add(relationFl);
-                }
-            });
-            if (CollUtil.isNotEmpty(relationDTOList)) {
-                relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOList);
-            }
-            vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmSpace.class, vos);
-        }
-        return AdmResponse.success(vos);
+        return service.doUpdate(vos);
     }
 
     /**

+ 2 - 2
src/main/java/com/persagy/proxy/object/model/AdmISpace.java

@@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
 import lombok.Data;
 
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * ADM 元空间 实体
@@ -80,5 +80,5 @@ public class AdmISpace {
     /** 创建时间 */
     private Date createTime;
     /** 需要删除的对象 */
-    private List<String> nullList;
+    private Set<String> nullList;
 }

+ 2 - 0
src/main/java/com/persagy/proxy/object/service/IAdmSpaceService.java

@@ -107,6 +107,8 @@ public interface IAdmSpaceService extends IAdmBaseService<AdmSpace> {
      */
     AdmResponse updateOutLine(List<AdmSpace> vos);
 
+    AdmResponse doUpdate(List<AdmSpace> vos);
+
     /**
      * 处理关系计算
      */

+ 16 - 9
src/main/java/com/persagy/proxy/object/service/impl/AdmEquipmentServiceImpl.java

@@ -144,27 +144,34 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
         // 待新增关系
         List<RelationDTO> relations = new ArrayList();
         for(AdmEquipment vo:voList) {
-            // 加入删除关系
-            arrayNode.add(vo.getId());
-            // 如果建筑ID为空,不用增加关系
-            if(isDelete || StrUtil.isBlank(vo.getBuildingId())) {
+            // 如果为删除或是清除buildingId和floorId,则直接删除
+            if(isDelete || CollUtil.containsAll(vo.getNullList(), CollUtil.newHashSet("buildingId", "floorId"))) {
+                arrayNode.add(vo.getId());
+                continue;
+            }
+            // 不用增加关系
+            if(StrUtil.isBlank(vo.getBuildingId())) {
                 continue;
             }
+            // 先清除原来的关系
+            arrayNode.add(vo.getId());
             // 增加BD关系
             relations.add(RelationDTO.builder().graphCode(graphCode).relCode(buildingRelCode).objFrom(vo.getId()).objTo(vo.getBuildingId()).build());
-            if(StrUtil.isBlank(vo.getFloorId())) {
+            // 如果有删除楼层关系
+            if(StrUtil.isBlank(vo.getFloorId()) || CollUtil.contains(vo.getNullList(), "floorId")) {
                 continue;
             }
             // 增加FL关系
             relations.add(RelationDTO.builder().graphCode(graphCode).relCode(floorRelCode).objFrom(vo.getId()).objTo(vo.getFloorId()).build());
         }
         // 先删除旧关系
-        relationService.doDelete(context, criteria);
+        if(arrayNode.size() > 0) {
+            relationService.doDelete(context, criteria);
+        }
         // 再创建新关系
-        if(CollUtil.isEmpty(relations)) {
-            return;
+        if(CollUtil.isNotEmpty(relations)) {
+            relationService.doSave(context, relations);
         }
-        relationService.doSave(context, relations);
     }
 
     @Override

+ 79 - 0
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -343,6 +343,85 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
         return AdmResponse.success(vos);
     }
 
+    @Override
+    public AdmResponse doUpdate(List<AdmSpace> vos) {
+        if(CollUtil.isNotEmpty(vos)) {
+            AdmRelationTypeEnum typeEnumBd = AdmRelationTypeEnum.BD2SP;
+            AdmRelationTypeEnum typeEnumFl = AdmRelationTypeEnum.FL2SP;
+            QueryCriteria criteria = new QueryCriteria();
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+
+            List<RelationDTO> relationDTOList = new ArrayList<>(vos.size());
+            vos.forEach(admSpace -> {
+                //处理建筑 楼层信息点
+                int removeflBd = 0 ;//关系处理 0:不删除; 1:删除bd; 2:删除fl; 3:都删除;
+                List<String> nullList = CollUtil.newArrayList(admSpace.getNullList());
+                if(CollUtil.isNotEmpty(nullList)){
+                   if(nullList.contains("flowBuild")){
+                       removeflBd = 3;
+                       Map<String, Object> infos = new HashMap<>(16);
+                       infos.put("$remove", Arrays.asList("floorId","buildingId"));
+                   }
+                }
+                if(StrUtil.isNotEmpty(admSpace.getFlowBuild())){
+                    String flowBuild = admSpace.getFlowBuild();
+                    if(!flowBuild.contains("-")){
+                        if(flowBuild.startsWith("Bd")){
+                            admSpace.setBuildingId(flowBuild);
+                            if(StrUtil.isNotEmpty(admSpace.getFloorId())){
+                                Map<String, Object> infos = new HashMap<>(16);
+                                infos.put("$remove", Arrays.asList("floorId"));
+                                admSpace.setInfos(infos);
+                                removeflBd = 2;
+                            }
+                        }
+                    }else {
+                        String[] str = flowBuild.split("-");
+                        if(str[0].startsWith("Bd")){
+                            admSpace.setBuildingId(str[0]);
+                            admSpace.setFloorId(str[1]);
+                        }else{
+                            admSpace.setBuildingId(str[1]);
+                            admSpace.setFloorId(str[0]);
+                        }
+                        removeflBd = 3;
+                    }
+                    admSpace.setFlowBuild(null);
+                }
+                //删除关系 然后重建
+                if(removeflBd == 3 || removeflBd == 2){
+                    node.put("relCode", typeEnumFl.getRelCode());
+                    node.put("objTo",  admSpace.getId());
+                    node.put("graphCode", typeEnumFl.getGraphCode());
+                    criteria.setCriteria(node);
+                    relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
+                }
+                if(removeflBd == 3 || removeflBd == 1){
+                    node.put("relCode", typeEnumBd.getRelCode());
+                    node.put("objTo", admSpace.getId());
+                    node.put("graphCode", typeEnumBd.getGraphCode());
+                    criteria.setCriteria(node);
+                    relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
+                }
+            });
+            vos.stream().forEach(space -> {
+                if (StrUtil.isNotEmpty(space.getBuildingId())) {
+                    RelationDTO relationBd = new RelationDTO(null, typeEnumBd.getGraphCode(), typeEnumBd.getRelCode(), null, space.getBuildingId(), space.getId());
+                    relationDTOList.add(relationBd);
+                }
+                if (StrUtil.isNotEmpty(space.getFloorId())) {
+                    RelationDTO relationFl = new RelationDTO(null, typeEnumFl.getGraphCode(), typeEnumFl.getRelCode(), null, space.getFloorId(), space.getId());
+                    relationDTOList.add(relationFl);
+                }
+            });
+            if (CollUtil.isNotEmpty(relationDTOList)) {
+                relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOList);
+            }
+            vos = super.doUpdate(AdmContextUtil.toDmpContext(), AdmSpace.class, vos);
+        }
+        return AdmResponse.success(vos);
+    }
+
     /**
      * 触发关系计算
      * @param vos

+ 2 - 2
src/main/java/com/persagy/proxy/report/controller/AdmReportEquipController.java

@@ -96,7 +96,7 @@ public class AdmReportEquipController {
                 } else {
                     equip.setCount(0);
                 }
-                //特殊处理前端需要展示的字段
+               /* //特殊处理前端需要展示的字段
                 if(StrUtil.isNotEmpty(equip.getLocalId())){
                     equip.getInfos().put("localId",equip.getLocalId());
                 }
@@ -105,7 +105,7 @@ public class AdmReportEquipController {
                 }
                 if(StrUtil.isNotEmpty(equip.getBimLocation())){
                     equip.getInfos().put("bimLocation",equip.getBimLocation());
-                }
+                }*/
             });
             //查询设备的类型信息,取list中的第一个数据
             AdmEquipment admEquipment = equipmentList.get(0);