Browse Source

Merge branch 'cygx_14.2' of http://8.136.199.33:3000/hongze/hongze_clpt

zhangchuanxing 2 months ago
parent
commit
5c0fc7a9e6

+ 143 - 205
controllers/report.go

@@ -841,9 +841,9 @@ func (this *MobileReportController) SearchReport() {
 	}
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
-	articleType, _ := this.GetInt("ArticleType", 1)
+	//articleType, _ := this.GetInt("ArticleType", 1)
 	keyWord := this.GetString("KeyWord")
-	isAll, _ := this.GetBool("IsAll")
+	//isAll, _ := this.GetBool("IsAll")
 	var condition string
 	var conditionYxSpecial string
 	var pars []interface{}
@@ -853,9 +853,9 @@ func (this *MobileReportController) SearchReport() {
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
 	}
-	if isAll {
-		pageSize = utils.PageSize5
-	}
+	//if isAll {
+	//	pageSize = utils.PageSize5
+	//}
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
@@ -863,198 +863,136 @@ func (this *MobileReportController) SearchReport() {
 
 	resp := new(models.ReoprtSearchResp)
 	//匹配报告标题、
-	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	//articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+	//	return
+	//}
+	//if articleTypeIds == "" {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "研选分类ID不能为空"
+	//	return
+	//}
+	//处理对应的文章类型标签按钮
+	nameMap, styleMap, err := services.GetArticleTypeMap()
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
 		return
 	}
