Răsfoiți Sursa

Merge branch 'cygx/7.4'

hsun 2 ani în urmă
părinte
comite
8e6f0aaff8

+ 160 - 11
controllers/activity.go

@@ -97,6 +97,10 @@ func (this *ActivityCoAntroller) ActivityList() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if activityTypeIds == "undefined" {
 		activityTypeIds = ""
 	}
@@ -641,6 +645,7 @@ func (this *ActivityCoAntroller) Detail() {
 		br.Msg = "请输入活动ID"
 		return
 	}
+
 	resp := new(models.CygxActivityResp)
 	hasPermission := 0
 	var companyDetailStatus string
@@ -920,18 +925,30 @@ func (this *ActivityCoAntroller) Detail() {
 			item.IndustryName = activityInfo.Label
 			industrialList = append(industrialList, item)
 		} else {
+			industryIds := make([]int, 0)
 			var industrialManagementId string
 			for k, v := range industrialList {
 				if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
 					industrialList[k].IsResearch = true
 				}
+				industryIds = append(industryIds, v.IndustrialManagementId)
 				industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
 			}
+
+			// 查研观向7.4-行业新标签
+			industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
+				return
+			}
+
 			//判断产业下是否有关联的报告,并处理是否跳转
 			industrialManagementId = strings.TrimRight(industrialManagementId, ",")
 			if industrialManagementId != "" {
 				var condition string
 				condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
+				condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
 				listIndustrialGrop, err := models.GetSearchResourceList(condition)
 				if err != nil && err.Error() != utils.ErrNoRow() {
 					br.Msg = "获取信息失败"
@@ -945,9 +962,10 @@ func (this *ActivityCoAntroller) Detail() {
 					}
 				}
 				for k, v := range industrialList {
-					if mapIndustrial[v.IndustrialManagementId] > 0 {
+					if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
 						industrialList[k].IsJump = true
 					}
+					industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
 				}
 			}
 		}
@@ -979,6 +997,7 @@ func (this *ActivityCoAntroller) Detail() {
 
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)
+
 	}
 	resp.HasPermission = hasPermission
 	br.Ret = 200
@@ -2034,6 +2053,10 @@ func (this *ActivityCoAntroller) LabelList() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if activityTypeIds == "undefined" {
 		activityTypeIds = ""
 	}
@@ -2387,6 +2410,10 @@ func (this *ActivityCoAntroller) LabelTypeList() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if whichDay == "undefined" {
 		whichDay = ""
 	}
@@ -2732,6 +2759,7 @@ func (this *ActivityCoAntroller) LabelMoreList() {
 // @Param   IsPower   query   int  false       "是否选择有权限行业 ,1是 0 否 默认0"
 // @Param   PlayBack   query   int  false       "是否仅展示回放 1:是、0:否 默认0"
 // @Param   KeyWord   query   string  false       "搜索关键词 多个用 , 隔开"
+// @Param   ActivityId   query   int  false       "活动列表传过来的活动ID"
 // @Success 200 {object} models.GetCygxActivityListRep
 // @router /listNew [get]
 func (this *ActivityCoAntroller) ActivityListNew() {
@@ -2757,12 +2785,19 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	activityTypeId := this.GetString("ActivityTypeId")
 	keyWord := this.GetString("KeyWord")
 	playBack, _ := this.GetInt("PlayBack")
+	activityId, _ := this.GetInt("ActivityId")	// 仅用于判断【新】标签
+
 	if label == "undefined" {
 		label = ""
 	}
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
+
 	if whichDay == "undefined" {
 		whichDay = ""
 	}
@@ -2964,10 +2999,49 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 		}
 		resp.List = append(resp.List, services.ActivityButtonShow(v))
 	}
+
+	// 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
+	if label != "" {
+		industry, e := models.GetIndustryByName(label)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
+			return
+		}
+		if industry != nil {
+			sourceIndustry, e := models.GetSourceIndustryByName(label)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
+				return
+			}
+			if sourceIndustry != nil {
+				resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
+				resp.IsJump = true
+				// 研选产业不跳资源包
+				if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
+					resp.IsJump = false
+				}
+			}
+		}
+		// 新标签
+		if activityId > 0 {
+			activityIds := []int{activityId}
+			activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
+				return
+			}
+			resp.IndustryNewLabel = activityNewMap[activityId]
+		}
+	}
+
 	//添加活动搜索记录
 	if keyWord != "" {
 		go services.AddActivitykeyWordSearch(keyWord, user)
 	}
+
 	resp.Paging = page
 	br.Ret = 200
 	br.Success = true
@@ -3007,6 +3081,10 @@ func (this *ActivityCoAntroller) LabelTypeListPc() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if whichDay == "undefined" {
 		whichDay = ""
 	}
@@ -3380,6 +3458,7 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 	chartPermissionIds := this.GetString("ChartPermissionIds")
 	whichDay := this.GetString("WhichDay")
 	activeState := this.GetString("ActiveState")
+
 	//入参为 undefined 时的处理
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
@@ -3390,6 +3469,12 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 	if activeState == "undefined" || activeState == "" {
 		activeState = "1"
 	}
+
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
+
 	//adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
 	//if err != nil {
 	//	br.Msg = "获取失败"
@@ -3423,6 +3508,14 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 	permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
 	permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
 	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
+
+	// 查研观向7.4-始终查询宏观的权限(无论是否有权限)
+	if permissionNameStr == `` {
+		permissionNameStr = `'宏观'`
+	} else {
+		permissionNameStr += `, '宏观'`
+	}
+
 	list, err := models.GetActivityTypeHomeList()
 	if err != nil {
 		br.Msg = "获取失败"
@@ -3523,12 +3616,17 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		itemList.ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl2
 		list = append(list, itemList)
 	}
+
 	//获取对应活动的数量并排序
+	activityIds := make([]int, 0)	// 用于查询活动【新】标签Map
 	intArr := make([]int, 0)
 	var items []*models.ActivityTypeHome
 	for _, v := range list {
 		item := new(models.ActivityTypeHome)
 		if len(v.List) > 0 {
+			for i := range v.List {
+				activityIds = append(activityIds, v.List[i].ActivityId)
+			}
 			item.List = v.List
 			item.ActivityTypeName = v.ActivityTypeName
 			item.ActivityTypeId = v.ActivityTypeId
@@ -3540,6 +3638,20 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		}
 	}
 	sort.Sort(sort.Reverse(sort.IntSlice(intArr)))
