|
@@ -17,7 +17,6 @@ import (
|
|
|
mediaDao "eta/eta_mini_ht_api/models/media"
|
|
|
reportDao "eta/eta_mini_ht_api/models/report"
|
|
|
userDao "eta/eta_mini_ht_api/models/user"
|
|
|
- "github.com/google/uuid"
|
|
|
"math/rand"
|
|
|
"strconv"
|
|
|
"strings"
|
|
@@ -349,28 +348,12 @@ func SyncETAReportList(list []eta.ETAReport) (err error) {
|
|
|
coverSrc = ids[randomIndex]
|
|
|
break
|
|
|
}
|
|
|
- //permissionsId := permissions[0].ChartPermissionID
|
|
|
- //var ids []int
|
|
|
- //ids, err = mediaDao.GetIdsByPermissionId(permissionsId)
|
|
|
- //if err != nil {
|
|
|
- // logger.Error("获取图片资源失败:%v", err)
|
|
|
- //}
|
|
|
- //if ids == nil || len(ids) == 0 {
|
|
|
- // coverSrc = 0
|
|
|
- //} else {
|
|
|
- // src := rand.NewSource(time.Now().UnixNano())
|
|
|
- // r := rand.New(src)
|
|
|
- // // 从切片中随机选择一个元素
|
|
|
- // randomIndex := r.Intn(len(ids))
|
|
|
- // coverSrc = ids[randomIndex]
|
|
|
- //}
|
|
|
}
|
|
|
status := etaStatus(etaRp.State)
|
|
|
destRp := convertEtaReport(etaRp, status)
|
|
|
destRp.CoverSrc = coverSrc
|
|
|
reports = append(reports, destRp)
|
|
|
}
|
|
|
- //}
|
|
|
esList, err := reportDao.InsertOrUpdateReport(reports, SourceETA)
|
|
|
if esList == nil {
|
|
|
return
|
|
@@ -445,41 +428,53 @@ func syncESAndSendMessage(reports []reportDao.Report) (err error) {
|
|
|
//生产meta信息
|
|
|
logger.Info("生成推送META信息")
|
|
|
for _, report := range reports {
|
|
|
- userIds := userService.GetPostUser(report.Author, report.PublishedTime)
|
|
|
- var author analystService.FinancialAnalystDTO
|
|
|
- author, err = analystService.GetAnalystByName(report.Author)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取研报作者失败:%v", err)
|
|
|
+ if report.Status == reportDao.StatusUnPublish {
|
|
|
+ logger.Info("报告取消发布,不需要生成推送消息")
|
|
|
continue
|
|
|
}
|
|
|
+ var From string
|
|
|
+ switch report.Source {
|
|
|
+ case SourceETA:
|
|
|
+ From = "ETA"
|
|
|
+ case SourceHT:
|
|
|
+ From = "HT"
|
|
|
+ default:
|
|
|
+ From = "UNKNOWN"
|
|
|
+ }
|
|
|
authors := strings.Split(report.Author, ",")
|
|
|
authors = stringUtils.RemoveEmptyStrings(authors)
|
|
|
- if len(authors) > 0 && len(userIds) > 0 {
|
|
|
- logger.Info("推送META信息,用户ID:%v", userIds)
|
|
|
+ if len(authors) > 0 {
|
|
|
for _, authorName := range authors {
|
|
|
- usersStr := stringUtils.IntToStringSlice(userIds)
|
|
|
- Meta := userService.MetaData{
|
|
|
- AuthorName: authorName,
|
|
|
- AuthorId: author.Id,
|
|
|
- SourceId: report.ID,
|
|
|
- PublishedTime: report.PublishedTime,
|
|
|
- }
|
|
|
- metaStr, _ := json.Marshal(Meta)
|
|
|
- toStr := strings.Join(usersStr, ",")
|
|
|
- UUID := uuid.New()
|
|
|
- uuidStr := UUID.String()
|
|
|
- metaContent := userService.MetaInfoDTO{
|
|
|
- From: "HT",
|
|
|
- Uid: "report:" + uuidStr,
|
|
|
- Meta: string(metaStr),
|
|
|
- MetaType: "USER_NOTICE",
|
|
|
- SourceType: "REPORT",
|
|
|
- To: toStr,
|
|
|
- }
|
|
|
- err = userService.CreateMetaInfo(metaContent)
|
|
|
- if err != nil {
|
|
|
- logger.Error("创建Meta信息失败:%v", err)
|
|
|
- return err
|
|
|
+ userIds := userService.GetPostUser(authorName, report.PublishedTime)
|
|
|
+ if len(userIds) > 0 {
|
|
|
+ logger.Info("推送META信息,用户ID:%v", userIds)
|
|
|
+ var author analystService.FinancialAnalystDTO
|
|
|
+ author, err = analystService.GetAnalystByName(authorName)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取研报作者失败:%v", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ usersStr := stringUtils.IntToStringSlice(userIds)
|
|
|
+ Meta := userService.MetaData{
|
|
|
+ AuthorName: author.Name,
|
|
|
+ AuthorId: author.Id,
|
|
|
+ SourceId: report.ID,
|
|
|
+ PublishedTime: report.PublishedTime,
|
|
|
+ }
|
|
|
+ metaStr, _ := json.Marshal(Meta)
|
|
|
+ toStr := strings.Join(usersStr, ",")
|
|
|
+ metaContent := userService.MetaInfoDTO{
|
|
|
+ From: From,
|
|
|
+ Meta: string(metaStr),
|
|
|
+ MetaType: "USER_NOTICE",
|
|
|
+ SourceType: "REPORT",
|
|
|
+ To: toStr,
|
|
|
+ }
|
|
|
+ err = userService.CreateMetaInfo(metaContent)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("创建Meta信息失败:%v", err)
|
|
|
+ return err
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -582,12 +577,8 @@ func SyncHTReportList(list []ht.HTReport) (noRecord bool, err error) {
|
|
|
if permission.AuthorNames != "" {
|
|
|
htRp.PublishUserName = permission.AuthorNames
|
|
|
}
|
|
|
- //authorNames := strings.Split(htRp.PublishUserName, ",")
|
|
|
- //authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
|
|
|
- //for _, authorName := range authorNamesWithOutEmpty {
|
|
|
status := htStatus(htRp.Status, htRp.IsDelete)
|
|
|
destRp := convertHTReport(htRp, status)
|
|
|
- //destRp.Author = authorName
|
|
|
var coverSrc int
|
|
|
var permissionId int
|
|
|
permissionId, err = etaDao.GetPermissionIdByName(htRp.PermissionName)
|