Browse Source

主题热度榜排序规则修改

xingzai 2 years ago
parent
commit
225bf889d6
4 changed files with 56 additions and 1 deletions
  1. 8 0
      controllers/report.go
  2. 11 0
      models/industrial_management.go
  3. 1 1
      models/report.go
  4. 36 0
      services/industrial_management.go

+ 8 - 0
controllers/report.go

@@ -2905,6 +2905,12 @@ func (this *ReportController) SearchReportAndResource() {
 
 	condition = `  AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
 
+	hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
+	if e != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
+		return
+	}
 	listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -2962,6 +2968,7 @@ func (this *ReportController) SearchReportAndResource() {
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			listHzResource[k].IsFollw = true
 		}
+		v.IsHot = hotMapindustrial[v.IndustrialManagementId]
 		industrialIdSlice := make([]int, 0)
 		articleIdArr := make([]int, 0)
 		industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
@@ -3137,6 +3144,7 @@ func (this *ReportController) SearchReportAndResource() {
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			listYxResource[k].IsFollw = true
 		}
+		v.IsHot = hotMapindustrial[v.IndustrialManagementId]
 		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
 	}
 

+ 11 - 0
models/industrial_management.go

@@ -146,6 +146,17 @@ func GetIndustrialSubjectAllByIndustrialId(industrialIdArr []int) (items []*Indu
 	return
 }
 
+// GetTopOneMonthArtReadNumIndustry 获取近一个月报告阅读数量最多的产业信息 根据行业分组
+func GetTopOneMonthArtReadNumIndustryAll(condition string, pars []interface{}) (items []*IndustrialManagement, err error) {
+	sql := `SELECT * FROM cygx_industrial_management WHERE 1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` ORDER BY article_read_num DESC `
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // 分析师列表
 func GetIndustrialAnalystAll(IndustrialManagementId int) (items []*IndustrialAnalyst, err error) {
 	o := orm.NewOrm()

+ 1 - 1
models/report.go

@@ -548,7 +548,7 @@ func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, p
           	MAX( a.publish_date ) AS publish_date,
 			MIN(a.publish_date) AS min_report_time,
 			( SELECT count( 1 ) FROM cygx_industry_fllow AS f  WHERE f.industrial_management_id = m.industrial_management_id  AND user_id =? AND f.type = 1  ) AS fllow_num,
-			( SELECT count( 1 ) FROM cygx_industry_fllow AS f  WHERE f.industrial_management_id = m.industrial_management_id  AND f.type = 1  ) AS sum_num
+			m.article_read_num + ( SELECT count( 1 ) FROM cygx_activity_meet_detail_log AS la  WHERE la.activity_id  IN  (SELECT activity_id FROM cygx_industrial_activity_group_management WHERE industrial_management_id = m.industrial_management_id  ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( la.activity_time ) ) AS sum_num
 		FROM
 			cygx_industrial_management AS m
 			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id

+ 36 - 0
services/industrial_management.go

@@ -553,3 +553,39 @@ func GetArticleTypeMap() (nameMapResp map[int]string, buttonStyleMapResp map[int
 	buttonStyleMapResp = buttonStyleMap
 	return
 }
+
+// IndustrialManagementHotMapGropuPermission获取近一个月报告阅读数量最多的产业信息 根据行业分组
+func IndustrialManagementHotMapGropuPermission() (mapResp map[int]bool, err error) {
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+	mapPermission := make(map[int][]*models.IndustrialManagement)
+	mapPermissionMax := make(map[int]int)
+
+	for _, v := range toplist {
+		item := new(models.IndustrialManagement)
+		item.ChartPermissionId = v.ChartPermissionId
+		item.IndustrialManagementId = v.IndustrialManagementId
+		item.ArticleReadNum = v.ArticleReadNum
+		mapPermission[v.ChartPermissionId] = append(mapPermission[v.ChartPermissionId], item)
+	}
+	for k, v := range mapPermission {
+		for _, item := range v {
+			//mapPermissionMax[k] = item.ArticleReadNum
+			if item.ArticleReadNum > mapPermissionMax[k] {
+				mapPermissionMax[k] = item.ArticleReadNum
+			}
+		}
+	}
+
+	mapResp = make(map[int]bool, 0)
+	for _, v := range toplist {
+		if v.ArticleReadNum == mapPermissionMax[v.ChartPermissionId] {
+			mapResp[v.IndustrialManagementId] = true
+		}
+	}
+	return
+}