+
+	// 活动【新】标签Map
+	newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
+		return
+	}
+	for k := range list {
+		for k2 := range list[k].List {
+			list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
+		}
+	}
+
 	var itemsNew []*models.ActivityTypeHome
 	activityMap := make(map[int]int)
 	for _, v := range intArr {
@@ -4361,12 +4473,17 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if whichDay == "undefined" {
 		whichDay = ""
 	}
 	if activeState == "undefined" || activeState == "" || activeState == "1" {
 		activeState = "1,2"
 	}
+
 	//adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
 	//if err != nil {
 	//	br.Msg = "获取失败"
@@ -4402,6 +4519,14 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 	permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
 	permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
 	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
+
+	// 查研观向7.4-始终查询宏观的权限(无论是否有权限)
+	if permissionNameStr == `` {
+		permissionNameStr = `'宏观'`
+	} else {
+		permissionNameStr += `, '宏观'`
+	}
+
 	list, err := models.GetActivityTypeHomeListPc()
 	if err != nil {
 		br.Msg = "获取失败"
@@ -4507,17 +4632,41 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 		itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
 		list = append(list, itemList)
 	}
+
+	// 查研观向7.4-活动【新】标签
+	activityIds := make([]int, 0)
+	for _, v := range list {
+		if len(v.List) > 0 {
+			for i := range v.List {
+				activityIds = append(activityIds, v.List[i].ActivityId)
+			}
+		}
+	}
+	newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
+		return
+	}
+	for k := range list {
+		for k2 := range list[k].List {
+			list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
+		}
+	}
+
 	//记录用户搜索的筛选条件
-	item := new(models.CygxActivitySearchHistory)
-	item.UserId = user.UserId
-	item.Mobile = user.Mobile
-	item.CompanyId = user.CompanyId
-	item.CompanyName = user.CompanyName
-	item.CreateTime = time.Now()
-	item.ChartPermissionIds = chartPermissionIds
-	item.IsPower = isPower
-	item.WhichDay = whichDay
-	go models.AddCygxActivitySearchHistory(item)
+	{
+		item := new(models.CygxActivitySearchHistory)
+		item.UserId = user.UserId
+		item.Mobile = user.Mobile
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.CreateTime = time.Now()
+		item.ChartPermissionIds = chartPermissionIds
+		item.IsPower = isPower
+		item.WhichDay = whichDay
+		go models.AddCygxActivitySearchHistory(item)
+	}
 
 	resp.List = list
 	br.Ret = 200

+ 85 - 7
controllers/report.go

