task.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package model
  2. import (
  3. libtime "go-common/library/time"
  4. )
  5. //..
  6. const (
  7. //初始状态
  8. TaskStateInit = int8(0)
  9. //已派发
  10. TaskStateDispatch = int8(1)
  11. //延迟
  12. TaskStateDelay = int8(2)
  13. //任务提交
  14. TaskStateSubmit = int8(3)
  15. //资源列表提交
  16. TaskStateRscSb = int8(4)
  17. //任务关闭
  18. TaskStateClosed = int8(5)
  19. // ActionCreate 生成任务
  20. ActionCreate = uint8(0)
  21. // ActionSeize 抢占任务
  22. ActionSeize = uint8(1)
  23. // ActionRelease 释放任务
  24. ActionRelease = uint8(2)
  25. // ActionDelay 延迟任务
  26. ActionDelay = uint8(3)
  27. // ActionSubmit 提交任务
  28. ActionSubmit = uint8(4)
  29. // ActionUnknow 其他变更
  30. ActionUnknow = uint8(5)
  31. LogBusinessTask = int(232)
  32. LogTypeTaskDispatch = int(1)
  33. LogTypeTaskConsumer = int(2)
  34. LogTYpeTaskWeight = int(3)
  35. // WeightTypeCycle 周期权重
  36. WeightTypeCycle = int8(0)
  37. // WeightTypeConst 定值权重
  38. WeightTypeConst = int8(1)
  39. )
  40. const (
  41. // ConfigStateOn .
  42. ConfigStateOn = int8(0)
  43. // ConfigStateOff .
  44. ConfigStateOff = int8(1)
  45. // ConsumerStateOn on
  46. ConsumerStateOn = int8(1)
  47. // ConsumerStateOff off
  48. ConsumerStateOff = int8(0)
  49. // ActionConsumerOff .
  50. ActionConsumerOff = int8(0)
  51. // ActionConsumerOn .
  52. ActionConsumerOn = int8(1)
  53. // TaskConfigAssign 指派
  54. TaskConfigAssign = int8(1)
  55. // TaskConfigRangeWeight 权重
  56. TaskConfigRangeWeight = int8(2)
  57. // TaskConfigEqualWeight 权重
  58. TaskConfigEqualWeight = int8(3)
  59. // TaskRoleMember 组员
  60. TaskRoleMember = int8(1)
  61. // TaskRoleLeader 组长
  62. TaskRoleLeader = int8(2)
  63. )
  64. // WeightItem 权重值
  65. type WeightItem struct {
  66. ID int64
  67. Weight int64
  68. }
  69. // Task ..
  70. type Task struct {
  71. ID int64 `form:"id" json:"id" gorm:"AUTO_INCREMENT;primary_key;"`
  72. BusinessID int64 `form:"business_id" json:"business_id" gorm:"column:business_id"`
  73. FlowID int64 `form:"flow_id" json:"flow_id" gorm:"column:flow_id"`
  74. RID int64 `form:"rid" json:"rid" gorm:"column:rid"`
  75. AdminID int64 `form:"admin_id" json:"admin_id" gorm:"column:admin_id"`
  76. UID int64 `form:"uid" json:"uid" gorm:"column:uid"`
  77. State int8 `form:"state" json:"state" gorm:"column:state"`
  78. Weight int64 `form:"weight" json:"weight" gorm:"column:weight"`
  79. Utime int64 `form:"utime" json:"utime" gorm:"column:utime"`
  80. Gtime IntTime `form:"gtime" json:"gtime" gorm:"column:gtime"`
  81. MID int64 `form:"mid" json:"mid" gorm:"column:mid"`
  82. Fans int64 `form:"fans" json:"fans" gorm:"column:fans"`
  83. Group string `form:"group" json:"group" gorm:"column:group"`
  84. Reason string `form:"reason" json:"reason" grom:"column:reason"`
  85. Ctime IntTime `form:"ctime" json:"ctime" gorm:"column:ctime"`
  86. Mtime IntTime `form:"mtime" json:"mtime" gorm:"column:mtime"`
  87. }
  88. // WeightLog task log
  89. type WeightLog struct {
  90. UPtime string `json:"uptime"`
  91. Mid int64 `json:"mid"`
  92. Fans int64 `json:"fans"`
  93. FansWeight int64 `json:"fans_weight"`
  94. Group string `json:"group"`
  95. GroupWeight int64 `json:"group_weight"`
  96. WaitTime string `json:"wait_time"`
  97. WaitWeight int64 `json:"wait_weight"`
  98. EqualWeight int64 `json:"config_weight"`
  99. ConfigItems []*ConfigItem `json:"config_items"`
  100. Weight int64 `json:"weight"`
  101. }
  102. // ConfigItem .
  103. type ConfigItem struct {
  104. Name string `json:"name"`
  105. Desc string `json:"desc"`
  106. Uname string `json:"uname"`
  107. }
  108. // EqualWeightConfig 等值权重
  109. type EqualWeightConfig struct {
  110. Uname string // 配置人
  111. Description string // 描述
  112. Name string `json:"name"` // taskid 或者 mid
  113. IDs string `json:"ids"`
  114. Weight int64 `json:"weight"`
  115. Type int8 `json:"type"` // 周期或者定值
  116. }
  117. // RangeWeightConfig 权重
  118. type RangeWeightConfig struct {
  119. Name string `json:"name"`
  120. Range []*RangeConfig `json:"range"`
  121. }
  122. // RangeConfig 范围配置
  123. type RangeConfig struct {
  124. Threshold int64 `json:"threshold"`
  125. Weight int64 `json:"weight"`
  126. }
  127. // AssignConfig 指派
  128. type AssignConfig struct {
  129. Admin int64 `json:"-"`
  130. Mids []int64 `json:"mids"`
  131. Uids []int64 `json:"uids"`
  132. }
  133. // TaskConfig .
  134. type TaskConfig struct {
  135. ID int64 `form:"id" json:"id" gorm:"AUTO_INCREMENT;primary_key;"`
  136. ConfJSON string `json:"conf_json" gorm:"column:conf_json"`
  137. ConfType int8 `form:"conf_type" json:"conf_type" gorm:"column:conf_type"`
  138. BusinessID int64 `form:"business_id" json:"business_id" gorm:"column:business_id"`
  139. FlowID int64 `form:"flow_id" json:"flow_id" gorm:"column:flow_id"`
  140. Btime libtime.Time `form:"btime" json:"btime" gorm:"column:btime"`
  141. Etime libtime.Time `form:"etime" json:"etime" gorm:"column:etime"`
  142. State int8 `form:"state" json:"state" gorm:"column:state"`
  143. UID int64 `form:"uid" json:"uid" gorm:"column:uid"`
  144. Uname string `form:"uname" json:"uname" gorm:"column:uname"`
  145. Description string `form:"description" json:"description" gorm:"column:description"`
  146. Ctime libtime.Time `form:"ctime" json:"ctime" gorm:"column:ctime"`
  147. Mtime libtime.Time `form:"mtime" json:"mtime" gorm:"column:mtime"`
  148. }
  149. // TableName for orm
  150. func (TaskConfig) TableName() string {
  151. return "task_config"
  152. }
  153. // WeightOPT .
  154. type WeightOPT struct {
  155. BusinessID int64
  156. FlowID int64
  157. TopListLen int64
  158. BatchListLen int64
  159. RedisListLen int64
  160. DbListLen int64
  161. AssignLen int64
  162. Minute int64
  163. }