-	if articleTypeIds == "" {
+
+	if keyWord != "" {
+		//if articleType == 1 {
+		//	condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id NOT IN (` + articleTypeIds + `)  `
+		//	total, err = models.GetReoprtSearchCountHz(condition)
+		//} else {
+		//	condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id  IN (` + articleTypeIds + `)  `
+		//	total, err = models.GetReoprtSearchCountYx(condition)
+		//}
+		condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body_text LIKE '%` + keyWord + `%'  OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1    `
+		conditionYxSpecial = `   AND ( a.title LIKE '%` + keyWord + `%' OR  a.content LIKE '%` + keyWord + `%')  `
+	}
+
+	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "研选分类ID不能为空"
+		br.Msg = "获取总数失败,Err:" + err.Error()
 		return
 	}
-	//处理对应的文章类型标签按钮
-	nameMap, styleMap, err := services.GetArticleTypeMap()
+	var list []*models.ArticleListResp
+	//list := new([]models.ArticleResearchResp)
+	//if articleType == 1 {
+	//	list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
+	//} else {
+	//	total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
+	//}
+	total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	if isAll {
-		total = utils.PageSize5
-		conditionHz := `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id NOT IN (` + articleTypeIds + `)  `
-		conditionYx := `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id  IN (` + articleTypeIds + `)  `
-
-		listHz, err := models.GetArticleResearchListHz(conditionHz, pars, startSize, pageSize, user.UserId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-		listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId, true)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-
-		listHz, err = services.HandleArticleCategoryImg(listHz, user)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
-			return
-		}
 
-		listYx, err = services.HandleArticleCategoryImg(listYx, user)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
-			return
-		}
+	//return
+	list, err = services.HandleArticleCategoryImg(list, user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
+		return
+	}
 
-		for _, v := range listHz {
-			item := models.ArticleResearchResp{
-				ArticleId:       v.ArticleId,
-				ArticleTypeId:   v.ArticleTypeId,
-				Title:           v.Title,
-				PublishDate:     v.PublishDate,
-				DepartmentId:    v.DepartmentId,
-				NickName:        v.NickName,
-				IsCollect:       v.IsCollect,
-				Pv:              v.Pv,
-				CollectNum:      v.CollectNum,
-				Abstract:        v.Abstract,
-				Annotation:      v.Annotation,
-				ImgUrlPc:        v.ImgUrlPc,
-				ArticleTypeName: nameMap[v.ArticleTypeId],
-				ButtonStyle:     styleMap[v.ArticleTypeId],
-				List:            v.List,
+	for _, v := range list {
+		item := models.ArticleResearchResp{
+			ArticleId:       v.ArticleId,
+			ArticleTypeId:   v.ArticleTypeId,
+			Title:           v.Title,
+			PublishDate:     v.PublishDate,
+			DepartmentId:    v.DepartmentId,
+			NickName:        v.NickName,
+			IsCollect:       v.IsCollect,
+			Pv:              v.Pv,
+			CollectNum:      v.CollectNum,
+			Abstract:        v.Abstract,
+			Annotation:      v.Annotation,
+			ImgUrlPc:        v.ImgUrlPc,
+			ArticleTypeName: nameMap[v.ArticleTypeId],
+			ButtonStyle:     styleMap[v.ArticleTypeId],
+			List:            v.List,
+		}
+
+		if v.IsSpecial == 1 {
+			//去除图片标签
+			item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation)
+
+			item.IsSpecial = true
+			item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
+			if v.CompanyTags != "" {
+				item.CompanyTags = strings.Split(v.CompanyTags, ",")
+			} else {
+				item.CompanyTags = []string{}
 			}
-			if v.ReportId > 0 {
-				item.Resource = 3
-				item.ReportId = v.ReportId
+			if v.IndustryTags != "" {
+				item.IndustryTags = strings.Split(v.IndustryTags, ",")
+			} else {
+				item.IndustryTags = []string{}
 			}
-			resp.ListHz = append(resp.ListHz, &item)
-		}
-
-		for _, v := range listYx {
-			item := models.ArticleResearchResp{
-				ArticleId:       v.ArticleId,
-				ArticleTypeId:   v.ArticleTypeId,
-				Title:           v.Title,
-				PublishDate:     v.PublishDate,
-				DepartmentId:    v.DepartmentId,
-				NickName:        v.NickName,
-				IsCollect:       v.IsCollect,
-				Pv:              v.Pv,
-				CollectNum:      v.CollectNum,
-				Abstract:        v.Abstract,
-				Annotation:      v.Annotation,
-				ImgUrlPc:        v.ImgUrlPc,
-				ArticleTypeName: nameMap[v.ArticleTypeId],
-				ButtonStyle:     styleMap[v.ArticleTypeId],
-				List:            v.List,
+			item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+			if v.SpecialType == 1 {
+				item.Title = "【笔记】" + item.Title
+			} else if v.SpecialType == 2 {
+				item.Title = "【观点】" + item.Title
 			}
-			resp.ListYx = append(resp.ListYx, &item)
-		}
-	} else {
-
-		if keyWord != "" {
-			if articleType == 1 {
-				condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id NOT IN (` + articleTypeIds + `)  `
-				total, err = models.GetReoprtSearchCountHz(condition)
-			} else {
-				condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id  IN (` + articleTypeIds + `)  `
-				total, err = models.GetReoprtSearchCountYx(condition)
+			if v.MyCollectNum > 0 {
+				item.IsCollect = true
 			}
-
-			conditionYxSpecial = `   AND ( a.title LIKE '%` + keyWord + `%' OR  a.content LIKE '%` + keyWord + `%')  `
-		}
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.Msg = "获取总数失败,Err:" + err.Error()
-			return
-		}
-		var list []*models.ArticleListResp
-		//list := new([]models.ArticleResearchResp)
-		if articleType == 1 {
-			list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
+			item.Resource = 2
+			item.ResourceObj = "articlespecial"
 		} else {
-			total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
-		}
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-		//return
-		list, err = services.HandleArticleCategoryImg(list, user)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
-			return
-		}
-
-		for _, v := range list {
-			item := models.ArticleResearchResp{
-				ArticleId:       v.ArticleId,
-				ArticleTypeId:   v.ArticleTypeId,
-				Title:           v.Title,
-				PublishDate:     v.PublishDate,
-				DepartmentId:    v.DepartmentId,
-				NickName:        v.NickName,
-				IsCollect:       v.IsCollect,
-				Pv:              v.Pv,
-				CollectNum:      v.CollectNum,
-				Abstract:        v.Abstract,
-				Annotation:      v.Annotation,
-				ImgUrlPc:        v.ImgUrlPc,
-				ArticleTypeName: nameMap[v.ArticleTypeId],
-				ButtonStyle:     styleMap[v.ArticleTypeId],
-				List:            v.List,
-			}
 			if v.ReportId > 0 {
 				item.Resource = 3
 				item.ReportId = v.ReportId
-			}
-			if v.IsSpecial == 1 {
-				//去除图片标签
-				item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation)
-
-				item.IsSpecial = true
-				item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
-				if v.CompanyTags != "" {
-					item.CompanyTags = strings.Split(v.CompanyTags, ",")
-				} else {
-					item.CompanyTags = []string{}
-				}
-				if v.IndustryTags != "" {
-					item.IndustryTags = strings.Split(v.IndustryTags, ",")
+				item.ResourceObj = "articleficc"
+			} else {
+				item.Resource = 1
+				if v.ArticleTypeId > 0 {
+					item.ResourceObj = "articleyx"
 				} else {
-					item.IndustryTags = []string{}
-				}
-				item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
-				if v.SpecialType == 1 {
-					item.Title = "【笔记】" + item.Title
-				} else if v.SpecialType == 2 {
-					item.Title = "【观点】" + item.Title
+					item.ResourceObj = "articlevmp"
 				}
-				if v.MyCollectNum > 0 {
-					item.IsCollect = true
-				}
-			}
-			if articleType == 1 {
-				resp.ListHz = append(resp.ListHz, &item)
-			} else {
-				resp.ListYx = append(resp.ListYx, &item)
+
 			}
 		}
+		resp.ListHz = append(resp.ListHz, &item)
+		//if articleType == 1 {
+		//	resp.ListHz = append(resp.ListHz, &item)
+		//} else {
+		//	resp.ListYx = append(resp.ListYx, &item)
+		//}
 	}
 
-	if keyWord != "" {
-		//go services.AddUserSearchLog(user, keyWord, 5)
-	}
+	//if keyWord != "" {
+	//go services.AddUserSearchLog(user, keyWord, 5)
+	//}
 	if len(resp.ListHz) == 0 {
 		resp.ListHz = make([]*models.ArticleResearchResp, 0)
 	}
@@ -1102,19 +1040,19 @@ func (this *MobileReportController) SearchResource() {
 	keyWord := this.GetString("KeyWord")
 	var condition string
 
-	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
-		return
-	}
-	if articleTypeIds == "" {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "研选分类ID不能为空"
-		return
-	}
+	//articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+	//	return
+	//}
+	//if articleTypeIds == "" {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "研选分类ID不能为空"
+	//	return
+	//}
 
-	condition = `  AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
+	condition = `  AND a.publish_status = 1  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
 	listHz, err := models.GetSearchResourceList(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -1122,42 +1060,42 @@ func (this *MobileReportController) SearchResource() {
 		return
 	}
 
-	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 + `%'  )  `
-	listYx, err := models.GetSearchResourceList(condition)
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-		return
-	}
+	//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 + `%'  )  `
+	//listYx, err := models.GetSearchResourceList(condition)
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+	//	return
+	//}
 
-	if len(listYx) > 0 {
-		listYx, err = services.HandleIndustryList(listYx, user, "Yx")
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取信息失败,Err:" + err.Error()
-			return
-		}
-	}
+	//if len(listYx) > 0 {
+	//	listYx, err = services.HandleIndustryList(listYx, user, "Yx")
+	//	if err != nil {
+	//		br.Msg = "获取信息失败"
+	//		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
 	if len(listHz) > 0 {
-		listHz, err = services.HandleIndustryList(listHz, user, "Hz")
+		listHz, err = services.HandleIndustryListHzAndYx(listHz, user, "Hz")
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
 	}
