wf_process.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. package model
  2. import (
  3. "gin-vue-admin/global"
  4. "gorm.io/gorm"
  5. "time"
  6. )
  7. var WorkflowBusinessStruct map[string]func() GVA_Workflow
  8. var WorkflowBusinessTable map[string]func() interface{}
  9. type GVA_Workflow interface {
  10. CreateWorkflowMove() *WorkflowMove
  11. GetBusinessType() string
  12. GetWorkflowBase() WorkflowBase
  13. }
  14. type WorkflowBase struct {
  15. BusinessID uint `gorm:"<-:false;column:id"` // 业务对应ID(businessID)的返回
  16. BusinessType string `json:"businessType" gorm:"-"`
  17. PromoterID uint `json:"promoterID" gorm:"-"`
  18. OperatorID uint `json:"operatorID" gorm:"-"`
  19. WorkflowProcessID string `json:"workflowProcessID" gorm:"-"`
  20. WorkflowNodeID string `json:"workflowNodeID" gorm:"-"`
  21. Action string `json:"action" gorm:"-"`
  22. }
  23. func (w WorkflowBase) CreateWorkflowMove() (businessModel *WorkflowMove) {
  24. return &WorkflowMove{
  25. BusinessType: w.BusinessType,
  26. PromoterID: w.PromoterID,
  27. OperatorID: w.OperatorID,
  28. WorkflowProcessID: w.WorkflowProcessID,
  29. WorkflowNodeID: w.WorkflowNodeID,
  30. BusinessID: w.BusinessID,
  31. Action: w.Action,
  32. IsActive: true,
  33. }
  34. }
  35. func (w WorkflowBase) GetBusinessType() (businessType string) {
  36. return w.BusinessType
  37. }
  38. func (w WorkflowBase) GetWorkflowBase() (workflowBase WorkflowBase) {
  39. return w
  40. }
  41. //定义clazz常量
  42. const (
  43. USER_TASK string = "userTask"
  44. SCRIPT_TASK string = "scriptTask"
  45. RECEIVE_TASK string = "receiveTask"
  46. MAIL_TASK string = "mailTask"
  47. TIMER_START string = "timerStart"
  48. MESSAGE_START string = "messageStart"
  49. EXCLUSIVE_GATEWAY string = "exclusiveGateway" // 排他网关
  50. INCLUSIVE_GATEWAY string = "inclusiveGateway" // 包容网关
  51. PARELLEL_GATEWAY string = "parallelGateway" // 并行网关
  52. FLOW string = "flow"
  53. START string = "start"
  54. END string = "end"
  55. PROCESS string = "process"
  56. )
  57. type WorkflowMove struct {
  58. global.GVA_MODEL
  59. WorkflowProcessID string `json:"workflowProcessID" gorm:"comment:工作流模板ID"`
  60. WorkflowProcess WorkflowProcess `gorm:"<-:false" json:"workflowProcess" gorm:"comment:工作流模板具体信息"`
  61. WorkflowNodeID string `json:"workflowNodeID" gorm:"comment:工作流节点ID"`
  62. WorkflowNode WorkflowNode `gorm:"<-:false" json:"workflowNode" gorm:"comment:工作流节点具体信息"`
  63. BusinessType string `json:"businessType" gorm:"comment:业务标记"`
  64. BusinessID uint `json:"businessID" gorm:"comment:业务ID"`
  65. PromoterID uint `json:"promoterID" gorm:"comment:当前流转发起人"`
  66. Promoter SysUser `gorm:"<-:false" json:"promoter" gorm:"comment:当前流转发起人信息"`
  67. OperatorID uint `json:"operatorID" gorm:"comment:当前流转操作人"`
  68. Operator SysUser `gorm:"<-:false" json:"operator" gorm:"comment:当前流转操作人信息"`
  69. Action string `json:"action" gorm:"comment:工作流驱动事件"`
  70. Param string `json:"param" gorm:"comment:工作流驱动参数"`
  71. IsActive bool `json:"isActive" gorm:"comment:是否是活跃节点 "`
  72. }
  73. type WorkflowProcess struct {
  74. ID string `json:"id" form:"id" gorm:"comment:流程标识;primaryKey;unique;not null"`
  75. CreatedAt time.Time
  76. UpdatedAt time.Time
  77. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  78. Name string `json:"name" gorm:"comment:流程名称"`
  79. Category string `json:"category" gorm:"comment:分类"`
  80. Clazz string `json:"clazz" gorm:"comment:类型"`
  81. Label string `json:"label" gorm:"comment:流程标题"`
  82. HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
  83. Description string `json:"description" gorm:"comment:详细介绍"`
  84. View string `json:"view" gorm:"comment:前端视图文件"`
  85. Nodes []WorkflowNode `json:"nodes"` // 流程节点数据
  86. Edges []WorkflowEdge `json:"edges"` // 流程链接数据
  87. }
  88. type WorkflowNode struct {
  89. ID string `json:"id" form:"id" gorm:"comment:节点id;primaryKey;unique;not null"`
  90. CreatedAt time.Time
  91. UpdatedAt time.Time
  92. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  93. WorkflowProcessID string `json:"workflowProcessID" gorm:"comment:流程标识"`
  94. Clazz string `json:"clazz" gorm:"comment:节点类型"`
  95. Label string `json:"label" gorm:"comment:节点名称"`
  96. Type string `json:"type" gorm:"comment:图标类型"`
  97. Shape string `json:"shape" gorm:"comment:形状"`
  98. Description string `json:"description" gorm:"comment:详细介绍"`
  99. View string `json:"view" gorm:"comment:前端视图文件"`
  100. X float64 `json:"y" gorm:"comment:x位置"`
  101. Y float64 `json:"x" gorm:"comment:y位置"`
  102. WaitState string `json:"waitState" gorm:"comment:等待属性"`
  103. StateValue string `json:"stateValue" gorm:"comment:等待值"`
  104. To string `json:"to" gorm:"comment:收件人"`
  105. Subject string `json:"subject" gorm:"comment:标题"`
  106. Content string `json:"content" gorm:"comment:内容"`
  107. Cycle string `json:"cycle" gorm:"comment:循环时间"`
  108. Duration string `json:"duration" gorm:"comment:持续时间"`
  109. HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
  110. DueDate time.Time `json:"dueDate" gorm:"comment:到期时间"`
  111. AssignType string `json:"assignType" gorm:"comment:审批类型"`
  112. AssignValue string `json:"assignValue" gorm:"comment:审批类型值"`
  113. Success bool `json:"success" gorm:"comment:是否成功"`
  114. }
  115. type WorkflowEdge struct {
  116. ID string `json:"id" form:"id" gorm:"comment:唯一标识;primaryKey;unique;not null"`
  117. CreatedAt time.Time
  118. UpdatedAt time.Time
  119. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  120. WorkflowProcessID string `json:"-" gorm:"comment:流程标识"`
  121. Clazz string `json:"clazz" gorm:"comment:类型(线)"`
  122. Source string `json:"source" gorm:"comment:起点节点"`
  123. Target string `json:"target" gorm:"comment:目标节点"`
  124. SourceAnchor int `json:"sourceAnchor" gorm:"comment:起点"`
  125. TargetAnchor int `json:"targetAnchor" gorm:"comment:目标点"`
  126. Description string `json:"description" gorm:"comment:详细介绍"`
  127. Shape string `json:"shape" gorm:"comment:形状"`
  128. StartPoint WorkflowStartPoint `json:"startPoint"` // 起点信息
  129. EndPoint WorkflowEndPoint `json:"endPoint"` // 终点信息
  130. Label string `json:"label" gorm:"comment:标题"`
  131. HideIcon bool `json:"hideIcon" gorm:"comment:隐藏图标"`
  132. ConditionExpression string `json:"conditionExpression" gorm:"comment:条件标识"`
  133. Seq string `json:"seq" gorm:"comment:序号"`
  134. Reverse bool `json:"reverse" gorm:"comment:是否反向"`
  135. }
  136. type WorkflowStartPoint struct {
  137. WorkflowEdgeID string
  138. global.GVA_MODEL
  139. X float64 `json:"x"`
  140. Y float64 `json:"y"`
  141. Index int `json:"index"`
  142. }
  143. type WorkflowEndPoint struct {
  144. WorkflowEdgeID string
  145. global.GVA_MODEL
  146. X float64 `json:"x"`
  147. Y float64 `json:"y"`
  148. Index int `json:"index"`
  149. }