@@ -78,6 +78,8 @@ func (this *ReportController) TradeList() {
 // @Param   IsDeepLabel   query   string  true       "是否属于深标签,1是,0否"
 // @Param   KeyWord   query   string  true       "搜索关键词"
 // @Param   OrderColumn   query   int  true       "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
+// @Param   DeepCover   query   int  false       "深度覆盖:0-否;1-是"
+// @Param   RecommendFocus   query   int  false       "推荐关注:0-否;1-是"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Success 200 {object} models.IndustrialManagementList
@@ -105,6 +107,8 @@ func (this *ReportController) IndustryList() {
 	keyWord := this.GetString("KeyWord")
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
+	deepCover, _ := this.GetInt("DeepCover")
+	recommendFocus, _ := this.GetInt("RecommendFocus")
 	var orderSrt string
 	var condition string
 	var startSize int
@@ -162,6 +166,39 @@ func (this *ReportController) IndustryList() {
 		sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
 		condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
 	}
+	// 深度覆盖
+	if deepCover == 1 {
+		// 查询深标签产业报告数
+		var deepCondition string
+		var deepPars []interface{}
+		deepCondition += ` AND man.is_deep_label = 1`
+		if ChartPermissionId > 0 {
+			deepCondition += ` AND man.chart_permission_id = ?`
+			deepPars = append(deepPars, ChartPermissionId)
+		}
+		industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
+		if e != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
+			return
+		}
+		deepIdArr := make([]string, 0)
+		for i := range industryCountList {
+			if industryCountList[i].ArtNum > 10 {
+				deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
+			}
+		}
+		deepIds := strings.Join(deepIdArr, ",")
+		if deepIds != "" {
+			condition = `AND man.industrial_management_id IN (` + deepIds + `)`
+		}
+	}
+	// 推荐关注
+	if recommendFocus == 1 {
+		condition += ` AND man.recommended_index >= 50`
+	}
+
+	// 列表总数据量
 	var list []*models.IndustrialManagement
 	total, err := models.GetIndustrialManagementAllCount(condition)
 	if err != nil {
@@ -170,6 +207,7 @@ func (this *ReportController) IndustryList() {
 		return
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
+
 	if orderColumn == "" {
 		orderColumn = "NewTime"
 	}
@@ -181,19 +219,40 @@ func (this *ReportController) IndustryList() {
 	if ChartPermissionId == 0 {
 		ChartPermissionId = 20
 	}
-	detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取信息失败,Err:" + err.Error()
-		return
-	}
 
+	// 阅读第三的产业详情
+	//detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取信息失败,Err:" + err.Error()
+	//	return
+	//}
 	list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	// 获取近一个月产业报告阅读次数最多的产业
+	var topCond string
+	var topPars []interface{}
+	topReadIndustryId := 0
+	if ChartPermissionId > 0 {
+		topCond += ` AND chart_permission_id = ?`
+		topPars = append(topPars, ChartPermissionId)
+	}
+	topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
+		return
+	}
+	if topReadIndustry != nil {
+		topReadIndustryId = topReadIndustry.IndustrialManagementId
+	}
+
+	nowTime := time.Now().Local()
+	threeMonBefore := nowTime.AddDate(0, -3, 0)
 	for k, v := range list {
 		industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
 		if err != nil {
@@ -219,9 +278,28 @@ func (this *ReportController) IndustryList() {
 		if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
 			list[k].IsRed = true
 		}
-		if v.ArticleReadNum >= detailHot3.ArticleReadNum {
+		// 原:关联的报告阅读量大于等于阅读第三的产业,则标记热门
+		//if v.ArticleReadNum >= detailHot3.ArticleReadNum {
+		//	list[k].IsHot = true
+		//}
+
+		// 近一个月报告阅读次数最多的产业标记Hot
+		if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
 			list[k].IsHot = true
 		}
+
+		// 关联报告发布时间均在3个月内则标记New
+		if v.MinReportTime != "" {
+			t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "报告最早发布时间有误, Err: " + e.Error()
+				return
+			}
+			if t.After(threeMonBefore) {
+				list[k].IsNew = true
+			}
+		}
 	}
 	//记录用户搜索的筛选条件
 	if orderColumnNew != "" {

+ 141 - 138
controllers/report_billboard.go

@@ -4,8 +4,6 @@ import (
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
-	"strconv"
-	"strings"
 	"time"
 )
 
@@ -43,7 +41,7 @@ func (this *ReportBillboardController) CompanyTableList() {
 
 // @Title 产业关注榜
 // @Description 获取产业关注榜接口
-// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Param   ChartPermissionId   query   int  false       "行业ID"
 // @Success 200 {object} models.IndustrialManagementList
 // @router /industry/fllowList [get]
 func (this *ReportBillboardController) FllowList() {
@@ -59,80 +57,98 @@ func (this *ReportBillboardController) FllowList() {
 		return
 	}
 	uid := user.UserId
-	pageSize, _ := this.GetInt("PageSize")
-	currentIndex, _ := this.GetInt("CurrentIndex")
-	var startSize int
-	if pageSize <= 0 {
-		pageSize = utils.PageSize15
-	}
-	if currentIndex <= 0 {
-		currentIndex = 1
-	}
+	// 行业ID暂时不需要了调整为非必填
 	chartPermissionId, _ := this.GetInt("ChartPermissionId")
-	if chartPermissionId < 1 {
-		br.Msg = "请输入行业ID"
+
+	// 查询有已归类行业报告的行业IDs
+	activeIndustryIds, e := models.GetActiveArticleIndustryIds()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
 		return
 	}
-	var condition string
-	var pars []interface{}
-	var orderSrt string
-	var industrialManagementIds string
-	condition += ` 	AND man.chart_permission_id = ?  `
-	pars = append(pars, chartPermissionId)
-	orderSrt = " man.user_fllow_num DESC  " // 排序方式
-	list, err := models.GetIndustrialManagementFllowBillboard(pars, condition, orderSrt, startSize, pageSize)
-	if err != nil {
+	activeIndustryLen := len(activeIndustryIds)
+
+	topNum := utils.PageSize15
+	var condition, subCond string
+	var pars, subPars []interface{}
+	if chartPermissionId > 0 {
+		condition += ` 	AND man.chart_permission_id = ?  `
+		pars = append(pars, chartPermissionId)
+	}
+	if activeIndustryLen > 0 {
+		condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
+		pars = append(pars, activeIndustryIds)
+	}
+	nowTime := time.Now().Local()
+	startTime := nowTime.AddDate(0, -1, 0)
+	endTime := nowTime.AddDate(0, 0, -1)
+	condition += ` AND idf.create_time BETWEEN ? AND ?`
+	pars = append(pars, startTime, endTime)
+
+	// 查询近一个月至昨日关注度最高的15个产业(不再指定行业, chartPermissionId可筛选行业)
+	list, e := models.GetTopIndustryFollowData(0, topNum, condition, pars)
+	if e != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,GetIndustrialManagementFllowBillboard Err:" + err.Error()
+		br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
 		return
 	}
-	fllowList, err := models.GetUserFllowIndustrialList(uid)
+	industryIdArr := make([]int, 0)
+	for i := range list {
+		industryIdArr = append(industryIdArr, list[i].IndustrialManagementId)
+	}
+	idsLen := len(industryIdArr)
+
+	// 查询当前用户关注的产业
+	followList, err := models.GetUserFllowIndustrialList(uid)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
 		return
 	}
-	fllowMap := make(map[int]int)
-	if len(fllowList) > 0 {
-		for _, v := range fllowList {
-			fllowMap[v.IndustrialManagementId] = uid
-		}
+	followMap := make(map[int]int, 0)
+	for i := range followList {
+		followMap[followList[i].IndustrialManagementId] = 1
 	}
-	for k, v := range list {
-		if fllowMap[v.IndustrialManagementId] > 0 {
-			list[k].IsFollow = 1
-		}
-		industrialManagementIds += strconv.Itoa(v.IndustrialManagementId) + ","
-	}
-	industrialManagementIds = strings.TrimRight(industrialManagementIds, ",")
-	silceindustrialManagementIds := strings.Split(industrialManagementIds, ",")
-	//获取关联的标的
-	pars = make([]interface{}, 0)
-	industrialIdList := make([]string, 0)
-	for _, v := range silceindustrialManagementIds {
-		industrialIdList = append(industrialIdList, v)
+
+	// 查询产业标的
+	if idsLen > 0 {
+		subCond = `AND s.industrial_management_id IN (  ` + utils.GetOrmInReplace(idsLen) + ` )  `
+		subPars = append(subPars, industryIdArr)
 	}
-	condition = `AND s.industrial_management_id IN (  ` + utils.GetOrmInReplace(len(silceindustrialManagementIds)) + ` )  `
-	pars = append(pars, industrialIdList)
-	subjectList, err := models.GetSubjectList(pars, condition)
+	subjectList, err := models.GetSubjectList(subPars, subCond)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
 		return
 	}
 	subjectMap := make(map[int][]*models.IndustrialSubject)
-	if len(fllowList) > 0 {
-		for _, v := range subjectList {
-			item := new(models.IndustrialSubject)
-			item.SubjectName = v.SubjectName
-			item.IndustrialManagementId = v.IndustrialManagementId
-			subjectMap[v.IndustrialManagementId] = append(subjectMap[v.IndustrialManagementId], item)
-		}
+	for i := range subjectList {
+		item := new(models.IndustrialSubject)
+		item.SubjectName = subjectList[i].SubjectName
+		item.IndustrialManagementId = subjectList[i].IndustrialManagementId
+		subjectMap[subjectList[i].IndustrialManagementId] = append(subjectMap[subjectList[i].IndustrialManagementId], item)
+	}
+
+	// 查询行业
+	permissionList, e := models.GetChartPermissionAll("")
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取行业信息失败, Err: " + e.Error()
+		return
 	}
+	permissionMap := make(map[int]string, 0)
+	for i := range permissionList {
+		permissionMap[permissionList[i].ChartPermissionId] = permissionList[i].PermissionName
+	}
+
 	for k, v := range list {
+		list[k].IsFollow = followMap[v.IndustrialManagementId]
 		list[k].IndustrialSubjectList = subjectMap[v.IndustrialManagementId]
+		list[k].PermissionName = permissionMap[v.ChartPermissionId]
 	}
-	page := paging.GetPaging(currentIndex, pageSize, len(list))
+
+	page := paging.GetPaging(1, topNum, len(list))
 	resp := new(models.IndustrialManagementList)
 	resp.List = list
 	resp.Paging = page
@@ -144,7 +160,7 @@ func (this *ReportBillboardController) FllowList() {
 
 // @Title 阅读飙升榜/报告收藏榜
 // @Description 获取阅读飙升榜/报告收藏榜接口
-// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Param   ChartPermissionId   query   int  false       "分类ID"
 // @Param   Source   query   int  true       "来源 2:阅读飙升 ,3:报告收藏"
 // @Success 200 {object} models.ArticleReportBillboardLIstResp
 // @router /industry/readList [get]
@@ -162,109 +178,96 @@ func (this *ReportBillboardController) ReadList() {
 	}
 	chartPermissionId, _ := this.GetInt("ChartPermissionId")
 	source, _ := this.GetInt("Source")
-	var list []*models.ArticleReportBillboardResp
-	if chartPermissionId < 1 {
-		br.Msg = "请输入行业ID"
+	sourceArr := []int{2, 3}
+	if !utils.InArrayByInt(sourceArr, source) {
+		br.Msg = "来源有误"
 		return
 	}
-	var err error
-	var condition string
-	var pars []interface{}
-	condition += ` 	AND m.chart_permission_id = ?  `
-	pars = append(pars, chartPermissionId)
+
+	topNum := utils.PageSize15
+	list := make([]*models.ArticleReportBillboardResp, 0)
+
+	// 阅读飙升榜
 	if source == 2 {
-		//阅读飙升榜
-		var conditionPv string
-		var articleTopIds string
-		conditionPv = condition
-		dateTime := time.Now().AddDate(0, 0, -15).Format(utils.FormatDate)
-		conditionPv += `  AND l.create_time > ?   AND l.create_time <  ?  `
-		pars = append(pars, dateTime, time.Now().Format(utils.FormatDate))
-		listTop, err := models.GetCygxArticleHistoryAllTop(pars, conditionPv)
-		if err != nil {
+		var topCond string
+		var topPars []interface{}
+		if chartPermissionId > 0 {
+			topCond += ` AND chart_permission_id = ?`
+			topPars = append(topPars, chartPermissionId)
+		}
+		topList, e := models.GetTopReadRecordArticleListByCondition(topNum, topCond, topPars)
+		if e != nil {
 			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,GetCygxArticleHistoryAllTop Err:" + err.Error()
+			br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + e.Error()
 			return
 		}
-		for _, v := range listTop {
-			articleTopIds += strconv.Itoa(v.ArticleId) + ","
-			item := new(models.ArticleReportBillboardResp)
-			item.ArticleId = v.ArticleId
-			list = append(list, item)
+		for i := range topList {
+			list = append(list, &models.ArticleReportBillboardResp{
+				ArticleId:      topList[i].ArticleId,
+				Title:          topList[i].Title,
+				PublishDate:    topList[i].PublishDate,
+				PermissionName: topList[i].PermissionName,
+			})
 		}
-		articleTopIds = strings.TrimRight(articleTopIds, ",")
-		//获取文章关联的产业
-		pars = make([]interface{}, 0)
-		articleIdList := make([]string, 0)
-		silcearticleIds := strings.Split(articleTopIds, ",")
-		for _, v := range silcearticleIds {
-			articleIdList = append(articleIdList, v)
+	}
+
+	// 报告收藏榜
+	if source == 3 {
+		var collectCond string
+		var collectPars []interface{}
+		if chartPermissionId > 0 {
+			collectCond += ` AND m.chart_permission_id = ?`
+			collectPars = append(collectPars, chartPermissionId)
 		}
-		condition = ` AND a.article_id IN (  ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` )  `
-		pars = append(pars, articleIdList)
-		condition += ` 	AND m.chart_permission_id = ?  `
-		pars = append(pars, chartPermissionId)
-		listPv, err := models.GetReportPvBillboardList(pars, condition)
-		if err != nil {
+		// 根据关注时间一个月前至昨日的增量数据排序
+		nowTime := time.Now().Local()
+		startTime := nowTime.AddDate(0, -1, 0)
+		endTime := nowTime.AddDate(0, 0, -1)
+		collectCond += ` AND ac.create_time BETWEEN ? AND ?`
+		collectPars = append(collectPars, startTime, endTime)
+		collectList, e := models.GetReportCollectionBillboardList(topNum, collectPars, collectCond)
+		if e != nil {
 			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,GetReportPvBillboardList Err:" + err.Error()
+			br.ErrMsg = "获取报告收藏排行榜失败, Err:" + e.Error()
 			return
 		}
-		//按照查询出来的顺序赋值
-		mapPv := make(map[int]*models.ArticleReportBillboardResp)
-		for _, v := range listPv {
-			mapPv[v.ArticleId] = v
-		}
-		for k, v := range list {
-			list[k] = mapPv[v.ArticleId]
-		}
-	} else {
-		//获取报告收藏
-		condition += `GROUP BY	a.article_id ORDER BY a.user_collection_num DESC,	ac.id DESC,	a.publish_date DESC LIMIT 15   `
-		list, err = models.GetReportCollectionBillboardList(pars, condition)
-	}
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
-		return
-	}
-	var articleIds string
-	for _, v := range list {
-		articleIds += strconv.Itoa(v.ArticleId) + ","
-	}
-	articleIds = strings.TrimRight(articleIds, ",")
-	silcearticleIds := strings.Split(articleIds, ",")
-	//获取文章关联的产业
-	pars = make([]interface{}, 0)
-	articleIdList := make([]string, 0)
-	for _, v := range silcearticleIds {
-		articleIdList = append(articleIdList, v)
+		list = collectList
 	}
-	condition = ` AND mg.article_id IN (  ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` )  `
-	pars = append(pars, articleIdList)
-	industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
-		return
+	articleIds := make([]int, 0)
+	for i := range list {
+		articleIds = append(articleIds, list[i].ArticleId)
 	}
-	industrialMap := make(map[int][]*models.IndustrialManagementIdInt)
-	if len(industrialList) > 0 {
-		for _, v := range industrialList {
-			item := new(models.IndustrialManagementIdInt)
-			item.ArticleId = v.ArticleId
-			item.IndustrialManagementId = v.IndustrialManagementId
-			item.IndustryName = v.IndustryName
-			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
+
+	// 报告关联产业信息
+	industryMap := make(map[int][]*models.IndustrialManagementIdInt, 0)
+	if len(articleIds) > 0 {
+		var industryCond string
+		var industryPars []interface{}
+		industryCond += ` AND mg.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+		industryPars = append(industryPars, articleIds)
+		industryList, e := models.GetIndustrialListByarticleId(industryPars, industryCond)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取报告关联的产业信息失败, Err: " + e.Error()
+			return
+		}
+		for i := range industryList {
+			v := industryList[i]
+			industryMap[v.ArticleId] = append(industryMap[v.ArticleId], &models.IndustrialManagementIdInt{
+				ArticleId:              v.ArticleId,
+				IndustrialManagementId: v.IndustrialManagementId,
+				IndustryName:           v.IndustryName,
+			})
 		}
 	}
 	for k, v := range list {
-		if len(industrialMap[v.ArticleId]) > 0 {
-			list[k].List = industrialMap[v.ArticleId]
+		if len(industryMap[v.ArticleId]) > 0 {
+			list[k].List = industryMap[v.ArticleId]
 		} else {
 			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
 		}
 	}
+
 	resp := new(models.ArticleReportBillboardLIstResp)
 	resp.List = list
 	br.Ret = 200

+ 10 - 5
models/activity.go

@@ -265,10 +265,14 @@ type CygxActivityList struct {
 }
 
 type GetCygxActivityListRep struct {
-	Paging *paging.PagingItem `description:"分页数据"`
-	List   []*ActivityDetail
-	Label  string `description:"主题"`
-	ImgUrl string `description:"图片路径"`
+	Paging                 *paging.PagingItem `description:"分页数据"`
+	List                   []*ActivityDetail
+	Label                  string `description:"主题"`
+	ImgUrl                 string `description:"图片路径"`
+	IsResearch             bool   `description:"是否属于研选"`
+	IsJump                 bool   `description:"是否跳转"`
+	IndustrialManagementId int    `description:"产业ID"`
+	IndustryNewLabel       bool   `description:"产业是否新标签"`
 }
 
 //列表
@@ -613,12 +617,13 @@ type CygxActivityLabelList struct {
 	IsShowSubjectName int    `description:"小程序内是否展示标的名称 1是 ,0否 默认0 "`
 	Resource          int    `description:"位置 ,1:活动 ,2:专项产业调研"`
 	TemporaryLabel    string `description:"临时标签"`
+	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
 }
 
 //主题列表
 func GetActivityLabelListAll(condition, sortTime string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT	label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort 
+	sql := `SELECT	activity_id, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort 
 		FROM cygx_activity as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition

+ 85 - 0
models/article_top_history_record.go

@@ -0,0 +1,85 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// ArticleTopHistoryRecord 报告阅读飙升榜
+type ArticleTopHistoryRecord struct {
+	Id                int       `orm:"column(id);pk"`
+	ArticleId         int       `description:"文章ID"`
+	Title             string    `description:"文章标题"`
+	PublishDate       string    `description:"发布日期"`
+	ChartPermissionId int       `description:"行业ID"`
+	PermissionName    string    `description:"行业名称"`
+	Pv                int       `description:"PV"`
+	CreateTime        time.Time `description:"创建时间"`
+}
+
+func (item *ArticleTopHistoryRecord) TableName() string {
+	return "cygx_article_top_history_record"
+}
+
+// GetTopReadRecordArticleListFromSource 获取阅读量排行榜源报告
+func GetTopReadRecordArticleListFromSource(startTime, endTime time.Time) (list []*ArticleTopHistoryRecord, err error) {
+	sql := `SELECT
+				a.article_id,
+				a.title,
+				date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
+				m.chart_permission_id,
+				m.chart_permission_name as permission_name,
+				COUNT(1) AS pv
+			FROM
+				cygx_article_history_record_newpv AS l
+			JOIN cygx_article AS a ON a.article_id = l.article_id
+			JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
+			WHERE
+				a.publish_status = 1 AND l.create_time BETWEEN ? AND ?
+			GROUP BY
+				l.article_id
+			ORDER BY
+				pv DESC,
+				a.publish_date DESC`
+	_, err = orm.NewOrm().Raw(sql, startTime, endTime).QueryRows(&list)
+	return
+}
+
+// UpdateTopReadRecordArticleList 更新榜单
+func UpdateTopReadRecordArticleList(items []*ArticleTopHistoryRecord) (err error) {
+	o := orm.NewOrm()
+	tx, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = tx.Rollback()
+		} else {
+			_ = tx.Commit()
+		}
+	}()
+	// 重置榜单
+	sql := `DELETE FROM cygx_article_top_history_record WHERE 1 = 1 `
+	_, err = tx.Raw(sql).Exec()
+	if err != nil {
+		return
+	}
+	// 新增今日榜单
+	_, err = tx.InsertMulti(len(items), items)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// GetTopReadRecordArticleListByCondition 获取阅读量排行榜
+func GetTopReadRecordArticleListByCondition(limit int, condition string, pars []interface{}) (list []*ArticleTopHistoryRecord, err error) {
+	sql := `SELECT * FROM cygx_article_top_history_record WHERE 1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` ORDER BY pv DESC, publish_date DESC LIMIT ?`
+	_, err = orm.NewOrm().Raw(sql, pars, limit).QueryRows(&list)
+	return
+}

+ 2 - 0
models/db.go

@@ -118,6 +118,8 @@ func init() {
 		new(CygxIndustrialActivityGroupSubject),
 		new(CygxActivityVoiceHistory),
 		new(CygxThreeApiLog),
+		new(CygxIndustrialArticleGroupManagement),
+		new(ArticleTopHistoryRecord),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 17 - 0
models/industrial_activity_group_management.go

@@ -66,3 +66,20 @@ func AddCygxActiuvityGroupMulti(items []*CygxIndustrialActivityGroupManagement,
 	}
 	return
 }
+
+// GetActivityIndustryRelationList 获取活动与产业关联列表
+func GetActivityIndustryRelationList(condition string, pars []interface{}) (list []*CygxIndustrialActivityGroupManagement, err error) {
+	sql := `SELECT
+				a.activity_id,
+				b.industrial_management_id
+			FROM
+				cygx_activity AS a
+			JOIN cygx_industrial_activity_group_management AS b ON a.activity_id = b.activity_id
+			WHERE
+				1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 65 - 0
models/industrial_article_group_management.go

@@ -0,0 +1,65 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxIndustrialArticleGroupManagement struct {
+	Id                     int       `orm:"column(id);pk" description:"主键ID"`
+	CygxArticleId          int       `description:"cygx_article表id"`
+	ArticleId              int       `description:"文章ID"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	Source                 int       `description:"来源,1 活动,2专项调研"`
+	CreateTime             time.Time `description:"创建时间"`
+}
+
+// IndustryArtCount 产业文章数
+type IndustryArtCount struct {
+	ArtNum                 int `json:"art_num" description:"文章数"`
+	IndustrialManagementId int `json:"industrial_management_id" description:"产业ID"`
+}
+
+// GetIndustryArtCountByCondition 获取产业文章关联的文章数
+func GetIndustryArtCountByCondition(condition string, pars []interface{}) (list []*IndustryArtCount, err error) {
+	sql := `SELECT
+				COUNT(1) AS art_num,
+				agm.industrial_management_id
+			FROM
+				cygx_industrial_article_group_management AS agm
+			JOIN cygx_industrial_management AS man ON man.industrial_management_id = agm.industrial_management_id
+			WHERE
+				1 = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY agm.industrial_management_id`
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}
+
+// IndustryArticleMinMaxPublishTime 产业文章最大最小发布时间
+type IndustryArticleMinMaxPublishTime struct {
+	IndustrialManagementId int       `description:"产业ID"`
+	MinPublishTime         time.Time `description:"文章最小发布时间"`
+	MaxPublishTime         time.Time `description:"文章最大发布时间"`
+}
+
+// GetIndustryArticleMinMaxPublishTime 获取产业文章最大最小发布时间
+func GetIndustryArticleMinMaxPublishTime(condition string, pars []interface{}) (list []*IndustryArticleMinMaxPublishTime, err error) {
+	sql := `SELECT
+				a.industrial_management_id,
+				MIN(b.publish_date) AS min_publish_time,
+				MAX(b.publish_date) AS max_publish_time
+			FROM
+				cygx_industrial_article_group_management AS a
+			JOIN cygx_article AS b ON a.article_id = b.article_id
+			WHERE
+				1 = 1`
+	if condition != `` {
+		sql += condition
+	}
+	sql += `GROUP BY a.industrial_management_id`
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 74 - 11
models/industrial_management.go

@@ -18,6 +18,7 @@ type IndustrialManagementRep struct {
 	ArticleReadNum         int    `description:"文章阅读数量"`
 	IsResearch             bool   `description:"是否属于研选"`
 	IsJump                 bool   `description:"是否跳转"`
+	IndustryNewLabel       bool   `description:"是否产业新标签"`
 }
 
 type IndustrialManagementCount struct {
@@ -61,7 +62,7 @@ func GetIndustrialManagementAll(uid int, condition, orderSrt string, startSize,
 	o := orm.NewOrm()
 	sql := `SELECT
 			man.*,
-            MAX( art.publish_date ) AS update_time ,(
+            MAX( art.publish_date ) AS update_time , MIN(art.publish_date) AS min_report_time,(
 			SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(uid) + ` AND rec.article_id = art.article_id ) AS readnum ,
 		    (SELECT COUNT( 1 )  FROM cygx_industry_fllow AS f WHERE f.user_id = ` + strconv.Itoa(uid) + ` AND f.industrial_management_id = man.industrial_management_id AND f.type = 1) AS is_follow
 			FROM
@@ -171,15 +172,23 @@ func GetIndustrialManagementDetail(industrialManagementId int) (items *Industria
 func GetIndustrialNewArticleDetail(industrialManagementId int) (item *ArticleDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-	* 
-FROM
-	cygx_article 
-WHERE
-	article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? )
-ORDER BY
-	is_report DESC,
-	publish_date DESC 
-	LIMIT 0,1`
+				*
+			FROM
+				cygx_article
+			WHERE
+				article_id IN (
+					SELECT
+						article_id
+					FROM
+						cygx_industrial_article_group_management
+					WHERE
+						industrial_management_id = ?
+				)
+			AND is_class = 1 AND is_report = 1
+			ORDER BY
+				is_report DESC,
+				publish_date DESC
+			LIMIT 0,1`
 	err = o.Raw(sql, industrialManagementId).QueryRow(&item)
 	return
 }
@@ -301,7 +310,7 @@ func IndustrialManagementAll() (items []*IndustrialManagement, err error) {
 
 func GetIndustrialManagementArtCount(industrialManagementId int) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  
-	 			FROM  cygx_article_history_record AS h
+	 			FROM  cygx_article_history_record_newpv AS h
 				INNER JOIN cygx_industrial_article_group_management as mg ON  mg.article_id = h.article_id
 				WHERE mg.industrial_management_id = ?  AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( h.create_time ) `
 	o := orm.NewOrm()
@@ -558,3 +567,57 @@ func GetindustrialManagement() (items []*IndustrialManagementRep, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// GetActiveArticleIndustryIds 获取有已归类行业报告的行业IDs
+func GetActiveArticleIndustryIds() (ids []int, err error) {
+	sql := `SELECT
+				man.industrial_management_id
+			FROM
+				cygx_industrial_management AS man
+			JOIN cygx_report_mapping AS re ON re.chart_permission_id = man.chart_permission_id
+			JOIN cygx_industrial_article_group_management AS man_g ON man_g.industrial_management_id = man.industrial_management_id
+			JOIN cygx_article AS art ON art.article_id = man_g.article_id
+			WHERE
+				1 = 1 AND re.report_type = 2 AND art.is_report = 1 AND art.is_class = 1 AND art.publish_status = 1
+			GROUP BY
+				man.industrial_management_id`
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&ids)
+	return
+}
+
+// GetTopOneMonthArtReadNumIndustry 获取近一个月报告阅读数量最多的产业信息
+func GetTopOneMonthArtReadNumIndustry(condition string, pars []interface{}) (item *IndustrialManagement, err error) {
+	sql := `SELECT * FROM cygx_industrial_management WHERE 1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` ORDER BY article_read_num DESC LIMIT 1`
+	err = orm.NewOrm().Raw(sql, pars).QueryRow(&item)
+	return
+}
+
+// GetSourceIndustryByName 通过名称获取资源包产业
+func GetSourceIndustryByName(industryName string) (item *IndustrialManagement, err error) {
+	sql := `SELECT
+				m.industry_name,
+				m.industrial_management_id,
+				m.chart_permission_id
+			FROM
+				cygx_industrial_management AS m
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
+			INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
+			WHERE
+				1 = 1 AND m.industry_name = ? AND a.publish_status = 1 AND a.article_id < 1000000
+			GROUP BY
+				m.industrial_management_id`
+	err = orm.NewOrm().Raw(sql, industryName).QueryRow(&item)
+	return
+}
+
+
+// GetIndustryByName 通过名称获取产业
+func GetIndustryByName(industryName string) (item *IndustrialManagement, err error) {
+	sql := `SELECT * FROM cygx_industrial_management WHERE industry_name = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, industryName).QueryRow(&item)
+	return
+}

+ 21 - 0
models/industry_fllow.go

@@ -157,3 +157,24 @@ func GetCountCygxIndustryFllowByUidAndChartPermissionId(userId, ChartPermissionI
 	err = orm.NewOrm().Raw(sql, userId, ChartPermissionId).QueryRow(&count)
 	return
 }
+
+// GetTopIndustryFollowData 获取关注度最高的产业关注数据
+func GetTopIndustryFollowData(startSize, pageSize int, condition string, pars []interface{}) (list []*IndustrialManagement, err error) {
+	sql := `SELECT
+				COUNT(1) AS one_month_follow_num,
+				man.*
+			FROM
+				cygx_industry_fllow AS idf
+			JOIN cygx_industrial_management AS man ON idf.industrial_management_id = man.industrial_management_id
+			WHERE 1 = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY
+				idf.industrial_management_id
+			ORDER BY
+				one_month_follow_num DESC
+			LIMIT ?,?`
+	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}

+ 24 - 14
models/report.go

@@ -19,14 +19,19 @@ type IndustrialManagement struct {
 	CategoryId             int                  `description:"文章分类ID"`
 	LayoutTime             string               `description:"布局时间"`
 	UpdateTime             string               `description:"更新时间"`
+	MinReportTime          string               `description:"报告最早发布时间"`
 	IsRed                  bool                 `description:"是否标记红点"`
 	IsTop                  bool                 `description:"是否置顶"`
-	IsHot                  bool                 `description:"是否是热门"`
+	IsHot                  bool                 `description:"是否是热门-近一个月内,产业下关联的报告阅读次数最多的"`
 	IsFollow               int                  `description:"是否关注"`
+	IsNew                  bool                 `description:"是否为新-关联报告的发布时间,均在3个月以内的"`
 	Analyst                string               `description:"分析师"`
 	ArticleReadNum         int                  `description:"文章阅读数量"`
+	OneMonFollowNum        int                  `description:"近一个月关注增量"`
 	AnalystList            []*IndustrialAnalyst `description:"分析师列表"`
 	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
+	ChartPermissionId      int                  `description:"行业ID"`
+	PermissionName         string               `description:"行业名称"`
 }
 
 type IndustrialAnalyst struct {
@@ -692,16 +697,17 @@ type ReportBillboardTableListResp struct {
 
 //报告榜单start
 type ArticleReportBillboardResp struct {
-	ArticleId    int    `description:"文章id"`
-	Title        string `description:"标题"`
-	PublishDate  string `description:"发布时间"`
-	DepartmentId int    `description:"作者Id"`
-	NickName     string `description:"作者昵称"`
-	IsCollect    bool   `description:"本人是否收藏"`
-	Pv           int    `description:"PV"`
-	CollectNum   int    `description:"收藏人数"`
-	Source       int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
-	List         []*IndustrialManagementIdInt
+	ArticleId      int    `description:"文章id"`
+	Title          string `description:"标题"`
+	PublishDate    string `description:"发布时间"`
+	PermissionName string `description:"行业名称"`
+	DepartmentId   int    `description:"作者Id"`
+	NickName       string `description:"作者昵称"`
+	IsCollect      bool   `description:"本人是否收藏"`
+	Pv             int    `description:"PV"`
+	CollectNum     int    `description:"收藏人数"`
+	Source         int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	List           []*IndustrialManagementIdInt
 }
 
 type ArticleReportBillboardLIstResp struct {
@@ -714,13 +720,15 @@ type ArticleReportBillboardLIstPageResp struct {
 }
 
 //报告收藏榜单列表
-func GetReportCollectionBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
+func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			ac.id,
 			a.article_id,
 			a.title,
-			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date 
+			date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
+			m.chart_permission_name AS permission_name,
+			COUNT(ac.id) AS collection_num
 		FROM
 			cygx_article AS a
 			INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
@@ -731,7 +739,9 @@ func GetReportCollectionBillboardList(pars []interface{}, condition string) (ite
 	if condition != "" {
 		sql += condition
 	}
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
+	sql += ` LIMIT ?`
+	_, err = o.Raw(sql, pars, limit).QueryRows(&items)
 	return
 }
 

+ 63 - 0
services/activity.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"github.com/tealeg/xlsx"
 	"hongze/hongze_cygx/models"
@@ -429,6 +430,11 @@ func CheckUserPowerByActivityChoose(user *models.WxUserItem, activityInfo *model
 
 // 校验用户报名的权限
 func GetHavePower(activityInfo *models.ActivityDetail, permissionStr, companyDetailStatus string, userType int) (havePower bool, err error) {
+	// 查研观向7.4-宏观活动不作权限限制
+	if activityInfo.ChartPermissionId == 1 {
+		havePower = true
+		return
+	}
 	if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 {
 		havePower = true
 	} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") {
@@ -501,6 +507,14 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 	permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
 	permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
 	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
+
+	// 查研观向7.4-始终查询宏观的权限(无论是否有权限)
+	if permissionNameStr == `` {
+		permissionNameStr = `'宏观'`
+	} else {
+		permissionNameStr += `, '宏观'`
+	}
+
 	var condition string
 	var conditionAdmin string
 	var conditionHz string // 弘则权限处理
@@ -531,6 +545,7 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 	if isPower == 1 {
 		condition += permissionSqlStr
 	}
+
 	//行业名称
 	if len(chartPermissionIds) > 0 {
 		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
@@ -1447,6 +1462,54 @@ func ActivityButtonShow(item *models.ActivityDetail) (articleDetail *models.Acti
 	return
 }
 
+// GetActivityNewLabelMap 获取活动【新】标签Map
+func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryNewMap map[int]bool, err error) {
+	labelMap = make(map[int]bool, 0)
+	industryNewMap = make(map[int]bool, 0)
+	if len(activityIds) == 0 {
+		return
+	}
+
+	// 获取活动关联的产业
+	var groupCond string
+	var groupPars []interface{}
+	groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
+	groupPars = append(groupPars, activityIds)
+	groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
+	if e != nil {
+		err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
+		return
+	}
+	activityIndustryMap := make(map[int][]int, 0)
+	industryIds := make([]int, 0)
+	for i := range groups {
+		industryIds = append(industryIds, groups[i].IndustrialManagementId)
+		activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
+	}
+
+	// 获取新产业Map
+	industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
+	if e != nil {
+		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
+		return
+	}
+
+	// 判断活动是否为新
+	for k := range industryLabelMap {
+		for k2, v2 := range activityIndustryMap {
+			if labelMap[k2] {
+				continue
+			}
+			// 活动的产业ID中存在一个新产业即为新活动
+			if utils.InArrayByInt(v2, k) {
+				labelMap[k2] = true
+			}
+		}
+	}
+
+	return
+}
+
 //GetActivityVoiceResp 处理活动音频回放
 func GetActivityVoiceResp(mapActivityId []int) (mapItem map[int]*models.CygxActivityVoiceReq, err error) {
 	activityVoiceList, err := models.GetCygxActivityVoiceReqList(mapActivityId)

+ 48 - 0
services/industrial_management.go

@@ -2,10 +2,12 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strings"
+	"time"
 )
 
 //修改标签状态
@@ -214,3 +216,49 @@ func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error)
 	}
 	return err
 }
+
+// GetIndustryNewLabelMap 获取产业【新】标签Map
+func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error) {
+	labelMap = make(map[int]bool, 0)
+	industryIdLen := len(industryIds)
+	if industryIdLen == 0 {
+		return
+	}
+
+	// 获取产业关联的报告最早发布时间及最近的发布时间
+	var timeCond string
+	var timePars []interface{}
+	timeCond += ` AND b.publish_status = 1`
+	if industryIdLen > 0 {
+		timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
+		timePars = append(timePars, industryIds)
+	}
+	industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
+	if e != nil {
+		err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
+		return
+	}
+
+	// 判断产业是否为新
+	nowTime := time.Now().Local()
+	threeMonthBefore := nowTime.AddDate(0, -3, 0)
+	nullTime, _ := time.ParseInLocation(utils.FormatDateTime, "0001-01-01 00:00:00", time.Local)
+	industryMap := make(map[int]*models.IndustryArticleMinMaxPublishTime, 0)
+	for i := range industryTimeList {
+		industryMap[industryTimeList[i].IndustrialManagementId] = industryTimeList[i]
+	}
+	for i := range industryIds {
+		iid := industryIds[i]
+		item := industryMap[iid]
+		if item != nil {
+			// 最早发布时间为空 / 最早发布时间在三个月前之后
+			if item.MinPublishTime.Equal(nullTime) || (item.MinPublishTime.After(threeMonthBefore)) {
+				labelMap[iid] = true
+			}
+		} else {
+			// 产业无报告, 则为新产业
+			labelMap[iid] = true
+		}
+	}
+	return
+}

+ 41 - 0
services/report_billboard.go

@@ -0,0 +1,41 @@
+package services
+
+import (
+	"context"
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+// UpdateDailyMonthReadBillboard 每日更新-月阅读飙升榜单
+func UpdateDailyMonthReadBillboard(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("查研观向-每日更新月阅读飙升榜单失败, ErrMsg: " + err.Error(), 3)
+		}
+	}()
+
+	// 获取上个月至昨日报告阅读增量最多的报告
+	nowTime := time.Now().Local()
+	startTime := nowTime.AddDate(0, -1, 0)
+	endTime := nowTime.AddDate(0, 0, -1)
+	list, e := models.GetTopReadRecordArticleListFromSource(startTime, endTime)
+	if e != nil {
+		err = errors.New("获取阅读量排行榜失败, Err: " + e.Error())
+		return
+	}
+	if len(list) == 0 {
+		return
+	}
+	for i := range list {
+		list[i].CreateTime = nowTime
+	}
+
+	// 清除昨日榜单并记录新榜单
+	if e = models.UpdateTopReadRecordArticleList(list); e != nil {
+		err = errors.New("更新阅读量排行榜失败, Err: " + e.Error())
+		return
+	}
+	return
+}

+ 8 - 0
services/task.go

@@ -90,6 +90,8 @@ func Task() {
 		dotongbuShangHai := task.NewTask("dotongbuShangHai", "0 */20 * * * *", DotongbuShangHai) //把信息同步到上海策略品台
 		task.AddTask("同步用户到上海", dotongbuShangHai)
 
+		updateDailyMonthReadBillboard := task.NewTask("updateDailyMonthReadBillboard", "0 0 3 * * *", UpdateDailyMonthReadBillboard) // 每日3:00更新阅读飙升榜单
+		task.AddTask("updateDailyMonthReadBillboard", updateDailyMonthReadBillboard)
 	}
 	if utils.RunMode != "release" {
 		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章
@@ -343,3 +345,9 @@ func SynchronizationArthistory() {
 //		}
 //	}
 //}
+
+//func init()  {
+//	fmt.Println("init start")
+//	go UpdateDailyMonthReadBillboardV2()
+//	fmt.Println("init end")
+//}

+ 23 - 0
utils/common.go

@@ -732,3 +732,26 @@ func ReplaceSpaceAndWrap(str string) string {
 	str = strings.Replace(str, "\n", "", -1)
 	return str
 }
+
+
+// InArrayByInt php中的in_array(判断Int类型的切片中是否存在该int值)
+func InArrayByInt(idIntList []int, searchId int) (has bool) {
+	for _, id := range idIntList {
+		if id == searchId {
+			has = true
+			return
+		}
+	}
+	return
+}
+
+// InArrayByStr php中的in_array(判断String类型的切片中是否存在该string值)
+func InArrayByStr(idStrList []string, searchId string) (has bool) {
+	for _, id := range idStrList {
+		if id == searchId {
+			has = true
+			return
+		}
+	}
+	return
+}

+ 1 - 1
utils/constants.go

@@ -116,7 +116,7 @@ const (
 
 	ACTIVITY_ZXDY_ImgUrl1 = "https://hzstatic.hzinsights.com/static/temp/20220830202208/20220830/2c4YHXzwb0uqvIfgPvBV4MZtKNX9.png"
 	ACTIVITY_ZXDY_ImgUrl2 = "https://hzstatic.hzinsights.com/static/temp/20220830202208/20220830/UERktOWyQQEoPeckdy01TEZP09Pu.png"
-	ACTIVITY_ZXDY_ImgUrl3 = "https://hzstatic.hzinsights.com/static/temp/20220830202208/20220830/Db2eF5jffaJlLqq1KtOgrBkddoxZ.png"
+	ACTIVITY_ZXDY_ImgUrl3 = "https://hzstatic.hzinsights.com/cygx/special_list_bg.png"
 )
 
 const (