|
@@ -2,6 +2,7 @@ package services
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "eta/eta_api/cache"
|
|
|
"eta/eta_api/models"
|
|
|
"eta/eta_api/models/report"
|
|
|
"eta/eta_api/services/alarm_msg"
|
|
@@ -47,7 +48,7 @@ func HandleInsertRaiReport(raiReportId int) (err error) {
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
|
err = fmt.Errorf("获取权益报告失败, Err: %s", err.Error())
|
|
|
- return
|
|
|
+ return
|
|
|
}
|
|
|
var articleResultDate models.ArticleDetailResultApi
|
|
|
err = json.Unmarshal(body, &articleResultDate)
|
|
@@ -55,7 +56,7 @@ func HandleInsertRaiReport(raiReportId int) (err error) {
|
|
|
fmt.Println("Getres.PublicGetDate Err:", err.Error())
|
|
|
return err
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
articleResult := articleResultDate.Data
|
|
|
err = handleInsertRaiReport(articleResult)
|
|
|
if err != nil {
|
|
@@ -90,7 +91,7 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -98,7 +99,7 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
if articleResult.IndustrId != 12 {
|
|
@@ -154,12 +155,16 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
}
|
|
|
state := reportInfo.State
|
|
|
|
|
|
+ publishSource := `publish`
|
|
|
+
|
|
|
|
|
|
if (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
|
|
|
|
|
|
state = models.ReportStatePublished
|
|
|
reportInfo.PublishTime = articleResult.PublishDate
|
|
|
- }else if !articleResult.IsActive {
|
|
|
+ } else if !articleResult.IsActive {
|
|
|
+ publishSource = `un_publish`
|
|
|
+
|
|
|
|
|
|
err = models.DeleteReport(reportInfo.Id)
|
|
|
if err != nil {
|
|
@@ -168,11 +173,12 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
}
|
|
|
go UpdateReportEs(reportInfo.Id, 1)
|
|
|
return
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
+ publishSource = `un_publish`
|
|
|
+
|
|
|
|
|
|
state = models.ReportStateUnpublished
|
|
|
reportInfo.PublishTime = articleResult.PublishDate
|
|
|
-
|
|
|
}
|
|
|
|
|
|
abstract := strings.ReplaceAll(articleResult.Content.Abstract, "<p>", "")
|
|
@@ -193,7 +199,7 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
reportInfo.ModifyTime = articleResult.UpdateDate
|
|
|
|
|
|
|
|
|
- updateCols := []string{"ClassifyIdFirst","ClassifyNameFirst","ClassifyIdSecond","ClassifyNameSecond","Title","Abstract","Author","Frequency","State","Content","ContentSub","ModifyTime","PublishTime"}
|
|
|
+ updateCols := []string{"ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond", "Title", "Abstract", "Author", "Frequency", "State", "Content", "ContentSub", "ModifyTime", "PublishTime"}
|
|
|
err = reportInfo.UpdateReport(updateCols)
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("更新报告失败, Err: %s", err.Error())
|
|
@@ -203,12 +209,15 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
if state == models.ReportStatePublished {
|
|
|
|
|
|
go handleReportPermission(int64(reportInfo.Id), reportInfo.ClassifyIdSecond)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
|
|
|
_ = ResetMiniProgramReportDetailCover(reportInfo.Id)
|
|
|
}
|
|
|
|
|
|
- }else if reportInfo.Id == 0 {
|
|
|
+
|
|
|
+ go cache.RagEtaReportOpToCache(reportInfo.Id, 0, publishSource)
|
|
|
+
|
|
|
+ } else if reportInfo.Id == 0 {
|
|
|
|
|
|
|
|
|
if (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
|
|
@@ -221,22 +230,22 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
}
|
|
|
|
|
|
|
|
|
- state := models.ReportStatePublished
|
|
|
+ state := models.ReportStatePublished
|
|
|
|
|
|
|
|
|
collaborateType := 1
|
|
|
-
|
|
|
+
|
|
|
|
|
|
reportLayout := 1
|
|
|
-
|
|
|
+
|
|
|
|
|
|
isPublicPublish := 1
|
|
|
-
|
|
|
+
|
|
|
abstract := strings.ReplaceAll(articleResult.Content.Abstract, "<p>", "")
|
|
|
abstract = strings.ReplaceAll(abstract, "</p>", "")
|
|
|
|
|
|
item := new(models.Report)
|
|
|
- item.AddType = 1
|
|
|
+ item.AddType = 1
|
|
|
item.ReportVersion = 2
|
|
|
item.ClassifyIdFirst = classifyFirst.Id
|
|
|
item.ClassifyNameFirst = articleResult.Industry.Name
|
|
@@ -293,12 +302,14 @@ func handleInsertRaiReport(articleResult models.ArticleResultApidate) (err error
|
|
|
go models.ModifyReportCode(reportId, reportCode)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
go handleReportPermission(reportId, item.ClassifyIdSecond)
|
|
|
|
|
|
|
|
|
_ = UpdateReportEs(int(reportId), 2)
|
|
|
+
|
|
|
+
|
|
|
+ go cache.RagEtaReportOpToCache(int(reportId), 0, `publish`)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -332,7 +343,7 @@ func getRaiReportLib(url string) (body []byte, err error) {
|
|
|
return
|
|
|
}
|
|
|
defer res.Body.Close()
|
|
|
- body, err = ioutil.ReadAll(res.Body)
|
|
|
+ body, err = ioutil.ReadAll(res.Body)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -355,11 +366,11 @@ func RaiReportInit() (err error) {
|
|
|
successCount := 0
|
|
|
failCount := 0
|
|
|
for i := 0; i <= totalPage; i++ {
|
|
|
- pageindex := i*pageSize
|
|
|
+ pageindex := i * pageSize
|
|
|
body, er := getRaiReportLib(fmt.Sprintf("%s/articles/mp?take=%d&skip=%d&publish_status=2&industry_id=12", utils.RaiReportLibUrl, pageSize, pageindex))
|
|
|
if er != nil {
|
|
|
err = fmt.Errorf("获取权益报告失败, Err: %s", er.Error())
|
|
|
- return
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
var articleResultDate models.RaiArticleListResultApi
|
|
@@ -380,7 +391,7 @@ func RaiReportInit() (err error) {
|
|
|
fmt.Printf("导入固收研究的历史报告失败%d, Err: %s\n", articleResult.ArticleId, err.Error())
|
|
|
failCount++
|
|
|
continue
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
fmt.Printf("导入固收研究的历史报告成功%d\n", articleResult.ArticleId)
|
|
|
successCount++
|
|
|
}
|