Documentation
¶
Overview ¶
管理扩展领域对象(v1.1.0)——流程设计 / 设计历史 / 委托代理
DDD 聚合根行为——对标 Java 版 domain/ProcessInstance + domain/ProcessTask
Package model 域类型定义——对标 Java 版 domain + model 包
Index ¶
- Constants
- type CcInstanceRow
- type CountersignType
- type DefineRow
- type DefineState
- type FlowEdge
- type FlowModel
- type FlowNode
- type InstanceRow
- type InstanceState
- type InstanceStatsRow
- type PerformType
- type ProcessDefine
- type ProcessDesign
- type ProcessDesignHis
- type ProcessInstance
- func (p *ProcessInstance) AbandonAllDoing(now time.Time) []*ProcessTask
- func (p *ProcessInstance) AbandonTask(task *ProcessTask, now time.Time)
- func (p *ProcessInstance) AddVariable(vars map[string]interface{})
- func (p *ProcessInstance) CompleteTask(task *ProcessTask, operator string, vars map[string]interface{}, now time.Time)
- func (p *ProcessInstance) CreateTask(id int64, taskName, displayName, actor, operator, formKey string, ...) *ProcessTask
- func (p *ProcessInstance) Finish(now time.Time)
- func (p *ProcessInstance) GetDoingTasks() []*ProcessTask
- func (p *ProcessInstance) GetDoneTasks() []*ProcessTask
- func (p *ProcessInstance) IsAllTasksFinished() bool
- func (p *ProcessInstance) Reject(now time.Time)
- func (p *ProcessInstance) Withdraw(now time.Time)
- type ProcessSurrogate
- type ProcessTask
- func (t *ProcessTask) Abandon(now time.Time)
- func (t *ProcessTask) Finish(operator string, vars map[string]interface{}, now time.Time)
- func (t *ProcessTask) IsAllowed(operator string) bool
- func (t *ProcessTask) IsDoing() bool
- func (t *ProcessTask) IsFinished() bool
- func (t *ProcessTask) Withdraw(now time.Time)
- type SubmitType
- type TaskRow
- type TaskState
- type TaskStatsRow
- type TaskType
- type UserInfo
Constants ¶
const ( TypeStart = "snaker:start" TypeEnd = "snaker:end" TypeTask = "snaker:task" TypeDecision = "snaker:decision" TypeFork = "snaker:fork" TypeJoin = "snaker:join" TypeCustom = "snaker:custom" )
const BusinessNoKey = "BUSINESS_NO"
业务号变量 key(engine 包 KeyBusinessNo 同值)
const IsFirstTaskNodeKey = "isFirstTaskNode"
IsFirstTaskNodeKey 行变量「本行节点是否 start 直接后继」的键(engine 包 KeyIsFirstTaskNode 同值, 对齐 Java FlowConst.IS_FIRST_TASK_NODE / issues/121 P1)——建单时落库,门面出口行上值优先读它
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CcInstanceRow ¶ added in v1.3.0
type CcInstanceRow struct {
ID int64
ParentID *int64
DefineID int64
State InstanceState
ParentNodeName string
BusinessNo string
Operator string
ExpireTime *time.Time
Variables map[string]interface{}
CreateTime time.Time
CreateUser string
UpdateTime time.Time
UpdateUser string
DefineName string
DefineDisplayName string
DefineVersion int
}
CcInstanceRow 抄送实例行数据(ccList 分页,v1.3.0,对齐 Java InstanceRow 字段)
type CountersignType ¶ added in v1.4.0
type CountersignType int
CountersignType 会签类型(wf_countersign_type)
const ( CountersignTypeParallel CountersignType = 0 CountersignTypeSequential CountersignType = 1 )
type DefineRow ¶ added in v1.5.0
type DefineRow struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
Type string `json:"type"`
State int `json:"state"`
Version int `json:"version"`
CreateTime time.Time `json:"createTime"`
CreateUser string `json:"createUser"`
UpdateTime time.Time `json:"updateTime"`
UpdateUser string `json:"updateUser"`
}
DefineRow 流程定义行数据(pageDefines 分页)
type DefineState ¶ added in v1.4.0
type DefineState int
DefineState 流程定义状态(wf_process_define_state)
const ( DefineStateDisable DefineState = 0 DefineStateEnable DefineState = 1 )
type InstanceRow ¶ added in v1.5.0
type InstanceRow struct {
ID int64 `json:"id"`
ParentID *int64 `json:"parentId"`
DefineID int64 `json:"processDefineId"`
State InstanceState `json:"state"`
ParentNodeName string `json:"parentNodeName"`
BusinessNo string `json:"businessNo"`
Operator string `json:"operator"`
ExpireTime *time.Time `json:"expireTime"`
Variables map[string]interface{} `json:"variables"`
CreateTime time.Time `json:"createTime"`
CreateUser string `json:"createUser"`
UpdateTime time.Time `json:"updateTime"`
UpdateUser string `json:"updateUser"`
DefineName string `json:"defineName"`
DefineDisplayName string `json:"defineDisplayName"`
DefineVersion int `json:"defineVersion"`
}
InstanceRow 流程实例行数据(pageInstances 分页)
type InstanceState ¶
type InstanceState int
const ( InstanceStateDoing InstanceState = 10 InstanceStateDone InstanceState = 20 InstanceStateWithdraw InstanceState = 30 InstanceStateInterrupt InstanceState = 40 InstanceStateReject InstanceState = 45 InstanceStatePending InstanceState = 50 InstanceStateAbandon InstanceState = 99 )
type InstanceStatsRow ¶ added in v1.8.25
type InstanceStatsRow struct {
ID int64
State int
CreateTime time.Time
DefineID int64
Operator string
}
InstanceStatsRow 实例统计行(轻量级,不加载关联任务)
type PerformType ¶ added in v1.4.0
type PerformType int
PerformType 任务参与方式(wf_process_task_perform_type)
const ( PerformTypeNormal PerformType = 0 PerformTypeCountersign PerformType = 1 )
type ProcessDefine ¶
type ProcessDesign ¶ added in v1.1.0
type ProcessDesign struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
Type string `json:"type"`
Icon string `json:"icon"`
IsDeployed int `json:"isDeployed"`
Remark string `json:"remark"`
CreateTime time.Time `json:"createTime"`
CreateUser string `json:"createUser"`
UpdateTime time.Time `json:"updateTime"`
UpdateUser string `json:"updateUser"`
}
ProcessDesign 流程设计(wf_process_design)——设计器保存的设计稿元信息
type ProcessDesignHis ¶ added in v1.1.0
type ProcessDesignHis struct {
ID int64 `json:"id"`
ProcessDesignID int64 `json:"processDesignId"`
Content []byte `json:"content"`
CreateTime time.Time `json:"createTime"`
CreateUser string `json:"createUser"`
}
ProcessDesignHis 流程设计历史(wf_process_design_his)——每次保存的 content 快照
type ProcessInstance ¶
type ProcessInstance struct {
ID int64
ParentID *int64
DefineID int64
State InstanceState
ParentNodeName string
BusinessNo string
Operator string
ExpireTime *time.Time
Variables map[string]interface{}
Tasks []*ProcessTask
CreateTime time.Time
CreateUser string
UpdateTime time.Time
UpdateUser string
}
func NewProcessInstance ¶
func NewProcessInstance(id, defineID int64, operator string, vars map[string]interface{}, now time.Time) *ProcessInstance
NewProcessInstance 工厂方法——创建流程实例
func (*ProcessInstance) AbandonAllDoing ¶
func (p *ProcessInstance) AbandonAllDoing(now time.Time) []*ProcessTask
AbandonAllDoing 废弃所有进行中任务,返回被废弃的任务列表(供调用方持久化)
func (*ProcessInstance) AbandonTask ¶
func (p *ProcessInstance) AbandonTask(task *ProcessTask, now time.Time)
AbandonTask 废弃单个任务
func (*ProcessInstance) AddVariable ¶
func (p *ProcessInstance) AddVariable(vars map[string]interface{})
AddVariable 追加变量
func (*ProcessInstance) CompleteTask ¶
func (p *ProcessInstance) CompleteTask(task *ProcessTask, operator string, vars map[string]interface{}, now time.Time)
CompleteTask 完成任务(子实体状态转换 + 实例变量合并)
func (*ProcessInstance) CreateTask ¶
func (p *ProcessInstance) CreateTask(id int64, taskName, displayName, actor, operator, formKey string, now time.Time, parentTaskID int64, isFirstTaskNode bool, performType ...int) *ProcessTask
CreateTask 创建任务(子实体工厂,引擎唯一建单入口)——performType:0 普通 / 1 会签(issues/52 E24 落库对齐 Java)
建单不变量(规范「引擎操作 04 · 退回上一步」/ issues/121 P1,对齐 Java ProcessTask.create): 所有建任务路径(普通 / 会签 / 串行会签下一位 / 回退建新)都过本工厂,两条不变量在此强制兑现,漏不掉: ① 必写 ParentTaskID——值=产生这条任务的那个"刚办结的任务"id(execution 上下文携带的当前任务 id);
发起流程那条 execution 没有当前任务 ⇒ 调用方传 0,落库 0(不是 NULL,与规范 01 那列注释口径一致)。
② 必写行变量 IsFirstTaskNodeKey(bool)——该行节点是否为 start 直接后继。判据由调用方用**现成**的
EngineImpl.isFirstTaskNode(对齐 Java FlowUtil.isFirstTaskName)算好传入,本层不另造拓扑遍历。 落库理由:门面出口「行上值优先、缺键才回退现算」的回退版带 doing 判定 ⇒ 已办结历史行恒 false, 而血缘版回退要读那条历史行决定参与者,故标记必须随行存活(issues/121 §4)。
func (*ProcessInstance) GetDoingTasks ¶
func (p *ProcessInstance) GetDoingTasks() []*ProcessTask
GetDoingTasks 获取进行中任务
func (*ProcessInstance) GetDoneTasks ¶
func (p *ProcessInstance) GetDoneTasks() []*ProcessTask
GetDoneTasks 获取已完成任务
func (*ProcessInstance) IsAllTasksFinished ¶
func (p *ProcessInstance) IsAllTasksFinished() bool
IsAllTasksFinished 所有任务是否都已完成(用于 join 合并判断)
func (*ProcessInstance) Withdraw ¶ added in v1.8.11
func (p *ProcessInstance) Withdraw(now time.Time)
Withdraw 撤回流程(issues/53 E25:withdraw 用 Withdraw(30),与 reject 区分)
type ProcessSurrogate ¶ added in v1.1.0
type ProcessSurrogate struct {
ID int64 `json:"id"`
ProcessName string `json:"processName"`
Operator string `json:"operator"`
Surrogate string `json:"surrogate"`
StartTime *time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime"`
Enabled int `json:"enabled"`
CreateTime time.Time `json:"createTime"`
CreateUser string `json:"createUser"`
UpdateTime time.Time `json:"updateTime"`
UpdateUser string `json:"updateUser"`
}
ProcessSurrogate 流程委托代理(wf_process_surrogate)——授权人把待办委托给代理人
生效规则见 ProcessSurrogate.IsEffective:enabled 严格等于 1、时间窗覆盖判定时刻 (起止为空 = 该侧不限)、自委托(surrogate = operator)不生效;ProcessName 为空 = 全部流程。 多条并存时由仓储按主键 id **取最新一条再交本方法裁决**(规范 06 §4.5 条款 1.4; 不得"先滤生效再取最新",见 issues/123)。
func (*ProcessSurrogate) IsEffective ¶ added in v1.8.29
func (s *ProcessSurrogate) IsEffective(operator string, at time.Time) bool
IsEffective 四判据(规范 06 §4.5 条款 5 + issues/123 §1):本条委托此刻对该授权人是否生效。
调用方必须先按 id 选出「该授权人在该流程作用域内的最新一条」再问本方法——本方法只裁决 单条,不做多条择优。SQL 仓与内存仓必须走同一份判据(08-compliance 用例 27 要求双仓同答案)。
operator 为授权人(判自委托:被委托人等于授权人 ⇒ 不新增、不重复); at 为零值表示不做窗口比较(对齐各栈"调用方没给时刻就整窗不限"的入参语义, 引擎建单路径恒有值)。
enabled 只认严格等于 1:0 / 2 / 负数 / 库里 NULL(扫描时已折成 0)一律不生效。
type ProcessTask ¶
type ProcessTask struct {
ID int64
ProcessInstanceID int64
TaskName string
DisplayName string
TaskType int
PerformType int
TaskState TaskState
ActorID string
ActorIDs []string
FinishTime *time.Time
ExpireTime *time.Time
FormKey string
ParentTaskID *int64
Variables map[string]interface{}
CreateTime time.Time
CreateUser string
UpdateTime time.Time
UpdateUser string
}
func (*ProcessTask) Finish ¶
func (t *ProcessTask) Finish(operator string, vars map[string]interface{}, now time.Time)
Finish 完成任务
func (*ProcessTask) IsAllowed ¶
func (t *ProcessTask) IsAllowed(operator string) bool
IsAllowed 操作人是否有权限处理该任务
func (*ProcessTask) Withdraw ¶ added in v1.8.28
func (t *ProcessTask) Withdraw(now time.Time)
Withdraw 随实例撤回任务(区别于 Abandon:撤回是发起人主动收回,废弃是引擎清理)
type SubmitType ¶ added in v1.4.0
type SubmitType int
SubmitType 流程提交类型(wf_process_submit_type)
7=转办留痕(issues/115):processTask/transfer 写审批记录用,不走 execute。
const ( SubmitTypeApply SubmitType = 0 SubmitTypeAgree SubmitType = 1 SubmitTypeReject SubmitType = 2 SubmitTypeRollback SubmitType = 3 SubmitTypeJump SubmitType = 4 SubmitTypeReApply SubmitType = 5 SubmitTypeRollbackToOperator SubmitType = 6 SubmitTypeTransfer SubmitType = 7 SubmitTypeCountersignDisagree SubmitType = 20 )
type TaskRow ¶ added in v1.5.0
type TaskRow struct {
ID int64 `json:"id"`
ProcessInstanceID int64 `json:"processInstanceId"`
TaskName string `json:"taskName"`
DisplayName string `json:"displayName"`
TaskType int `json:"taskType"`
PerformType int `json:"performType"`
TaskState TaskState `json:"taskState"`
Operator string `json:"operator"`
FinishTime *time.Time `json:"finishTime"`
ExpireTime *time.Time `json:"expireTime"`
FormKey string `json:"formKey"`
TaskParentID *int64 `json:"taskParentId"`
Variables map[string]interface{} `json:"variables"`
CreateTime time.Time `json:"createTime"`
CreateUser string `json:"createUser"`
UpdateTime time.Time `json:"updateTime"`
UpdateUser string `json:"updateUser"`
ProcessDefineName string `json:"processDefineName"`
ProcessDefineDisplayName string `json:"processDefineDisplayName"`
DefineVersion int `json:"defineVersion"`
InstanceVariable string `json:"instanceVariable"`
InstanceCreateTime time.Time `json:"instanceCreateTime"`
}
TaskRow 任务行数据(pageTodoTasks / pageDoneTasks 分页)
type TaskStatsRow ¶ added in v1.8.25
type TaskStatsRow struct {
ID int64
ProcessInstanceID int64
TaskState int
PerformType int
Operator string
DisplayName string
CreateTime *time.Time
FinishTime *time.Time
ExpireTime *time.Time
}
TaskStatsRow 任务统计行