wf_process.go 7.7 KB

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