-	if keyWord != "" {
-		//go services.AddUserSearchLog(user, keyWord, 4)
-	}
+	//if keyWord != "" {
+	//go services.AddUserSearchLog(user, keyWord, 4)
+	//}
 	resp := new(models.SearchResourceResp)
 	if len(listHz) == 0 {
 		listHz = make([]*models.IndustrialManagement, 0)
 	}
-	if len(listYx) == 0 {
-		listYx = make([]*models.IndustrialManagement, 0)
-	}
+	//if len(listYx) == 0 {
+	//	listYx = make([]*models.IndustrialManagement, 0)
+	//}
 	resp.ListHz = listHz
-	resp.ListYx = listYx
+	resp.ListYx = make([]*models.IndustrialManagement, 0)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 1 - 0
controllers/search.go

@@ -396,6 +396,7 @@ func (this *MobileSearchController) ComprehensiveList() {
 		br.ErrMsg = "检索失败,Err:" + err.Error()
 		return
 	}
+	fmt.Println("tmpTotalResult", tmpTotalResult)
 
 	list, err := services.GetResourceDataEsList(tmpResult, user)
 	if err != nil {

+ 8 - 0
models/activity.go

@@ -647,3 +647,11 @@ func GetActivityListByCondition(condition string, pars []interface{}) (items []*
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 获取所有未开始、进行中的活动ID
+func GetActivityIdListNoEnd() (items []*CygxActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT activity_id  FROM cygx_activity WHERE  active_state IN (1,2) `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 8 - 0
models/industry_fllow.go

@@ -92,3 +92,11 @@ func GetUserFllowIndustrialList(userId int) (items []*CygxIndustryFllow, err err
 	_, err = o.Raw(sql, userId).QueryRows(&items)
 	return
 }
+
+// UpdateIndustrialManagementTimeLineData   更新时间线关联对应最新文章的数据信息
+func UpdateIndustrialManagementTimeLineData(industrialManagementId int, timeLineData string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industrial_management SET time_line_data = ? WHERE  industrial_management_id = ?   `
+	_, err = o.Raw(sql, timeLineData, industrialManagementId).Exec()
+	return
+}

+ 14 - 3
models/report.go

@@ -31,10 +31,17 @@ type IndustrialManagement struct {
 	Source                 int                  `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
 	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
 	MinReportTime          string               `description:"报告最早发布时间"`
+	TimeLineData           string               `description:"时间线所关联最新三篇文章的json数据"`
+	ListTimeLine           []TimeLineReportResp `description:"时间线所关联最新三篇文章列表"`
 	IndustryVideo          *MicroVideoSimpleInfo
 	AuthInfo               *UserPermissionAuthInfo
 }
 
+type TimeLineReportResp struct {
+	Title       string `description:"标题"`
+	PublishDate string `description:"发布时间"`
+}
+
 type MicroVideoSimpleInfo struct {
 	Id                  int    `description:"视频ID"`
 	Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
@@ -238,6 +245,7 @@ func GetReportAndproductIndustrylListimg(categoryId, userId, startSize, pageSize
 func GetSearchResourceList(condition string) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
+			m.time_line_data,
 			m.industry_name,
 			m.chart_permission_id,
 			m.industrial_management_id,
@@ -861,6 +869,7 @@ type ArticleResearchResp struct {
 	SpecialColumnId int                          `description:"专栏栏目id"`
 	TopTime         int                          `description:"置顶时间"`
 	Resource        int                          `description:"来源类型,1:文章、2:产品内测、3:FICC研报"`
+	ResourceObj     string                       `description:"articleficc:FICC研报、articlevmp:上海策略平台报告、articleyx:研选报告、articlespecial:研选专栏"`
 	ReportId        int                          `description:"FICC研报ID"`
 }
 
@@ -1012,6 +1021,7 @@ func GetArticleResearchListYx(condition string, pars []interface{}, startSize, p
 func GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (total int, items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
+   			a.category_id,
 			a.article_id,
 			a.title,
 			a.body,
@@ -1034,15 +1044,16 @@ func GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial string, pa
 			cygx_article AS a
 			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
 			LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
-			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
+			LEFT JOIN cygx_article_department AS d ON d.department_id = a.department_id 
 		WHERE
-			1 = 1  AND a.publish_status = 1  `
+			1 = 1  AND a.publish_status = 1   `
 	if condition != "" {
-		sql += condition
+		sql += condition + " GROUP BY article_id  "
 	}
 	if needYanxuanSpecial {
 		sql += `UNION ALL
 	SELECT
+		0 as category_id,
 		a.id AS article_id,
 		a.title AS title,
 		'' AS body,

+ 1 - 1
models/resource_data.go

@@ -134,7 +134,7 @@ func GetResourceDataListCondition(condition string, pars []interface{}, startSiz
 	if condition != "" {
 		sql += condition
 	}
-	sql += `  ORDER BY search_order_time DESC   LIMIT ?,? `
+	sql += `  ORDER BY  sort DESC , search_order_time DESC   LIMIT ?,? `
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 22 - 4
services/es_comprehensive.go

@@ -549,7 +549,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
 		}
 	}
-
+	//fmt.Println(industrialResourceIdsHz)
 	//产业资源包
 	if len(industrialResourceIdsHz) > 0 {
 		pars = make([]interface{}, 0)
@@ -584,6 +584,17 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 		//listIndustrialResourceIds, _ = HandleIndustryList(listIndustrialResourceIds, user, "Hz")
 		for _, v := range listIndustrialResourceIds {
+			if v.TimeLineData == "" {
+				v.ListTimeLine = make([]models.TimeLineReportResp, 0)
+			} else {
+
+				if err = json.Unmarshal([]byte(v.TimeLineData), &v.ListTimeLine); err != nil {
+
+					e = errors.New("Unmarshal, Err: " + e.Error())
+					//return
+				}
+			}
+			//fmt.Println(v.ListTimeLine)
 			v.Source = 1
 			v.UpdateTime = v.PublishDate
 			mapItems[fmt.Sprint("industrialsourceHz", v.IndustrialManagementId)].IndustrialResource = v
@@ -605,7 +616,6 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			err = errors.New("GetSearchResourceList, Err: " + e.Error())
 			return
 		}
-		fmt.Println(listIndustrialResourceIds)
 		conditionSubject := condition + ` AND 	m.industrial_management_id  IN (` + utils.GetOrmInReplace(len(industrialResourceIdsYx)) + `)`
 		pars = append(pars, industrialResourceIdsYx)
 		listSubjcet, e := models.GetIndustrialSubjectAllByIndustrialId(pars, conditionSubject)
@@ -849,10 +859,18 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 }
 
 func SqlComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*SearchComprehensiveItem, total int, err error) {
+	listListNoEnd, e := models.GetActivityIdListNoEnd()
+	var activityIds []string
+	for _, v := range listListNoEnd {
+		activityIds = append(activityIds, strconv.Itoa(v.ActivityId))
+	}
+	activityIds = append(activityIds, "0")
+
+	conditionActivity := " AND IF   ( source IN('activity') , source_id IN (" + strings.Join(activityIds, ",") + ")  ,1=1 )"
 	keyWord = "%" + keyWord + "%"
 	var conditionTitle string
 	var parsTitle []interface{}
-	conditionTitle = " AND  is_hide = 0  AND search_title LIKE ? AND IF   ( source IN('activityvoice','activityvideo') , chart_permission_id != 31 ,1=1 ) "
+	conditionTitle = " AND  is_hide = 0  AND search_title LIKE ? AND IF   ( source IN('activityvoice','activityvideo') , chart_permission_id != 31 ,1=1 ) " + conditionActivity
 	parsTitle = append(parsTitle, keyWord)
 	totalTitle, e := models.GetResourceDataCount(conditionTitle, parsTitle)
 	if e != nil {
@@ -863,7 +881,7 @@ func SqlComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*
 	var conditionContent string
 	var parsContent []interface{}
 
-	conditionContent = " AND  is_hide = 0  AND search_content LIKE ? AND search_title  NOT LIKE ?   AND IF   ( source IN('activityvoice','activityvideo') , chart_permission_id != 31 ,1=1 )   "
+	conditionContent = " AND  is_hide = 0  AND search_content LIKE ? AND search_title  NOT LIKE ?   AND IF   ( source IN('activityvoice','activityvideo') , chart_permission_id != 31 ,1=1 )   " + conditionActivity
 	parsContent = append(parsContent, keyWord, keyWord)
 	totalContent, e := models.GetResourceDataCount(conditionContent, parsContent)
 	if e != nil {

+ 101 - 0
services/industrial_management.go

@@ -1,6 +1,7 @@
 package services
 
 import (
+	"encoding/json"
 	"errors"
 	"fmt"
 	"hongze/hongze_clpt/models"
@@ -310,11 +311,62 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 				list[k].IsNew = true
 			}
 		}
+		if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
+			v.Source = 2
+		} else {
+			v.Source = 1
+		}
+
+		if v.TimeLineData == "" {
+			v.ListTimeLine = make([]models.TimeLineReportResp, 0)
+		} else {
+			if err = json.Unmarshal([]byte(v.TimeLineData), &v.ListTimeLine); err != nil {
+				e = errors.New("Unmarshal, Err: " + e.Error())
+				return
+			}
+		}
 	}
 	items = list
 	return
 }
 
