This commit is contained in:
yumoqing 2026-03-13 17:14:16 +08:00
parent 49e5a32e2a
commit d50744af4e
3 changed files with 18 additions and 21 deletions

View File

@ -1,7 +1,5 @@
# Workflow Engine 使用说明书 # Workflow Engine 使用说明书
> 版本v1.1sqlor 持久化 + 子流程 input/output mapping
本文档用于说明当前 Workflow Engine 的**设计目标、核心概念、数据模型、DSL 用法、执行语义以及使用示例**。不涉及未来规划能力。 本文档用于说明当前 Workflow Engine 的**设计目标、核心概念、数据模型、DSL 用法、执行语义以及使用示例**。不涉及未来规划能力。
--- ---
@ -45,10 +43,10 @@
包含内容: 包含内容:
* 起始节点start * 流程id(id)
* 节点集合nodes * 节点集合nodes
* 边集合edges * 边集合edges
* 流程启动上下文规格说明ctx_spec)
--- ---
### 2.2 FlowInstance流程实例 ### 2.2 FlowInstance流程实例
@ -57,7 +55,6 @@
* 持有自己的: * 持有自己的:
* ctx上下文 * ctx上下文
* active_nodes当前活跃节点
* statusrunning / finished * statusrunning / finished
**所有流转都发生在实例中,而不是定义中。** **所有流转都发生在实例中,而不是定义中。**
@ -68,9 +65,9 @@
| 类型 | 说明 | | 类型 | 说明 |
| -------- | ------------------ | | -------- | ------------------ |
| start | 开始节点 |
| task | 普通执行节点(业务 / skill | | task | 普通执行节点(业务 / skill |
| decision | 条件判断节点 | | haman | 手工节点 |
| join | 并发汇合节点 |
| subflow | 子流程节点 | | subflow | 子流程节点 |
| end | 结束节点 | | end | 结束节点 |
@ -99,7 +96,6 @@
* id实例 ID * id实例 ID
* flow_def_id关联定义 * flow_def_id关联定义
* ctxJSON 上下文 * ctxJSON 上下文
* active_nodes当前节点集合
* statusrunning / finished * statusrunning / finished
--- ---
@ -160,32 +156,32 @@ id: order_flow_v1
start: start start: start
nodes: nodes:
start: start: # 每个流程必须要有一个start
type: task type: start # 类型必须是start
end: end: # 每个流程必须要有一个end
type: end type: end # 类型必须上end
task1: task1:
title: task1 title title: task1 title
type: task type: task
description: desc description: desc
input_ctx:["k1:g1", "k2.kk1:g2"] # 可选, 缺省使用流程实例的全部ctx input_ctx: jinja2的模版字符串 # 可选, 缺省使用流程实例的全部ctx
output_ctx:["k1:ck1", "k2:ck2.x"] # 可选, 缺失全部输出更新到流程实例的ctx output_ctx: jinja2的模版字符串 可选, 缺失全部输出更新到流程实例的ctx
subflow1: subflow1:
title: subf title: subf
type: subflow type: subflow
subflow_id: payment_flow_v2 subflow_id: payment_flow_v2
input_ctx:["k1:g1", "k2.kk1:g2"] # 可选, 缺省使用流程实例的全部ctx input_ctx: jinja2的模版字符串 # 可选, 缺省使用流程实例的全部ctx
output_ctx:["k1:ck1", "k2:ck2.x"] # 可选, 子流程实例的ctx到本流程实例的缺失全部输出更新到流程实例的ctx output_ctx: jinja2的模版字符串 # 可选, 子流程实例的ctx到本流程实例的缺失全部输出更新到流程实例的ctx
humantask1: humantask1:
title: conform title: conform
type: human type: human
description: desc description: desc
input_ctx:["k1:g1", "k2.kk1:g2"] # 可选, 缺省使用流程实例的全部ctx input_ctx: jinja2的模版字符串 # 可选, 缺省使用流程实例的全部ctx
output_ctx:["k1:ck1", "k2:ck2.x"] # 可选, 缺失全部输出更新到流程实例的ctx output_ctx: jinja2的模版字符串 # 可选, 缺失全部输出更新到流程实例的ctx
edges: edges:
- from: start - from: start
@ -193,6 +189,7 @@ edges:
multile_on: ctx.charpter # multile_on: ctx.charpter #
when: ctx.x == 'xxx' # 可选,转移条件 when: ctx.x == 'xxx' # 可选,转移条件
``` ```
### 流程定义节点数据要求 ### 流程定义节点数据要求
除开始节点和结束节点外,所有节点都需要有 除开始节点和结束节点外,所有节点都需要有
``` ```
@ -245,7 +242,7 @@ edges:
edges: edges:
- from: gen_docs - from: gen_docs
to: evalution_chapter to: evalution_chapter
multiple_on: ctx.docs.chapters foreach: ctx.docs.chapters
``` ```
#### Fork隐式 #### Fork隐式

View File

@ -10,5 +10,5 @@ description: 根据用户输入创建工作流
## 新建流程 ## 新建流程
将用户输入拆解为流程引擎添加流程的json数据然后调用以下函数 将用户输入拆解为流程引擎添加流程的json数据然后调用以下函数
``` ```
CALL{ "function": "add_new_workflow", "params":{"name":流程名字,"dsl":YAML格式的符合上述流程规范的流程定义} CALL{ "function": "add_new_workflow", "params":{"name":流程名字,"description": 用户输入的"dsl":YAML格式的符合上述流程规范的流程定义}
``` ```

View File

@ -316,7 +316,7 @@ where backid=${backid}$
cond = edge.get('when') cond = edge.get('when')
if cond and not eval(cond, {}, {'ctx': ctx}): if cond and not eval(cond, {}, {'ctx': ctx}):
continue continue
m_on = edge.get('multiple_on') m_on = edge.get('foreach')
ns = { ns = {
'm_on': m_on, 'm_on': m_on,
'ctx': ctx, 'ctx': ctx,