Browse Source

fix : 空间更新建筑楼层关系,前端使用flowBuild进行更新

lvxianyun 3 years ago
parent
commit
c15297ab3a

+ 32 - 10
src/main/java/com/persagy/proxy/object/controller/AdmSpaceController.java

@@ -129,28 +129,50 @@ public class AdmSpaceController {
             QueryCriteria criteria = new QueryCriteria();
             ObjectNode node = JsonNodeFactory.instance.objectNode();
 
-            admSpaceMap.keySet().stream().forEach(spId -> {
+            List<RelationDTO> relationDTOList = new ArrayList<>(vos.size());
+            vos.stream().forEach(admSpace -> {
+                //删除关系 然后重建
                 node.put("relCode", typeEnumBd.getRelCode());
-                node.put("objTo", spId);
+                node.put("objTo", admSpace.getId());
                 node.put("graphCode", typeEnumBd.getGraphCode());
                 criteria.setCriteria(node);
                 relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
 
                 node.put("relCode", typeEnumFl.getRelCode());
-                node.put("objTo", spId);
+                node.put("objTo",  admSpace.getId());
                 node.put("graphCode", typeEnumFl.getGraphCode());
                 criteria.setCriteria(node);
                 relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
+                //处理建筑 楼层信息点
+                if(StrUtil.isNotEmpty(admSpace.getFlowBuild())){
+                    String flowBuild = admSpace.getFlowBuild();
+                    if(!flowBuild.contains("-")){
+                        if(flowBuild.startsWith("Bd")){
+                            admSpace.setBuildingId(flowBuild);
+                            admSpace.setFloorId(null);
+                        }
+                    }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]);
+                        }
+                    }
+                }else{
+                    admSpace.setBuildingId(null);
+                    admSpace.setFloorId(null);
+                }
             });
-
-            List<RelationDTO> relationDTOList = new ArrayList<>(vos.size());
-            admSpaceMap.keySet().stream().forEach(spaceId -> {
-                if (StrUtil.isNotEmpty(admSpaceMap.get(spaceId).getBuildingId())) {
-                    RelationDTO relationBd = new RelationDTO(null, typeEnumBd.getGraphCode(), typeEnumBd.getRelCode(), null, admSpaceMap.get(spaceId).getBuildingId(), spaceId);
+            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(admSpaceMap.get(spaceId).getFloorId())) {
-                    RelationDTO relationFl = new RelationDTO(null, typeEnumFl.getGraphCode(), typeEnumFl.getRelCode(), null, admSpaceMap.get(spaceId).getFloorId(), spaceId);
+                if (StrUtil.isNotEmpty(space.getFloorId())) {
+                    RelationDTO relationFl = new RelationDTO(null, typeEnumFl.getGraphCode(), typeEnumFl.getRelCode(), null, space.getFloorId(), space.getId());
                     relationDTOList.add(relationFl);
                 }
             });

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

@@ -101,6 +101,8 @@ public class AdmSpace extends AdmBaseEntity<AdmSpace> {
     private Boolean isAi = false;
     /** 垂直交通关系空间id */
     private Set<String> spaceIdList;
+    /** 更新的时候使用此字段保存楼层和建筑id */
+    private String flowBuild;
 
     /** 信息点 */
     //private Map<String, Object> infos;