+func HandleIndustryListHzAndYx(list []*models.IndustrialManagement, user *models.WxUserItem, resource string) (items []*models.IndustrialManagement, err error) {
+	var listHz []*models.IndustrialManagement
+	var lisYx []*models.IndustrialManagement
+	for _, v := range list {
+		if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
+			lisYx = append(lisYx, v)
+		} else {
+			listHz = append(listHz, v)
+		}
+	}
+	listHz, err = HandleIndustryList(listHz, user, "Hz")
+	if err != nil {
+		return
+	}
+	lisYx, err = HandleIndustryList(lisYx, user, "Yx")
+	if err != nil {
+		return
+	}
+	maplistHz := make(map[int]*models.IndustrialManagement)
+	maplistYx := make(map[int]*models.IndustrialManagement)
+	for _, v := range listHz {
+		maplistHz[v.IndustrialManagementId] = v
+	}
+	for _, v := range lisYx {
+		maplistYx[v.IndustrialManagementId] = v
+	}
+	for _, v := range list {
+		if maplistHz[v.IndustrialManagementId] != nil {
+			items = append(items, maplistHz[v.IndustrialManagementId])
+		}
+		if maplistYx[v.IndustrialManagementId] != nil {
+			items = append(items, maplistYx[v.IndustrialManagementId])
+		}
+	}
+	return
+}
+
 // 通过文章ID获取文章所关联的产业
 func GetArticleIndustrialByArticleId(articleIds []int) (itemMap map[int][]*models.IndustrialManagementResp, err error) {
 	lenarticleIds := len(articleIds)
@@ -416,3 +468,52 @@ func IndustrialManagementHotMapGropuPermission() (mapResp map[int]bool, err erro
 	}
 	return
 }
