浏览代码

no message

xingzai 2 年之前
父节点
当前提交
1dc0fe6330

+ 28 - 19
controllers/report.go

@@ -41,27 +41,36 @@ func (this *ReportController) TradeList() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	ChartPermissionId, _ := this.GetInt("ChartPermissionId")
 	if ChartPermissionId < 1 {
 		br.Msg = "请输入分类ID"
 		return
 	}
-	list, err := models.GetTradeAll(ChartPermissionId)
+	listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	var condition string
-	var pars []interface{}
-	for k, v := range list {
-		if v.PolymerizationId != "" {
-			condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
-		} else {
-			condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
+	var list []*models.TradeReportMapping
+	categoryMap := make(map[int]int)
+	for _, v := range listCategory {
+		if categoryMap[v.CategoryId] > 0 {
+			continue
 		}
-		listArticle, err := models.GetHomeList(condition, pars, 0, 1)
+		categoryMap[v.CategoryId] = v.CategoryId
+		list = append(list, v)
+	}
+	//var condition string
+	//var pars []interface{}
+	for k, v := range list {
+		//if v.PolymerizationId != "" {
+		//	condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
+		//} else {
+		//	condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
+		//}
+		listArticle, _, err := models.GetReportAndproductIndustrylList(v.CategoryId, 0, 1)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.Msg = "GetHomeList,Err:" + err.Error()
@@ -70,15 +79,15 @@ func (this *ReportController) TradeList() {
 		if len(listArticle) > 0 {
 			list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
 
-			count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
-			if err != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
-				return
-			}
-			if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
-				list[k].IsRed = true
-			}
+			//count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
+			//if err != nil {
+			//	br.Msg = "获取信息失败"
+			//	br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+			//	return
+			//}
+			//if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
+			//	list[k].IsRed = true
+			//}
 		}
 	}
 	resp := new(models.TradeReportMappingResp)

+ 118 - 96
controllers/tactics.go

@@ -42,7 +42,7 @@ func (this *TacticsController) List() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	categoryId, _ := this.GetInt("CategoryId")
@@ -56,99 +56,121 @@ func (this *TacticsController) List() {
 	}
 	startSize = paging.StartIndex(currentIndex, pageSize)
 
-	var condition string
-	var listTacticsSrt string
-	var pars []interface{}
-	var total int
+	//var condition string
+	//var listTacticsSrt string
+	//var pars []interface{}
+	//var total int
 	resp := new(models.TacticsListResp)
-	page := paging.GetPaging(currentIndex, pageSize, total)
+	//page := paging.GetPaging(currentIndex, pageSize, total)
 
 	//获取该产业下所对应的行业图片
-	detail, errCategory := models.GetdetailByCategoryIdOneByHangye(categoryId)
-	if errCategory != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-		return
-	}
+	//detail, errCategory := models.GetdetailByCategoryIdOneByHangye(categoryId)
+	//if errCategory != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
+	//	return
+	//}
 	//对应行业的图片
-	detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
-	if err != nil {
-		br.Msg = "获取数据失败"
-		br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
-		return
-	}
-	chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
-	mapChartPermission := make(map[string]string)
-	var permissionName string
-	var imgUrlChartPermission string
-	for _, v := range chartPermissionUrlList {
-		vslice := strings.Split(v, "_")
-		permissionName = vslice[0]
-		imgUrlChartPermission = vslice[len(vslice)-1]
-		mapChartPermission[permissionName] = imgUrlChartPermission
-	}
+	//detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
+	//if err != nil {
+	//	br.Msg = "获取数据失败"
+	//	br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
+	//mapChartPermission := make(map[string]string)
+	//var permissionName string
+	//var imgUrlChartPermission string
+	//for _, v := range chartPermissionUrlList {
+	//	vslice := strings.Split(v, "_")
+	//	permissionName = vslice[0]
+	//	imgUrlChartPermission = vslice[len(vslice)-1]
+	//	mapChartPermission[permissionName] = imgUrlChartPermission
+	//}
 
 	//对应分类的所图片
