zhangchuanxing vor 4 Monaten
Ursprung
Commit
6b3b5b5250
7 geänderte Dateien mit 323 neuen und 0 gelöschten Zeilen
  1. 156 0
      controllers/report.go
  2. 3 0
      models/article.go
  3. 24 0
      models/report.go
  4. 9 0
      models/tactics.go
  5. 64 0
      models/zhouqi_article_map.go
  6. 18 0
      routers/commentsRouter.go
  7. 49 0
      services/ficc_report.go

+ 156 - 0
controllers/report.go

@@ -3936,3 +3936,159 @@ func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
 	br.Msg = "操作成功"
 	return
 }
+
+// @Title 周期行业报告分类列表接口
+// @Description 周期获取行业报告分类列表接口
+// @Success 200 {object} models.TradeReportMappingResp
+// @router /zhouqi_tradeList [get]
+func (this *ReportController) ZouqiTradeList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	listCategory, err := models.GetCygxZhouqiArticleMapFirst()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.TradeReportMappingResp)
+	var list []*models.TradeReportMapping
+	if len(listCategory) == 0 {
+		list = make([]*models.TradeReportMapping, 0)
+	} else {
+		for _, v := range listCategory {
+			item := new(models.TradeReportMapping)
+			item.CategoryId = v.CategoryId
+			item.MatchTypeName = v.MatchTypeName
+			item.UpdateTime = v.ArticleUpdateTime
+			//item.ListArticle = make([]*models.HomeArticle, 0)
+			list = append(list, item)
+		}
+	}
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 周期根据行业分类获取行业文章列表
+// @Description 周期根据行业分类获取行业文章列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   CategoryId   query   int  true       "分类ID"
+// @Success 200 {object} models.TacticsListResp
+// @router /tactics/zhouqi_list [get]
+func (this *ReportController) ZhouqiTacticsList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	//uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	categoryId, _ := this.GetInt("CategoryId")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var total int
+	var err error
+	resp := new(models.TacticsListZhouqiResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	list := make([]*models.HomeArticle, 0)
+	listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
+		return
+	}
+	var matchTypeName = []string{}
+	for _, v := range listCategory {
+		matchTypeName = append(matchTypeName, v.MatchTypeName)
+	}
+
+	var condition string
+	//var pars []interface{}
+	condition = " AND field_name  IN  ('" + strings.Join(matchTypeName, "','") + "')"
+
+	list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.Msg = "GetReportAndproductIndustrylListimgZhouqi,Err:" + err.Error()
+		return
+	}
+
+	listPublic, err := services.HandleArticleCategoryImg(list)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
+		return
+	}
+
+	var articleIds []int
+	for _, v := range listPublic {
+		if v.Resource == 1 {
+			articleIds = append(articleIds, v.ArticleId)
+		}
+	}
+
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIds)                       //文章Pv
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
+	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
+
+	listResp := make([]*models.HomeArticle, 0)
+	for _, v := range listPublic {
+		item := new(models.HomeArticle)
+		item.ArticleId = v.ArticleId
+		item.ReportId = v.ReportId
+		item.Title = v.Title
+		item.Annotation = v.Annotation
+		item.Abstract = v.Abstract
+		item.ImgUrlPc = v.ImgUrlPc
+		item.PublishDate = v.PublishDate
+		item.Resource = v.Resource
+		if v.Resource == 1 {
+			item.Pv = articleMapPv[v.ArticleId]
+			item.IsCollect = articleCollectMap[v.ArticleId]
+			item.CollectNum = articleCollectNumMap[v.ArticleId]
+		}
+
+		if v.ReportId > 0 {
+			item.Resource = 3
+		}
+		listResp = append(listResp, item)
+	}
+	if len(listResp) == 0 {
+		listResp = make([]*models.HomeArticle, 0)
+	}
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = listResp
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 3 - 0
models/article.go

@@ -124,6 +124,9 @@ type HomeArticle struct {
 	BodyHighlight       []string             `description:"搜索高亮展示结果"`
 	ArticleTypeId       int                  `description:"文章类型ID"`
 	ReportId            int                  `description:"FICC研报ID"`
+	Resource            int                  `description:"来源类型,1:文章、2:产品内测"`
+	IsCollect           bool                 `description:"本人是否收藏"`
+	CollectNum          int                  `description:"收藏人数"`
 	List                []*IndustrialManagementIdInt
 }
 

+ 24 - 0
models/report.go

@@ -1540,3 +1540,27 @@ GROUP BY a.article_id ORDER BY publish_date DESC
 	_, err = o.Raw(sql, createtime).QueryRows(&items)
 	return
 }
