|
@@ -2,11 +2,16 @@ package com.persagy.proxy.relation.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.excel.util.CollectionUtils;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
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.common.constant.ResponseCode;
|
|
|
+import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
+import com.persagy.dmp.digital.client.DigitalRelationFacade;
|
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
@@ -87,53 +92,59 @@ public class RelationSyInFlController {
|
|
|
String sysId = syInFlList.getSysId();
|
|
|
//楼层Id
|
|
|
List<String> floorIdList = syInFlList.getFloorIdList();
|
|
|
- if (StringUtils.isBlank(sysId) || CollectionUtils.isEmpty(floorIdList)) {
|
|
|
+ if (StringUtils.isBlank(sysId)) {
|
|
|
//return AdmResponse.failure("必填项:sysId(系统id)、floorIdList(楼层Id)");
|
|
|
//兼容adm历史逻辑,若楼层id为空时,返回success
|
|
|
return AdmResponse.success();
|
|
|
}
|
|
|
-
|
|
|
+ // 按原有逻辑接口处理:2021年11月2日16:52:13 by lijie
|
|
|
+ // 1.根据系统id,图类型编码为MechInArch,边类型为Sy2Fl删除关系
|
|
|
+ // 1.1 组装删除参数
|
|
|
+ QueryCriteria deleteQueryCriteria = new QueryCriteria();
|
|
|
+ ObjectMapper mapper = SpringUtil.getBean(ObjectMapper.class);
|
|
|
+ ObjectNode criteria = mapper.createObjectNode();
|
|
|
+ criteria.put("graphCode",AdmRelationTypeEnum.SY2FL.getGraphCode());
|
|
|
+ criteria.put("relCode",AdmRelationTypeEnum.SY2FL.getRelCode());
|
|
|
+ criteria.put("objFrom",sysId);
|
|
|
+ criteria.put("valid",Boolean.TRUE);
|
|
|
+ deleteQueryCriteria.setCriteria(criteria);
|
|
|
+ // 1.2 根据参数删除关系
|
|
|
+ InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
+ CommonResult<List<ObjectRelation>> commonResult = DigitalRelationFacade.deleteByCriteria(context.getGroupCode(),
|
|
|
+ context.getProjectId(), context.getAppId(), context.getUserId(), deleteQueryCriteria);
|
|
|
+ if (!ResponseCode.A00000.getDesc().equals(commonResult.getResult())){
|
|
|
+ return AdmResponse.failure(commonResult.getMessage());
|
|
|
+ }
|
|
|
+ if (CollUtil.isEmpty(floorIdList)){
|
|
|
+ return AdmResponse.success(new ArrayList<>());
|
|
|
+ }
|
|
|
+ // 2.创建系统所属楼层关系
|
|
|
List<RelationDTO> voList = new ArrayList<>();
|
|
|
AdmRelationTypeEnum sy2fl = AdmRelationTypeEnum.SY2FL;
|
|
|
String graphCode = sy2fl.getGraphCode();
|
|
|
String relCode = sy2fl.getRelCode();
|
|
|
-
|
|
|
- //需要解绑关系
|
|
|
- QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
- ObjectNode criteriaDel = JsonNodeFactory.instance.objectNode();
|
|
|
- criteriaDel.put("graphCode", graphCode);
|
|
|
- criteriaDel.put("relCode", relCode);
|
|
|
- criteriaDel.put("objFrom", sysId);
|
|
|
- queryCriteria.setCriteria(criteriaDel);
|
|
|
- service.doDelete(AdmContextUtil.toDmpContext(), queryCriteria);
|
|
|
-
|
|
|
- criteriaDel.put("relCode", "Sy2Bd");
|
|
|
- queryCriteria.setCriteria(criteriaDel);
|
|
|
- service.doDelete(AdmContextUtil.toDmpContext(), queryCriteria);
|
|
|
-
|
|
|
for (String floorId : floorIdList) {
|
|
|
RelationDTO relation = new RelationDTO(null, graphCode, relCode, null, sysId, floorId);
|
|
|
voList.add(relation);
|
|
|
}
|
|
|
- //查询 floor所属的建筑 增加关系
|
|
|
- QueryCriteria criteriaQuery = new QueryCriteria();
|
|
|
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
- criteria.put(ObjectRelation.REL_CODE_HUM, "Bd2Fl");
|
|
|
- criteria.put(ObjectRelation.GRAPH_CODE_HUM, "ArchSubset");
|
|
|
- ArrayNode arrayNode = criteria.putObject("objTo").putArray("$in");
|
|
|
- floorIdList.stream().forEach(floorId -> arrayNode.add(floorId));
|
|
|
- criteriaQuery.setCriteria(criteria);
|
|
|
- List<ObjectRelation> relationList = service.queryByCondition(AdmContextUtil.toDmpContext(), criteriaQuery);
|
|
|
- if(CollUtil.isNotEmpty(relationList)){
|
|
|
- Map<String,ObjectRelation> objectRelationMap = CollUtil.fieldValueMap(relationList, "objFrom");
|
|
|
- for (String buildingId : objectRelationMap.keySet()) {
|
|
|
- RelationDTO relation = new RelationDTO(null, graphCode, "Sy2Bd", null, sysId, buildingId);
|
|
|
- voList.add(relation);
|
|
|
- }
|
|
|
- }
|
|
|
+ //查询 floor所属的建筑 增加关系:页面交互的/rel/sy-in-bd/link-bd接口会创建系统所属建筑的关系,该处省略.防止重复创建
|
|
|
+// QueryCriteria criteriaQuery = new QueryCriteria();
|
|
|
+// ObjectNode buildCriteria = JsonNodeFactory.instance.objectNode();
|
|
|
+// buildCriteria.put(ObjectRelation.REL_CODE_HUM, "Bd2Fl");
|
|
|
+// buildCriteria.put(ObjectRelation.GRAPH_CODE_HUM, "ArchSubset");
|
|
|
+// ArrayNode arrayNode = buildCriteria.putObject("objTo").putArray("$in");
|
|
|
+// floorIdList.stream().forEach(floorId -> arrayNode.add(floorId));
|
|
|
+// criteriaQuery.setCriteria(buildCriteria);
|
|
|
+// List<ObjectRelation> relationList = service.queryByCondition(AdmContextUtil.toDmpContext(), criteriaQuery);
|
|
|
+// if(CollUtil.isNotEmpty(relationList)){
|
|
|
+// Map<String,ObjectRelation> objectRelationMap = CollUtil.fieldValueMap(relationList, "objFrom");
|
|
|
+// for (String buildingId : objectRelationMap.keySet()) {
|
|
|
+// RelationDTO relation = new RelationDTO(null, graphCode, "Sy2Bd", null, sysId, buildingId);
|
|
|
+// voList.add(relation);
|
|
|
+// }
|
|
|
+// }
|
|
|
// 组装上下文条件
|
|
|
- InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
- service.doSave(context, voList);
|
|
|
+ service.doSave(AdmContextUtil.toDmpContext(), voList);
|
|
|
log.info("创建系统所在楼层关系link-fl方法结束");
|
|
|
return AdmResponse.success();
|
|
|
}
|