1、andflow引擎

andflow_js可以实现在Html端设计流程,并将设计结果保存为json模型andflow可以用于设计业务流程、数据处理流程、工作流、控制流等一切可流程化的过程
由于golang具备高效、跨平台、并且还能够直接编译成可执行文件,这些优势让我们第一个andflow引擎开发优先选择golang
在这里插入图片描述

2、设计思路

3、一个例子

例子主要执行流程,并在节点中实现

json文件《4执行脚本.json

在这里插入图片描述


{
  "code": "",
  "name": "",
  "show_action_body": "true",
  "show_action_content": "true",
  "theme": "flow_theme_default",
  "link_type": "Flowchart",
  "params": [],
  "actions": [
    {
      "id": "f7a6ec0031784f5a80d8633a6418fd52",
      "left": "30px",
      "top": "90px",
      "name": "begin",
      "theme": "action_theme_icon",
      "params": {},
      "title": "开始",
      "icon": "begin.png",
      "width": "120px",
      "height": "80px",
      "content": {
        "content_type": "msg",
        "content": "yes"
      }
    },
    {
      "id": "f558687ca5f34a6c89732eb50749a15a",
      "left": "700px",
      "top": "170px",
      "name": "end",
      "theme": "action_theme_icon",
      "params": {},
      "title": "结束",
      "icon": "end.png",
      "width": "120px",
      "height": "80px"
    },
    {
      "id": "1c53b069bfd34d4da0ac0d74d8e539d5",
      "left": "310px",
      "top": "120px",
      "name": "script",
      "params": {},
      "title": "执行脚本",
      "icon": "script.png",
      "width": "120px",
      "height": "80px",
      "content": {
        "content": "如果name=='zgq'就继续,否则不继续"
      },
      "theme": "action_theme_default",
      "once": "false",
      "collect": "false",
      "script": "var name = getParam("name");print("hello "+name);nnif(name=="zgq"){nreturn 1;n}else{nreturn 0;n}"
    }
  ],
  "links": [
    {
      "source_id": "1c53b069bfd34d4da0ac0d74d8e539d5",
      "target_id": "f558687ca5f34a6c89732eb50749a15a"
    },
    {
      "source_id": "f7a6ec0031784f5a80d8633a6418fd52",
      "target_id": "1c53b069bfd34d4da0ac0d74d8e539d5"
    }
  ],
  "groups": [],
  "lists": [],
  "tips": []
}

golang代码

import (
"fmt"
"io/ioutil"
​
​
"github.com/zone-7/andflow_go/actions"
"github.com/zone-7/andflow_go/engine"
)
​
​
func main() {
file := "4执行脚本.json"
​
​
engine.RegistActionRunner("common", &actions.CommonActionRunner{})
​
​
param := make(map[string]interface{})
​param["name"] = "zgq"
​
data, _ := ioutil.ReadFile(file)
​
​
flow, err := engine.ParseFlow(string(data))
if err != nil {
fmt.Println(err)
return
}
​
​
runtime := engine.CreateRuntime(flow, param)
​
​
runner := engine.CommonFlowRunner{}
engine.Execute(runtime, &runner, 10000)
​
​
fmt.Println("time used(ms):", runtime.Timeused)
​
​
}
​

​执行结果
在这里插入图片描述
下载源代码扫码回复 ”流程引擎
在这里插入图片描述

原文地址:https://blog.csdn.net/u012474395/article/details/128083955

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_48500.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注