|
@@ -1,9 +1,11 @@
|
|
|
package com.persagy.adm.diagram.controller;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.adm.diagram.core.ContentParser;
|
|
|
import com.persagy.adm.diagram.core.DataStrategy;
|
|
|
import com.persagy.adm.diagram.core.model.Diagram;
|
|
|
+import com.persagy.adm.diagram.core.model.DiagramNode;
|
|
|
import com.persagy.adm.diagram.core.model.template.DiagramTemplate;
|
|
|
import com.persagy.adm.diagram.frame.BdtpRequest;
|
|
|
import com.persagy.adm.diagram.manage.DemoDiagramManager;
|
|
@@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
@@ -69,7 +72,6 @@ public class DiagramController {
|
|
|
*
|
|
|
* @param params 参数集合
|
|
|
* @param projectId 项目id
|
|
|
- * @param systemId 系统实例id
|
|
|
* @param groupCode 集团code
|
|
|
* @return 系统图信息
|
|
|
*/
|
|
@@ -77,12 +79,10 @@ public class DiagramController {
|
|
|
@PostMapping("/newDiagram")
|
|
|
public CommonResult<Diagram> newDiagram(@RequestBody Map<String, Object> params,
|
|
|
@RequestParam String projectId,
|
|
|
- @RequestParam(required = false) String systemId,
|
|
|
@RequestParam String groupCode) {
|
|
|
Diagram diagram = new Diagram();
|
|
|
diagram.setGroupCode(groupCode);
|
|
|
diagram.setProjectId(projectId);
|
|
|
- diagram.setSystemId(systemId);
|
|
|
|
|
|
Optional.ofNullable(params).ifPresent(map -> {
|
|
|
Optional.ofNullable(map.get("id")).ifPresent(o -> diagram.setId(String.valueOf(o)));
|
|
@@ -93,6 +93,7 @@ public class DiagramController {
|
|
|
diagram.setType(String.valueOf(o));
|
|
|
diagram.setSystem(String.valueOf(o).substring(0, 4));
|
|
|
});
|
|
|
+ Optional.ofNullable(map.get("systemId")).ifPresent(o -> diagram.setSystemId(String.valueOf(o)));
|
|
|
Optional.ofNullable(map.get("name")).ifPresent(o -> diagram.setName(String.valueOf(o)));
|
|
|
Optional.ofNullable(map.get("remark")).ifPresent(o -> diagram.setRemark(String.valueOf(o)));
|
|
|
Optional.ofNullable(map.get("templateId")).ifPresent(o -> diagram.setTemplateId(String.valueOf(o)));
|
|
@@ -102,10 +103,11 @@ public class DiagramController {
|
|
|
});
|
|
|
Optional.ofNullable(map.get("lines")).ifPresent(lines ->
|
|
|
diagram.setLines(parser.parseContent(parser.toJson(lines), List.class)));
|
|
|
- Optional.ofNullable(map.get("nodes")).ifPresent(nodes ->
|
|
|
- diagram.setNodes(parser.parseContent(parser.toJson(nodes), List.class)));
|
|
|
- Optional.ofNullable(map.get("template")).ifPresent(s ->
|
|
|
- diagram.setTemplate(parser.parseContent(parser.toJson(s), DiagramTemplate.class)));
|
|
|
+ Optional.ofNullable(map.get("nodes")).ifPresent(nodes -> {
|
|
|
+ DiagramNode[] diagramNodes = parser.parseContent(parser.toJson(nodes), DiagramNode[].class);
|
|
|
+ List<DiagramNode> asList = Arrays.asList(diagramNodes);
|
|
|
+ diagram.setNodes(asList);
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
return ResultHelper.single(dataStrategy.saveDiagram(diagram));
|
|
@@ -132,7 +134,9 @@ public class DiagramController {
|
|
|
@ApiOperation("根据系统图id获取系统图信息")
|
|
|
@GetMapping("/getDiagram")
|
|
|
public CommonResult<Diagram> getDiagram(String diagramId) {
|
|
|
- return ResultHelper.single(dataStrategy.getDiagram(diagramId));
|
|
|
+ Diagram diagram = dataStrategy.getDiagram(diagramId);
|
|
|
+ diagramManager.buildDiagram(diagram, true);
|
|
|
+ return ResultHelper.single(diagram);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -217,4 +221,15 @@ public class DiagramController {
|
|
|
public CommonResult<Diagram> loadData(@RequestBody Diagram diagram) {
|
|
|
return ResultHelper.single(diagramManager.loadData(diagram.getId(), true));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 系统图转台变更
|
|
|
+ *
|
|
|
+ * @return 模板列表
|
|
|
+ */
|
|
|
+ @ApiOperation("获取所有的系统模板")
|
|
|
+ @PostMapping("/update/state")
|
|
|
+ public CommonResult<Boolean> updateState(@RequestBody Map<String,String> params) {
|
|
|
+ return ResultHelper.single(dataStrategy.updateState(params.get("state"),params.get("id")));
|
|
|
+ }
|
|
|
}
|