task.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. package archive
  2. import (
  3. "time"
  4. "go-common/app/admin/main/videoup/model/utils"
  5. "go-common/library/log"
  6. "go-common/library/xstr"
  7. )
  8. const (
  9. // ActionHandsUP 0签入
  10. ActionHandsUP = int8(0)
  11. // ActionHandsOFF 1签出
  12. ActionHandsOFF = int8(1)
  13. // ActionSubmit 2提交
  14. ActionSubmit = int8(2)
  15. // ActionDelay 3延迟
  16. ActionDelay = int8(3)
  17. // ActionClose 4关闭
  18. ActionClose = int8(4)
  19. //ActionOldSubmit 5旧一审提交
  20. ActionOldSubmit = int8(5)
  21. //ActionTaskDelete 10任务删除
  22. ActionTaskDelete = int8(10)
  23. //ActionDispatch 分配
  24. ActionDispatch = int8(6)
  25. //ActionRelease 释放(拒审)
  26. ActionRelease = int8(7)
  27. // WConfMid 按照mid配置权重
  28. WConfMid = int8(0)
  29. // WConfTaskID 按照taskid配置权重
  30. WConfTaskID = int8(1)
  31. // WConfType 按照分区配置权重
  32. WConfType = int8(2)
  33. // WConfUpFrom 按照投稿来源配置权重
  34. WConfUpFrom = int8(3)
  35. // WConfRelease 指派任务释放
  36. WConfRelease = int8(4)
  37. // TimeFormatSec 时间格式化
  38. TimeFormatSec = "2006-01-02 15:04:05"
  39. )
  40. var (
  41. // TookTypeMinute 一审耗时每分钟打点
  42. TookTypeMinute = int8(1)
  43. // TookTypeHalfHour 一审耗时半小时打点
  44. TookTypeHalfHour = int8(2)
  45. // PoolForFirst 一审任务池
  46. PoolForFirst = int8(0)
  47. // PoolForSecond 二审任务池
  48. PoolForSecond = int8(1)
  49. // TypeRealTime 实时任务
  50. TypeRealTime = int8(0)
  51. // TypeDispatched 已分发任务
  52. TypeDispatched = int8(1)
  53. // TypeFinished 结束任务
  54. TypeFinished = int8(2)
  55. // TypeDelay 延时任务
  56. TypeDelay = int8(3)
  57. // TypeClosed 停滞任务
  58. TypeClosed = int8(4)
  59. // TypeSpecial 特殊任务
  60. TypeSpecial = int8(5)
  61. // TypeUpDelete 已删除任务
  62. TypeUpDelete = int8(6)
  63. // TypeSpecialWait 特殊停滞任务
  64. TypeSpecialWait = int8(7)
  65. // SubjectForNormal 普通任务
  66. SubjectForNormal = int8(0) //normal task subject
  67. // SubjectForTask 指派任务
  68. SubjectForTask = int8(1) //specified task subject
  69. _taskdispatchstate = map[int8]struct{}{
  70. TypeRealTime: struct{}{},
  71. TypeDispatched: struct{}{},
  72. TypeFinished: struct{}{},
  73. TypeDelay: struct{}{},
  74. TypeClosed: struct{}{},
  75. TypeSpecial: struct{}{},
  76. TypeUpDelete: struct{}{},
  77. TypeSpecialWait: struct{}{},
  78. }
  79. // WLVConf 默认值
  80. WLVConf = &WeightVC{
  81. MaxWeight: int64(200000), //最大权重值
  82. SubRelease: int64(18), //指派再释放的任务
  83. //特殊任务参数
  84. Slv1: int64(8), // 普通用户>=1W粉
  85. Slv2: int64(10), // 普通用户>=10W粉
  86. Slv3: int64(12), // 优质用户<1W粉
  87. Slv4: int64(15), // 优质用户>=1W粉
  88. Slv5: int64(18), // 优质用户>=10W粉
  89. Slv6: int64(6), // 高危用户>=10W粉
  90. Slv7: int64(0), // 其他高危
  91. //普通任务参数
  92. Nlv1: int64(3), // 等待时长 9-15
  93. Nlv2: int64(6), // 等待时长 15-27
  94. Nlv3: int64(9), // 等待时长 27-45
  95. Nlv4: int64(12), // 等待时长 >45
  96. Nlv5: int64(0), // 等待时长 <=9
  97. //定时任务参数
  98. Tlv1: int64(3), // 距离发布2h-4h
  99. Tlv2: int64(9), // 距离发布1-2h
  100. Tlv3: int64(21), // 距离发布 <1h
  101. Tlv4: int64(0), // 距离发布 > 4h
  102. }
  103. )
  104. // CfWeightDesc 权重配置文字描述
  105. func CfWeightDesc(radio int8) (desc string) {
  106. switch radio {
  107. case WConfMid:
  108. desc = "mid配置"
  109. case WConfTaskID:
  110. desc = "taskid配置"
  111. case WConfType:
  112. desc = "分区配置"
  113. case WConfUpFrom:
  114. desc = "投稿来源"
  115. case WConfRelease:
  116. desc = "指派释放"
  117. default:
  118. desc = "其他配置"
  119. }
  120. return
  121. }
  122. // IsDispatch 判断任务状态
  123. func IsDispatch(st int8) bool {
  124. if _, ok := _taskdispatchstate[st]; ok {
  125. return true
  126. }
  127. return false
  128. }
  129. // ParseWeightConf 解析权重配置
  130. func ParseWeightConf(twc *WeightConf, uid int64, uname string) (mcases map[int64]*WCItem, IsTaskID bool, err error) {
  131. var (
  132. ids []int64
  133. )
  134. mcases = make(map[int64]*WCItem)
  135. if ids, err = xstr.SplitInts(twc.Ids); err != nil {
  136. log.Error("ParseWeightConfig Config(%v) parse error(%v) Idlist(%s)", twc, err)
  137. return nil, false, err
  138. }
  139. for _, id := range ids {
  140. wci := &WCItem{
  141. CID: id,
  142. Radio: twc.Radio,
  143. Rule: twc.Rule,
  144. Weight: twc.Weight,
  145. Uname: uname,
  146. Desc: twc.Desc,
  147. Bt: twc.Bt,
  148. Et: twc.Et,
  149. Mtime: utils.NewFormatTime(time.Now()),
  150. }
  151. if twc.Radio == WConfTaskID {
  152. IsTaskID = true
  153. }
  154. mcases[id] = wci
  155. }
  156. return
  157. }
  158. // WeightVC Weight Value Config 权重分值配置
  159. type WeightVC struct {
  160. MaxWeight int64 `json:"maxweight" form:"maxweight" default:"20000"`
  161. SubRelease int64 `json:"subrelease" form:"subrelease" default:"18"`
  162. Slv1 int64 `json:"slv1" form:"slv1" default:"8"`
  163. Slv2 int64 `json:"slv2" form:"slv2" default:"10"`
  164. Slv3 int64 `json:"slv3" form:"slv3" default:"12"`
  165. Slv4 int64 `json:"slv4" form:"slv4" default:"15"`
  166. Slv5 int64 `json:"slv5" form:"slv5" default:"18"`
  167. Slv6 int64 `json:"slv6" form:"slv6" default:"6"`
  168. Slv7 int64 `json:"slv7" form:"slv7" default:"0"`
  169. Nlv1 int64 `json:"nlv1" form:"nlv1" default:"3"`
  170. Nlv2 int64 `json:"nlv2" form:"nlv2" default:"6"`
  171. Nlv3 int64 `json:"nlv3" form:"nlv3" default:"9"`
  172. Nlv4 int64 `json:"nlv4" form:"nlv4" default:"12"`
  173. Nlv5 int64 `json:"nlv5" form:"nlv5" default:"0"`
  174. Tlv1 int64 `json:"tlv1" form:"tlv1" default:"3"`
  175. Tlv2 int64 `json:"tlv2" form:"tlv2" default:"9"`
  176. Tlv3 int64 `json:"tlv3" form:"tlv3" default:"21"`
  177. Tlv4 int64 `json:"tlv4" form:"tlv4" default:"0"`
  178. }
  179. // Task 审核任务
  180. type Task struct {
  181. ID int64 `json:"id"`
  182. Pool int8 `json:"pool"`
  183. Subject int8 `json:"subject"`
  184. AdminID int64 `json:"adminid"`
  185. Aid int64 `json:"aid"`
  186. Cid int64 `json:"cid"`
  187. UID int64 `json:"uid"`
  188. State int8 `json:"state"`
  189. UTime int64 `json:"utime"`
  190. CTime utils.FormatTime `json:"ctime"`
  191. MTime utils.FormatTime `json:"mtime"`
  192. DTime utils.FormatTime `json:"dtime"`
  193. GTime utils.FormatTime `json:"gtime"`
  194. PTime utils.FormatTime `json:"ptime"`
  195. Weight int64 `json:"weight"`
  196. Mid int64 `json:"mid"`
  197. }
  198. // TaskWeightLog 权重变更日志
  199. type TaskWeightLog struct {
  200. TaskID int64 `json:"taskid"`
  201. Mid int64 `json:"mid"`
  202. Weight int64 `json:"weight"`
  203. CWeight int64 `json:"cweight"`
  204. NWeight int64 `json:"nweight"`
  205. SWeight int64 `json:"sweight"`
  206. TWeight int64 `json:"tweight"`
  207. Uptime utils.FormatTime `json:"uptime"`
  208. Creator string `json:"creator"` //创作者
  209. UpSpecial []int8 `json:"upspecial"` //标记是否优质,劣质用户
  210. Fans int64 `json:"fans"` //粉丝数
  211. Wait float64 `json:"wait"` //等待时长
  212. Ptime string `json:"ptime,omitempty"`
  213. CfItems []*WCItem `json:"cfitems,omitempty"`
  214. Desc string `json:"desc,omitempty"` // 配置描述
  215. }
  216. // TaskPriority 审核任务权重的相关参数
  217. type TaskPriority struct {
  218. TaskID int64 `json:"taskid"`
  219. Weight int64 `json:"weight"` //权重总值
  220. State int8 `json:"state"` //任务状态
  221. Mid int64 `json:"mid"`
  222. Special int8 `json:"special"` //特殊任务
  223. Ctime utils.FormatTime `json:"ctime"` //任务生成时间
  224. Ptime utils.FormatTime `json:"ptime"` //定时发布时间
  225. CfItems []*WCItem `json:"cfitems,omitempty"`
  226. // 兼容videoup-task-admin 用于判断复审的参数
  227. /*
  228. TODO:
  229. 目前前端v1版本使用videoup-admin接口 v2版本使用videoup-task-admin接口
  230. 待前端迁移完成,再将videoup-admin中任务代码删除
  231. */
  232. Fans int64 `json:"fans"` //粉丝数
  233. AccFailed bool `json:"accfaild"` //账号查询是否失败
  234. UpGroups []int8 `json:"ugs"` //分组
  235. UpFrom int8 `json:"upfrom"` //来源
  236. TypeID int16 `json:"typeid"` //分区
  237. }
  238. // WeightConf 任务权重配置
  239. type WeightConf struct {
  240. Radio int8 `form:"radio"` // 0,mid,1,taskid,2,分区, 3, 投稿来源
  241. Ids string `form:"ids" validate:"required"` // id列表,逗号分隔
  242. Rule int8 `form:"rule"` // 0,动态权重,1,静态权重
  243. Weight int64 `form:"weight" validate:"required"` // 配置的权重
  244. Desc string `form:"desc" validate:"required"` // 描述信息
  245. Bt utils.FormatTime `form:"bt"` //配置生效开始时间
  246. Et utils.FormatTime `form:"et"` //配置生效结束时间
  247. }
  248. // WCItem task weight config item
  249. type WCItem struct {
  250. Radio int8 `json:"radio"`
  251. ID int64 `json:"id,omitempty"`
  252. CID int64 `json:"cid"` // config id 四种配置通用
  253. UID int64 `json:"uid,omitempty"`
  254. Uname string `json:"user,omitempty"`
  255. TypeName string `json:"typename,omitempty"`
  256. UpFrom string `json:"upfrom,omitempty"`
  257. Rule int8 `json:"rule"`
  258. State int8 `json:"state"`
  259. Weight int64 `json:"weight,omitempty"`
  260. Mtime utils.FormatTime `json:"mtime,omitempty"`
  261. Desc string `json:"desc,omitempty"`
  262. FileName string `json:"filename,omitempty"`
  263. Title string `json:"title,omitempty"`
  264. Vid int64 `json:"vid,omitempty"`
  265. Creator string `json:"creator,omitempty"`
  266. Fans int64 `json:"fans,omitempty"`
  267. Bt utils.FormatTime `json:"bt,omitempty"`
  268. Et utils.FormatTime `json:"et,omitempty"`
  269. }
  270. // Confs 权重配置筛选参数
  271. type Confs struct {
  272. Radio int8 `form:"radio" default:"1"`
  273. Cid int64 `form:"cid" default:"-1"`
  274. Operator string `form:"operator"`
  275. Bt utils.FormatTime `form:"bt"`
  276. Et utils.FormatTime `form:"et"`
  277. Rule int8 `form:"rule" default:"-1"`
  278. State int `form:"state"`
  279. Pn int `form:"page" default:"1"`
  280. Ps int `form:"ps" default:"20"`
  281. }
  282. // TaskTook 一审耗时
  283. type TaskTook struct {
  284. ID int64 `json:"id"`
  285. M90 int `json:"m90"`
  286. M80 int `json:"m80"`
  287. M60 int `json:"m60"`
  288. M50 int `json:"m50"`
  289. TypeID int8 `json:"type"`
  290. Ctime time.Time `json:"ctime"`
  291. Mtime time.Time `json:"-"`
  292. }
  293. // AuthRole 一审任务角色
  294. type AuthRole struct {
  295. ID int64 `json:"id"`
  296. UID int64 `json:"uid"`
  297. Role int8 `json:"role"`
  298. UserName string `json:"username"`
  299. NickName string `json:"nickname"`
  300. Ctime time.Time `json:"ctime"`
  301. Mtime time.Time `json:"mtime"`
  302. }
  303. // Consumers 组员信息
  304. type Consumers struct {
  305. ID int64 `json:"id"`
  306. UID int64 `json:"uid"`
  307. UserName string `json:"username"`
  308. State int8 `json:"state"`
  309. Ctime utils.FormatTime `json:"ctime"`
  310. Mtime utils.FormatTime `json:"mtime"`
  311. LastOut string `json:"lastout,omitempty"`
  312. }
  313. // ConsumerLog 组员日志
  314. type ConsumerLog struct {
  315. UID int64 `json:"uid"`
  316. Uname string `json:"uname"`
  317. Action int8 `json:"action"`
  318. Ctime string `json:"ctime"`
  319. Desc string `json:"desc"`
  320. }
  321. // InQuit 组员日志
  322. type InQuit struct {
  323. Date string `json:"date"`
  324. UID int64 `json:"uid"`
  325. Uname string `json:"uname"`
  326. InTime string `json:"inTime"`
  327. OutTime string `json:"quitTime"`
  328. }
  329. // SearchLogResult is.
  330. type SearchLogResult struct {
  331. Code int `json:"code"`
  332. Data struct {
  333. Order string `json:"order"`
  334. Sort string `json:"sort"`
  335. Result []struct {
  336. UID int64 `json:"uid"`
  337. Uname string `json:"uname"`
  338. OID int64 `json:"oid"`
  339. Type int8 `json:"type"`
  340. Action string `json:"action"`
  341. Str0 string `json:"str_0"`
  342. Str1 string `json:"str_1"`
  343. Str2 string `json:"str_2"`
  344. Int0 int `json:"int_0"`
  345. Int1 int `json:"int_1"`
  346. Int2 int `json:"int_2"`
  347. Ctime string `json:"ctime"`
  348. Extra string `json:"extra_data"`
  349. } `json:"result"`
  350. Page struct {
  351. Num int `json:"num"`
  352. Size int `json:"size"`
  353. Total int `json:"total"`
  354. } `json:"page"`
  355. } `json:"data"`
  356. }
  357. // TaskForLog 释放任务
  358. type TaskForLog struct {
  359. ID int64
  360. Cid int64
  361. Subject int8
  362. Mtime time.Time
  363. }