RelationShInBdController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.persagy.proxy.adm.controller;
  2. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  3. import com.persagy.proxy.adm.model.relation.ShInBdList;
  4. import com.persagy.proxy.adm.request.AdmResponse;
  5. import com.persagy.proxy.adm.service.IAdmRelationService;
  6. import com.persagy.proxy.adm.utils.AdmContextUtil;
  7. import com.persagy.proxy.common.entity.InstanceUrlParam;
  8. import com.persagy.proxy.common.entity.RelationDTO;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.apache.commons.lang.StringUtils;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.beans.factory.annotation.Value;
  13. import org.springframework.util.CollectionUtils;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.ArrayList;
  16. import java.util.List;
  17. /**
  18. * @author zhangwencheng
  19. *关系-竖井所在建筑
  20. */
  21. @Slf4j
  22. @RestController
  23. @RequestMapping("/rel/sh-in-bd")
  24. public class RelationShInBdController {
  25. @Autowired
  26. private IAdmRelationService service;
  27. @Value("${middleware.group.code}")
  28. private String groupCode;
  29. /**
  30. * 创建竖井所在建筑关系
  31. * @param shInBdList
  32. * @return
  33. */
  34. @PostMapping("link-bd")
  35. public AdmResponse createBd(@RequestBody ShInBdList shInBdList){
  36. log.info("创建系统所在建筑关系link-bd");
  37. List<String> buildingIdList = shInBdList.getBuildingIdList();
  38. String shaftId = shInBdList.getShaftId();
  39. //检验输入参数
  40. if(CollectionUtils.isEmpty(buildingIdList)|| StringUtils.isEmpty(shaftId)){
  41. return AdmResponse.failure("必填项:shaftId(竖井id)、BuildingIdList(建筑id列表)");
  42. }
  43. List<RelationDTO> voList = new ArrayList<>();
  44. AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.BD2SH_ARCHFORARCH;
  45. String graphCode = typeEnum.getGraphCode();
  46. String relCode = typeEnum.getRelCode();
  47. for (String buildingId : buildingIdList) {
  48. //ArchForArch
  49. RelationDTO relation = new RelationDTO(null, graphCode, relCode, "", shaftId,buildingId);
  50. voList.add(relation);
  51. }
  52. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  53. service.doSave(context, voList);
  54. return AdmResponse.success();
  55. }
  56. }