Skip to content

Repository files navigation

工作流引擎

工作流设计器

获取项目

go get github.com/antlinker/flow

使用

1. 初始化工作流引擎

import (
"time""ant-flow""ant-flow/service/db"
_ "github.com/go-sql-driver/mysql"
)
funcmain() {
flow.Init(
db.SetDSN("root:123456@tcp(127.0.0.1:3306)/flows?charset=utf8"),
db.SetTrace(true),
)
}

2. 加载工作流文件

err:=flow.LoadFile("leave.bpmn")
iferr!=nil {
// 处理错误
}

3. 发起流程

input:=map[string]interface{}{
"day": 1,
}
result, err:=flow.StartFlow("流程编号", "开始节点编号", "流程发起人ID", input)
iferr!=nil {
// 处理错误
}

4. 查询待办流程列表

todos, err:=flow.QueryTodoFlows("流程编号", "流程待办人ID")
iferr!=nil {
// 处理错误
}

5. 处理流程

input:=map[string]interface{}{
"action": "pass",
}
result, err=flow.HandleFlow("待办流程节点实例ID", "流程处理人ID", input)
iferr!=nil {
// 处理错误
}

6. 停止流程

err:=flow.StopFlow("待办流程节点实例ID", func(flowInstance*schema.FlowInstance) bool {
returnflowInstance.Launcher=="XXX"
})
iferr!=nil {
// 处理错误
}

7. 接入WEB流程管理

funcmain() {
serverOptions:= []flow.ServerOption{
flow.ServerStaticRootOption("./web"),
flow.ServerPrefixOption("/flow/"),
flow.ServerMiddlewareOption(filter),
}
http.Handle("/flow/", flow.StartServer(serverOptions...))
}
funcfilter(ctx*gear.Context) error {
fmt.Printf("请求参数:%s - %s \n", ctx.Path, ctx.Method)
returnnil
}

8. 查询流程待办数据

result,err:=flow.QueryTodoFlows("流程编号","流程处理人ID")
iferr!=nil {
// 处理错误
}

9. 查询流程历史数据

result,err:=flow.QueryFlowHistory("待办流程实例ID")
iferr!=nil {
// 处理错误
}

10. 查询已办理的流程实例ID列表

ids,err:=flow.QueryDoneFlowIDs("流程编号","流程处理人ID")
iferr!=nil {
// 处理错误
}

11. 查询节点实例的候选人ID列表

ids,err:=flow.QueryNodeCandidates("待办流程节点实例ID")
iferr!=nil {
// 处理错误
}

12. 停止流程实例

err:=flow.StopFlowInstance("待办流程节点实例ID", func(flowInstance*schema.FlowInstance) bool {
returnflowInstance.Launcher=="XXX"
})
iferr!=nil {
// 处理错误
}

流程管理流程设计器

About

基于bpmn 2.0协议实现的工作流引擎

Resources

Stars

135 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages