|
@@ -326,54 +326,7 @@ func SyncETAReportList(list []eta.ETAReport) (err error) {
|
|
|
logger.Error("同步ETA研报失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return syncESAndSendMessage(reports)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
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
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
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)
|
|
|
+
|
|
|
+ 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) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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,
|