wf_process.go 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. 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. WorkflowProcessID: w.WorkflowProcessID,
  28. WorkflowNodeID: w.WorkflowNodeID,
  29. BusinessID: w.BusinessID,
  30. Action: w.Action,
  31. IsActive: true,
  32. }
  33. }
  34. func (w WorkflowBase) GetBusinessType() (businessType string) {
  35. return w.BusinessType
  36. }
  37. func (w WorkflowBase) GetWorkflowBase() (workflowBase WorkflowBase) {
  38. return w
  39. }
  40. func (w WorkflowBase) GetTableName() string {
  41. return WorkflowBusinessTable[w.BusinessType]
  42. }
  43. //定义clazz常量
  44. const (
  45. USER_TASK string = "userTask"
  46. SCRIPT_TASK string = "scriptTask"
  47. RECEIVE_TASK string = "receiveTask"
  48. MAIL_TASK string = "mailTask"
  49. TIMER_START string = "timerStart"
  50. MESSAGE_START string = "messageStart"
  51. GATEWAY string = "gateway"
  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. WorkflowNodeID string `json:"workflowNodeID" gorm:"comment:工作流节点ID"`
  61. BusinessType string `json:"businessType" gorm:"comment:业务标记"`
  62. BusinessID uint `json:"businessID" gorm:"comment:业务ID"`
  63. PromoterID uint `json:"promoterID" gorm:"comment:当前流转发起人"`
  64. Action string `json:"action" gorm:"comment:工作流驱动事件"`
  65. Param string `json:"param" gorm:"comment:工作流驱动参数"`
  66. IsActive bool `json:"isActive" gorm:"comment:是否是活跃节点 "`
  67. }
  68. type WorkflowProcess struct {
  69. ID string `json:"id" form:"id" gorm:"comment:流程标识;primaryKey;unique;not null"`
  70. CreatedAt time.Time
  71. UpdatedAt time.Time
  72. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  73. Name string `json:"name" gorm:"comment:流程名称"`
  74. Category string `json:"category" gorm:"comment:分类"`
  75. Clazz string `json:"clazz" gorm:"comment:类型"`
  76. Label string `json:"label" gorm:"comment:流程标题"`
  77. HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
  78. Description string `json:"description" gorm:"comment:详细介绍"`
  79. View string `json:"view" gorm:"comment:前端视图文件"`
  80. Nodes []WorkflowNode `json:"nodes"` // 流程节点数据
  81. Edges []WorkflowEdge `json:"edges"` // 流程链接数据
  82. }
  83. type WorkflowNode struct {
  84. ID string `json:"id" form:"id" gorm:"comment:节点id;primaryKey;unique;not null"`
  85. CreatedAt time.Time
  86. UpdatedAt time.Time
  87. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  88. WorkflowProcessID string `json:"workflowProcessID" gorm:"comment:流程标识"`
  89. Clazz string `json:"clazz" gorm:"comment:节点类型"`
  90. Label string `json:"label" gorm:"comment:节点名称"`
  91. Type string `json:"type" gorm:"comment:图标类型"`
  92. Shape string `json:"shape" gorm:"comment:形状"`
  93. Description string `json:"description" gorm:"comment:详细介绍"`
  94. View string `json:"view" gorm:"comment:前端视图文件"`
  95. X float64 `json:"y" gorm:"comment:x位置"`
  96. Y float64 `json:"x" gorm:"comment:y位置"`
  97. WaitState string `json:"waitState" gorm:"comment:等待属性"`
  98. StateValue string `json:"stateValue" gorm:"comment:等待值"`
  99. To string `json:"to" gorm:"comment:收件人"`
  100. Subject string `json:"subject" gorm:"comment:标题"`
  101. Content string `json:"content" gorm:"comment:内容"`
  102. Cycle string `json:"cycle" gorm:"comment:循环时间"`
  103. Duration string `json:"duration" gorm:"comment:持续时间"`
  104. HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
  105. DueDate time.Time `json:"dueDate" gorm:"comment:到期时间"`
  106. AssignType string `json:"assignType" gorm:"comment:审批类型"`
  107. AssignValue string `json:"assignValue" gorm:"comment:审批类型值"`
  108. Success bool `json:"success" gorm:"comment:是否成功"`
  109. }
  110. type WorkflowEdge struct {
  111. ID string `json:"id" form:"id" gorm:"comment:唯一标识;primaryKey;unique;not null"`
  112. CreatedAt time.Time
  113. UpdatedAt time.Time
  114. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  115. WorkflowProcessID string `json:"-" gorm:"comment:流程标识"`
  116. Clazz string `json:"clazz" gorm:"comment:类型(线)"`
  117. Source string `json:"source" gorm:"comment:起点节点"`
  118. Target string `json:"target" gorm:"comment:目标节点"`
  119. SourceAnchor int `json:"sourceAnchor" gorm:"comment:起点"`
  120. TargetAnchor int `json:"targetAnchor" gorm:"comment:目标点"`
  121. Description string `json:"description" gorm:"comment:详细介绍"`
  122. Shape string `json:"shape" gorm:"comment:形状"`
  123. StartPoint WorkflowStartPoint `json:"startPoint"` // 起点信息
  124. EndPoint WorkflowEndPoint `json:"endPoint"` // 终点信息
  125. Label string `json:"label" gorm:"comment:标题"`
  126. HideIcon bool `json:"hideIcon" gorm:"comment:隐藏图标"`
  127. ConditionExpression string `json:"conditionExpression" gorm:"comment:条件标识"`
  128. Seq string `json:"seq" gorm:"comment:序号"`
  129. Reverse bool `json:"reverse" gorm:"comment:是否反向"`
  130. }
  131. type WorkflowStartPoint struct {
  132. WorkflowEdgeID string
  133. WorkflowPoint
  134. }
  135. type WorkflowEndPoint struct {
  136. WorkflowEdgeID string
  137. WorkflowPoint
  138. }
  139. //
  140. type WorkflowPoint struct {
  141. global.GVA_MODEL
  142. X float64 `json:"x"`
  143. Y float64 `json:"y"`
  144. Index int `json:"index"`
  145. }