notice_task.go 983 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package message
  2. import (
  3. logger "eta/eta_mini_ht_api/common/component/log"
  4. "eta/eta_mini_ht_api/domian/message"
  5. userService "eta/eta_mini_ht_api/domian/user"
  6. "eta/eta_mini_ht_api/task/base"
  7. "sync"
  8. )
  9. var (
  10. taskName base.TaskType = "NoticeTask"
  11. cron = "0/5 * * * * *"
  12. )
  13. // Execute Task ETA取研报的数据
  14. func (au *NoticeTask) Execute(taskDetail *base.TaskDetail) (err error) {
  15. metaInfoList := message.GetInitMetaInfos()
  16. var wg sync.WaitGroup
  17. wg.Add(len(metaInfoList))
  18. for _, metaInfo := range metaInfoList {
  19. go func(metaInfo message.MetaInfoDTO) {
  20. defer wg.Done()
  21. if !message.PendingMetaInfo(metaInfo.Id) {
  22. return
  23. }
  24. msgErr := userService.CreateMessage(metaInfo)
  25. if msgErr != nil {
  26. logger.Error("生成消息失败:%v", err)
  27. }
  28. }(metaInfo)
  29. }
  30. //报告和媒体
  31. return
  32. }
  33. type NoticeTask struct {
  34. }
  35. func init() {
  36. reportTask := base.NewTask(taskName, cron, new(NoticeTask), base.PROD)
  37. base.RegisterTask(&reportTask)
  38. }