-	detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
-	if err != nil {
-		br.Msg = "获取数据失败"
-		br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
-		return
-	}
-	categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
-	mapCategoryUrl := make(map[string]string)
-	var categoryIdStr string
-	var imgUrlChart string
-	for _, v := range categoryUrlList {
-		vslice := strings.Split(v, "_")
-		categoryIdStr = vslice[0]
-		imgUrlChart = vslice[len(vslice)-1]
-		mapCategoryUrl[categoryIdStr] = imgUrlChart
-	}
+	//detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
+	//if err != nil {
+	//	br.Msg = "获取数据失败"
+	//	br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+	//mapCategoryUrl := make(map[string]string)
+	//var categoryIdStr string
+	//var imgUrlChart string
+	//for _, v := range categoryUrlList {
+	//	vslice := strings.Split(v, "_")
+	//	categoryIdStr = vslice[0]
+	//	imgUrlChart = vslice[len(vslice)-1]
+	//	mapCategoryUrl[categoryIdStr] = imgUrlChart
+	//}
 
-	if categoryId < 0 {
-		listTactics, err := models.GetReportMappingStrategyAll()
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
-			return
-		}
-		for _, v := range listTactics {
-			listTacticsSrt = listTacticsSrt + strconv.Itoa(v.CategoryId) + `,`
-		}
-		listTacticsSrt = strings.TrimRight(listTacticsSrt, ",")
-		condition = ` AND category_id IN(` + listTacticsSrt + `)`
-	} else {
-		if detail.CeLueFieldId != "" {
-			condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
-		} else if detail.PolymerizationId != "" {
-			condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
-		} else {
-			condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
-		}
-	}
-	total, err = models.GetHomeCount(condition, pars)
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.Msg = "获取帖子总数失败,Err:" + err.Error()
-		return
-	}
-	page = paging.GetPaging(currentIndex, pageSize, total)
-	list, err := models.GetReportTacticsList(condition, pars, uid, startSize, pageSize)
+	//if categoryId < 0 {
+	//	listTactics, err := models.GetReportMappingStrategyAll()
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		br.Msg = "获取信息失败"
+	//		br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	for _, v := range listTactics {
+	//		listTacticsSrt = listTacticsSrt + strconv.Itoa(v.CategoryId) + `,`
+	//	}
+	//	listTacticsSrt = strings.TrimRight(listTacticsSrt, ",")
+	//	condition = ` AND category_id IN(` + listTacticsSrt + `)`
+	//} else {
+	//	if detail.CeLueFieldId != "" {
+	//		condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
+	//	} else if detail.PolymerizationId != "" {
+	//		condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
+	//	} else {
+	//		condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
+	//	}
+	//}
+	//total, err = models.GetHomeCount(condition, pars)
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.Msg = "获取帖子总数失败,Err:" + err.Error()
+	//	return
+	//}
+
+	//list, err := models.GetReportTacticsList(condition, pars, uid, startSize, pageSize)
+
+	list, total, err := models.GetReportAndproductIndustrylList(categoryId, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取帖子数据失败,Err:" + err.Error()
 		return
 	}
-
+	var articleIds []int
+	var productInteriorIs []int
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	for _, v := range list {
+		//if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
+		//	list[k].IsRed = true
+		//}
+		if v.Resource == 1 {
+			articleIds = append(articleIds, v.ArticleId)
+		} else {
+			productInteriorIs = append(productInteriorIs, v.ArticleId)
+		}
+		//list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+	}
+	ArticleHistoryMap := services.GetArticleHistoryByUser(articleIds, user)
+	ProductInteriorHistoryMap := services.GetCygxProductInteriorHistoryListMap(articleIds, user)
 	for k, v := range list {
-		if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
-			list[k].IsRed = true
+		if v.Resource == 1 {
+			if ArticleHistoryMap[v.ArticleId] == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
+				list[k].IsRed = true
+			}
+		} else {
+			if ProductInteriorHistoryMap[v.ArticleId] == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
+				list[k].IsRed = true
+			}
 		}
