mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-13 11:53:47 +08:00
网关判断
This commit is contained in:
@@ -72,6 +72,12 @@ type FlowHistoryResp struct {
|
||||
CreateTime core.TsTime `json:"createTime" structs:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
type gateway struct {
|
||||
// 网关节点
|
||||
Id string `json:"id"`
|
||||
Condition string `json:"condition"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
type FlowTree struct {
|
||||
Id string `json:"id"`
|
||||
Pid string `json:"pid"`
|
||||
@@ -85,6 +91,8 @@ type FlowTree struct {
|
||||
|
||||
FieldAuth map[string]int `json:"fieldAuth"`
|
||||
|
||||
Gateway *[]gateway
|
||||
|
||||
Children *[]FlowTree `json:"children"`
|
||||
}
|
||||
type NextNodeReq struct {
|
||||
|
||||
@@ -3,6 +3,8 @@ package flow_history
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"x_admin/admin/flow/flow_apply"
|
||||
"x_admin/admin/system/admin"
|
||||
"x_admin/admin/system/dept"
|
||||
@@ -390,12 +392,66 @@ func DeepNextNode(nextNodes []FlowTree, flowTree *[]FlowTree, formValue map[stri
|
||||
break
|
||||
} else if v.Type == "bpmn:exclusiveGateway" {
|
||||
// 网关
|
||||
// v.Gateway
|
||||
var haveFalse = false
|
||||
var gateway = *v.Gateway
|
||||
for i := 0; i < len(gateway); i++ {
|
||||
var id = gateway[i].Id
|
||||
var value = gateway[i].Value
|
||||
var condition = gateway[i].Condition
|
||||
if condition == "==" {
|
||||
if formValue[id].(string) == value { // 等与
|
||||
|
||||
// 判断formValue值,决定是不是递归这个网关
|
||||
child := DeepNextNode(nextNodes, v.Children, formValue)
|
||||
nextNodes = append(nextNodes, v)
|
||||
nextNodes = append(nextNodes, child...)
|
||||
break
|
||||
} else {
|
||||
haveFalse = true
|
||||
}
|
||||
} else if condition == "!=" {
|
||||
if formValue[id].(string) != value { // 不等与
|
||||
|
||||
} else {
|
||||
haveFalse = true
|
||||
}
|
||||
} else if condition == ">=" {
|
||||
var val, err = strconv.Atoi(value)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
var formVal = formValue[id].(int64)
|
||||
if formVal >= int64(val) { // 大于等于
|
||||
|
||||
} else {
|
||||
haveFalse = true
|
||||
}
|
||||
} else if condition == "<=" {
|
||||
var val, err = strconv.Atoi(value)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
var formVal = formValue[id].(int64)
|
||||
|
||||
if formVal <= int64(val) { // 小于等于
|
||||
|
||||
} else {
|
||||
haveFalse = true
|
||||
}
|
||||
} else {
|
||||
haveFalse = true
|
||||
fmt.Println("未知的条件")
|
||||
}
|
||||
|
||||
}
|
||||
// 不满足条件,继续循环
|
||||
if haveFalse {
|
||||
continue
|
||||
} else {
|
||||
// 判断formValue值,决定是不是递归这个网关
|
||||
child := DeepNextNode(nextNodes, v.Children, formValue)
|
||||
nextNodes = append(nextNodes, v)
|
||||
nextNodes = append(nextNodes, child...)
|
||||
break
|
||||
}
|
||||
} else if v.Type == "bpmn:serviceTask" {
|
||||
// 系统服务
|
||||
child := DeepNextNode(nextNodes, v.Children, formValue)
|
||||
|
||||
Reference in New Issue
Block a user