图形界面流程控制思路 workflow ?

1. 问题描述?

Laravel

这个是阿里云机器学习的流程控制,最近需要做一个类似这个图形界面操作的流程控制,请教下大家有没有好的想法和思路,
现在有一个思路,使用processmaker 但是没有中文文档,开发起来很吃力

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 5

我之前调研过类似的解决方案,使用 Temporal 引擎。Temporal 前身是 Uber 的内部工作流组件 Cadence,是一个封装的比较好的工作流编排引擎。由 Go 编写,客户端支持多种语言!

常见的工作流定义,都是通过硬编码来实现的,但是 Temporal 也支持 领域特定语言(DSL domain-specific language),也就是说,你可以根据自己的业务场景,定义一套用于编排流程的语言和结构!

例如我定义如下结构体,用来存储工作历程,用它来实现表单提交后的处理流:

type (
    Argument struct {
        Name        string `bson:"name" json:"name"`
        Type        string `bson:"type" json:"type"`
        Reference   string `bson:"reference" json:"reference"`
        Description string `bson:"description" json:"description"`
    }

    // Activity is used to express invoking an Activity. The Arguments defined expected arguments as input to
    // the Activity, the result specify the name of variable that it will store the result as which can then be used as
    // arguments to subsequent ActivityInvocation.
    Activity struct {
        Id        *primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
        Name      string              `bson:"name" json:"name"`
        Version   string              `bson:"version" json:"version"`
        Arguments []Argument          `bson:"arguments" json:"arguments"`
        CreatedAt *time.Time          `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
        UpdatedAt *time.Time          `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
    }

    // Sequence consist of a collection of Statements that runs in sequential.
    Sequence struct {
        Elements []*Statement `bson:"elements" json:"elements"`
    }

    // Parallel can be a collection of Statements that runs in parallel.
    Parallel struct {
        Branches []*Statement `bson:"branches" json:"branches"`
    }

    // Condition an executable branch.
    Condition struct {
        Name        string            `bson:"name" json:"name"`
        Statement   Statement         `bson:"statement" json:"statement"`
        References  map[string]string `bson:"references" json:"references"`
        Expression  string            `bson:"expression" json:"expression"`
        Description string            `bson:"description" json:"description"`
    }

    // Conditions can be a collection of logical branches.
    Conditions struct {
        Branches []*Condition `bson:"branches" json:"branches"`
    }

    // Statement is the building block of dsl workflow. A Statement can be a simple Activity or could be a Sequence or Parallel.
    Statement struct {
        Delay      uint64      `bson:"delay" json:"delay"`
        Activity   *Activity   `bson:"activity" json:"activity"`
        Sequence   *Sequence   `bson:"sequence" json:"sequence"`
        Parallel   *Parallel   `bson:"parallel" json:"parallel"`
        Conditions *Conditions `bson:"conditions" json:"conditions"`
    }

    // Workflow is the type used to express the workflow definition. Payload can be used as input to Activity.
    Workflow struct {
        Id        primitive.ObjectID `bson:"_id" json:"id"`
        Root      Statement          `bson:"root" json:"root"`
        SchemaID  primitive.ObjectID `bson:"schemaID" json:"schemaID"`
        CreatedAt *time.Time         `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
        UpdatedAt *time.Time         `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
    }

    Executable interface {
        execute(ctx workflow.Context, record Record) error
    }
)

然后就是通过 JSON 定义流程:

{
    "root": {
        "sequence": {
            "elements": [
                {
                    "activity": {
                        "name": "ValidateCaptcha",
                        "arguments": {
                            "mobile": {
                                "name": "mobile",
                                "type": "string",
                                "reference": ".mobile"
                            },
                            "captcha": {
                                "name": "captcha",
                                "type": "string",
                                "reference": ".captcha"
                            }
                        },
                        "description": "Validate customer mobile."
                    }
                },
                {
                    "activity": {
                        "name": "StoreInquiry",
                        "arguments": {
                            "inquiry": {
                                "name": "inquiry",
                                "type": "object",
                                "reference": "."
                            }
                        },
                        "description": "Inquiry form playload"
                    }
                }
            ]
        }
    },
    "schemaID": "62d7b184d7a6925d36886719"
}

当然做到这一步,只能通过开发者来定义 JSON 实现对流程的控制。至于如何通过 UI 来实现将用户的拖拽生成 JSON,我还在寻找合适前端开源项目。

Workflow 的执行端代码,可以参考官方文档和官方 Example!

1年前 评论
微加加的朋友 (楼主) 1年前

一般的使用 processmaker 完全支持了,接口提供的也比较全面

1年前 评论

camunda bpmn.js

1年前 评论
微加加的朋友 (楼主) 1年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!