Browse Source

no message

xingzai 5 months ago
parent
commit
f08ec1011d
3 changed files with 43 additions and 18 deletions
  1. 1 0
      models/article.go
  2. 2 0
      models/report.go
  3. 40 18
      services/ficc_report.go

+ 1 - 0
models/article.go

@@ -416,6 +416,7 @@ func GetReportMappingById(categoryId int) (count int, err error) {
 
 type ReportArticle struct {
 	ArticleId        int    `description:"文章id"`
+	ReportId         int    `description:"文章id"`
 	Title            string `description:"标题"`
 	TitleEn          string `description:"英文标题 "`
 	UpdateFrequency  string `description:"更新周期"`

+ 2 - 0
models/report.go

@@ -156,6 +156,7 @@ func GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (item
 	o := orm.NewOrm()
 	sql := `SELECT
 			art.article_id,
+			art.report_id,
 			art.title,
 			art.abstract,
 			art.publish_date,
@@ -167,6 +168,7 @@ func GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (item
 			AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
 		SELECT
 			art.product_interior_id AS article_id,
+			0 AS report_id,
 			art.title,
 			"" as abstract,
 			art.publish_time AS publish_date,

+ 40 - 18
services/ficc_report.go

@@ -445,8 +445,8 @@ func GetChapterListByReportChapterIdList(classifyNameFirst string, reportId int,
 }
 
 //func init() {
-//	//GetFiccRreportToCygxArticle()
-//	UpdateFICCReportResourceData(5542)
+//	GetFiccRreportToCygxArticle()
+//	//UpdateFICCReportResourceData(5542)
 //}
 
 // 获取FICC研报到查研观向数据库中
@@ -481,9 +481,9 @@ func GetFiccRreportToCygxArticle() (err error) {
 		err = errors.New("GetCygxCygxArticleListByReportIds, Err: " + e.Error())
 		return
 	}
-	mapFiccReport := make(map[int]bool)
+	mapFiccReport := make(map[int]int)
 	for _, v := range listaFiccReport {
-		mapFiccReport[v.IsReport] = true
+		mapFiccReport[v.IsReport] = v.ArticleId
 	}
 	//量不大,先这么写吧
 	for _, v := range reportList {
@@ -494,6 +494,7 @@ func GetFiccRreportToCygxArticle() (err error) {
 		item.Title = v.Title
 		item.Body = v.Content
 		item.Abstract = v.Abstract
+		item.CreateDate = time.Now().Format(utils.FormatDate)
 		item.PublishStatus = 1
 		if (v.ClassifyNameFirst == "宏观报告" && v.ClassifyNameSecond == "大类资产周报") || (v.ClassifyNameFirst == "晨会纪要" && v.ClassifyNameSecond == "晨会纪要") {
 			item.SubCategoryName = "产业跟踪"
@@ -503,8 +504,8 @@ func GetFiccRreportToCygxArticle() (err error) {
 				item.CategoryId = 10091
 				item.CategoryIdTwo = 10091
 			} else {
-				//item.CategoryId = 10091
-				//item.CategoryIdTwo = 10091
+				item.CategoryId = 10089
+				item.CategoryIdTwo = 10089
 			}
 		} else if v.ClassifyNameFirst == "调研纪要" && v.ClassifyNameSecond == "调研纪要" {
 			item.SubCategoryName = "调研纪要"
@@ -513,31 +514,52 @@ func GetFiccRreportToCygxArticle() (err error) {
 				item.CategoryId = 10090
 				item.CategoryIdTwo = 10090
 			} else {
-				//item.CategoryId = 10091
-				//item.CategoryIdTwo = 10091
+				item.CategoryId = 10090
+				item.CategoryIdTwo = 10090
 			}
 		} else {
 			continue
 		}
-		var articleIdMax int
-		maxArticleIdArticleInfo, e := models.GetMaxArticleIdInfo()
-		if e != nil {
-			err = errors.New("GetMaxArticleIdInfo, Err: " + e.Error())
-			return
-		}
-		articleIdMax = maxArticleIdArticleInfo.ArticleId + 1
-		item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdMax))
-		item.ArticleId = articleIdMax
 
+		var articleIdMax int
 		//如果不存在就新增
-		if !mapFiccReport[v.Id] {
+		if mapFiccReport[v.Id] == 0 {
+			maxArticleIdArticleInfo, e := models.GetMaxArticleIdInfo()
+			if e != nil {
+				err = errors.New("GetMaxArticleIdInfo, Err: " + e.Error())
+				return
+			}
+			articleIdMax = maxArticleIdArticleInfo.ArticleId + 1
+			item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdMax))
+			item.ArticleId = articleIdMax
 			_, e = models.AddCygxArticles(item)
 			if e != nil {
 				err = errors.New("AddCygxArticles, Err: " + e.Error())
 				return
 			}
+		} else {
+			articleIdMax = mapFiccReport[v.Id]
+			item.ArticleId = mapFiccReport[v.Id]
+			updateParams := make(map[string]interface{})
+			updateParams["Title"] = item.Title
+			updateParams["PublishDate"] = item.PublishDate
+			updateParams["Body"] = item.Body
+			updateParams["Abstract"] = item.Abstract
+			updateParams["PublishStatus"] = item.PublishStatus
+			updateParams["SubCategoryName"] = item.SubCategoryName
+			updateParams["MatchTypeName"] = item.MatchTypeName
+			updateParams["CategoryId"] = item.CategoryId
+			updateParams["CategoryIdTwo"] = item.CategoryIdTwo
+			whereParam := map[string]interface{}{"article_id": item.ArticleId}
+			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
+			if err != nil {
+				fmt.Println("UpdateByExpr Err:" + err.Error())
+				return err
+			}
 		}
 		UpdateFICCReportResourceData(v.Id)
+
+		AddCygxReportMappingCategoryGroupByArticleId(articleIdMax)
 		fmt.Println(v)
 	}
 	return