123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package com.persagy.proxy.adm.controller;
- import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
- import com.persagy.proxy.adm.model.relation.ShInBdList;
- import com.persagy.proxy.adm.request.AdmResponse;
- import com.persagy.proxy.adm.service.IAdmRelationService;
- import com.persagy.proxy.adm.utils.AdmContextUtil;
- import com.persagy.proxy.common.entity.InstanceUrlParam;
- import com.persagy.proxy.common.entity.RelationDTO;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.bind.annotation.*;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * @author zhangwencheng
- *关系-竖井所在建筑
- */
- @Slf4j
- @RestController
- @RequestMapping("/rel/sh-in-bd")
- public class RelationShInBdController {
- @Autowired
- private IAdmRelationService service;
- @Value("${middleware.group.code}")
- private String groupCode;
- /**
- * 创建竖井所在建筑关系
- * @param shInBdList
- * @return
- */
- @PostMapping("link-bd")
- public AdmResponse createBd(@RequestBody ShInBdList shInBdList){
- log.info("创建系统所在建筑关系link-bd");
- List<String> buildingIdList = shInBdList.getBuildingIdList();
- String shaftId = shInBdList.getShaftId();
- //检验输入参数
- if(CollectionUtils.isEmpty(buildingIdList)|| StringUtils.isEmpty(shaftId)){
- return AdmResponse.failure("必填项:shaftId(竖井id)、BuildingIdList(建筑id列表)");
- }
- List<RelationDTO> voList = new ArrayList<>();
- AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.BD2SH_ARCHFORARCH;
- String graphCode = typeEnum.getGraphCode();
- String relCode = typeEnum.getRelCode();
- for (String buildingId : buildingIdList) {
- //ArchForArch
- RelationDTO relation = new RelationDTO(null, graphCode, relCode, "", shaftId,buildingId);
- voList.add(relation);
- }
- InstanceUrlParam context = AdmContextUtil.toDmpContext();
- service.doSave(context, voList);
- return AdmResponse.success();
- }
- }
|