-		list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
 	}
 	if categoryId > 0 {
-		detail, errCategory := models.GetdetailByCategoryId(categoryId)
+		detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
 		if errCategory != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
@@ -156,24 +178,24 @@ func (this *TacticsController) List() {
 		}
 		resp.MatchTypeName = detail.MatchTypeName
 	}
-	lenList := len(list)
-	for i := 0; i < lenList; i++ {
-		item := list[i]
-		list[i].Body, _ = services.GetReportContentTextSub(item.Body)
-		list[i].Abstract = html.UnescapeString(item.Abstract)
-		//list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
-		list[i].Annotation = strings.Replace(item.Annotation, "<br>", "", -1)
-		//行业比较研究、资金流向,显示报告的摘要
-		if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
-			list[i].Annotation = list[i].Abstract
-		}
-		//if item.ArticleId == 6881 {
-		//	fmt.Println(list[i].Annotation)
-		//}
-		list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
-	}
-
-	resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
+	//lenList := len(list)
+	//for i := 0; i < lenList; i++ {
+	//	item := list[i]
+	//	list[i].Body, _ = services.GetReportContentTextSub(item.Body)
+	//	list[i].Abstract = html.UnescapeString(item.Abstract)
+	//	//list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
+	//	list[i].Annotation = strings.Replace(item.Annotation, "<br>", "", -1)
+	//	//行业比较研究、资金流向,显示报告的摘要
+	//	if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
+	//		list[i].Annotation = list[i].Abstract
+	//	}
+	//	//if item.ArticleId == 6881 {
+	//	//	fmt.Println(list[i].Annotation)
+	//	//}
+	//	list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
+	//}
+	//
+	//resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 	resp.List = list
 	resp.Paging = page
 	br.Ret = 200

+ 8 - 0
models/article_category_mapping.go