+
+// 获取行业报告列表
+func GetReportAndproductIndustrylListimgZhouqi(condition string, startSize, pageSize int) (items []*HomeArticle, total int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			art.article_id,
+			art.report_id,
+			art.body,
+			art.annotation,
+			art.abstract,
+			art.category_id,
+			art.title,
+			art.publish_date,
+			1 AS resource 
+		FROM
+			cygx_article AS art 
+		WHERE
+			art.publish_status = 1  ` + condition
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	sql += `    ORDER BY publish_date DESC LIMIT ?,? `
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 9 - 0
models/tactics.go

@@ -124,6 +124,15 @@ type TacticsListResp struct {
 	List              []*ReportArticle
 }
 
+type TacticsListZhouqiResp struct {
+	Paging            *paging.PagingItem
+	MatchTypeName     string `description:"匹配类型"`
+	ChartPermissionId int    `description:"行业ID"`
+	CategoryImgUrlPc  string `description:"图片"`
+	IsShowAbstract    bool   `description:"是否展示摘要"`
+	List              []*HomeArticle
+}
+
 func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT * ,(SELECT COUNT(1) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND  rec.article_id=a.article_id) AS readnum

+ 64 - 0
models/zhouqi_article_map.go

@@ -0,0 +1,64 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type CygxZhouqiArticleMap struct {
+	CategoryId        int    `description:"产业Id"`
+	ParentId          int    `description:"父级ID"`
+	MatchTypeName     string `description:"行业名称"`
+	ArticleUpdateTime string `description:"对应文章的更新时间"`
+}
+
+// 获取周期下面的一级分类
+func GetCygxZhouqiArticleMapFirst() (items []*CygxZhouqiArticleMap, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			category_id,
+			parent_id,
+			match_type_name,
+			article_update_time 
+		FROM
+			cygx_zhouqi_article_map 
+		WHERE
+			hidden = 0 
+			AND parent_id = 0 
+		ORDER BY
+			sort DESC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 根据父级分类ID获取下面的子分类
+func GetCygxZhouqiArticleMapByParentId(parentId int) (items []*CygxZhouqiArticleMap, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			category_id,
+			match_type_name,
+			article_update_time 
+		FROM
+			cygx_zhouqi_article_map 
+		WHERE
+			parent_id = ?  `
+	_, err = o.Raw(sql, parentId).QueryRows(&items)
+	return
+}
+
+// 根据名称获取详情
+func GetCygxZhouqiArticleMapByMatchTypeName(matchTypeName string) (item *CygxZhouqiArticleMap, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.* FROM cygx_zhouqi_article_map AS a WHERE a.match_type_name=? AND  parent_id > 0  `
+	err = o.Raw(sql, matchTypeName).QueryRow(&item)
+	return
+}
+
+// 更新对应分类所关联的最新文章的时间
+func UpdateCygxZhouqiArticleMapTime(articleUpdateTime string, categoryId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_zhouqi_article_map SET hidden=0,article_update_time=? WHERE category_id = ? `
+	_, err = o.Raw(sql, articleUpdateTime, categoryId).Exec()
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -1204,6 +1204,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "ZhouqiTacticsList",
+            Router: `/tactics/zhouqi_list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
             Method: "ArticleCategoryList",
@@ -1231,6 +1240,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "ZouqiTradeList",
+            Router: `/zhouqi_tradeList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
         beego.ControllerComments{
             Method: "AddStopTime",

+ 49 - 0
services/ficc_report.go

@@ -502,6 +502,7 @@ func GetFiccRreportToCygxArticle(cont context.Context) (err error) {
 			}
 			item.Body = v.Content
 			item.Abstract = v.Abstract
+			item.FieldName = v.ClassifyNameSecond
 			item.CreateDate = time.Now().Format(utils.FormatDate)
 			item.PublishStatus = 1
 			item.IsReport = 1
@@ -553,6 +554,7 @@ func GetFiccRreportToCygxArticle(cont context.Context) (err error) {
 				updateParams["PublishStatus"] = item.PublishStatus
 				updateParams["SubCategoryName"] = item.SubCategoryName
 				updateParams["MatchTypeName"] = item.MatchTypeName
+				updateParams["FieldName"] = item.FieldName
 				updateParams["CategoryId"] = item.CategoryId
 				updateParams["CategoryIdTwo"] = item.CategoryIdTwo
 				whereParam := map[string]interface{}{"article_id": item.ArticleId}
@@ -684,3 +686,50 @@ func GetFiccReportXcxItem(user *models.WxUserItem) (itemSourceResp *models.CygxR
 	itemSourceResp = itemSource
 	return
 }
+
+//func init() {
+//	UpdateCygxZhouqiArticleMapTime("煤炭")
+//}
+
+// UpdateCygxZhouqiArticleMapTime 更新周期对应分类下所管理文章的更新时间
+func UpdateCygxZhouqiArticleMapTime(fieldName string) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新周期对应分类下所管理文章的更新时间 失败,UpdateCygxZhouqiArticleMapTime Err:"+err.Error()+"fieldName", fieldName), 3)
+		}
+	}()
+
+	detail, e := models.GetCygxZhouqiArticleMapByMatchTypeName(fieldName)
+	if e != nil {
+		err = errors.New("GetCygxZhouqiArticleMapByMatchTypeName, Err: " + err.Error())
+		return
+	}
+
+	listCategory, err := models.GetCygxZhouqiArticleMapByParentId(detail.ParentId)
+	if e != nil {
+		err = errors.New("GetCygxZhouqiArticleMapByParentId, Err: " + err.Error())
+		return
+	}
+	var matchTypeName = []string{}
+	for _, v := range listCategory {
+		matchTypeName = append(matchTypeName, v.MatchTypeName)
+	}
+
+	var condition string
+	var pars []interface{}
+	condition = " AND field_name  IN  ('" + strings.Join(matchTypeName, "','") + "')  ORDER  BY  publish_date  DESC  "
+
+	articleList, e := models.GetCygxCygxArticleList(condition, pars, 0, 1)
+	if e != nil {
+		err = errors.New("GetCygxCygxArticleList, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range articleList {
+		e = models.UpdateCygxZhouqiArticleMapTime(v.PublishDate, detail.ParentId)
+	}
+
+	return
+}