|
@@ -326,54 +326,7 @@ func SyncETAReportList(list []eta.ETAReport) (err error) {
|
|
|
logger.Error("同步ETA研报失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- //for _, etaRp := range reports {
|
|
|
- // esRp := convertEsReport(etaRp)
|
|
|
- // esReports = append(esReports, esRp)
|
|
|
- //}
|
|
|
return syncESAndSendMessage(reports)
|
|
|
- ////同步es
|
|
|
- //err = elastic().BulkInsert(htConfig.GetReportIndex(), esReports)
|
|
|
- //if err != nil {
|
|
|
- // logger.Error("同步ETA研报到es失败:%v", err)
|
|
|
- // return
|
|
|
- //}
|
|
|
- ////生产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)
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // if len(userIds) > 0 {
|
|
|
- // usersStr := stringUtils.IntToStringSlice(userIds)
|
|
|
- // Meta := userService.MetaData{
|
|
|
- // AuthorName: report.Author,
|
|
|
- // 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: "ETA",
|
|
|
- // 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
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
}
|
|
|
func syncESAndSendMessage(reports []reportDao.Report) (err error) {
|
|
|
var esReports []es.ESBase
|
|
@@ -439,90 +392,52 @@ func syncES(reports []reportDao.Report) (err error) {
|
|
|
logger.Error("同步ETA研报到es失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- ////生产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)
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // if len(userIds) > 0 {
|
|
|
- // usersStr := stringUtils.IntToStringSlice(userIds)
|
|
|
- // Meta := userService.MetaData{
|
|
|
- // AuthorName: report.Author,
|
|
|
- // 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
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
return
|
|
|
}
|
|
|
func InitHTReportList(list []ht.HTReport) (err error) {
|
|
|
logger.Info("同步研报数量%d", len(list))
|
|
|
var reports []reportDao.Report
|
|
|
- for _, htRp := range list {
|
|
|
- var authorStr string
|
|
|
- authorStr, err = reportDao.GetGLAuthorNames(htRp.Plate, htRp.Permission)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取钢联研报作者失败:%v", err)
|
|
|
- }
|
|
|
- if authorStr != "" {
|
|
|
- htRp.Author = authorStr
|
|
|
- }
|
|
|
- authorNames := strings.Split(htRp.Author, ",")
|
|
|
- authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
|
|
|
- for _, authorName := range authorNamesWithOutEmpty {
|
|
|
- destRp := convertHTReport(htRp)
|
|
|
- destRp.Author = authorName
|
|
|
- reports = append(reports, destRp)
|
|
|
- }
|
|
|
- }
|
|
|
- err = reportDao.BatchInsertReport(&reports)
|
|
|
+ //获取系统中ht品种名
|
|
|
+ permissions, err := reportDao.GetGLAuthorNames()
|
|
|
if err != nil {
|
|
|
- logger.Error("同步HT研报失败:%v", err)
|
|
|
+ logger.Error("获取钢联研报作者失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- return syncES(reports)
|
|
|
-}
|
|
|
-func SyncHTReportList(list []ht.HTReport) (err error) {
|
|
|
- logger.Info("同步研报数量%d", len(list))
|
|
|
- var reports []reportDao.Report
|
|
|
for _, htRp := range list {
|
|
|
- var authorStr string
|
|
|
- authorStr, err = reportDao.GetGLAuthorNames(htRp.Plate, htRp.Permission)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取钢联研报作者失败:%v", err)
|
|
|
- }
|
|
|
- if authorStr != "" {
|
|
|
- htRp.Author = authorStr
|
|
|
- }
|
|
|
- authorNames := strings.Split(htRp.Author, ",")
|
|
|
- authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
|
|
|
- for _, authorName := range authorNamesWithOutEmpty {
|
|
|
- destRp := convertHTReport(htRp)
|
|
|
- destRp.Author = authorName
|
|
|
- reports = append(reports, destRp)
|
|
|
+ for _, permission := range permissions {
|
|
|
+ if htRp.PermissionName == permission.Permission {
|
|
|
+ if permission.AuthorNames != "" {
|
|
|
+ htRp.PublishUserName = permission.AuthorNames
|
|
|
+ }
|
|
|
+ authorNames := strings.Split(htRp.PublishUserName, ",")
|
|
|
+ authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
|
|
|
+ for _, authorName := range authorNamesWithOutEmpty {
|
|
|
+ destRp := convertHTReport(htRp)
|
|
|
+ destRp.Author = authorName
|
|
|
+ var coverSrc int
|
|
|
+ permissionId, err := etaDao.GetPermissionIdByName(htRp.PermissionName)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("HT获取eta品种id失败:%v", err)
|
|
|
+ coverSrc = 0
|
|
|
+ }
|
|
|
+ ids, err := mediaDao.GetIdsByPermissionId(permissionId)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取图片资源失败:%v", err)
|
|
|
+ coverSrc = 0
|
|
|
+ }
|
|
|
+ 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]
|
|
|
+ }
|
|
|
+ destRp.CoverSrc = coverSrc
|
|
|
+ reports = append(reports, destRp)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
err = reportDao.BatchInsertReport(&reports)
|
|
@@ -530,7 +445,35 @@ func SyncHTReportList(list []ht.HTReport) (err error) {
|
|
|
logger.Error("同步HT研报失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- return syncESAndSendMessage(reports)
|
|
|
+ return syncES(reports)
|
|
|
+}
|
|
|
+func SyncHTReportList(list []ht.HTReport) (err error) {
|
|
|
+ //logger.Info("同步研报数量%d", len(list))
|
|
|
+ //var reports []reportDao.Report
|
|
|
+ //for _, htRp := range list {
|
|
|
+ // var authorStr string
|
|
|
+ // authorStr, err = reportDao.GetGLAuthorNames(htRp.Plate, htRp.Permission)
|
|
|
+ // if err != nil {
|
|
|
+ // logger.Error("获取钢联研报作者失败:%v", err)
|
|
|
+ // }
|
|
|
+ // if authorStr != "" {
|
|
|
+ // htRp.Author = authorStr
|
|
|
+ // }
|
|
|
+ // authorNames := strings.Split(htRp.Author, ",")
|
|
|
+ // authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
|
|
|
+ // for _, authorName := range authorNamesWithOutEmpty {
|
|
|
+ // destRp := convertHTReport(htRp)
|
|
|
+ // destRp.Author = authorName
|
|
|
+ // reports = append(reports, destRp)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //err = reportDao.BatchInsertReport(&reports)
|
|
|
+ //if err != nil {
|
|
|
+ // logger.Error("同步HT研报失败:%v", err)
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //return syncESAndSendMessage(reports)
|
|
|
+ return
|
|
|
}
|
|
|
func GetListOrderByConditionWeekly(week bool, column string, limit int, order models.Order) (dtoList []ReportDTO, err error) {
|
|
|
reports, err := reportDao.GetListOrderByCondition(week, column, limit, order)
|
|
@@ -595,11 +538,10 @@ func convertEtaReport(etaRp eta.ETAReport) reportDao.Report {
|
|
|
|
|
|
func convertHTReport(etaRp ht.HTReport) reportDao.Report {
|
|
|
return reportDao.Report{
|
|
|
- OrgID: etaRp.ID,
|
|
|
- Title: etaRp.Title,
|
|
|
- Abstract: etaRp.Abstract,
|
|
|
- Author: etaRp.Author,
|
|
|
- PublishedTime: etaRp.PublishTime,
|
|
|
+ OrgID: etaRp.Id,
|
|
|
+ Title: etaRp.ReportName,
|
|
|
+ Author: etaRp.PublishUserName,
|
|
|
+ PublishedTime: etaRp.PublishedTime,
|
|
|
CoverSrc: 0,
|
|
|
Source: reportDao.SourceHT,
|
|
|
SendStatus: reportDao.UNSEND,
|