Code Monkey home page Code Monkey logo

flow's Introduction

工作流引擎

工作流设计器

获取项目

go get github.com/antlinker/flow

使用

1. 初始化工作流引擎

import (
	"time"

	"ant-flow"
	"ant-flow/service/db"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	flow.Init(
		db.SetDSN("root:123456@tcp(127.0.0.1:3306)/flows?charset=utf8"),
		db.SetTrace(true),
	)
}

2. 加载工作流文件

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

3. 发起流程

  input := map[string]interface{}{
	"day": 1,
  }

	result, err := flow.StartFlow("流程编号", "开始节点编号", "流程发起人ID", input)
	if err != nil {
		// 处理错误
	}

4. 查询待办流程列表

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

5. 处理流程

  input := map[string]interface{}{
	"action": "pass",
  }

  result, err = flow.HandleFlow("待办流程节点实例ID", "流程处理人ID", input)
	if err != nil {
		// 处理错误
	}

6. 停止流程

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

7. 接入WEB流程管理

func main() {
serverOptions := []flow.ServerOption{
		flow.ServerStaticRootOption("./web"),
		flow.ServerPrefixOption("/flow/"),
		flow.ServerMiddlewareOption(filter),
	}

	http.Handle("/flow/", flow.StartServer(serverOptions...))
}

func filter(ctx *gear.Context) error {
	fmt.Printf("请求参数:%s - %s \n", ctx.Path, ctx.Method)
	return nil
}

8. 查询流程待办数据

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

9. 查询流程历史数据

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

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

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

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

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

12. 停止流程实例

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

流程管理 流程设计器

flow's People

Contributors

lyrictian avatar yupengfei avatar programkingdom avatar yinbaoqiang avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.