+
+//func init() {
+//	IndustrialManagementTimeLineDateList3(542)
+//}
+
+// 时间线关联文章的三条数据
+func IndustrialManagementTimeLineDateList3(industrialManagementId int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("修改行业关注或者取消关注的时候,对于用户全部赛道的影响信息失败"+err.Error(), 2)
+		}
+	}()
+	list, total, e := models.GetTimeLineReportIndustrialListTime(0, industrialManagementId, 0, 3)
+	if e != nil {
+		err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+		return
+	}
+	fmt.Println(total)
+
+	type TimeLineReportItem struct {
+		Title       string `description:"标题"`
+		PublishDate string `description:"发布时间"`
+	}
+	//type TimeLIineData struct {
+	//	ListTimeLine []*TimeLineReportItem
+	//}
+
+	var listData []*TimeLineReportItem
+	for _, v := range list {
+		item := new(TimeLineReportItem)
+		item.Title = v.Title
+		item.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+		listData = append(listData, item)
+	}
+
+	//var listData2 TimeLIineData
+	//listData2.ListTimeLine = listData
+	jsonData, err := json.Marshal(listData)
+	if err != nil {
+		fmt.Println("Error marshaling to JSON:", err)
+		return
+	}
+
+	e = models.UpdateIndustrialManagementTimeLineData(industrialManagementId, string(jsonData))
+	fmt.Println(string(jsonData))
+	fmt.Println(e)
+	return err
+}