@@ -100,3 +100,11 @@ func GetCygxReportMappingcelue(condition string) (items []*CygxReportMapping, er
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// 通过分类ID获取详情
+func GetCygxReportMappingCygxByCategoryId(categoryId int) (item *CygxReportMappingCygx, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping_cygx WHERE  id=? `
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}

+ 21 - 10
models/article_history_record_newpv.go

@@ -23,7 +23,7 @@ type CygxArticleHistoryRecordNewpv struct {
 	Source      string `description:"来源,MOBILE:手机端,PC:电脑端"`
 }
 
-//添加阅读记录信息
+// 添加阅读记录信息
 func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId int64, err error) {
 	o, err := orm.NewOrm().Begin()
 	if err != nil {
@@ -69,7 +69,7 @@ func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId
 	return
 }
 
-//获取最新的一条阅读记录
+// 获取最新的一条阅读记录
 func GetNewArticleHistoryRecordNewpv(uid, articleId int, modifytime string) (item *AddStopTimeNewRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM  cygx_article_history_record_newpv WHERE user_id = ? AND article_id = ? 	AND modify_time <='` + modifytime + `'  ORDER BY id DESC LIMIT 1;`
@@ -77,7 +77,7 @@ func GetNewArticleHistoryRecordNewpv(uid, articleId int, modifytime string) (ite
 	return
 }
 
-//把十分钟之内的阅读记录进行累加
+// 把十分钟之内的阅读记录进行累加
 func UpdateCygxArticleViewRecordNewpv(itemRep *CygxArticleHistoryRecordNewpv, stopTime int) (err error) {
 	o, err := orm.NewOrm().Begin()
 	if err != nil {
@@ -113,7 +113,7 @@ func UpdateCygxArticleViewRecordNewpv(itemRep *CygxArticleHistoryRecordNewpv, st
 	return
 }
 
-//把十分钟之内的阅读记录进行累加
+// 把十分钟之内的阅读记录进行累加
 func UpdateCygxArticleViewRecordNewpvList(itemRep *CygxArticleHistoryRecordNewpv, stopTime int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_article_history_record_newpv 
@@ -148,7 +148,7 @@ type CygxArticleHistoryRecordAll struct {
 	IsDel          int       `description:"是否删除"`
 }
 
-//获取当天总表的阅读记录
+// 获取当天总表的阅读记录
 func GetArticleHistoryRecordAllList() (items []*CygxArticleHistoryRecordNewpv, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT * FROM cygx_article_history_record_all WHERE create_time >= date(NOW()) 
@@ -159,7 +159,7 @@ func GetArticleHistoryRecordAllList() (items []*CygxArticleHistoryRecordNewpv, e
 	return
 }
 
-//获取列表信息根据手机号分组
+// 获取列表信息根据手机号分组
 func GetArticleHistoryRecordAllByMobileList(condition string) (items []*CygxArticleHistoryRecordAll, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_article_history_record_all  WHERE 1 = 1 ` + condition + `  GROUP BY mobile   `
@@ -167,7 +167,7 @@ func GetArticleHistoryRecordAllByMobileList(condition string) (items []*CygxArti
 	return
 }
 
-//修改用户阅读的相关信息
+// 修改用户阅读的相关信息
 func UpdateCygxArticleHistoryRecordAll(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string
@@ -201,7 +201,7 @@ type EsUserInteraction struct {
 	CompanyArticleHistoryNum int    `description:"机构阅读数量"`
 }
 
-//机构阅读记录列表
+// 机构阅读记录列表
 func GetCygxArticleHistoryRecordByCompanyList(condition string, startSize, pageSize int) (items []*EsUserInteraction, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT
@@ -239,7 +239,7 @@ func GetCygxArticleHistoryRecordByCompanyList(condition string, startSize, pageS
 	return
 }
 
-//获取阅读记录数量
+// 获取阅读记录数量
 func GetCygxArticleHistoryCountByCompany(condition string) (count int, err error) {
 	o := orm.NewOrm()
 	sqlCount := `SELECT
@@ -270,7 +270,7 @@ type CygxArticleHistoryAllTopResp struct {
 	Num       int `description:"数量"`
 }
 
-//获取近15天之内的阅读数据最多的15报告
+// 获取近15天之内的阅读数据最多的15报告
 func GetCygxArticleHistoryAllTop(pars []interface{}, condition string) (items []*CygxArticleHistoryAllTopResp, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT
@@ -291,3 +291,14 @@ func GetCygxArticleHistoryAllTop(pars []interface{}, condition string) (items []
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetCygxArticleHistoryRecordNewpvList(condition string, pars []interface{}) (items []*CygxArticleHistoryRecordNewpv, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_history_record_newpv as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 11 - 0
models/product_interior_history.go

@@ -26,3 +26,14 @@ func AddCygxProductInteriorHistory(item *CygxProductInteriorHistory) (lastId int
 	lastId, err = o.Insert(item)
 	return
 }
+
+// 列表
+func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*CygxProductInteriorHistory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_product_interior_history as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 31 - 0
models/report.go

@@ -151,6 +151,37 @@ func GetReportAndproductInteriorIndustrialList(pars []interface{}, categoryId, i
 	return
 }
 
+// 获取行业报告列表
+func GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (items []*ReportArticle, total int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			art.article_id,
+			art.title,
+			art.publish_date,
+			1 AS resource 
+		FROM
+			cygx_article AS art 
+		WHERE
+			art.publish_status = 1 
+			AND category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
+		SELECT
+			art.product_interior_id AS article_id,
+			art.title,
+			art.publish_time AS publish_date,
+			2 AS resource 
+		FROM
+			cygx_product_interior AS art 
+		WHERE
+			art.STATUS = 1 
+			AND art.visible_range = 1 
+			AND art.match_type_id = ` + strconv.Itoa(categoryId)
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	sql += `    ORDER BY publish_date DESC LIMIT ?,? `
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 // 产业下所关联的文章分类列表
 func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
 	o := orm.NewOrm()

+ 43 - 0
models/report_mapping.go

@@ -115,6 +115,49 @@ func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error)
 	return
 }
 
+// 行业列表
+func GetTradeArticleAndProductInterior(ChartPermissionId int) (items []*TradeReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			map.sort,
+			map.match_type_name,
+			map.id AS category_id 
+		FROM
+			cygx_report_mapping_cygx AS map
+			INNER JOIN cygx_report_mapping_group AS g ON g.id_cygx = map.id
+			INNER JOIN cygx_report_mapping_celue AS cl ON cl.category_id = g.category_id_celue
+			INNER JOIN cygx_article AS art ON art.category_id = cl.category_id 
+		WHERE
+			1 = 1 
+			AND map.report_type = 1 
+			AND map.is_report = 1 
+			AND art.is_report = 1 
+			AND art.publish_status = 1 
+			AND map.chart_permission_id = ? 
+		GROUP BY
+			match_type_name UNION ALL
+		SELECT
+			map.sort,
+			map.match_type_name,
+			map.id AS category_id 
+		FROM
+			cygx_report_mapping_cygx AS map
+			INNER JOIN cygx_industrial_management AS im ON im.chart_permission_id = map.chart_permission_id
+			INNER JOIN cygx_product_interior AS art ON art.match_type_id = map.id 
+		WHERE
+			1 = 1 
+			AND art.STATUS = 1 
+			AND art.visible_range = 1 
+			AND map.report_type = 1 
+			AND map.chart_permission_id = ? 
+		GROUP BY
+			match_type_name 
+		ORDER BY
+			sort DESC `
+	_, err = o.Raw(sql, ChartPermissionId, ChartPermissionId).QueryRows(&items)
+	return
+}
+
 type IndustrialToArticleCategoryRep struct {
 	CategoryId    int    `description:"分类ID"`
 	MatchTypeName string `description:"匹配类型"`

+ 34 - 0
services/article_history.go

@@ -0,0 +1,34 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+func GetArticleHistoryByUser(articleIds []int, user *models.WxUserItem) (mapResp map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取用户的阅读数据,信息失败,Err:"+err.Error(), 3)
+		}
+	}()
+	lenIds := len(articleIds)
+	if lenIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenIds) + `) AND  user_id = ?`
+	pars = append(pars, articleIds, user.UserId)
+	list, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
+	if err != nil {
+		return
+	}
+	mapResp = make(map[int]int, 0)
+	for _, v := range list {
+		mapResp[v.ArticleId]++
+	}
+	return
+}

+ 28 - 0
services/product_interior.go

@@ -133,3 +133,31 @@ func AddCygxProductInteriorHistory(user *models.WxUserItem, articleId int) (err
 	_, err = models.AddCygxProductInteriorHistory(historyRecord)
 	return
 }
+
+// 获取产品内测的阅读数据
+func GetCygxProductInteriorHistoryListMap(productInteriorIs []int, user *models.WxUserItem) (mapPv map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取产品内测的阅读数据,信息失败,Err:"+err.Error(), 3)
+		}
+	}()
+	lenproductInteriorIs := len(productInteriorIs)
+	if lenproductInteriorIs == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND product_interior_id IN (` + utils.GetOrmInReplace(lenproductInteriorIs) + `) AND  user_id = ?`
+	pars = append(pars, productInteriorIs, user.UserId)
+	list, err := models.GetCygxProductInteriorHistoryList(condition, pars)
+	if err != nil {
+		return
+	}
+	mapPv = make(map[int]int, 0)
+	for _, v := range list {
+		mapPv[v.ProductInteriorId]++
+	}
+	return
+}