|
@@ -13,6 +13,7 @@ import (
|
|
|
"eta/eta_mini_ht_api/models"
|
|
|
"eta/eta_mini_ht_api/models/eta"
|
|
|
etaDao "eta/eta_mini_ht_api/models/eta"
|
|
|
+ "eta/eta_mini_ht_api/models/ht"
|
|
|
reportDao "eta/eta_mini_ht_api/models/report"
|
|
|
"github.com/google/uuid"
|
|
|
"strconv"
|
|
@@ -54,18 +55,19 @@ type ESReport struct {
|
|
|
}
|
|
|
|
|
|
type ReportDTO struct {
|
|
|
- ReportID int `json:"reportId"`
|
|
|
- OrgId int `json:"orgId"`
|
|
|
- Title string `json:"title"`
|
|
|
- Author string `json:"author"`
|
|
|
- Source string `json:"source"`
|
|
|
- Abstract string `json:"abstract"`
|
|
|
- PublishedTime string `json:"publishedTime"`
|
|
|
- Permissions map[int]string `json:"-"`
|
|
|
- PermissionNames interface{} `json:"permissionNames,omitempty"`
|
|
|
- Highlight []string `json:"highlight,omitempty"`
|
|
|
- Detail json.RawMessage `json:"detail,omitempty"`
|
|
|
- CoverSrc string `json:"coverSrc"`
|
|
|
+ ReportID int `json:"reportId"`
|
|
|
+ OrgId int `json:"orgId"`
|
|
|
+ Title string `json:"title"`
|
|
|
+ Author string `json:"author"`
|
|
|
+ Source string `json:"source"`
|
|
|
+ Abstract string `json:"abstract"`
|
|
|
+ PublishedTime string `json:"publishedTime"`
|
|
|
+ SecondPermission map[int]string `json:"-"`
|
|
|
+ Permissions map[int]string `json:"-"`
|
|
|
+ PermissionNames interface{} `json:"permissionNames,omitempty"`
|
|
|
+ Highlight []string `json:"highlight,omitempty"`
|
|
|
+ Detail json.RawMessage `json:"detail,omitempty"`
|
|
|
+ CoverSrc string `json:"coverSrc"`
|
|
|
}
|
|
|
|
|
|
type Detail struct {
|
|
@@ -232,6 +234,23 @@ func getETAReportFirstPermissions(id int) (permissionDTOs []PermissionDTO) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func getETAReportSecondPermissions(id int) (permissionDTOs []PermissionDTO) {
|
|
|
+ classifyId, err := etaDao.GetReportClassifyById(id)
|
|
|
+ if err != nil || classifyId == 0 {
|
|
|
+ logger.Error("获取研报分类信息失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissions, err := etaDao.GetSecondPermissionsByClassifyID(classifyId)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取研报二级品种信息失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, permission := range permissions {
|
|
|
+ permissionDTOs = append(permissionDTOs, convertPermissionDTO(permission))
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
func (es ESReport) GetId() string {
|
|
|
return strconv.Itoa(es.ReportID)
|
|
|
}
|
|
@@ -360,15 +379,22 @@ func syncESAndSendMessage(reports []reportDao.Report) (err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func SyncHTReportList(list []eta.HTReport) (err error) {
|
|
|
+func SyncHTReportList(list []ht.HTReport) (err error) {
|
|
|
logger.Info("同步研报数量%d", len(list))
|
|
|
var reports []reportDao.Report
|
|
|
-
|
|
|
- for _, etaRp := range list {
|
|
|
- authorNames := strings.Split(etaRp.Author, ",")
|
|
|
+ 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(etaRp)
|
|
|
+ destRp := convertHTReport(htRp)
|
|
|
destRp.Author = authorName
|
|
|
reports = append(reports, destRp)
|
|
|
}
|
|
@@ -436,7 +462,7 @@ func convertEtaReport(etaRp eta.ETAReport) reportDao.Report {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func convertHTReport(etaRp eta.HTReport) reportDao.Report {
|
|
|
+func convertHTReport(etaRp ht.HTReport) reportDao.Report {
|
|
|
return reportDao.Report{
|
|
|
OrgID: etaRp.ID,
|
|
|
Title: etaRp.Title,
|