123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package message
- import (
- logger "eta/eta_mini_ht_api/common/component/log"
- "eta/eta_mini_ht_api/common/contants"
- "eta/eta_mini_ht_api/domian/financial_analyst"
- "eta/eta_mini_ht_api/models/eta"
- "eta/eta_mini_ht_api/task/base"
- "fmt"
- "github.com/google/uuid"
- "sync"
- "time"
- )
- var (
- taskName base.TaskType = "NoticeTask"
- cron = "0/5 * * * * *"
- duration = 5 * time.Second
- )
- // Execute Task ETA取研报的数据
- func (au *AuthorTask) Execute(taskDetail *base.TaskDetail) error {
- logger.Info(contants.TaskFormat, "监听更新通知开始")
- //报告和媒体
- var wg sync.WaitGroup
- wg.Add(2)
- UUID := uuid.New()
- uuidStr := UUID.String()
- timeBefore := time.Now().Add(-duration)
- fmt.Printf("监听更新通知开始:%v", timeBefore)
- //监听报告
- go func(uuid string) {
- defer wg.Done()
- //list := reportService.GetNewReportByPublishTime(timeBefore)
- // users := userService.GetNoticeUsersByReports(list)
- }(uuidStr)
- //监听媒体
- go func(uuid string) {
- defer wg.Done()
- }(uuidStr)
- wg.Wait()
- return nil
- }
- type AuthorTask struct {
- }
- func convert(author eta.ReportAuthor) financial_analyst.FinancialAnalystDTO {
- return financial_analyst.FinancialAnalystDTO{
- Deleted: author.IsDelete,
- ETAId: author.Id,
- Name: author.ReportAuthor,
- Status: author.Enable,
- }
- }
- func init() {
- authorTask := base.NewTask(taskName, cron, new(AuthorTask), base.PROD)
- base.RegisterTask(&authorTask)
- }
|