You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
8.0 KiB

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