增加formily json schema生成

This commit is contained in:
dengqichen 2025-10-20 17:51:47 +08:00
parent 79c9804dbd
commit f8dc82b7a9
7 changed files with 394 additions and 343 deletions

View File

@ -62,8 +62,6 @@ public class WorkflowDefinitionDTO extends BaseDTO {
private WorkflowDefinitionStatusEnums status;
private JsonNode localVariablesSchema;
/**
* 流程描述
*/

View File

@ -7,6 +7,7 @@ import java.util.Map;
/**
* 工作流边
*
* @author cascade
* @date 2024-12-11
*/

View File

@ -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<String, Object> position;
@Schema(description = "节点属性")
private JsonNode panelVariables;
private Map<String, String> configs;
@Schema(description = "节点环境变量")
private JsonNode localVariables;
private Map<String, String> inputMapping;
@Schema(description = "节点表单 JSON SCHEMA")
private JsonNode formVariablesSchema;
private Map<String, String> outputMapping;
}

View File

@ -231,11 +231,11 @@ public class BpmnConverter {
* @param extensionElements 扩展元素
*/
private void configureServiceTask(ServiceTask serviceTask, WorkflowDefinitionGraphNode node, Process process, Map<String, List<ExtensionElement>> 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);
@ -265,31 +265,31 @@ public class BpmnConverter {
*/
private void addExecutionVariables(Map<String, List<ExtensionElement>> 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<String, List<ExtensionAttribute>> 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<String, List<ExtensionAttribute>> 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) {
@ -453,32 +453,33 @@ public class BpmnConverter {
* @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;
}
/**

View File

@ -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:
# 连接池最大连接数

View File

@ -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
);
-- --------------------------------------------------------------------------------------
-- 初始化项目管理数据

View File

@ -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
);