|
@@ -598,4 +598,39 @@ public class DataStrategyImpl implements DataStrategy {
|
|
|
}));
|
|
|
return majorNodes;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据系统类获取系统类型下的模板列表 以树状结构数据返回
|
|
|
+ *
|
|
|
+ * @param diagram diagram.getSystem() 参数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ObjectNode> loadSystemTypeTemplate(Diagram diagram) {
|
|
|
+ if (diagram == null || StrUtil.isBlank(diagram.getSystem())) {
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(), "系统类[system]不能为空");
|
|
|
+ }
|
|
|
+ String system = diagram.getSystem();
|
|
|
+ List<DiagramType> diagramTypes = diagramTypeMapper.getDiagramTypes();
|
|
|
+ //符合system的系统图类型数据
|
|
|
+ List<DiagramType> diagramTypeList = Optional.ofNullable(diagramTypes).map(types -> types.stream().filter(diagramType ->
|
|
|
+ diagramType.getDSystem().equalsIgnoreCase(system)).collect(Collectors.toList())).orElse(new ArrayList<>());
|
|
|
+
|
|
|
+ List<TemplateEntity> templates = templateMapper.getTemplates();
|
|
|
+ List<ObjectNode> objectNodes = JsonNodeUtils.toListNode(diagramTypeList, null, null);
|
|
|
+ Optional.ofNullable(objectNodes).ifPresent(nodes -> nodes.forEach(node -> {
|
|
|
+ JsonNode jsonNode = node.get(Constants.CODE);
|
|
|
+ ArrayNode children = node.putArray(Constants.CHILDREN);
|
|
|
+ if (jsonNode != null) {
|
|
|
+ List<TemplateEntity> templateEntities = templates.stream().filter(templateEntity ->
|
|
|
+ templateEntity.getDiagramType().equalsIgnoreCase(jsonNode.asText())).collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(templateEntities)) {
|
|
|
+ List<ObjectNode> templateNodes = JsonNodeUtils.toListNode(templateEntities, null, null);
|
|
|
+ children.addAll(templateNodes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }));
|
|
|
+
|
|
|
+ return objectNodes;
|
|
|
+ }
|
|
|
}
|