瀏覽代碼

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_9.3.1_0

xingzai 2 年之前
父節點
當前提交
61e08b214e

+ 52 - 18
controllers/activity.go

@@ -296,6 +296,7 @@ func (this *ActivityCoAntroller) ScheduleList() {
 // @Title  活动详情
 // @Description 获取活动详情接口
 // @Param   ActivityId   query   int  true       "活动ID"
+// @Param   IsSendWx   query   int  false       "是否是通过微信模版进来的 1是,其它否"
 // @Success Ret=200 {object} models.CygxActivityResp
 // @router /detail [get]
 func (this *ActivityCoAntroller) Detail() {
@@ -313,12 +314,12 @@ func (this *ActivityCoAntroller) Detail() {
 	}
 	uid := user.UserId
 	activityId, _ := this.GetInt("ActivityId")
+	isSendWx, _ := this.GetInt("IsSendWx")
 	if activityId < 1 {
 		br.Msg = "请输入活动ID"
 		return
 	}
 	resp := new(models.CygxActivityResp)
-
 	activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
@@ -361,23 +362,23 @@ func (this *ActivityCoAntroller) Detail() {
 		if activityInfo.IsHideAppointment == 0 {
 			activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
 		}
-		if activityInfo.ReportLink != "" {
-			artList := strings.Split(activityInfo.ReportLink, "{|}")
-			if len(artList) > 0 {
-				for _, v := range artList {
-					artitem := new(models.ActivityArticleResp)
-					artitem.ReportLink = v
-					artIdSlice := strings.Split(v, "/")
-					if len(artIdSlice) > 0 {
-						articleId, _ := strconv.Atoi(artIdSlice[len(artIdSlice)-1])
-						artitem.ArticleId = articleId
-					}
-					activityInfo.ArticleList = append(activityInfo.ArticleList, artitem)
-				}
-			}
-		} else {
-			activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
-		}
+		//if activityInfo.ReportLink != "" {
+		//	artList := strings.Split(activityInfo.ReportLink, "{|}")
+		//	if len(artList) > 0 {
+		//		for _, v := range artList {
+		//			artitem := new(models.ActivityArticleResp)
+		//			artitem.ReportLink = v
+		//			artIdSlice := strings.Split(v, "/")
+		//			if len(artIdSlice) > 0 {
+		//				articleId, _ := strconv.Atoi(artIdSlice[len(artIdSlice)-1])
+		//				artitem.ArticleId = articleId
+		//			}
+		//			activityInfo.ArticleList = append(activityInfo.ArticleList, artitem)
+		//		}
+		//	}
+		//} else {
+		//	activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
+		//}
 		activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
 
 		//处理活动关联的产业
@@ -495,6 +496,39 @@ func (this *ActivityCoAntroller) Detail() {
 			return
 		}
 		activityInfo.SignupType = mapActivitySignup[activityId]
+		//处理活动关联的产业
+		industrialListNew, err := models.GetIndustrialActivityGroupManagementList(activityId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+			return
+		}
+		//判断是不是通过微信模版推送消息进来的
+		if isSendWx == 1 && len(industrialListNew) > 0 {
+			industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
+				return
+			}
+			for _, v := range industrialListNew {
+				if industryUserFollowMap[v.IndustrialManagementId] {
+					activityInfo.IsFollowButton = true
+				}
+			}
+			activityInfo.IsShowFollowButton = true
+		}
+		if activityInfo.ReportLink != "" {
+			artList, err := services.GetActivityReportLinkToArticleList(activityInfo)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "解析文章关联的报告内容失败:" + activityInfo.ReportLink
+				return
+			}
+			activityInfo.ArticleList = artList
+		} else {
+			activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
+		}
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)
 	} else {

+ 30 - 0
controllers/article.go

@@ -40,6 +40,7 @@ type ArticleControllerMobile struct {
 // @Title 获取报告详情
 // @Description 获取报告详情接口
 // @Param   ArticleId   query   int  true       "报告ID"
+// @Param   IsSendWx   query   int  false       "是否是通过微信模版进来的 1是,其它否"
 // @Success 200 {object} models.ArticleDetailResp
 // @router /detail [get]
 func (this *ArticleController) Detail() {
@@ -58,6 +59,7 @@ func (this *ArticleController) Detail() {
 
 	uid := user.UserId
 	articleId, err := this.GetInt("ArticleId")
+	isSendWx, _ := this.GetInt("IsSendWx")
 	if articleId <= 0 {
 		br.Msg = "文章不存在"
 		br.ErrMsg = "文章不存在,文章ID错误"
@@ -80,6 +82,34 @@ func (this *ArticleController) Detail() {
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 	}
+	if isSendWx == 1 {
+		var condition string
+		var pars []interface{}
+		pars = make([]interface{}, 0)
+		condition = ` AND article_id  = ? `
+		pars = append(pars, articleId)
+		industrialList, err := models.GetIndustrialArticleGroupManagementList(condition, pars)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		if len(industrialList) > 0 {
+			industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
+				return
+			}
+			for _, v := range industrialList {
+				fmt.Println(v.IndustrialManagementId)
+				if industryUserFollowMap[v.IndustrialManagementId] {
+					detail.IsFollowButton = true
+				}
+			}
+			detail.IsShowFollowButton = true
+		}
+	}
 	//是否属于专项调研报告
 	if detail.SubCategoryName == "专项调研" {
 		detail.IsSpecialArticle = true

+ 130 - 0
controllers/industry.go

@@ -0,0 +1,130 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
+)
+
+// 报告
+type IndustryController struct {
+	BaseAuthController
+}
+
+// @Title 关注/取消关注产业
+// @Description 关注/取消关注 接口
+// @Param	request	body models.CygxIndustryFllowRep true "type json string"
+// @Success 200
+// @router /follow [post]
+func (this *IndustryController) Fllow() {
+	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
+	var req models.IndustryFllowArryReq
+	resp := new(models.CygxIndustryFllowResp)
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	sourceId := req.SourceId
+	source := req.Source
+	doType := req.DoType
+	var status int
+	var condition string
+	var pars []interface{}
+	var industrialIds []int
+	if source == "article" {
+		pars = make([]interface{}, 0)
+		condition = ` AND article_id  = ? `
+		pars = append(pars, sourceId)
+		industrialList, err := models.GetIndustrialArticleGroupManagementList(condition, pars)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		if len(industrialList) > 0 {
+			for _, v := range industrialList {
+				industrialIds = append(industrialIds, v.IndustrialManagementId)
+			}
+		}
+	} else if source == "activity" {
+		//处理活动关联的产业
+		industrialList, err := models.GetIndustrialActivityGroupManagementList(sourceId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(sourceId)
+			return
+		}
+		if len(industrialList) > 0 {
+			for _, v := range industrialList {
+				industrialIds = append(industrialIds, v.IndustrialManagementId)
+			}
+		}
+	} else {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "资源类型有误:" + source
+		return
+	}
+	lenindustrialIds := len(industrialIds)
+	if lenindustrialIds == 0 {
+		br.Msg = "操作失败!"
+		br.ErrMsg = "对应的产业不存在:" + source + "ID:" + strconv.Itoa(sourceId)
+		return
+	}
+	//批量取关与关注
+	if doType == "add" {
+		status = 1
+		var industryFllowItems []*models.CygxIndustryFllow
+		for _, v := range industrialIds {
+			item := new(models.CygxIndustryFllow)
+			item.IndustrialManagementId = v
+			item.UserId = uid
+			item.Email = user.Email
+			item.Mobile = user.Mobile
+			item.RealName = user.RealName
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.Type = 1
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			industryFllowItems = append(industryFllowItems, item)
+		}
+		err = models.AddCygxIndustryFllowMulti(industryFllowItems)
+	} else if doType == "cancel" {
+		status = 2
+		pars = make([]interface{}, 0)
+		condition = ` AND  industrial_management_id IN (` + utils.GetOrmInReplace(lenindustrialIds) + `)`
+		pars = append(pars, industrialIds)
+		err = models.RemoveCygxIndustryFllowArry(uid, condition, pars)
+	} else {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "操作方式有误:" + doType
+		return
+	}
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "取消关注失败,Err:" + err.Error()
+		return
+	}
+	resp.Status = status
+	//处理是否关注全部赛道字段
+	//go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
+	br.Msg = "操作成功"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 23 - 22
controllers/micro_roadshow.go

@@ -80,34 +80,35 @@ func (this *MicroRoadShowController) List() {
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
 		return
 	}
-	var pageSizeIk int
-
-	//获取总的数量
-	totalIk, e := services.CountMicroRoadShowPageListIkWord(audioId, videoId, activityVideoId, filter, keyWordArr, audioIds, videoIds, activityVideoIds)
-	if e != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取微路演联想词列表失败, Err: " + e.Error()
-		return
-	}
-	pageSizeIk = totalIk - len(list)
-	//处理IK分词部分的分页获取条数
-	startSizeIk := utils.StartIndex(currentIndex, pageSize)
-	startSizeIk = startSizeIk - total
-	if startSizeIk < 0 {
-		startSizeIk = 0
-	}
-	if pageSizeIk > 0 {
-		lisIk, e := services.GetMicroRoadShowPageListIkWord(startSizeIk, pageSizeIk, audioId, videoId, activityVideoId, filter, keyWordArr, audioIds, videoIds, activityVideoIds, keywords)
+	if keywords != "" {
+		var pageSizeIk int
+		//获取总的数量
+		totalIk, e := services.CountMicroRoadShowPageListIkWord(audioId, videoId, activityVideoId, filter, keyWordArr, audioIds, videoIds, activityVideoIds)
 		if e != nil {
 			br.Msg = "获取失败"
-			br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+			br.ErrMsg = "获取微路演联想词列表失败, Err: " + e.Error()
 			return
 		}
-		for _, item := range lisIk {
-			list = append(list, item)
+		pageSizeIk = totalIk - len(list)
+		//处理IK分词部分的分页获取条数
+		startSizeIk := utils.StartIndex(currentIndex, pageSize)
+		startSizeIk = startSizeIk - total
+		if startSizeIk < 0 {
+			startSizeIk = 0
+		}
+		if pageSizeIk > 0 {
+			lisIk, e := services.GetMicroRoadShowPageListIkWord(startSizeIk, pageSizeIk, audioId, videoId, activityVideoId, filter, keyWordArr, audioIds, videoIds, activityVideoIds, keywords)
+			if e != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+				return
+			}
+			for _, item := range lisIk {
+				list = append(list, item)
+			}
 		}
+		total = totalIk
 	}
-	total = totalIk
 	userId := user.UserId
 	listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
 	if err != nil {

+ 116 - 7
controllers/report.go

@@ -258,6 +258,7 @@ func (this *ReportController) IndustryList() {
 // @Description 产业下所关联的文章分类列表接口
 // @Param   IndustrialManagementId   query   int  true       "产业ID"
 // @Param   ShowTimeLine   query   int  true       "是否展示时间线 0不展示,1展示"
+// @Param   IsSendWx   query   int  false       "是否是通过微信模版进来的 1是,其它否"
 // @Success 200 {object} models.IndustrialToArticleCategoryListRep
 // @router /toArticleCategoryList [get]
 func (this *ReportController) ArticleCategoryList() {
@@ -279,6 +280,7 @@ func (this *ReportController) ArticleCategoryList() {
 		return
 	}
 	showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
+	isSendWx, _ := this.GetInt("IsSendWx")
 
 	detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
 	if err != nil {
@@ -440,7 +442,16 @@ func (this *ReportController) ArticleCategoryList() {
 	if videoSimple.Id > 0 {
 		resp.IndustryVideo = videoSimple
 	}
-
+	if isSendWx == 1 {
+		industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
+			return
+		}
+		resp.IsFollowButton = industryUserFollowMap[industrialManagementId]
+		resp.IsShowFollowButton = true
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -1529,6 +1540,7 @@ func (this *ReportController) ReportListByType() {
 // @Title 获取报告精选详情
 // @Description 获取报告精选详情接口
 // @Param   ArticleId   query   int  true       "报告ID"
+// @Param   IsBestNew   query   bool  false       "是否获取最新的一篇报告"
 // @Success 200 {object} models.ReportSelectionLetailResp
 // @router /reportSelection/detail [get]
 func (this *ReportController) Detail() {
@@ -1543,11 +1555,32 @@ func (this *ReportController) Detail() {
 		br.Ret = 408
 		return
 	}
+	if user.CompanyId != utils.HZ_COMPANY_ID {
+		br.Msg = "报告编辑中,请稍后"
+		br.IsSendEmail = false
+		return
+	}
 	uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
-	if articleId < 0 {
-		br.Msg = "参数错误"
-		br.ErrMsg = "参数错误"
+	isBestNew, _ := this.GetBool("IsBestNew")
+	if isBestNew {
+		tbdb := "cygx_report_selection"
+		//reportTypeStr := "bgjx"
+		condition := ` AND publish_status = 1  `
+		var pars []interface{}
+		list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		for _, v := range list {
+			articleId = v.ArticleId
+		}
+	}
+	if articleId < 1 {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
 		return
 	}
 	resp := new(models.ReportSelectionLetailResp)
@@ -1571,21 +1604,69 @@ func (this *ReportController) Detail() {
 		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
 		return
 	}
+
+	if detail.ReportLink != "" {
+		articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
+		detail.CeLueArticleId = articleIdLink
+	}
+
+	//较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
+	var isAllNew bool // 判断是否都打新的标签
+	lastPeriods := detail.Periods - 1
+	mapBodyChartSummary := make(map[int]string)
+	mapLabel := make(map[int]string)
+	if lastPeriods > 0 {
+		detailLast, err := models.GetCygxReportSelectionInfoByperiods(lastPeriods)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "报告不存在,Err:" + err.Error() + "Periods:" + strconv.Itoa(lastPeriods)
+			return
+		}
+		if detailLast != nil {
+			articleIdLast := detailLast.ArticleId
+			listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
+				return
+			}
+			for _, v := range listLogLast {
+				mapBodyChartSummary[v.IndustrialSubjectId], _ = services.GetReportContentTextSubNew(v.Body)
+				mapLabel[v.IndustrialSubjectId] = v.Label
+			}
+		}
+	} else {
+		isAllNew = true
+	}
 	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
 	existMap := make(map[int]int)
 	var items []*models.ReportSelectionChartPermission
+	var itemsSubject []*models.ReportSelectionChartLogPermission
 	listLog, err := models.GetReportSelectionlogListAll(articleId)
-	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
 		return
 	}
-	//var itemLogs []*models.CygxReportSelectionLogDetail
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
+	//获取行业核心逻辑汇总
+	listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	mapChartLog := make(map[string]string)
+	for _, v := range listChartLog {
+		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
+	}
 	for _, v := range listLog {
 		item := new(models.ReportSelectionChartPermission)
+		itemSubject := new(models.ReportSelectionChartLogPermission)
+		itemSubject.PermissionName = v.PermissionName
 		if existMap[v.ChartPermissionId] == 0 {
-			item.PermissionName = v.PermissionName + "领域深度报告和调研"
+			//item.PermissionName = v.PermissionName + "领域深度报告和调研"
+			item.PermissionName = v.PermissionName
 			item.IcoLink = v.IcoLink
 			listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -1594,6 +1675,15 @@ func (this *ReportController) Detail() {
 				return
 			}
 			for k2, v2 := range listSonLog {
+				var isNew bool
+				if isAllNew {
+					isNew = true
+				} else {
+					v2Body, _ := services.GetReportContentTextSubNew(v2.Body)
+					if mapBodyChartSummary[v2.IndustrialSubjectId] != v2Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
+						isNew = true
+					}
+				}
 				if v2.IndustrialManagementId != "" {
 					listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
 					if err != nil && err.Error() != utils.ErrNoRow() {
@@ -1601,15 +1691,24 @@ func (this *ReportController) Detail() {
 						br.ErrMsg = "获取信息失败,Err:" + err.Error()
 						return
 					}
+					//v2.IsNew = isNew
 					listSonLog[k2].List = listIndustrial
+					if v2.Label != "" {
+						v2.CompanyLabel = strings.Split(v2.Label, "{|}")
+					}
 				}
+				isNew = false
+				itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
 			}
+			item.BodyChartSummary = mapChartLog[v.PermissionName]
 			item.List = listSonLog
 			items = append(items, item)
+			itemsSubject = append(itemsSubject, itemSubject)
 			//itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
 		}
 		existMap[v.ChartPermissionId] = v.ChartPermissionId
 	}
+
 	historyRecord := new(models.CygxReportHistoryRecord)
 	historyRecord.UserId = uid
 	historyRecord.ArticleId = articleId
@@ -1629,8 +1728,10 @@ func (this *ReportController) Detail() {
 	if sellerItem != nil {
 		historyRecord.SellerName = sellerItem.RealName
 	}
+
 	go models.AddCygxReportHistoryRecord(historyRecord)
 	resp.List = items
+	resp.ListPermissionSubject = itemsSubject
 	resp.Detail = detail
 	br.Ret = 200
 	br.Success = true
@@ -2905,6 +3006,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 +3069,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 +3245,7 @@ func (this *ReportController) SearchReportAndResource() {
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			listYxResource[k].IsFollw = true
 		}
+		v.IsHot = hotMapindustrial[v.IndustrialManagementId]
 		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
 	}
 

+ 2 - 2
controllers/user.go

@@ -12,7 +12,7 @@ import (
 	"time"
 )
 
-//用户
+// 用户
 type UserController struct {
 	BaseAuthController
 }
@@ -1721,4 +1721,4 @@ func (this *UserController) Tracking() {
 	br.Msg = "新增成功!"
 	br.Ret = 200
 	br.Success = true
-}
+}

+ 7 - 0
models/activity.go

@@ -115,6 +115,7 @@ type ActivityRep struct {
 type ActivityArticleResp struct {
 	ReportLink string `description:"报告链接"`
 	ArticleId  int    `description:"报告id(报告链接跳转使用)"`
+	Title      string `description:"报告id(报告链接跳转使用)"`
 }
 
 // 活动详情
@@ -196,6 +197,12 @@ type ActivityDetail struct {
 	SourceType              int                        `description:"活动来源。 1:活动 、2:专项产业调研"`
 	TripImgLink             string                     `description:"专项产业调研行程链接"`
 	ActivityTimeEnd         string                     `description:"专项产业调研活动预期结束时间"`
+	IsShowFollowButton      bool                       `description:"是否展示关注取关按钮"`
+	IsFollowButton          bool                       `description:"是否关注"`
+}
+type ListArticleActivity struct {
+	Title   string `description:"文章标题"`
+	ArtleId int    `description:"产业id"`
 }
 
 type CygxActivityResp struct {

+ 7 - 0
models/article.go

@@ -163,6 +163,8 @@ type ArticleDetail struct {
 	ArticleTypeId           int    `description:"文章类型ID"`
 	IsSpecialArticle        bool   `description:"是否属于专项调研报告"`
 	Annotation              string `description:"核心观点"`
+	IsShowFollowButton      bool   `description:"是否展示关注取关按钮"`
+	IsFollowButton          bool   `description:"是否关注"`
 }
 
 type ArticleDetailFileLink struct {
@@ -450,6 +452,11 @@ type ArticleId struct {
 	ArticleId int `description:"文章id"`
 }
 
+type ArticleIdAndTitle struct {
+	Title     string `description:"标题"`
+	ArticleId int    `description:"文章id"`
+}
+
 // 获取自定义分类的文章ID
 func GetCustomArticleId() (item []*ArticleId, err error) {
 	o := orm.NewOrm()

+ 73 - 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()
@@ -320,6 +331,54 @@ func GetIndustrialManagementArtCount(industrialManagementId int) (count int, err
 	return
 }
 
+type IndustrialManagementArtHistoryCount struct {
+	IndustrialManagementId int `description:"产业id"`
+	Count                  int `description:"数量"`
+}
+
+func GetIndustrialManagementArtHistoryCount(condition string) (items []*IndustrialManagementArtHistoryCount, err error) {
+	sql := `SELECT
+				COUNT( 1 ) AS count,
+				mg.industrial_management_id 
+			FROM
+				cygx_article_history_record_newpv AS h
+				INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = h.article_id
+				INNER JOIN cygx_article AS a ON a.article_id = h.article_id 
+			WHERE
+				1 = 1 
+				AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( h.create_time )  ` + condition + `
+			GROUP BY
+				mg.industrial_management_id `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetIndustrialManagementActivityHistoryCount() (items []*IndustrialManagementArtHistoryCount, err error) {
+	sql := `SELECT
+			COUNT( 1 ) AS count,
+			mg.industrial_management_id 
+		FROM
+			cygx_activity_meet_detail_log AS h
+			INNER JOIN cygx_industrial_activity_group_management AS mg ON mg.activity_id = h.activity_id
+			INNER JOIN cygx_activity AS a ON a.activity_id = h.activity_id 
+		WHERE
+			1 = 1 
+			AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( a.activity_time ) 
+		GROUP BY
+			mg.industrial_management_id `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func UpdateIndustrialManagementArtticleReadNum() (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industrial_management SET article_read_num = 0 ,yanxuan_article_read_num = 0 ,activity_num = 0  `
+	_, err = o.Raw(sql).Exec()
+	return
+}
+
 func UpdateIndustrialManagementArtReadNum(num, industrialManagementId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_industrial_management SET article_read_num = ? WHERE industrial_management_id = ?`
@@ -327,6 +386,20 @@ func UpdateIndustrialManagementArtReadNum(num, industrialManagementId int) (err
 	return
 }
 
+func UpdateIndustrialManagementArtYanXuanReadNum(num, industrialManagementId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industrial_management SET yanxuan_article_read_num = ? WHERE industrial_management_id = ?`
+	_, err = o.Raw(sql, num, industrialManagementId).Exec()
+	return
+}
+
+func UpdateIndustrialManagementActivityNum(num, industrialManagementId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industrial_management SET activity_num = ? WHERE industrial_management_id = ?`
+	_, err = o.Raw(sql, num, industrialManagementId).Exec()
+	return
+}
+
 // 更新产业布局时间
 func UpdateIndustrialManagementLayoutTime(layoutTime string, industrialManagementId int) (err error) {
 	o := orm.NewOrm()

+ 35 - 10
models/industry_fllow.go

@@ -24,14 +24,20 @@ type CygxIndustryFllowRep struct {
 	IndustrialManagementId int `description:"产业D"`
 }
 
-//添加
+type IndustryFllowArryReq struct {
+	SourceId int    `description:"资源ID"`
+	Source   string `description:"资源类型 报告 :article 、活动 :activity"`
+	DoType   string `description:"操作方式 关注 :add 、取消关注 :cancel"`
+}
+
+// 添加
 func AddCygxIndustryFllow(item *CygxIndustryFllow) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-//批量添加
+// 批量添加
 func AddCygxIndustryFllowMulti(items []*CygxIndustryFllow) (err error) {
 	o := orm.NewOrm()
 	if len(items) > 0 {
@@ -53,21 +59,32 @@ func RemoveCygxIndustryFllow(userId, industrialManagementId int) (err error) {
 	return
 }
 
-//获取数量
+// RemoveCygxIndustryFllowArry 多个产业同时取消关注
+func RemoveCygxIndustryFllowArry(userId int, condition string, pars []interface{}) (err error) {
+	o := orm.NewOrm()
+	if condition == "" {
+		return
+	}
+	sql := `DELETE FROM cygx_industry_fllow WHERE user_id=?  ` + condition
+	_, err = o.Raw(sql, userId, pars).Exec()
+	return
+}
+
+// 获取数量
 func GetCountCygxIndustryFllow(userId, industrialManagementId int, condition string) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? ` + condition
 	err = orm.NewOrm().Raw(sql, userId, industrialManagementId).QueryRow(&count)
 	return
 }
 
-//获取数量
+// 获取数量
 func GetCountCygxIndustryFllowByUid(userId int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? `
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
 	return
 }
 
-//获取列表信息根据手机号分组
+// 获取列表信息根据手机号分组
 func GetCygxIndustryFllowList(condition string) (items []*CygxIndustryFllow, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_industry_fllow  WHERE 1 =1   ` + condition + `  GROUP BY user_id  `
@@ -75,7 +92,15 @@ func GetCygxIndustryFllowList(condition string) (items []*CygxIndustryFllow, err
 	return
 }
 
-//修改用户关注的相关信息
+// 获取列表信息根据手机号分组
+func GetCygxIndustryFllowListByUserId(condition string) (items []*CygxIndustryFllow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industry_fllow  WHERE 1 =1   ` + condition
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 修改用户关注的相关信息
 func UpdateCygxIndustryFllow(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string
@@ -89,7 +114,7 @@ func UpdateCygxIndustryFllow(wxUser *WxUserItem) (err error) {
 	return
 }
 
-//获取用户关注的产业列表
+// 获取用户关注的产业列表
 func GetUserFllowIndustrialList(userId int) (items []*CygxIndustryFllow, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -112,7 +137,7 @@ type CygxIndustryFllowCountRep struct {
 	Num                    int `description:"数量"`
 }
 
-//获取产业被关注的数量
+// 获取产业被关注的数量
 func GetUserFllowIndustrialCountList() (items []*CygxIndustryFllowCountRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -133,7 +158,7 @@ func GetUserFllowIndustrialCountList() (items []*CygxIndustryFllowCountRep, err
 	return
 }
 
-//GetUserFllowIndustrialListByUserIdAndIndustrial 通过用户ID 跟产业ID获取用户关注的产业列表
+// GetUserFllowIndustrialListByUserIdAndIndustrial 通过用户ID 跟产业ID获取用户关注的产业列表
 func GetUserFllowIndustrialListByUserIdAndIndustrial(userIds, industrials string) (items []*CygxIndustryFllow, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_industry_fllow 
@@ -144,7 +169,7 @@ func GetUserFllowIndustrialListByUserIdAndIndustrial(userIds, industrials string
 	return
 }
 
-//获取某个用户关注某个行业下的产业数量
+// 获取某个用户关注某个行业下的产业数量
 func GetCountCygxIndustryFllowByUidAndChartPermissionId(userId, ChartPermissionId int) (count int, err error) {
 	sql := `SELECT
 			COUNT( 1 ) AS count 

+ 2 - 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.yanxuan_article_read_num + m.activity_num 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
@@ -623,6 +623,7 @@ type IndustrialDepartmentListResp struct {
 }
 
 // 作者列表
+
 func GetDepartmentList(condition, conditionOrder string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT

+ 2 - 0
models/report_mapping.go

@@ -106,6 +106,8 @@ type IndustrialToArticleCategoryListRep struct {
 	LayoutTime             string `description:"布局时间"`
 	IndustryName           string `description:"产业名称"`
 	IndustrialManagementId int    `description:"产业D"`
+	IsShowFollowButton     bool   `description:"是否展示关注取关按钮"`
+	IsFollowButton         bool   `description:"是否关注"`
 	IndustryVideo          *MicroVideoSimpleInfo
 	List                   []*IndustrialToArticleCategoryRep
 }

+ 50 - 18
models/report_selection.go

@@ -30,31 +30,52 @@ type DetailCygxReportSelectionRep struct {
 	PublishDate        string `description:"发布时间"`
 	CreateTime         string `description:"创建时间"`
 	LastUpdatedTime    string `description:"最后一次更新时间"`
-	Periods            string `description:"期数"`
+	Periods            int    `description:"期数"`
 	VideoUrl           string `description:"链接"`
 	VideoPlaySeconds   string `description:"时长"`
 	VideoName          string `description:"音频名称"`
 	ProductDescription string `description:"产品说明"`
 	UpdateDescription  string `description:"更新说明"`
 	FocusOn            string `description:"近期重点关注方向"`
+	MarketStrategy     string `description:"市场策略核心逻辑汇总"`
+	ReportLink         string `description:"报告链接"`
+	CeLueArticleId     int    `description:"策略报告详情"`
 }
 
 type ReportSelectionLetailResp struct {
-	Detail        *DetailCygxReportSelectionRep
-	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
-	List          []*ReportSelectionChartPermission
+	Detail                *DetailCygxReportSelectionRep
+	HasPermission         int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List                  []*ReportSelectionChartPermission
+	ListPermissionSubject []*ReportSelectionChartLogPermission `description:"行业列表"`
 }
 
 type ReportSelectionChartPermission struct {
-	PermissionName string `description:"权限名称"`
-	IcoLink        string `orm:"column(image_url)"description:"图标链接"`
-	List           []*CygxReportSelectionLogDetail
+	PermissionName   string `description:"权限名称"`
+	IcoLink          string `orm:"column(image_url)"description:"图标链接"`
+	List             []*CygxReportSelectionLogDetail
+	BodyChartSummary string `description:"行业核心逻辑汇总"`
+}
+
+type ReportSelectionChartLogPermission struct {
+	PermissionName string                                `description:"权限名称"`
+	ListSubject    []*ReportSelectionChartLogSubjectName `description:"标的列表"`
+}
+
+type ReportSelectionChartLogSubjectName struct {
+	SubjectName         string `description:"标的名称"`
+	IndustrialSubjectId int    `description:"标的ID"`
+	IsNew               bool   `description:"是否展示新标签"`
 }
 
 type CygxReportSelectionLogDetail struct {
-	IndustrialManagementId string `description:"产业Id"`
-	SubjectName            string `description:"标的名称"`
-	Body                   string `description:"内容"`
+	IndustrialManagementId string   `description:"产业Id"`
+	IndustrialSubjectId    int      `description:"标的ID"`
+	SubjectName            string   `description:"标的名称"`
+	IsNew                  bool     `description:"是否展示新标签"`
+	Body                   string   `description:"内容"`
+	CompanyLabel           []string `description:"公司标签"`
+	Label                  string   `description:"公司标签"`
+	OverviewArticleId      int      `description:"综述报告Id"`
 	List                   []*IndustriaReportSelection
 }
 type IndustriaReportSelection struct {
@@ -66,7 +87,7 @@ type ReportSelectionId struct {
 	ArticleId int `description:"报告I"`
 }
 
-//获取数量
+// 获取数量
 func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1   `
 	if condition != "" {
@@ -77,7 +98,7 @@ func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (c
 	return
 }
 
-//通过纪要ID获取活动详情
+// 通过ID获取详情
 func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_report_selection  WHERE article_id=? AND publish_status = 1 `
@@ -85,7 +106,15 @@ func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelect
 	return
 }
 
-//列表
+// 通过期数获取详情
+func GetCygxReportSelectionInfoByperiods(periods int) (item *DetailCygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  WHERE periods=?  `
+	err = o.Raw(sql, periods).QueryRow(&item)
+	return
+}
+
+// 列表
 func GetReportSelectionListPublic(condition, readSql, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * ,` + readSql + ` FROM  ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1  `
@@ -104,16 +133,19 @@ type CygxReportSelectionLog struct {
 	PermissionName         string    `description:"行业ID"`
 	CreateTime             time.Time `description:"创建时间"`
 	Body                   string    `description:"内容"`
-	IndustrialSubjectId    string    `description:"标的ID"`
+	IndustrialSubjectId    int       `description:"标的ID"`
 	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
 	SubjectName            string    `description:"标的名称"`
 	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
+	CompanyLabel           []string  `description:"公司标签"`
+	Label                  string    `description:"公司标签"`
+	OverviewArticleId      int       `description:"综述报告Id"`
 }
 
-//列表
+// 列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.* 
+	sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.*  ,l.company_label as label
 			FROM
 			cygx_report_selection_log AS l
 			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
@@ -123,10 +155,10 @@ func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLo
 	return
 }
 
-//列表
+// 列表
 func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name , l.* 
+	sql := `SELECT c.permission_name , l.* ,l.company_label as label
 			FROM
 			cygx_report_selection_log AS l
 			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 

+ 36 - 0
models/report_selection_chart_log.go

@@ -0,0 +1,36 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportSelectionChartLog struct {
+	ArticleSunId      int       `orm:"column(article_sun_id);pk"description:"子级报告id"`
+	ArticleId         int       `description:"父级报告Id"`
+	ChartPermissionId int       `description:"行业ID"`
+	CreateTime        time.Time `description:"创建时间"`
+	Body              string    `description:"内容"`
+}
+
+type CygxReportSelectionChartLogRep struct {
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业ID"`
+	BodyChartSummary    string `orm:"column(body)"description:"内容"`
+}
+
+type AddCygxReportSelectionChartLog struct {
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业ID"`
+	BodyChartSummary    string `orm:"column(body)"description:"内容"`
+}
+
+func GetCygxReportSelectionChartLogRepList(articleId int) (items []*CygxReportSelectionChartLogRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT l.*,c.chart_permission_name
+			FROM cygx_report_selection_chart_log AS l
+			LEFT JOIN chart_permission as c  ON c.chart_permission_id = l.chart_permission_id
+			WHERE  1= 1 AND article_id=?  `
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -700,6 +700,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:IndustryController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:IndustryController"],
+        beego.ControllerComments{
+            Method: "Fllow",
+            Router: `/follow`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
         beego.ControllerComments{
             Method: "Collect",

+ 5 - 0
routers/router.go

@@ -134,6 +134,11 @@ func init() {
 				&controllers.ActivitySpecialCoAntroller{},
 			),
 		),
+		web.NSNamespace("/industry",
+			web.NSInclude(
+				&controllers.IndustryController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 45 - 0
services/activity.go

@@ -1948,6 +1948,51 @@ func ActivityVideoUserRmind(user *models.WxUserItem, activityId, fileType int) (
 	return
 }
 
+// 解析活动填写的报告链接
+func GetActivityReportLinkToArticleList(item *models.ActivityDetail) (items []*models.ActivityArticleResp, err error) {
+	reportLink := item.ReportLink
+	//处理活动的
+	var articleIds []int
+	var articleList []string
+	if strings.Contains(reportLink, ";") {
+		articleList = strings.Split(reportLink, ";")
+	} else {
+		articleList = strings.Split(reportLink, ";")
+	}
+	for _, v := range articleList {
+		linkList := strings.Split(v, "/")
+		if linkList[len(linkList)-1] != "" {
+			linkArticleId, _ := strconv.Atoi(linkList[len(linkList)-1])
+			articleIds = append(articleIds, linkArticleId)
+		}
+	}
+
+	lenarticleIds := len(articleIds)
+	if lenarticleIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	pars = make([]interface{}, 0)
+	condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(lenarticleIds) + `)`
+	pars = append(pars, articleIds)
+
+	listArticle, e := models.GetHomeList(condition, pars, 0, len(articleIds))
+	if e != nil {
+		err = errors.New("GetResourceDataList, Err: " + e.Error())
+		return
+	}
+	if len(listArticle) > 0 {
+		for _, v := range listArticle {
+			artItem := new(models.ActivityArticleResp)
+			artItem.ArticleId = v.ArticleId
+			artItem.Title = v.Title
+			items = append(items, artItem)
+		}
+	}
+	return
+}
+
 // GetActivityCityResp 获取活动关联城市,当同一个活动标签对应多个城市的时候,展示最近举办的活动
 func GetActivityCityResp() (mapItem map[string]string, err error) {
 	activityList, err := models.GetActivityLabelListCity()

+ 47 - 0
services/article.go

@@ -1935,3 +1935,50 @@ func YxArticleAnnotation(article *models.HomeArticle) (annotation string) {
 	annotation = body
 	return
 }
+
+// 通过接解析带有Md5的文章链接获取文章ID
+func GetReportLinkToArticleid(reportLink string) (articleId int, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("通过接解析带有Md5的文章链接获取文章ID失败"+err.Error(), 2)
+		}
+	}()
+	var artMd5 string
+	//处理Md5的
+	strnum1 := strings.Index(reportLink, "id=")
+	if strnum1 > 0 {
+		sliceId := strings.Split(reportLink, "id=")
+		if len(sliceId) > 1 {
+			reportLink = sliceId[1]
+			sliceMd5Id := strings.Split(reportLink, "&")
+			artMd5 = sliceMd5Id[0]
+		}
+		if artMd5 != "" {
+			detail, errArt := models.GetArticleDetailByIdMd5(artMd5)
+			if errArt != nil && errArt.Error() != utils.ErrNoRow() {
+				err = errArt
+				return
+			}
+			if detail != nil {
+				articleId = detail.ArticleId
+			}
+		}
+	} else {
+		//处理活动的
+		linkList := strings.Split(reportLink, "/")
+		if linkList[len(linkList)-1] != "" {
+			linkArticleId, _ := strconv.Atoi(linkList[len(linkList)-1])
+			if linkArticleId > 0 {
+				articleInfo, errArt := models.GetArticleDetailById(linkArticleId)
+				if errArt != nil && errArt.Error() != utils.ErrNoRow() {
+					err = errArt
+					return
+				}
+				if articleInfo != nil {
+					articleId = articleInfo.ArticleId
+				}
+			}
+		}
+	}
+	return
+}

+ 19 - 1
services/config.go

@@ -1,11 +1,13 @@
 package services
 
 import (
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
+	"strconv"
 )
 
-//是否展示限免标签
+// 是否展示限免标签
 func GetShowSustainable() (isShowSustainable bool) {
 	total, err := models.GetShowSustainable()
 	if err != nil {
@@ -29,3 +31,19 @@ func GetShowSustainableNew() (isShowSustainable bool, err error) {
 	}
 	return
 }
+
+// GetIndustryUserFollowMap 获取用户关注的产业
+func GetIndustryUserFollowMap(user *models.WxUserItem) (itemMap map[int]bool, err error) {
+	condition := ` AND  user_id = ` + strconv.Itoa(user.UserId)
+	listIndustryFllow, e := models.GetCygxIndustryFllowListByUserId(condition)
+	if e != nil {
+		err = errors.New("GetCygxIndustryFllowList  " + e.Error())
+		return
+	}
+	follwMap := make(map[int]bool)
+	for _, v := range listIndustryFllow {
+		follwMap[v.IndustrialManagementId] = true
+	}
+	itemMap = follwMap
+	return
+}

+ 130 - 13
services/industrial_management.go

@@ -77,26 +77,107 @@ func UpdateIndustrialManagementSubjectNnames() (err error) {
 }
 
 func ChageIndustrialArticleNum(cont context.Context) (err error) {
-	allList, err := models.IndustrialManagementAll()
+	IndustrialHzArticleNumUpdate()
+	IndustrialYxArticleNumUpdate()
+	IndustrialActivityNumUpdate()
+	return
+}
+
+//func init() {
+//	IndustrialHzArticleNumUpdate()
+//	IndustrialYxArticleNumUpdate()
+//	IndustrialActivityNumUpdate()
+//}
+
+// 更改弘则对应的报告关联产业近一个月的阅读量
+func IndustrialHzArticleNumUpdate() (err error) {
+	defer func() {
+		if err != nil {
+			//fmt.Println(err)
+			go utils.SendAlarmMsg("更改弘则对应的报告关联产业近一个月的阅读量失败"+err.Error(), 2)
+			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"更改弘则对应的报告关联产业近一个月的阅读量失败失败提醒", err.Error(), utils.EmailSendToUsers)
+		}
+	}()
+
+	err = models.UpdateIndustrialManagementArtticleReadNum()
+	if err != nil {
+		return
+	}
+	articleTypeIds, err := GetYanXuanArticleTypeIds()
+	if err != nil {
+		return
+	}
+	var condition string
+	if articleTypeIds == "" {
+		return
+	}
+	condition = ` AND a.article_type_id NOT  IN (` + articleTypeIds + `)  `
+	list, err := models.GetIndustrialManagementArtHistoryCount(condition)
 	if err != nil {
-		fmt.Println("GetArticleAll Err:", err.Error())
 		return
 	}
-	for _, v := range allList {
-		total, errTop := models.GetIndustrialManagementArtCount(v.IndustrialManagementId)
-		if errTop != nil {
-			fmt.Println("Top Err:", errTop.Error())
+	for _, v := range list {
+		err = models.UpdateIndustrialManagementArtReadNum(v.Count, v.IndustrialManagementId)
+		if err != nil {
 			return
 		}
-		if total > 0 {
-			err = models.UpdateIndustrialManagementArtReadNum(total, v.IndustrialManagementId)
-			if err != nil {
-				fmt.Println("Update Err:", err.Error())
-				return
-			}
+	}
+	return err
+}
+
+// 更改研选对应的报告关联产业近一个月的阅读量
+func IndustrialYxArticleNumUpdate() (err error) {
+	defer func() {
+		if err != nil {
+			//fmt.Println(err)
+			go utils.SendAlarmMsg("更改研选对应的报告关联产业近一个月的阅读量失败"+err.Error(), 2)
+			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"更改研选对应的报告关联产业近一个月的阅读量失败提醒", err.Error(), utils.EmailSendToUsers)
 		}
+	}()
+
+	articleTypeIds, err := GetYanXuanArticleTypeIds()
+	if err != nil {
+		return
 	}
-	return
+	var condition string
+	if articleTypeIds == "" {
+		return
+	}
+	condition = ` AND a.article_type_id   IN (` + articleTypeIds + `)  `
+	list, err := models.GetIndustrialManagementArtHistoryCount(condition)
+	if err != nil {
+		return
+	}
+	for _, v := range list {
+		err = models.UpdateIndustrialManagementArtYanXuanReadNum(v.Count, v.IndustrialManagementId)
+		if err != nil {
+			return
+		}
+	}
+	return err
+}
+
+// 更改活动关联产业近一个月的到会量
+func IndustrialActivityNumUpdate() (err error) {
+	defer func() {
+		if err != nil {
+			//fmt.Println(err)
+			go utils.SendAlarmMsg("更改活动关联产业近一个月的到会量失败"+err.Error(), 2)
+			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"更改活动关联产业近一个月的到会量失败", err.Error(), utils.EmailSendToUsers)
+		}
+	}()
+
+	list, err := models.GetIndustrialManagementActivityHistoryCount()
+	if err != nil {
+		return
+	}
+	for _, v := range list {
+		err = models.UpdateIndustrialManagementActivityNum(v.Count, v.IndustrialManagementId)
+		if err != nil {
+			return
+		}
+	}
+	return err
 }
 
 func ReportBillboardUpdate(cont context.Context) (err error) {
@@ -553,3 +634,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
+}

+ 15 - 15
services/wx_template_msg.go

@@ -51,7 +51,7 @@ func SendWxMsgWithFrequency(first, activityName, reserveResults, activityTime, a
 	return
 }
 
-//发送报告提问消息提醒
+// 发送报告提问消息提醒
 func SendWxMsgWithAsk(name, askTime, askMsg, title string, openIdList []*models.OpenIdList, articleId int) (err error) {
 	var msg string
 	defer func() {
@@ -127,7 +127,7 @@ func SendWxMsgWithAsk(name, askTime, askMsg, title string, openIdList []*models.
 	return
 }
 
-//到期提醒模板消息
+// 到期提醒模板消息
 func SendWxMsgWithCompanyRemind(first, keyword1, keyword2, remark string, openIdList []*models.OpenIdList) (err error) {
 	var msg string
 	defer func() {
@@ -165,7 +165,7 @@ func SendWxMsgWithCompanyRemind(first, keyword1, keyword2, remark string, openId
 	return
 }
 
-//发送报告提问消息提醒
+// 发送报告提问消息提醒
 func SendWxMsgWithArticleClassToAdmin(keyWord1, keyWord2, keyWord3, keyWord4 string, openIdList []*models.OpenIdList, articleId int) (err error) {
 	var msg string
 	defer func() {
@@ -207,7 +207,7 @@ func SendWxMsgWithArticleClassToAdmin(keyWord1, keyWord2, keyWord3, keyWord4 str
 	return
 }
 
-//发送用户阅读报告消息提醒
+// 发送用户阅读报告消息提醒
 func SendWxMsgWithArticleUserRemind(keyWord1, keyWord2 string, openIdList []*models.OpenIdList, articleId int) (err error) {
 	var msg string
 	defer func() {
@@ -245,7 +245,7 @@ func SendWxMsgWithArticleUserRemind(keyWord1, keyWord2 string, openIdList []*mod
 	return
 }
 
-//发送用户操作活动消息提醒
+// 发送用户操作活动消息提醒
 func SendWxMsgWithActivityUserRemind(keyWord1, keyWord2 string, openIdList []*models.OpenIdList, activityId int) (err error) {
 	var msg string
 	defer func() {
@@ -280,7 +280,7 @@ func SendWxMsgWithActivityUserRemind(keyWord1, keyWord2 string, openIdList []*mo
 	return
 }
 
-//发送用户操作专项调研活动消息提醒
+// 发送用户操作专项调研活动消息提醒
 func SendWxMsgWithSpecialActivityUserRemind(keyWord1, keyWord2 string, openIdList []*models.OpenIdList, activityId int) (err error) {
 	var msg string
 	defer func() {
@@ -315,7 +315,7 @@ func SendWxMsgWithSpecialActivityUserRemind(keyWord1, keyWord2 string, openIdLis
 	return
 }
 
-//活动带问提醒
+// 活动带问提醒
 func SendActivityAskApplyTemplateMsg(applyName, applyTime, askContent, activityName string, activityId int, itemOpenid *models.OpenIdList) (err error) {
 	var msg string
 	defer func() {
@@ -381,7 +381,7 @@ func SendActivityAskApplyTemplateMsg(applyName, applyTime, askContent, activityN
 	return
 }
 
-//活动带问提醒
+// 活动带问提醒
 func SendActivityAskApplyTemplateMsgV2(keyword1, keyword2, keyword3, keyword4, remark string, itemOpenid *models.OpenIdList, itemAct *models.ActivityDetail) (err error) {
 	var msg string
 	defer func() {
@@ -450,7 +450,7 @@ func SendActivityAskApplyTemplateMsgV2(keyword1, keyword2, keyword3, keyword4, r
 	return
 }
 
-//专项产业调研模板消息推送
+// 专项产业调研模板消息推送
 func SendSpecialTemplateMsg(applyName, applyTime, mobile, activityName, resource string, itemOpenid *models.OpenIdList) (err error) {
 	var msg string
 	defer func() {
@@ -586,7 +586,7 @@ func SendTemplateMsg(sendUrl string, data []byte, resource string, sendType int,
 	return
 }
 
-//发送报告更新的消息给预约的用户
+// 发送报告更新的消息给预约的用户
 func SendWxMsgWithArticleUpdate(first, keyWord1, keyWord2, keyWord3, keyWord4 string, item *models.OpenIdList, articleId int) (err error) {
 	var msg string
 	defer func() {
@@ -612,7 +612,7 @@ func SendWxMsgWithArticleUpdate(first, keyWord1, keyWord2, keyWord3, keyWord4 st
 	sendMap := make(map[string]interface{})
 	sendData := make(map[string]interface{})
 	sendMap["template_id"] = templateId
-	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "pageMy/reportDetail/reportDetail?id=" + strconv.Itoa(articleId)}
+	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "pageMy/reportDetail/reportDetail?id=" + strconv.Itoa(articleId) + "&IsSendWx=1"}
 	sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
 	sendData["keyword1"] = map[string]interface{}{"value": keyWord1, "color": "#173177"}
 	sendData["keyword2"] = map[string]interface{}{"value": keyWord2, "color": "#173177"}
@@ -624,7 +624,7 @@ func SendWxMsgWithArticleUpdate(first, keyWord1, keyWord2, keyWord3, keyWord4 st
 	return
 }
 
-//周日下午4点半,推送全部活动
+// 周日下午4点半,推送全部活动
 func SendActivityOnenIdWxTemplateMsg(first, keyWord1, keyWord2, keyWord3, keyWord4 string, openIdList []*models.OpenIdList) (err error) {
 	var msg string
 	defer func() {
@@ -663,8 +663,8 @@ func SendActivityOnenIdWxTemplateMsg(first, keyWord1, keyWord2, keyWord3, keyWor
 	return
 }
 
-//发送用户留言提醒
-//func SendCommentWxTemplateMsg(title, companyName, userName, sellerName, createTime, content string, openIdList []*models.OpenIdList, articleId int) (err error) {
+// 发送用户留言提醒
+// func SendCommentWxTemplateMsg(title, companyName, userName, sellerName, createTime, content string, openIdList []*models.OpenIdList, articleId int) (err error) {
 func SendCommentWxTemplateMsg(req models.AddCygxArticleCommentReq, user *models.WxUserItem, articleInfo *models.ArticleDetail) (err error) {
 	var msg string
 	defer func() {
@@ -762,7 +762,7 @@ func SendCommentWxTemplateMsg(req models.AddCygxArticleCommentReq, user *models.
 	return
 }
 
-//微路演新增留言提问消息提醒
+// 微路演新增留言提问消息提醒
 func SendWxMsgWithMicroRoadshowAsk(req models.AddVideoCommnetReq, user *models.WxUserItem, resourceId int) (err error) {
 	var msg string
 	defer func() {