From f8dc82b7a93708d09140946c4ae96701ca99817c Mon Sep 17 00:00:00 2001 From: dengqichen Date: Mon, 20 Oct 2025 17:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0formily=20json=20schema?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflow/dto/WorkflowDefinitionDTO.java | 2 - .../workflow/WorkflowDefinitionGraphEdge.java | 1 + .../workflow/WorkflowDefinitionGraphNode.java | 26 +- .../backend/workflow/util/BpmnConverter.java | 143 ++++--- backend/src/main/resources/application.yml | 6 +- .../db/migration/V1.0.1__init_data.sql | 404 +++++++----------- backend/workflow_node_definition_fix.sql | 155 +++++++ 7 files changed, 394 insertions(+), 343 deletions(-) create mode 100644 backend/workflow_node_definition_fix.sql diff --git a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/WorkflowDefinitionDTO.java b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/WorkflowDefinitionDTO.java index b8afdab0..3ba3d323 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/WorkflowDefinitionDTO.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/WorkflowDefinitionDTO.java @@ -62,8 +62,6 @@ public class WorkflowDefinitionDTO extends BaseDTO { private WorkflowDefinitionStatusEnums status; - private JsonNode localVariablesSchema; - /** * 流程描述 */ diff --git a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphEdge.java b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphEdge.java index 9a175fad..8ad769ad 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphEdge.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphEdge.java @@ -7,6 +7,7 @@ import java.util.Map; /** * 工作流边 + * * @author cascade * @date 2024-12-11 */ diff --git a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphNode.java b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphNode.java index fc55c1ed..6ce49550 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphNode.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/workflow/WorkflowDefinitionGraphNode.java @@ -5,6 +5,8 @@ import com.qqchen.deploy.backend.workflow.enums.NodeTypeEnums; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.Map; + /** * 工作流节点数据传输对象 * @@ -14,36 +16,20 @@ import lombok.Data; @Data public class WorkflowDefinitionGraphNode { - /** - * 节点ID - */ private String id; - /** - * 节点Code - */ private String nodeCode; - /** - * 节点类型 - */ private NodeTypeEnums nodeType; - /** - * 节点名称 - */ private String nodeName; - @Schema(description = "节点UI") - private JsonNode uiVariables; + private Map position; - @Schema(description = "节点属性") - private JsonNode panelVariables; + private Map configs; - @Schema(description = "节点环境变量") - private JsonNode localVariables; + private Map inputMapping; - @Schema(description = "节点表单 JSON SCHEMA") - private JsonNode formVariablesSchema; + private Map outputMapping; } diff --git a/backend/src/main/java/com/qqchen/deploy/backend/workflow/util/BpmnConverter.java b/backend/src/main/java/com/qqchen/deploy/backend/workflow/util/BpmnConverter.java index 3464d909..3bec0dae 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/workflow/util/BpmnConverter.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/workflow/util/BpmnConverter.java @@ -74,7 +74,7 @@ public class BpmnConverter { * 创建并初始化BPMN模型 * * @param processKey 流程定义的唯一标识 - * @param bpmnModel BPMN模型对象 + * @param bpmnModel BPMN模型对象 * @return 初始化后的Process对象 */ private Process createAndInitializeBpmnModel(String processKey, BpmnModel bpmnModel) { @@ -99,7 +99,7 @@ public class BpmnConverter { /** * 转换工作流节点为BPMN节点 * - * @param nodes 工作流定义节点列表 + * @param nodes 工作流定义节点列表 * @param process 流程定义对象 * @return 节点ID映射关系 */ @@ -119,8 +119,8 @@ public class BpmnConverter { /** * 转换单个工作流节点为BPMN节点 * - * @param node 工作流节点定义 - * @param process 流程定义对象 + * @param node 工作流节点定义 + * @param process 流程定义对象 * @param idMapping 节点ID映射关系 */ private void convertSingleNode(WorkflowDefinitionGraphNode node, Process process, Map idMapping) { @@ -225,17 +225,17 @@ public class BpmnConverter { /** * 配置服务任务节点 * - * @param serviceTask 服务任务节点 - * @param node 工作流节点定义 - * @param process 当前流程 + * @param serviceTask 服务任务节点 + * @param node 工作流节点定义 + * @param process 当前流程 * @param extensionElements 扩展元素 */ private void configureServiceTask(ServiceTask serviceTask, WorkflowDefinitionGraphNode node, Process process, Map> extensionElements) { - if (node.getPanelVariables() != null && node.getPanelVariables().has("delegate")) { - String delegate = node.getPanelVariables().get("delegate").asText(); - serviceTask.setImplementationType("delegateExpression"); - serviceTask.setImplementation(delegate); - } +// if (node.getPanelVariables() != null && node.getPanelVariables().has("delegate")) { +// String delegate = node.getPanelVariables().get("delegate").asText(); +// serviceTask.setImplementationType("delegateExpression"); +// serviceTask.setImplementation(delegate); +// } addExecutionVariables(extensionElements, node); addRetryStrategy(extensionElements); @@ -246,7 +246,7 @@ public class BpmnConverter { /** * 创建扩展属性 * - * @param name 属性名 + * @param name 属性名 * @param value 属性值 * @return 扩展属性 */ @@ -261,35 +261,35 @@ public class BpmnConverter { * 添加执行实例级变量 * * @param extensionElements 扩展元素 - * @param node 工作流节点定义 + * @param node 工作流节点定义 */ private void addExecutionVariables(Map> extensionElements, WorkflowDefinitionGraphNode node) { // 添加panelVariables变量 - if (node.getPanelVariables() != null) { - ExtensionElement fieldElement = new ExtensionElement(); - fieldElement.setName("field"); - fieldElement.setNamespace("http://flowable.org/bpmn"); - fieldElement.setNamespacePrefix("flowable"); - - // 创建field的子元素string - ExtensionElement stringElement = new ExtensionElement(); - stringElement.setName("string"); - stringElement.setNamespace("http://flowable.org/bpmn"); - stringElement.setNamespacePrefix("flowable"); - // 直接设置JSON内容,不使用CDATA - stringElement.setElementText(node.getPanelVariables().toString()); - - // 设置field的name属性 - Map> fieldAttributes = new HashMap<>(); - fieldAttributes.put("name", Collections.singletonList(createAttribute("name", "panelVariables"))); - fieldElement.setAttributes(fieldAttributes); - - // 添加string子元素到field - fieldElement.addChildElement(stringElement); - - // 添加field到extensionElements - extensionElements.computeIfAbsent("field", k -> new ArrayList<>()).add(fieldElement); - } +// if (node.getPanelVariables() != null) { +// ExtensionElement fieldElement = new ExtensionElement(); +// fieldElement.setName("field"); +// fieldElement.setNamespace("http://flowable.org/bpmn"); +// fieldElement.setNamespacePrefix("flowable"); +// +// // 创建field的子元素string +// ExtensionElement stringElement = new ExtensionElement(); +// stringElement.setName("string"); +// stringElement.setNamespace("http://flowable.org/bpmn"); +// stringElement.setNamespacePrefix("flowable"); +// // 直接设置JSON内容,不使用CDATA +// stringElement.setElementText(node.getPanelVariables().toString()); +// +// // 设置field的name属性 +// Map> fieldAttributes = new HashMap<>(); +// fieldAttributes.put("name", Collections.singletonList(createAttribute("name", "panelVariables"))); +// fieldElement.setAttributes(fieldAttributes); +// +// // 添加string子元素到field +// fieldElement.addChildElement(stringElement); +// +// // 添加field到extensionElements +// extensionElements.computeIfAbsent("field", k -> new ArrayList<>()).add(fieldElement); +// } // 添加localVariables变量 // if (node.getLocalVariables() != null) { @@ -339,7 +339,7 @@ public class BpmnConverter { /** * 创建执行监听器扩展元素 * - * @param event 事件类型(start/end) + * @param event 事件类型(start/end) * @param delegateExpression 委托表达式 * @return 配置好的监听器扩展元素 */ @@ -372,8 +372,8 @@ public class BpmnConverter { * 为活动节点添加错误边界事件和错误结束事件 * 当节点执行失败时,会触发错误边界事件,并流转到错误结束事件 * - * @param process BPMN流程定义 - * @param activity 需要添加错误处理的活动节点 + * @param process BPMN流程定义 + * @param activity 需要添加错误处理的活动节点 */ private void addErrorBoundaryEventHandler(Process process, Activity activity) { BoundaryEvent boundaryEvent = createErrorBoundaryEvent(activity); @@ -448,45 +448,46 @@ public class BpmnConverter { /** * 创建网关节点 * - * @param node 工作流节点定义 + * @param node 工作流节点定义 * @param validId 有效的节点ID * @return 创建的网关节点 */ private Gateway createGatewayElement(WorkflowDefinitionGraphNode node, String validId) { - if (node.getPanelVariables() == null) { - throw new IllegalArgumentException("Gateway node must have panel variables"); - } - - String gatewayTypeCode = node.getPanelVariables().get("gatewayType").asText(); - GatewayTypeEnums gatewayType = GatewayTypeEnums.fromCode(gatewayTypeCode); - - Gateway gateway; - switch (gatewayType) { - case EXCLUSIVE_GATEWAY: - gateway = new ExclusiveGateway(); - break; - case PARALLEL_GATEWAY: - gateway = new ParallelGateway(); - break; - case INCLUSIVE_GATEWAY: - gateway = new InclusiveGateway(); - break; - default: - throw new IllegalArgumentException("Unsupported gateway type: " + gatewayType); - } - - gateway.setId(validId); - gateway.setName(node.getNodeName()); - - return gateway; +// if (node.getPanelVariables() == null) { +// throw new IllegalArgumentException("Gateway node must have panel variables"); +// } +// +// String gatewayTypeCode = node.getPanelVariables().get("gatewayType").asText(); +// GatewayTypeEnums gatewayType = GatewayTypeEnums.fromCode(gatewayTypeCode); +// +// Gateway gateway; +// switch (gatewayType) { +// case EXCLUSIVE_GATEWAY: +// gateway = new ExclusiveGateway(); +// break; +// case PARALLEL_GATEWAY: +// gateway = new ParallelGateway(); +// break; +// case INCLUSIVE_GATEWAY: +// gateway = new InclusiveGateway(); +// break; +// default: +// throw new IllegalArgumentException("Unsupported gateway type: " + gatewayType); +// } +// +// gateway.setId(validId); +// gateway.setName(node.getNodeName()); +// +// return gateway; + return null; } /** * 转换连线为顺序流 * - * @param edges 工作流定义边集合 + * @param edges 工作流定义边集合 * @param idMapping 节点ID映射 - * @param process 流程定义 + * @param process 流程定义 */ private void convertEdgesToSequenceFlows(List edges, Map idMapping, Process process) { for (WorkflowDefinitionGraphEdge edge : edges) { diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index ec59b89e..cda468d1 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -2,9 +2,9 @@ server: port: 8080 spring: datasource: - url: jdbc:mysql://localhost:3306/deploy-ease-platform?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true - username: root - password: root + url: jdbc:mysql://172.22.222.111:3306/deploy-ease-platform?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true + username: deploy-ease-platform + password: Qichen5210523 driver-class-name: com.mysql.cj.jdbc.Driver hikari: # 连接池最大连接数 diff --git a/backend/src/main/resources/db/migration/V1.0.1__init_data.sql b/backend/src/main/resources/db/migration/V1.0.1__init_data.sql index 293096be..7d6cbc39 100644 --- a/backend/src/main/resources/db/migration/V1.0.1__init_data.sql +++ b/backend/src/main/resources/db/migration/V1.0.1__init_data.sql @@ -607,253 +607,163 @@ INSERT INTO workflow_definition ( -- -------------------------------------------------------------------------------------- -- 初始化工作流节点定义数据 -- -------------------------------------------------------------------------------------- -# INSERT INTO workflow_node_definition (id, create_time, create_by, update_time, update_by, type, name, description, category, graph_config, enabled) -# VALUES -# (1, NOW(), -# 'system', -# NOW(), -# 'system', 'START_EVENT', '开始节点', '工作流的起点', 'EVENT', '{ -# "code": "START_EVENT", -# "name": "开始节点", -# "description": "工作流的起点", -# "details": { -# "description": "标记流程的开始位置,可以定义流程启动条件和初始化流程变量", -# "features": ["标记流程的开始位置", "定义流程启动条件", "初始化流程变量"], -# "scenarios": ["用户手动启动流程", "定时触发流程", "外部系统调用启动"] -# }, -# "configSchema": { -# "type": "object", -# "properties": { -# "code": {"type": "string", "title": "节点Code", "description": "工作流节点的Code"}, -# "name": {"type": "string", "title": "节点名称", "description": "工作流节点的显示名称"}, -# "description": {"type": "string", "title": "节点描述", "description": "工作流节点的详细描述"} -# }, -# "required": ["code", "name"] -# }, -# "uiSchema": { -# "shape": "circle", -# "size": {"width": 40, "height": 40}, -# "style": { -# "fill": "#e8f7ff", -# "stroke": "#1890ff", -# "strokeWidth": 2, -# "icon": "play-circle", -# "iconColor": "#1890ff" -# }, -# "ports": { -# "groups": { -# "out": { -# "position": "right", -# "attrs": { -# "circle": { -# "r": 4, -# "fill": "#ffffff", -# "stroke": "#1890ff" -# } -# } -# } -# } -# } -# } -# }', 1); -# INSERT INTO workflow_node_definition (id, create_time, create_by, update_time, update_by, type, name, description, category, graph_config, enabled) -# VALUES -# (2, NOW(), -# 'system', -# NOW(), -# 'system', 'END_EVENT', '结束节点', '工作流的终点', 'EVENT', '{ -# "code": "END_EVENT", -# "name": "结束节点", -# "description": "工作流的终点", -# "details": { -# "description": "标记流程的结束位置,可以定义流程结束时的清理操作和设置返回值", -# "features": ["标记流程的结束位置", "定义结束时清理操作", "设置流程结果和返回值"], -# "scenarios": ["流程正常结束", "流程异常终止", "需要返回处理结果"] -# }, -# "configSchema": { -# "type": "object", -# "properties": { -# "code": {"type": "string", "title": "节点Code", "description": "工作流节点的Code"}, -# "name": {"type": "string", "title": "节点名称", "description": "工作流节点的显示名称"}, -# "description": {"type": "string", "title": "节点描述", "description": "工作流节点的详细描述"} -# }, -# "required": ["code", "name"] -# }, -# "uiSchema": { -# "shape": "circle", -# "size": {"width": 40, "height": 40}, -# "style": { -# "fill": "#fff1f0", -# "stroke": "#ff4d4f", -# "strokeWidth": 2, -# "icon": "stop", -# "iconColor": "#ff4d4f" -# }, -# "ports": { -# "groups": { -# "in": { -# "position": "left", -# "attrs": { -# "circle": { -# "r": 4, -# "fill": "#ffffff", -# "stroke": "#1890ff" -# } -# } -# } -# } -# } -# } -# }', 1); -# -# INSERT INTO workflow_node_definition (id, create_time, create_by, update_time, update_by, type, name, description, category, graph_config, enabled) -# VALUES -# (5, NOW(), -# 'system', -# NOW(), -# 'system', 'SCRIPT_TASK', '脚本任务', '脚本执行任务', 'TASK', '{ -# "code": "SCRIPT_TASK", -# "name": "脚本任务", -# "details": { -# "description": "脚本执行任务", -# "features": [], -# "scenarios": [] -# }, -# "configSchema": { -# "type": "object", -# "properties": { -# "code": { -# "type": "string", -# "title": "节点Code", -# "description": "工作流节点的Code" -# }, -# "name": { -# "type": "string", -# "title": "节点名称", -# "description": "工作流节点的显示名称" -# }, -# "description": { -# "type": "string", -# "title": "节点描述", -# "description": "工作流节点的详细描述" -# }, -# "script": { -# "type": "string", -# "title": "脚本内容", -# "description": "需要执行的脚本内容,例如:\\n#!/bin/bash\\necho \\\"开始执行脚本\\\"\\nls -la\\necho \\\"脚本执行完成\\\"", -# "format": "textarea" -# }, -# "language": { -# "type": "string", -# "title": "脚本语言", -# "description": "脚本语言类型", -# "default": "shell", -# "enum": [ -# "shell", -# "python", -# "javascript", -# "groovy" -# ], -# "enumNames": [ -# "Shell脚本 (已支持)", -# "Python脚本 (开发中)", -# "JavaScript脚本 (开发中)", -# "Groovy脚本 (开发中)" -# ] -# }, -# "interpreter": { -# "type": "string", -# "title": "解释器路径", -# "description": "脚本解释器的路径,例如:/bin/bash, /usr/bin/python3" -# }, -# "workingDirectory": { -# "type": "string", -# "title": "工作目录", -# "description": "脚本执行的工作目录", -# "default": "/tmp" -# }, -# "environment": { -# "type": "object", -# "title": "环境变量", -# "description": "脚本执行时的环境变量", -# "additionalProperties": { -# "type": "string" -# } -# }, -# "successExitCode": { -# "type": "integer", -# "title": "成功退出码", -# "description": "脚本执行成功时的退出码", -# "default": 0 -# }, -# "supportedLanguages": { -# "type": "array", -# "title": "支持的脚本语言", -# "enum": [ -# "shell", -# "python", -# "javascript", -# "groovy" -# ], -# "items": { -# "type": "string" -# } -# }, -# "delegate": { -# "type": "string", -# "title": "执行委派者", -# "description": "执行委派者", -# "default": "${shellTaskDelegate}" -# } -# }, -# "required": [ -# "code", -# "name", -# "script", -# "language", -# "interpreter", -# "delegate" -# ] -# }, -# "uiSchema": { -# "shape": "rect", -# "size": { -# "width": 120, -# "height": 60 -# }, -# "style": { -# "fill": "#ffffff", -# "stroke": "#1890ff", -# "strokeWidth": 2, -# "icon": "code", -# "iconColor": "#1890ff" -# }, -# "ports": { -# "groups": { -# "in": { -# "position": "left", -# "attrs": { -# "circle": { -# "r": 4, -# "fill": "#ffffff", -# "stroke": "#1890ff" -# } -# } -# }, -# "out": { -# "position": "right", -# "attrs": { -# "circle": { -# "r": 4, -# "fill": "#ffffff", -# "stroke": "#1890ff" -# } -# } -# } -# } -# } -# } -# }', 1); +-- 初始化工作流节点定义数据 +INSERT INTO workflow_node_definition ( + node_type, node_code, node_name, description, category, + ui_variables, panel_variables_schema, local_variables_schema, + form_variables_schema, enabled, + create_time, create_by, update_time, update_by, version, deleted +) VALUES +-- 开始节点 +( + 'START_EVENT', 'START_EVENT', '开始节点', '工作流的起点', 'EVENT', + '{ + "shape": "circle", + "size": {"width": 40, "height": 40}, + "style": { + "fill": "#e8f7ff", + "stroke": "#1890ff", + "strokeWidth": 2, + "icon": "play-circle", + "iconColor": "#1890ff" + }, + "ports": { + "groups": { + "out": { + "position": "right", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + } + } + } + }', + '{ + "type": "object", + "properties": { + "code": {"type": "string", "title": "节点Code"}, + "name": {"type": "string", "title": "节点名称"}, + "description": {"type": "string", "title": "节点描述"} + }, + "required": ["code", "name"] + }', + '{}', + '{"formItems": []}', + 1, + NOW(), 'system', NOW(), 'system', 1, 0 +), +-- 结束节点 +( + 'END_EVENT', 'END_EVENT', '结束节点', '工作流的终点', 'EVENT', + '{ + "shape": "circle", + "size": {"width": 40, "height": 40}, + "style": { + "fill": "#fff1f0", + "stroke": "#ff4d4f", + "strokeWidth": 2, + "icon": "stop", + "iconColor": "#ff4d4f" + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + } + } + } + }', + '{ + "type": "object", + "properties": { + "code": {"type": "string", "title": "节点Code"}, + "name": {"type": "string", "title": "节点名称"}, + "description": {"type": "string", "title": "节点描述"} + }, + "required": ["code", "name"] + }', + '{}', + '{"formItems": []}', + 1, + NOW(), 'system', NOW(), 'system', 1, 0 +), +-- 脚本任务节点 +( + 'SCRIPT_TASK', 'SCRIPT_TASK', '脚本任务', '脚本执行任务', 'TASK', + '{ + "shape": "rect", + "size": {"width": 120, "height": 60}, + "style": { + "fill": "#ffffff", + "stroke": "#1890ff", + "strokeWidth": 2, + "icon": "code", + "iconColor": "#1890ff" + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + }, + "out": { + "position": "right", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + } + } + } + }', + '{ + "type": "object", + "properties": { + "code": {"type": "string", "title": "节点Code"}, + "name": {"type": "string", "title": "节点名称"}, + "description": {"type": "string", "title": "节点描述"}, + "script": { + "type": "string", + "title": "脚本内容", + "format": "textarea", + "description": "需要执行的脚本内容" + }, + "language": { + "type": "string", + "title": "脚本语言", + "default": "shell", + "enum": ["shell", "python", "javascript"], + "enumNames": ["Shell脚本", "Python脚本", "JavaScript脚本"] + }, + "interpreter": { + "type": "string", + "title": "解释器路径", + "description": "脚本解释器的路径,例如:/bin/bash" + }, + "workingDirectory": { + "type": "string", + "title": "工作目录", + "default": "/tmp" + }, + "delegate": { + "type": "string", + "title": "执行委派者", + "default": "${shellTaskDelegate}" + } + }, + "required": ["code", "name", "script", "language", "delegate"] + }', + '{ + "environment": {"type": "object", "additionalProperties": {"type": "string"}} + }', + '{"formItems": []}', + 1, + NOW(), 'system', NOW(), 'system', 1, 0 +); -- -------------------------------------------------------------------------------------- -- 初始化项目管理数据 diff --git a/backend/workflow_node_definition_fix.sql b/backend/workflow_node_definition_fix.sql new file mode 100644 index 00000000..6e437f62 --- /dev/null +++ b/backend/workflow_node_definition_fix.sql @@ -0,0 +1,155 @@ +-- ===================================================== +-- 修复 workflow_node_definition 表的初始化数据 +-- ===================================================== + +-- 删除注释,添加正确的节点定义数据 +INSERT INTO workflow_node_definition ( + node_type, node_code, node_name, description, category, + ui_variables, panel_variables_schema, local_variables_schema, + form_variables_schema, enabled, + create_time, create_by, update_time, update_by, version, deleted +) VALUES +-- 开始节点 +( + 'START_EVENT', 'START_EVENT', '开始节点', '工作流的起点', 'EVENT', + '{ + "shape": "circle", + "size": {"width": 40, "height": 40}, + "style": { + "fill": "#e8f7ff", + "stroke": "#1890ff", + "strokeWidth": 2, + "icon": "play-circle", + "iconColor": "#1890ff" + }, + "ports": { + "groups": { + "out": { + "position": "right", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + } + } + } + }', + '{ + "type": "object", + "properties": { + "code": {"type": "string", "title": "节点Code"}, + "name": {"type": "string", "title": "节点名称"}, + "description": {"type": "string", "title": "节点描述"} + }, + "required": ["code", "name"] + }', + '{}', + '{"formItems": []}', + 1, + NOW(), 'system', NOW(), 'system', 1, 0 +), +-- 结束节点 +( + 'END_EVENT', 'END_EVENT', '结束节点', '工作流的终点', 'EVENT', + '{ + "shape": "circle", + "size": {"width": 40, "height": 40}, + "style": { + "fill": "#fff1f0", + "stroke": "#ff4d4f", + "strokeWidth": 2, + "icon": "stop", + "iconColor": "#ff4d4f" + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + } + } + } + }', + '{ + "type": "object", + "properties": { + "code": {"type": "string", "title": "节点Code"}, + "name": {"type": "string", "title": "节点名称"}, + "description": {"type": "string", "title": "节点描述"} + }, + "required": ["code", "name"] + }', + '{}', + '{"formItems": []}', + 1, + NOW(), 'system', NOW(), 'system', 1, 0 +), +-- 脚本任务节点 +( + 'SCRIPT_TASK', 'SCRIPT_TASK', '脚本任务', '脚本执行任务', 'TASK', + '{ + "shape": "rect", + "size": {"width": 120, "height": 60}, + "style": { + "fill": "#ffffff", + "stroke": "#1890ff", + "strokeWidth": 2, + "icon": "code", + "iconColor": "#1890ff" + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + }, + "out": { + "position": "right", + "attrs": { + "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"} + } + } + } + } + }', + '{ + "type": "object", + "properties": { + "code": {"type": "string", "title": "节点Code"}, + "name": {"type": "string", "title": "节点名称"}, + "description": {"type": "string", "title": "节点描述"}, + "script": { + "type": "string", + "title": "脚本内容", + "format": "textarea" + }, + "language": { + "type": "string", + "title": "脚本语言", + "default": "shell", + "enum": ["shell", "python", "javascript"], + "enumNames": ["Shell脚本", "Python脚本", "JavaScript脚本"] + }, + "workingDirectory": { + "type": "string", + "title": "工作目录", + "default": "/tmp" + }, + "delegate": { + "type": "string", + "title": "执行委派者", + "default": "${shellTaskDelegate}" + } + }, + "required": ["code", "name", "script", "language", "delegate"] + }', + '{ + "environment": {"type": "object", "additionalProperties": {"type": "string"}} + }', + '{"formItems": []}', + 1, + NOW(), 'system', NOW(), 'system', 1, 0 +);