notice_task.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package message
  2. import (
  3. logger "eta/eta_mini_ht_api/common/component/log"
  4. "eta/eta_mini_ht_api/common/contants"
  5. "eta/eta_mini_ht_api/domian/financial_analyst"
  6. "eta/eta_mini_ht_api/models/eta"
  7. "eta/eta_mini_ht_api/task/base"
  8. "fmt"
  9. "github.com/google/uuid"
  10. "sync"
  11. "time"
  12. )
  13. var (
  14. taskName base.TaskType = "NoticeTask"
  15. cron = "0/5 * * * * *"
  16. duration = 5 * time.Second
  17. )
  18. // Execute Task ETA取研报的数据
  19. func (au *AuthorTask) Execute(taskDetail *base.TaskDetail) error {
  20. logger.Info(contants.TaskFormat, "监听更新通知开始")
  21. //报告和媒体
  22. var wg sync.WaitGroup
  23. wg.Add(2)
  24. UUID := uuid.New()
  25. uuidStr := UUID.String()
  26. timeBefore := time.Now().Add(-duration)
  27. fmt.Printf("监听更新通知开始:%v", timeBefore)
  28. //监听报告
  29. go func(uuid string) {
  30. defer wg.Done()
  31. //list := reportService.GetNewReportByPublishTime(timeBefore)
  32. // users := userService.GetNoticeUsersByReports(list)
  33. }(uuidStr)
  34. //监听媒体
  35. go func(uuid string) {
  36. defer wg.Done()
  37. }(uuidStr)
  38. wg.Wait()
  39. return nil
  40. }
  41. type AuthorTask struct {
  42. }
  43. func convert(author eta.ReportAuthor) financial_analyst.FinancialAnalystDTO {
  44. return financial_analyst.FinancialAnalystDTO{
  45. Deleted: author.IsDelete,
  46. ETAId: author.Id,
  47. Name: author.ReportAuthor,
  48. Status: author.Enable,
  49. }
  50. }
  51. func init() {
  52. authorTask := base.NewTask(taskName, cron, new(AuthorTask), base.PROD)
  53. base.RegisterTask(&authorTask)
  54. }