|
@@ -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);
|
|
|
}
|
|
|
|
|
|
/**
|