Documentation ¶
Index ¶
- Constants
- type ActivityRunMode
- type ByIndex
- type Case
- type CaseInfo
- type CaseItem
- type CaseList
- type Choice
- type Condition
- type Flow
- type FlowActorType
- type FlowCase
- type FlowCaseList
- type FlowCaseService
- type FlowDefineService
- type FlowInfo
- type FlowList
- type FlowService
- type FlowUser
- type NextStatuInfo
- type OrgService
- type Participant
- type ServiceFactory
- type Status
- type TransitJoinMode
- type TransitOut
- type TransitSplitMode
- type Transition
- type WaitMode
- type WorkItemStatus
- type Workflow
- func (w *Workflow) CreateWorkflow(caseid, flowid, appdata string, user FlowUser) (string, string, error)
- func (w *Workflow) HandNextStep(nid int32, ns *Status, user *FlowUser, appdata string) (*CaseItem, error)
- func (w *Workflow) HandlCurrentStep(choice, mark string, ci *CaseItem, s *Status) error
- func (w *Workflow) JumpToStep(itemid int32, stepname, choice, mark string, user *FlowUser) error
- func (w *Workflow) LoadWorkflow(caseid string, appdata string) error
- func (w *Workflow) PreCreateWorkflow(flowid string, appdata string, userid, username string) (string, error)
- func (w *Workflow) PreRun(itemid int32, choice string) (*NextStatuInfo, error)
- func (w *Workflow) Run(itemid int32, choice, mark string, user *FlowUser) (string, error)
Constants ¶
const ( OpEqual uint32 = iota //等于 OpLess // < OpGreater // > OpLessEq // <= OpGreaterEq // >= OpNotEq // != )
比较符常量
const ( LogicAnd uint32 = iota // and LogicOr // or )
逻辑操作符
const ( StepStatusNew int32 = iota StepStatusRead StepStatusFinish )
流程步骤的状态
const ( ParitciTypeUserid uint32 = iota //指定用户 ParitciTypeRoledept //部门+角色 ParticiTypeDept //部门 ParticiTypeRole //角色 ParticiTypeFree //自由选择 ParticiTypeAnyUserid //通讯录所有人的人 ParticiTypeCreator //流程发起人 ParticiTypeStepUsers //参与过流程的人 )
流程参与人的寻找方案
const ( DeptGetCreator uint32 = iota //流程发起人所在部门 DeptGetStepUser //步骤处理人所在部门 DeptGetDeptid //指定部门 DeptGetStepUserParent //步骤处理人所在部门的父级部门 )
部门定义方案
const ( // StatusStart 发起 StatusStart = "started" // StatusFinished 结束 StatusFinished = "finished" // StatusAbandon 丢弃 StatusAbandon = "abandoned" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivityRunMode ¶
type ActivityRunMode uint32
ActivityRunMode 环节运行模式
const ( //手动 ActivityRunModeManual ActivityRunMode = iota //自动 ActivityRunModeAuto )
环节运行模式枚举
type Case ¶
type Case struct { CaseID string `json:"caseid"` //实例id ItemID int32 `json:"itemid"` //当前实例顺序 AppID string `json:"appid"` BizID1 string `json:"bizid1"` BizID2 string `json:"bizid2"` FlowID string `json:"flowid"` //流程定义id FlowName string `json:"flowname"` //流程名称 CreatorID string `json:"creatorid"` //创建人id CreatorName string `json:"creatorname"` //创建人名字 Step string `json:"stepname"` //当前状态 Status int32 `json:"status"` //状态 0:审批中 1:通过 2:不通过 CreateTime time.Time `json:"createtime"` //创建时间 EndTime time.Time `json:"endtime"` //结束时间 CopyUser []int `json:"copyuser"` //抄送人 AppData string `json:"appdata"` //表单json数据 SendTime string `json:"sendtime"` //发送时间 ChoiceItems string `json:"choiceitems"` //审核选项 SerialNumber string `json:"serialnumber"` //流水号 HandleUserid string `json:"handleuserid"` //步骤处理人 HandleUserName string `json:"handleusername"` //处理人名字 HandleTime string `json:"handletime"` //处理时间 StepStatus int32 `json:"stepstatus"` //处理状态 0未读1已读2已处理 PluginID string `json:"pluginid"` VersionNo int32 `json:"versionno"` }
Case 流程实例对象
type CaseInfo ¶
type CaseInfo struct { CaseID string `json:"caseid"` //流程实例id ItemID int32 `json:"itemid"` //流程当前步骤id FlowID string `json:"flowid"` //流程id Name string `json:"flowname"` //流程名称 Creator string `json:"creator"` //流程发起人账号 Creatorname string `json:"creatorname"` //流程发起人姓名 Createtime time.Time `json:"createtime"` //流程发起时间 Handleuserid string `json:"handleuserid"` //步骤原处理人(有代理人) Handleusername string `json:"handleusername"` //步骤原处理人姓名 Handletime string `json:"handletime"` //处理时间 ChoiceItems string `json:"choiceitems"` //审核选项 Stepname string `json:"stepname"` //当前步骤名称 Stepstatus int32 `json:"stepstatus"` //当前步骤的状态,0:未处理 1:已读 2:已处理 Status int32 `json:"status"` //状态,0:审批中 1:通过 2:不通过 Appid string `json:"appid"` //流程关联的业务对象(记录在crm_t_entityreg) Bizid1 string `json:"bizid1"` //业务主键1 Bizid2 string `json:"bizid2"` //业务主键2 SendTime string `json:"sendtime"` //发送时间 SerialNumber string `json:"serialnumber"` //流水号 Choice string `json:"choice"` //审核 FlowStatus int32 `json:"flowstatus"` //流程状态 1启用0停用 }
CaseInfo DTO对象,流程事务
type CaseItem ¶
type CaseItem struct { ItemID int32 `json:"itemid"` //步骤id HandleUserid string `json:"handleuserid"` //步骤处理人 HandleUserName string `json:"handleusername"` //处理人名字 StepName string `json:"stepname"` //这个步骤的状态名字 Choice string `json:"choice"` //用户的选择结果 Mark string `json:"mark"` //处理人的备注 CreateTime time.Time `json:"createtime"` //发起时间 HandleTime string `json:"handletime"` //处理时间 AgentUserid string `json:"agentuserid"` //代理人id AgentUserName string `json:"agentusername"` //代理人名字 StepStatus int32 `json:"stepstatus"` //流程步骤的状态 SysEnterInfo string `json:"sysenterinfo"` //进入步骤,系统信息记录 SysExitInfo string `json:"sysexitinfo"` //离开步骤,系统信息记录 ChoiceItems string `json:"choiceitems"` //审核选项 }
CaseItem 流程实例的步骤数据
func NewCaseItem ¶
NewCaseItem 新创建步骤流转信息
type Choice ¶
type Choice struct { Index int //选项的序号 Name string //选择项的值 Trans *Transition //选项对应的状态变化 }
Choice 流程步骤的选择项, 如: 同意 / 不同意
type Condition ¶
type Condition struct { GetNot bool //是否取反 Operator uint32 //比较操作符 DataKey string //业务数据取值属性 Value string //比较目标值 Logic uint32 //逻辑操作符 }
Condition 条件
func NewCondition ¶
NewCondition 根据xml描述创建一个新的节点
type FlowActorType ¶
type FlowActorType uint32
FlowActorType 流程参与者类型
const ( //创建人 FlowActorTypeCreator FlowActorType = iota //代理人 FlowActorTypeAgent //当前用户 FlowActorTypeCurrentUser )
流程参与者类型枚举
type FlowCase ¶
type FlowCase struct { CaseInfo *Case //`json:"case"` //流程实例信息 CaseItems map[int32]*CaseItem //`json:"caseitems"` //流程的步骤记录 }
FlowCase 流程实例的数据
func NewStartFlowCase ¶
func NewStartFlowCase(creatorid, creatorname, caseid, flowid, step string, versionno int32) *FlowCase
NewStartFlowCase 新启动一个流程实例
type FlowCaseList ¶
type FlowCaseList struct { CaseInfo *Case //`json:"case"` //流程实例信息 CaseItems []*CaseItem //`json:"caseitems"` //流程的步骤记录 }
FlowCaseList 流程实例信息
type FlowCaseService ¶
type FlowCaseService interface { // LoadFlowCase 加载一个流程的完整信息 LoadFlowCase(caseid string) (fc *FlowCase, err error) // SaveNewCase 保存一个新的流程实例 SaveNewCase(fc *FlowCase, versionno int32) (string, error) // ComitFlow 在一个事务中提交流程数据,case,当前item,下一步item ComitFlow(c *Case, ci *CaseItem, ni *CaseItem) error // FindAgent 找到步骤处理人的代理人 FindAgent(userid string) (user *FlowUser, find bool) // StepHandled 记录步骤进入,退出的消息 StepHandled(ca *Case, ci *CaseItem, ni *CaseItem) error // WriteBackSendTime 更新发送时间?? WriteBackSendTime(caseinfo *CaseInfo) error }
FlowCaseService 流程实例服务
type FlowDefineService ¶
type FlowDefineService interface { //保存一个新的流程定义 AddFlow(flow *FlowInfo, appid string) error //删除一个流程定义 DeleteFlow(flowid string) error //修改一个流程定义 UpdateFlow(flow *FlowInfo) error //启用流程 EnableFlow(flow *FlowInfo) error //停用流程 DisableFlow(flow *FlowInfo) error // GetFlow 获得流程的定义(最新版本)属性:flowid, name, descript, flowxml GetFlow(flowid string) (flow *Flow, err error) // GetFlowByVersionNo 获取特定版本的流程定义 GetFlowByVersionNo(flowid string, versionno int32) (flow *Flow, err error) }
FlowDefineService 流程定义服务接口
type FlowInfo ¶
type FlowInfo struct { FlowID string `json:"flowid"` Name string `json:"flowname"` Descript string `json:"descript"` FlowXML string `json:"flowxml"` StepCount int32 `json:"stepcount"` CreateTime time.Time `json:"createtime"` Creator string `json:"creator"` Status int32 `json:"status"` UpdateTime string `json:"updatetime"` Updator string `json:"updator"` FlowType int32 `json:"flowtype"` AppID string `json:"appid"` EntityType int32 `json:"entitytype"` //1系统对象2插件对象 FlowCategory int32 `json:"flowcategory"` //1表示固定流程,0表示自由流程 PluginStatus int32 `json:"pluginstatus"` //插件状态 1在用 PVersionStatus int32 `json:"pversionstatus"` //插件版本 PowerControl int32 `json:"powercontrol"` //权限控制 }
FlowInfo 流程的信息
type FlowService ¶
type FlowService interface { // GetTodoCases 获取用户的代办列表---flowname查询条件 GetTodoCases(flowname, usernumber string, pageindex, pagesize int32) (*CaseList, error) // GetMyCases 获取用户事务列表 GetMyCases(usernumber string, finishstate, filter, pageindex, pagesize int32, flowid, keyword, begintime, endtime, createtime, handletime, sorttype string) (*CaseList, error) // GetWorkFlows 获取流程列表, 可按状态, 名称过滤, 分页 GetWorkFlows(status, flowname string, pageindex, pagesize int32) (*FlowList, error) // GetWorkFlowDetail 获取指定流程的详情 GetWorkFlowDetail(flowid string) (*FlowInfo, error) // GetCaseDetail 流程实例详情 GetCaseDetail(caseid string) (*FlowCaseList, error) // AddCase 新发起一个流程, 返回caseid // todo: caseid应该是返回的, 不是传入的, 返回的什么值? AddCase(caseid, flowid, flowname, usernumber, username, biz1, biz2, appid, handeruserid, handerusername string, copyuser []int, appdata, remark string) (string, string, error) // PreAddCase 预新发起一个流程, 返回步骤和人 // todo: 跟下面是同一个方法 PreAddCase(flowid, usernumber, username, appdata string) (*NextStatuInfo, error) // PreCommitCase 预提交, 选择审批选项, 返回下一步去到的步骤和可选审批人 PreCommitCase(caseid, choice string, itemid int32, appdata string) (nsif *NextStatuInfo, err error) // CommitCase 处理待办项, 返回进入的状态名称 CommitCase(enterprise, usernumber, caseid, choice, remark string, itemid int32, flowuser *FlowUser, appdata string) (string, error) //作废流程实列 AbandonCase(enterprise, usernumber, caseid, choice, remark string, itemid int32, appdata string) error //结束流程实列 FinishCase(caseid, choice, remark string, itemid int32, appdata string) error //流程实列, 退回到发起人 SendbackCase(enterprise, usernumber, caseid, choice, remark string, itemid int32, appdata string) error //流程实列, 退回给上一个步骤 FallbackCase(caseid, choice, remark string, itemid int32, appdata string) error //标记流程步骤为已读 Readed(itemid int32, caseid, usernumber string) error //设置代理人 SetAgent(userid, agentid string) error //取消代理人 UnsetAgent(userid string) error //动态获取审批选项 GetDynamicSel(flowid, stepname string) ([]*Choice, error) //??? WBStepStatus(itemid int32, caseid, usernumber string) }
FlowService 流程服务接口
type FlowUser ¶
type FlowUser struct { Userid string `json:"userid,omitempty"` UserName string `json:"username,omitempty"` HeadPhoto string `json:"headphoto,omitempty"` }
FlowUser 用户
type NextStatuInfo ¶
type NextStatuInfo struct { // StepName 步骤名称 StepName string // Users 流程参与人 Users []*FlowUser // IsFree 是否自由流程 IsFree bool // SelectType 如何选择人员 0表示只能选Users数组内的人 1表示可以选择所有的人 SelectType bool }
NextStatuInfo 流程下一步的信息
type OrgService ¶
type OrgService interface { //根据角色, 部门id找到用户 FindUser(role, departid string) (us []*FlowUser, err error) //找到用户直属部门 FindUserDept(userid string) (deptid string, err error) //找到用户直属部门的父部门 FindUserParentDept(userid string) (deptid string, err error) //根据用户id,获取用户 GetUser(userid string) (us []*FlowUser, err error) //根据部门找到所有用户 FindUserByDept(departid string) (us []*FlowUser, err error) //根据角色找到所有用户 FindUserByRole(role string) (us []*FlowUser, err error) }
OrgService 为流程提供组织架构信息的服务接口
type Participant ¶
type Participant struct { //寻找步骤的处理人,userid: 指定的用户id为处理人,roledept:使用部门+角色寻找 //dept:部门内的人; role: 角色的所有人; free: 自由选人; //creator:流程发起人; stepusers:参与过流程的人; ParticiType uint32 Userid string //指定的用户处理 Role string //指定的角色 Deptid string //特定的部门, DType="deptid"时生效 //如何获取部门, //creator: 流程的创建人所在部门,stepuser: 流程步骤的处理人人所在部门, //deptid: 特定的部门, stepuserparent: 流程步骤的处理人人所在部门的父部门 DeptGetType uint32 }
Participant 流程步骤参与人
func NewParticipant ¶
func NewParticipant(n *xmlx.Node) (*Participant, error)
NewParticipant 根据xml定义,构造流程参与人
func (*Participant) FindUser ¶
func (p *Participant) FindUser(opd OrgService, fcase *FlowCase) ([]*FlowUser, error)
FindUser 使用组织服务,
type ServiceFactory ¶
type ServiceFactory struct { }
ServiceFactory 服务工厂
func (ServiceFactory) NewCaseService ¶
func (sf ServiceFactory) NewCaseService(conn string) (FlowCaseService, error)
NewCaseService 创建组织服务
func (ServiceFactory) NewFlowDefineService ¶
func (sf ServiceFactory) NewFlowDefineService(conn string) (FlowDefineService, error)
NewFlowDefineService 创建流程定义服务
func (ServiceFactory) NewOrgService ¶
func (sf ServiceFactory) NewOrgService(conn string) (OrgService, error)
NewOrgService 创建组织服务
type Status ¶
type Status struct { Name string //状态的名字, 也就是流程的步骤名称StepName Sequence int //状态的默认顺序 Partici *Participant //状态的处理人定义 Choices map[string]*Choice //状态处理时给用户的选择项,如:同意;不同意; }
Status 流程状态, 也就是去到的环节
func (*Status) NextStatus ¶
NextStatus 找到下一步 choice: 选择, 同意/不同意 appdata: 业务表单的数据.
type TransitJoinMode ¶
type TransitJoinMode uint32
TransitJoinMode 迁入模式
const ( //与 TransitJoinModeAND TransitJoinMode = iota //异或 TransitJoinModeXOR )
迁入模式枚举
type TransitOut ¶
type TransitOut uint32
TransitOut 环节迁出规则
const ( //只有一个条件满足,就可以迁出 One TransitOut = iota //所有条件满足,才可以迁出 All )
环节迁出规则枚举
type TransitSplitMode ¶
type TransitSplitMode uint32
TransitSplitMode 迁出模式
const ( //与 TransitSplitModeAND TransitSplitMode = iota //异或 TransitSplitModeXOR )
迁出模式枚举
type Transition ¶
type Transition struct { TrueTo string //如果有condition节点, 条件运算结果为true时去到的目标步骤名称 FalseTo string //如果有condition节点, 条件运算结果为false时去掉的目标步骤名称 Conditions []*Condition //条件集合 }
Transition 迁移, 对应流程图上节点之间的线条
func NewTransition ¶
func NewTransition(n *xmlx.Node) (*Transition, error)
NewTransition 根据xml节点信息创建迁移对象.
func (*Transition) NextStatus ¶
func (t *Transition) NextStatus(appdata string) (nextstep string, err error)
NextStatus 根据appdata和流程节点定义, 计算出下一步的步骤名称 nextstep 返回下一步去到的步骤
type WorkItemStatus ¶
type WorkItemStatus uint32
WorkItemStatus 工作项状态
const ( //已接收 WorkItemStatusReceived WorkItemStatus = iota //已读 WorkItemStatusReaded //已完成 WorkItemStatusFinished )
工作项状态枚举
type Workflow ¶
type Workflow struct { // FlowDef 流程的定义 FlowDef *Flow // Fcase 流程实例信息 Fcase *FlowCase // Appdata 流程节点运算需要的业务数据, 用json格式传递. Appdata string // FlowDefSRV 流程定义管理服务 FlowDefSRV FlowDefineService // OrgSRV 组织架构/人员管理服务 OrgSRV OrgService // FlowCaseSRV 流程实例服务 CaseSRV FlowCaseService }
Workflow 流程引擎对象
func NewWorkflow ¶
New_Workflow 创建一个新的工作流对象. connstr: db连接串, 这个是多租户模式需要, 一个流程服务可以服务于多个租户数据库, 租户按数据库隔离. 如果非多租户模式使用, db连接串写在服务配置文件.
func (*Workflow) CreateWorkflow ¶
func (w *Workflow) CreateWorkflow(caseid, flowid, appdata string, user FlowUser) (string, string, error)
CreateWorkflow 创建一个新的流程实例, 返回caseid
func (*Workflow) HandNextStep ¶
func (w *Workflow) HandNextStep(nid int32, ns *Status, user *FlowUser, appdata string) (*CaseItem, error)
HandNextStep 处理下一步骤的数据
func (*Workflow) HandlCurrentStep ¶
HandlCurrentStep 处理当前步骤的数据
func (*Workflow) JumpToStep ¶
跳转到步骤, 如: 通过, 不通过
func (*Workflow) LoadWorkflow ¶
LoadWorkflow 加载一个已经存在的流程 caseid: 流程实例id appdata: 流程节点运算需要的数据