Selaa lähdekoodia

Merge branch 'need/cygx_1008' of http://8.136.199.33:3000/hongze/hongze_cygx

zhangchuanxing 5 kuukautta sitten
vanhempi
commit
bd1b0041c2

+ 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
 }
 

+ 2 - 2
models/ficc_report/report.go

@@ -138,12 +138,12 @@ func GetFiccRreportToCygxArticle(condition string, pars []interface{}) (items []
 	o := orm.NewOrmUsingDB("rddp")
 	sql := ` SELECT	* FROM report WHERE state = 2 AND  is_public_publish = 1 
 			AND classify_name_first IN ('宏观报告','晨会纪要','调研纪要','数据点评','从宏观看商品')
-			AND classify_name_second IN ('大类资产周报','晨会纪要','黑色调研','宏观G2观察','人民币汇率双周报','房地产市场跟踪','黄金月报','铜行业数据点评','原油基本面推演','原油船期数据跟踪','EIA原油库存点评','从宏观看商品')
+			AND classify_name_second IN ('大类资产周报','晨会纪要','黑色调研','宏观G2观察','人民币汇率双周报','房地产市场跟踪','黄金月报','铜行业数据点评','原油基本面推演','原油船期数据跟踪','EIA原油库存点评','从宏观看商品','铜行业跟踪')
 			AND IF ( classify_name_first = '宏观报告' , classify_name_second IN  ('大类资产周报','宏观G2观察','人民币汇率双周报','房地产市场跟踪','黄金月报')  ,1=1 )
 			AND IF ( classify_name_first = '晨会纪要' , classify_name_second = '晨会纪要' ,1=1 )
 			AND IF ( classify_name_first = '调研纪要' , classify_name_second = '黑色调研' ,1=1 ) 
 			AND IF ( classify_name_first = '从宏观看商品' , classify_name_second = '从宏观看商品' ,1=1 ) 
-			AND IF ( classify_name_first = '数据点评' , classify_name_second  IN  ('铜行业数据点评','原油基本面推演','原油船期数据跟踪','EIA原油库存点评')  ,1=1 ) ` + condition + ` ORDER BY  modify_time	 DESC   `
+			AND IF ( classify_name_first = '数据点评' , classify_name_second  IN  ('铜行业数据点评','原油基本面推演','原油船期数据跟踪','EIA原油库存点评','铜行业跟踪')  ,1=1 ) ` + condition + ` ORDER BY  modify_time	 DESC   `
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 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",

+ 4 - 0
services/article.go

@@ -1293,6 +1293,9 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			go DoArticleOnenIdWxTemplateMsg(v.ArticleId)
 		}
 
+		if v.CategoryName == utils.ZHOU_QI_NAME {
+			UpdateCygxZhouqiArticleMapTime(v.FieldName) //更新周期对应分类下所管理文章的更新时间
+		}
 		//【公司调研】系列纪要发布/更新后 end
 
 		//查研观向6.9模板消息推送规则
@@ -1334,6 +1337,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 	}
 
 	AddCygxReportMappingCategoryGroupByArticleId(artcleId)
+
 	return err
 }
 

+ 55 - 0
services/ficc_report.go

@@ -500,8 +500,10 @@ func GetFiccRreportToCygxArticle(cont context.Context) (err error) {
 			if v.ClassifyNameFirst == "晨会纪要" && v.ClassifyNameSecond == "晨会纪要" {
 				item.Title = "FICC/周期品晨会纪要"
 			}
+			item.CategoryName = "周期"
 			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 +555,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}
@@ -565,6 +568,7 @@ func GetFiccRreportToCygxArticle(cont context.Context) (err error) {
 			UpdateFICCReportResourceData(v.Id, listFiccSet)
 
 			AddCygxReportMappingCategoryGroupByArticleId(articleIdMax)
+			UpdateCygxZhouqiArticleMapTime(item.FieldName) //更新周期对应分类下所管理文章的更新时间
 		}
 	}
 
@@ -684,3 +688,54 @@ func GetFiccReportXcxItem(user *models.WxUserItem) (itemSourceResp *models.CygxR
 	itemSourceResp = itemSource
 	return
 }
+
+//func init() {
+//	strslice := []string{"晨会纪要", "煤炭", "铜行业数据点评", "石油石化", "黑色调研", "宏观G2观察", "黄金月报"}
+//	for _, v := range strslice {
+//		fmt.Println(v)
+//		UpdateCygxZhouqiArticleMapTime(v)
+//	}
+//}
+
+// 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, e := 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 category_name = '周期' 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
+}

+ 7 - 0
services/tag.go

@@ -63,6 +63,7 @@ func GetConditionInitByTagIds(tagIds string, chartPermissionId int) (conditionIn
 	}
 
 	var tagType int // 定义特殊标签的类型,判断传过来的参数是否有固定标签的搜索
+	var tagName string
 	for _, tagInfo := range listTag {
 		//ActivityTypes 与 ArticleTypes 进行合并
 		if tagInfo.ActivityTypes != "" {
@@ -95,6 +96,7 @@ func GetConditionInitByTagIds(tagIds string, chartPermissionId int) (conditionIn
 		if tagType == 0 && tagInfo.TagType > 0 {
 			tagType = tagInfo.TagType
 		}
+		tagName = tagInfo.TagName
 	}
 
 	switch tagType {
@@ -184,6 +186,11 @@ func GetConditionInitByTagIds(tagIds string, chartPermissionId int) (conditionIn
 			}
 			conditionInit += " AND id IN  (" + strings.Join(resourceDataIdStrs, ",") + ")   "
 		}
+
+		var tagNames = []string{"纪要", "深度", "概览", "点评"}
+		if utils.InArrayByStr(tagNames, tagName) { //如果是这个四个类型的标签搜索单独针对FICC研报的周期行业进行筛选
+			conditionInit += " OR (  tag_name IN ('" + tagName + "')   AND  chart_permission_id =   " + strconv.Itoa(chartPermissionId) + ")  "
+		}
 	case 1: // 热门活动
 		conf, e := models.GetConfigByCode(utils.CYGX_TAG_HOT_ACTIVITY_ID)
 		if e != nil {

+ 1 - 1
utils/config.go

@@ -335,7 +335,7 @@ func YiDongApiConfig() {
 	}
 }
 
-// 行业ID信息 易董开放api配置
+// 行业ID信息
 func ChartPermissionId() {
 	if RunMode == "release" {
 		ZHOU_QI_ID = 62