12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package message
- import (
- logger "eta/eta_mini_ht_api/common/component/log"
- "eta/eta_mini_ht_api/domian/message"
- userService "eta/eta_mini_ht_api/domian/user"
- "eta/eta_mini_ht_api/task/base"
- "sync"
- )
- var (
- taskName base.TaskType = "NoticeTask"
- cron = "0/5 * * * * *"
- )
- // Execute Task ETA取研报的数据
- func (au *NoticeTask) Execute(taskDetail *base.TaskDetail) (err error) {
- metaInfoList := message.GetInitMetaInfos()
- var wg sync.WaitGroup
- wg.Add(len(metaInfoList))
- for _, metaInfo := range metaInfoList {
- go func(metaInfo message.MetaInfoDTO) {
- defer wg.Done()
- if !message.PendingMetaInfo(metaInfo.Id) {
- return
- }
- msgErr := userService.CreateMessage(metaInfo)
- if msgErr != nil {
- logger.Error("生成消息失败:%v", err)
- }
- }(metaInfo)
- }
- //报告和媒体
- return
- }
- type NoticeTask struct {
- }
- func init() {
- reportTask := base.NewTask(taskName, cron, new(NoticeTask), base.PROD)
- base.RegisterTask(&reportTask)
- }
|