|
@@ -247,7 +247,9 @@ public class DataStrategyImpl implements DataStrategy {
|
|
|
throw new BusinessException(ResponseCode.A0400.getCode(), "equipmentType不能为空");
|
|
|
}
|
|
|
String systemCode = Optional.of(equipmentType).map(s -> s.substring(0, 4)).orElse(StrUtil.EMPTY);
|
|
|
- return getLegends(systemCode);
|
|
|
+ List<Legend> list = getLegends(systemCode);
|
|
|
+ //按设备类型过滤
|
|
|
+ return list.stream().filter(legend -> legend.getEquipmentTypes() != null && legend.getEquipmentTypes().contains(equipmentType)).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -396,7 +398,7 @@ public class DataStrategyImpl implements DataStrategy {
|
|
|
/**
|
|
|
* 根据关系类型列表、节点id列表、项目id、集团code获取对象关系列表
|
|
|
*
|
|
|
- * @param relationTypes 关系类型列表
|
|
|
+ * @param relationTypes 关系类型列表 [graphCode, relCode]
|
|
|
* @param objectIds 节点id列表
|
|
|
* @param projectId 项目id
|
|
|
* @param groupCode 集团code
|
|
@@ -408,17 +410,21 @@ public class DataStrategyImpl implements DataStrategy {
|
|
|
if (CollectionUtil.isEmpty(objectIds)) {
|
|
|
throw new BusinessException(ResponseCode.A0400.getCode(), "objectIds不能为空");
|
|
|
}
|
|
|
+
|
|
|
+ //按图类型过滤查询
|
|
|
+ Set<String> graphTypes = new HashSet<>();
|
|
|
+ relationTypes.forEach(relTypeArr -> graphTypes.add(relTypeArr[0]));
|
|
|
//查询到的所有关系
|
|
|
- List<ObjectRelation> allRelations = queryRelationsByObjIds(projectId, groupCode, objectIds);
|
|
|
+ List<ObjectRelation> allRelations = queryRelationsByObjIds(projectId, groupCode, objectIds, graphTypes);
|
|
|
//所有关系类型
|
|
|
Set<String> types = new HashSet<>();
|
|
|
Optional.ofNullable(relationTypes).ifPresent(relations ->
|
|
|
- relations.forEach(strings -> types.addAll(Arrays.asList(strings))));
|
|
|
+ relations.forEach(strings -> types.add(strings[0] + '/' + strings[1])));
|
|
|
Set<String> typeSet = types.stream().filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
//最终符合结果的关系
|
|
|
if (CollectionUtil.isNotEmpty(typeSet)) {
|
|
|
List<ObjectRelation> res = allRelations.stream().filter(objectRelation ->
|
|
|
- typeSet.contains(objectRelation.getRelCode())).collect(Collectors.toList());
|
|
|
+ typeSet.contains(objectRelation.getGraphCode() + '/' + objectRelation.getRelCode())).collect(Collectors.toList());
|
|
|
//转换并返回
|
|
|
return JsonNodeUtils.toListNode(res, null, null);
|
|
|
}
|
|
@@ -431,15 +437,24 @@ public class DataStrategyImpl implements DataStrategy {
|
|
|
* @param projectId 项目id
|
|
|
* @param groupCode 集团code
|
|
|
* @param objectIds 对象id列表
|
|
|
+ * @param graphTypes 关系的图类型(同时处理图类型和边类型不太可行,优选图类型过滤)
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<ObjectRelation> queryRelationsByObjIds(String projectId, String groupCode, List<String> objectIds) {
|
|
|
+ private List<ObjectRelation> queryRelationsByObjIds(String projectId, String groupCode, List<String> objectIds, Set<String> graphTypes) {
|
|
|
List<ObjectRelation> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ //graph_code
|
|
|
+ ArrayNode graphCode = objectMapper.createArrayNode();
|
|
|
+ if(graphTypes.size() > 0)
|
|
|
+ graphTypes.forEach(code -> graphCode.add(code));
|
|
|
+
|
|
|
//obj_from
|
|
|
CompletableFuture<List<ObjectRelation>> fromFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
QueryCriteria criteria = ServiceUtil.getQueryCriteria(objectMapper);
|
|
|
ArrayNode objFrom = criteria.getCriteria().putArray(ObjectRelation.OBJ_FROM_HUM);
|
|
|
Optional.ofNullable(objectIds).ifPresent(strings -> strings.forEach(objFrom::add));
|
|
|
+ if(graphCode.size() > 0)
|
|
|
+ criteria.getCriteria().set(ObjectRelation.GRAPH_CODE_HUM, graphCode);
|
|
|
return DigitalRelationFacade.query(groupCode, projectId, null, null, criteria);
|
|
|
}, executor);
|
|
|
//obj_to
|
|
@@ -447,6 +462,8 @@ public class DataStrategyImpl implements DataStrategy {
|
|
|
QueryCriteria criteria = ServiceUtil.getQueryCriteria(objectMapper);
|
|
|
ArrayNode objTo = criteria.getCriteria().putArray(ObjectRelation.OBJ_TO_HUM);
|
|
|
Optional.ofNullable(objectIds).ifPresent(strings -> strings.forEach(objTo::add));
|
|
|
+ if(graphCode.size() > 0)
|
|
|
+ criteria.getCriteria().set(ObjectRelation.GRAPH_CODE_HUM, graphCode);
|
|
|
return DigitalRelationFacade.query(groupCode, projectId, null, null, criteria);
|
|
|
}, executor);
|
|
|
|