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.

155 lines
7.4 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. type WorkflowMove struct {
  50. global.GVA_MODEL
  51. WorkflowProcessID string `json:"workflowProcessID" gorm:"comment:工作流模板ID"`
  52. WorkflowProcess WorkflowProcess `gorm:"<-:false" json:"workflowProcess" gorm:"comment:工作流模板具体信息"`
  53. WorkflowNodeID string `json:"workflowNodeID" gorm:"comment:工作流节点ID"`
  54. WorkflowNode WorkflowNode `gorm:"<-:false" json:"workflowNode" gorm:"comment:工作流节点具体信息"`
  55. BusinessType string `json:"businessType" gorm:"comment:业务标记"`
  56. BusinessID uint `json:"businessID" gorm:"comment:业务ID"`
  57. PromoterID uint `json:"promoterID" gorm:"comment:当前流转发起人"`
  58. Promoter SysUser `gorm:"<-:false" json:"promoter" gorm:"comment:当前流转发起人信息"`
  59. OperatorID uint `json:"operatorID" gorm:"comment:当前流转操作人"`
  60. Operator SysUser `gorm:"<-:false" json:"operator" gorm:"comment:当前流转操作人信息"`
  61. Action string `json:"action" gorm:"comment:工作流驱动事件"`
  62. Param string `json:"param" gorm:"comment:工作流驱动参数"`
  63. IsActive bool `json:"isActive" gorm:"comment:是否是活跃节点 "`
  64. }
  65. type WorkflowProcess struct {
  66. ID string `json:"id" form:"id" gorm:"comment:流程标识;primaryKey;unique;not null"`
  67. CreatedAt time.Time
  68. UpdatedAt time.Time
  69. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  70. Name string `json:"name" gorm:"comment:流程名称"`
  71. Category string `json:"category" gorm:"comment:分类"`
  72. Clazz string `json:"clazz" gorm:"comment:类型"`
  73. Label string `json:"label" gorm:"comment:流程标题"`
  74. HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
  75. Description string `json:"description" gorm:"comment:详细介绍"`
  76. View string `json:"view" gorm:"comment:前端视图文件"`
  77. Nodes []WorkflowNode `json:"nodes"` // 流程节点数据
  78. Edges []WorkflowEdge `json:"edges"` // 流程链接数据
  79. }
  80. type WorkflowNode struct {
  81. ID string `json:"id" form:"id" gorm:"comment:节点id;primaryKey;unique;not null"`
  82. CreatedAt time.Time
  83. UpdatedAt time.Time
  84. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  85. WorkflowProcessID string `json:"workflowProcessID" gorm:"comment:流程标识"`
  86. Clazz string `json:"clazz" gorm:"comment:节点类型"`
  87. Label string `json:"label" gorm:"comment:节点名称"`
  88. Type string `json:"type" gorm:"comment:图标类型"`
  89. Shape string `json:"shape" gorm:"comment:形状"`
  90. Description string `json:"description" gorm:"comment:详细介绍"`
  91. View string `json:"view" gorm:"comment:前端视图文件"`
  92. X float64 `json:"y" gorm:"comment:x位置"`
  93. Y float64 `json:"x" gorm:"comment:y位置"`
  94. WaitState string `json:"waitState" gorm:"comment:等待属性"`
  95. StateValue string `json:"stateValue" gorm:"comment:等待值"`
  96. To string `json:"to" gorm:"comment:收件人"`
  97. Subject string `json:"subject" gorm:"comment:标题"`
  98. Content string `json:"content" gorm:"comment:内容"`
  99. Cycle string `json:"cycle" gorm:"comment:循环时间"`
  100. Duration string `json:"duration" gorm:"comment:持续时间"`
  101. HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
  102. DueDate time.Time `json:"dueDate" gorm:"comment:到期时间"`
  103. AssignType string `json:"assignType" gorm:"comment:审批类型"`
  104. AssignValue string `json:"assignValue" gorm:"comment:审批类型值"`
  105. Success bool `json:"success" gorm:"comment:是否成功"`
  106. }
  107. type WorkflowEdge struct {
  108. ID string `json:"id" form:"id" gorm:"comment:唯一标识;primaryKey;unique;not null"`
  109. CreatedAt time.Time
  110. UpdatedAt time.Time
  111. DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
  112. WorkflowProcessID string `json:"-" gorm:"comment:流程标识"`
  113. Clazz string `json:"clazz" gorm:"comment:类型(线)"`
  114. Source string `json:"source" gorm:"comment:起点节点"`
  115. Target string `json:"target" gorm:"comment:目标节点"`
  116. SourceAnchor int `json:"sourceAnchor" gorm:"comment:起点"`
  117. TargetAnchor int `json:"targetAnchor" gorm:"comment:目标点"`
  118. Description string `json:"description" gorm:"comment:详细介绍"`
  119. Shape string `json:"shape" gorm:"comment:形状"`
  120. StartPoint WorkflowStartPoint `json:"startPoint"` // 起点信息
  121. EndPoint WorkflowEndPoint `json:"endPoint"` // 终点信息
  122. Label string `json:"label" gorm:"comment:标题"`
  123. HideIcon bool `json:"hideIcon" gorm:"comment:隐藏图标"`
  124. ConditionExpression string `json:"conditionExpression" gorm:"comment:条件标识"`
  125. Seq string `json:"seq" gorm:"comment:序号"`
  126. Reverse bool `json:"reverse" gorm:"comment:是否反向"`
  127. }
  128. type WorkflowStartPoint struct {
  129. WorkflowEdgeID string
  130. global.GVA_MODEL
  131. X float64 `json:"x"`
  132. Y float64 `json:"y"`
  133. Index int `json:"index"`
  134. }
  135. type WorkflowEndPoint struct {
  136. WorkflowEdgeID string
  137. global.GVA_MODEL
  138. X float64 `json:"x"`
  139. Y float64 `json:"y"`
  140. Index int `json:"index"`
  141. }