Răsfoiți Sursa

保存策略报告同步时的类型字段,类型是综述报告的,不区分是什么系列,统一归类到对应产业的路演精华

xingzai 2 ani în urmă
părinte
comite
6b3ce76c73
4 a modificat fișierele cu 34 adăugiri și 2 ștergeri
  1. 1 0
      models/article.go
  2. 15 0
      models/report_mapping.go
  3. 2 0
      models/tactics.go
  4. 16 2
      services/article.go

+ 1 - 0
models/article.go

@@ -44,6 +44,7 @@ type CygxArticle struct {
 	Stock            string `description:"个股标签"`
 	FieldName        string `description:"产业标签"`
 	Annotation       string `description:"核心观点"`
+	TypeName         string `description:"策略平台报告类型"`
 }
 
 type CygxArticleEs struct {

+ 15 - 0
models/report_mapping.go

@@ -226,3 +226,18 @@ func GetStatisticalReportArtilceExpert() (items []*ReportMappingStatistical, err
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+//通过分类ID获取详情 处理路演精华的映射
+func GetdetailByCategoryIdLyjh(categoryId int) (item *ReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	* 
+FROM
+	cygx_report_mapping 
+WHERE
+	sub_category_name = '路演精华' 
+	AND chart_permission_id = ( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? ) 
+	LIMIT 1 `
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}

+ 2 - 0
models/tactics.go

@@ -72,6 +72,7 @@ type Tactics2 struct {
 	CategoryName    string    `description:"分类"`
 	SubCategoryName string    `description:"子级分类"`
 	CategoryId      int       `description:"分类id"`
+	CategoryIdTwo   int       `description:"分类id"`
 	CreateDate      string    `description:"创建日期"`
 	IsClass         int       `description:"是否归类,1是,0否"`
 	IsSummary       int       `description:"是否是纪要库,1是,0否"`
@@ -80,6 +81,7 @@ type Tactics2 struct {
 	Stock           string    `description:"个股标签"`
 	FieldName       string    `description:"产业标签"`
 	File            string    `description:"Pdf下载链接"`
+	TypeName        string    `description:"策略平台报告类型"`
 }
 
 func GetTacticsList2(endDate string) (list []*Tactics2, err error) {

+ 16 - 2
services/article.go

@@ -672,7 +672,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 }
 
 //func init() {
-//	HandleArticleListByApi(7507)
+//	HandleArticleListByApi(5978)
 //}
 
 //处理同步过来的文章
@@ -768,6 +768,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		item.Annotation = articleResult.Content.Annotation
 		item.CategoryName = articleResult.Industry.Name
 		item.CategoryId = exitMap[articleResult.SeriesId]
+		item.CategoryIdTwo = exitMap[articleResult.SeriesId]
 		item.SubCategoryName = articleResult.Series.Name
 		if len(articleResult.Stock) > 0 {
 			var stock string
@@ -778,6 +779,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			item.Stock = stock
 		}
 		item.FieldName = articleResult.Field.Name
+		item.TypeName = articleResult.Type.Name
 		list = append(list, item)
 		itemAuthor.ArticleId = articleResult.ArticleId
 		itemAuthor.Name = articleResult.Author.Name
@@ -894,6 +896,16 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		if v.CategoryId == 80 {
 			titleNew = v.Title + utils.WeekByDate(v.PublishDate)
 		}
+
+		//类型是综述报告的,不区分是什么系列,统一归类到对应产业的路演精华
+		if articleResult.Type.Name == "综述报告" {
+			detailCategory, err := models.GetdetailByCategoryIdLyjh(v.CategoryIdTwo)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				return err
+			}
+			v.CategoryId = detailCategory.CategoryId
+		}
+
 		if count > 0 {
 			fmt.Println(k, v.ArticleId, "edit")
 			var isCustom bool
@@ -936,6 +948,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			updateParams["Stock"] = v.Stock
 			updateParams["FieldName"] = v.FieldName
 			updateParams["Annotation"] = v.Annotation
+			updateParams["TypeName"] = v.TypeName
 			whereParam := map[string]interface{}{"article_id": v.ArticleId}
 			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
 			if err != nil {
@@ -959,7 +972,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			item.CategoryName = v.CategoryName
 			item.SubCategoryName = v.SubCategoryName
 			item.CategoryId = v.CategoryId
-			item.CategoryIdTwo = v.CategoryId
+			item.CategoryIdTwo = v.CategoryIdTwo
 			item.PublishStatus = 1
 			item.ExpertBackground = expertContentStr
 			item.ExpertNumber = expertNumStr
@@ -975,6 +988,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			item.Stock = v.Stock
 			item.FieldName = v.FieldName
 			item.Annotation = v.Annotation
+			item.TypeName = v.TypeName
 			newId, err := models.AddCygxArticles(item)
 			if err != nil {
 				fmt.Println("AddCygxArticle Err:", err.Error())