|
@@ -295,7 +295,7 @@ func InitETAReportList(list []eta.ETAReport) (err error) {
|
|
coverSrc = ids[randomIndex]
|
|
coverSrc = ids[randomIndex]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- destRp := convertEtaReport(etaRp)
|
|
|
|
|
|
+ destRp := convertEtaReport(etaRp, reportDao.StatusPublish)
|
|
//destRp.Author = authorName
|
|
//destRp.Author = authorName
|
|
destRp.CoverSrc = coverSrc
|
|
destRp.CoverSrc = coverSrc
|
|
reports = append(reports, destRp)
|
|
reports = append(reports, destRp)
|
|
@@ -310,6 +310,13 @@ func InitETAReportList(list []eta.ETAReport) (err error) {
|
|
return initES(reports)
|
|
return initES(reports)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+func etaStatus(status int) reportDao.ReportStatus {
|
|
|
|
+ if status == etaDao.Passed || status == etaDao.Published {
|
|
|
|
+ return reportDao.StatusPublish
|
|
|
|
+ } else {
|
|
|
|
+ return reportDao.StatusUnPublish
|
|
|
|
+ }
|
|
|
|
+}
|
|
func SyncETAReportList(list []eta.ETAReport) (err error) {
|
|
func SyncETAReportList(list []eta.ETAReport) (err error) {
|
|
logger.Info("同步研报数量%d", len(list))
|
|
logger.Info("同步研报数量%d", len(list))
|
|
var reports []reportDao.Report
|
|
var reports []reportDao.Report
|
|
@@ -317,7 +324,8 @@ func SyncETAReportList(list []eta.ETAReport) (err error) {
|
|
//authorNames := strings.Split(etaRp.Author, ",")
|
|
//authorNames := strings.Split(etaRp.Author, ",")
|
|
//authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
|
|
//authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
|
|
//for _, authorName := range authorNamesWithOutEmpty {
|
|
//for _, authorName := range authorNamesWithOutEmpty {
|
|
- destRp := convertEtaReport(etaRp)
|
|
|
|
|
|
+ status := etaStatus(etaRp.State)
|
|
|
|
+ destRp := convertEtaReport(etaRp, status)
|
|
//destRp.Author = authorName
|
|
//destRp.Author = authorName
|
|
reports = append(reports, destRp)
|
|
reports = append(reports, destRp)
|
|
}
|
|
}
|
|
@@ -334,6 +342,7 @@ type UpdateESReport struct {
|
|
Author string `json:"author"`
|
|
Author string `json:"author"`
|
|
Abstract string `json:"abstract"`
|
|
Abstract string `json:"abstract"`
|
|
PublishedTime string `json:"publishedTime"`
|
|
PublishedTime string `json:"publishedTime"`
|
|
|
|
+ Status string `json:"status"`
|
|
}
|
|
}
|
|
|
|
|
|
func syncESAndSendMessage(reports []reportDao.Report) (err error) {
|
|
func syncESAndSendMessage(reports []reportDao.Report) (err error) {
|
|
@@ -349,11 +358,13 @@ func syncESAndSendMessage(reports []reportDao.Report) (err error) {
|
|
Author: report.Author,
|
|
Author: report.Author,
|
|
PublishedTime: report.PublishedTime,
|
|
PublishedTime: report.PublishedTime,
|
|
Abstract: report.Abstract,
|
|
Abstract: report.Abstract,
|
|
|
|
+ Status: string(report.Status),
|
|
}
|
|
}
|
|
success := elastic().Update(htConfig.GetReportIndex(), report.ID, update)
|
|
success := elastic().Update(htConfig.GetReportIndex(), report.ID, update)
|
|
if !success {
|
|
if !success {
|
|
logger.Error("更新es失败,reportId::%d,err:%v", report.ID, err)
|
|
logger.Error("更新es失败,reportId::%d,err:%v", report.ID, err)
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//err = elastic().BulkInsert(htConfig.GetReportIndex(), esReports)
|
|
//err = elastic().BulkInsert(htConfig.GetReportIndex(), esReports)
|
|
@@ -587,7 +598,7 @@ func GetTotalPageCountByPermissionIds(permissionIds []int) (total int64, latestI
|
|
latestId = reportDao.GetMaxIdByPermissionIds(ids)
|
|
latestId = reportDao.GetMaxIdByPermissionIds(ids)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-func convertEtaReport(etaRp eta.ETAReport) reportDao.Report {
|
|
|
|
|
|
+func convertEtaReport(etaRp eta.ETAReport, status reportDao.ReportStatus) reportDao.Report {
|
|
return reportDao.Report{
|
|
return reportDao.Report{
|
|
OrgID: etaRp.ID,
|
|
OrgID: etaRp.ID,
|
|
Title: etaRp.Title,
|
|
Title: etaRp.Title,
|
|
@@ -597,7 +608,7 @@ func convertEtaReport(etaRp eta.ETAReport) reportDao.Report {
|
|
PublishedTime: etaRp.PublishTime.Format(time.DateTime),
|
|
PublishedTime: etaRp.PublishTime.Format(time.DateTime),
|
|
Source: reportDao.SourceETA,
|
|
Source: reportDao.SourceETA,
|
|
SendStatus: reportDao.UNSEND,
|
|
SendStatus: reportDao.UNSEND,
|
|
- Status: reportDao.StatusPublish,
|
|
|
|
|
|
+ Status: status,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -647,13 +658,13 @@ func convertReportDTO(report reportDao.Report, fullTime bool) (reportDTO ReportD
|
|
|
|
|
|
func matchAll(sorts []string, key string) (request *es.ESQueryRequest) {
|
|
func matchAll(sorts []string, key string) (request *es.ESQueryRequest) {
|
|
req := new(es.ESQueryRequest)
|
|
req := new(es.ESQueryRequest)
|
|
- return req.CreateESQueryRequest(htConfig.GetReportIndex(), ESColumn, key, 0, 1, sorts, es.MatchAll)
|
|
|
|
|
|
+ return req.CreateESQueryRequest(htConfig.GetReportIndex(), ESColumn, key, 0, 1, sorts, es.MatchAllByCondition).ByCondition("status", "PUBLUSH")
|
|
}
|
|
}
|
|
func match(key string, from int, to int, sorts []string) (request *es.ESQueryRequest) {
|
|
func match(key string, from int, to int, sorts []string) (request *es.ESQueryRequest) {
|
|
req := new(es.ESQueryRequest)
|
|
req := new(es.ESQueryRequest)
|
|
- return req.CreateESQueryRequest(htConfig.GetReportIndex(), ESColumn, key, from, to, sorts, es.Match)
|
|
|
|
|
|
+ return req.CreateESQueryRequest(htConfig.GetReportIndex(), ESColumn, key, from, to, sorts, es.MatchAllByCondition).ByCondition("status", "PUBLUSH")
|
|
}
|
|
}
|
|
func matchRange(key string, from int, to int, max int64, sorts []string) (request *es.ESQueryRequest) {
|
|
func matchRange(key string, from int, to int, max int64, sorts []string) (request *es.ESQueryRequest) {
|
|
req := new(es.ESQueryRequest)
|
|
req := new(es.ESQueryRequest)
|
|
- return req.CreateESQueryRequest(htConfig.GetReportIndex(), ESColumn, key, from, to, sorts, es.Range).Range(0, max, ESRangeColumn)
|
|
|
|
|
|
+ return req.CreateESQueryRequest(htConfig.GetReportIndex(), ESColumn, key, from, to, sorts, es.RangeByCondition).Range(0, max, ESRangeColumn).ByCondition("status", "PUBLISH")
|
|
}
|
|
}
|