浏览代码

no message

zhangchuanxing 2 天之前
父节点
当前提交
21c1bfd0ca
共有 6 个文件被更改,包括 199 次插入4 次删除
  1. 20 0
      models/activity_video.go
  2. 20 0
      models/activity_voice.go
  3. 20 0
      models/resource_data.go
  4. 133 1
      services/article.go
  5. 3 3
      services/es_comprehensive.go
  6. 3 0
      services/task.go

+ 20 - 0
models/activity_video.go

@@ -184,3 +184,23 @@ func UpdateCygxActivityVideo(item *CygxActivityVideo) (err error) {
 	_, err = qs.Update(updateParams)
 	return
 }
+
+// 活动详情
+type CygxActivityVideoListResp15_0 struct {
+	ActivityId    int    `description:"活动ID 等于0新增活动,大于0修改活动"`
+	Id            int    `orm:"column(video_id)";description:"视频id"`
+	Title         string `orm:"column(video_name)";description:"视频名称"`
+	ResourceUrl   string `orm:"column(video_url)";description:"视频地址"`
+	VideoDuration string `description:"视频时长"`
+	ActivityTime  string `description:"活动时间"`
+	Label         string `description:"活动时间"`
+	VideoId       int    `description:"活动时间"`
+}
+
+// 列表
+func GetActivityVideoListAll15_0() (items []*CygxActivityVideoListResp15_0, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT art.*,v.video_id,v.video_name,v.video_url,video_duration FROM cygx_activity as art  INNER JOIN cygx_activity_video AS v ON v.activity_id = art.activity_id   WHERE 1= 1   `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 20 - 0
models/activity_voice.go

@@ -160,3 +160,23 @@ func UpdateCygxActivityVoice(item *CygxActivityVoice) (err error) {
 	_, err = qs.Update(updateParams)
 	return
 }
+
+// 活动详情
+type Cygxcygx_activity_voiceListResp struct {
+	ActivityId      int    `description:"活动ID 等于0新增活动,大于0修改活动"`
+	Id              int    `orm:"column(video_id)";description:"视频id"`
+	Title           string `orm:"column(video_name)";description:"视频名称"`
+	ResourceUrl     string `orm:"column(video_url)";description:"视频地址"`
+	VideoDuration   string `description:"视频时长"`
+	ActivityTime    string `description:"活动时间"`
+	Label           string `description:"活动时间"`
+	ActivityVoiceId int    `description:"活动时间"`
+}
+
+// 列表
+func GetActivityVoiceListAll15_0() (items []*Cygxcygx_activity_voiceListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT art.* , v.activity_voice_id   FROM cygx_activity as art  INNER JOIN cygx_activity_voice AS v ON v.activity_id = art.activity_id   WHERE 1= 1  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 20 - 0
models/resource_data.go

@@ -127,6 +127,14 @@ func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
 	return
 }
 
+// 修改数据
+func UpdateResourceDataHYSDSortBytime() (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_resource_data SET sort= 0   WHERE sort > 0   AND source = 'article'  AND search_order_time   <  ? `
+	_, err = o.Raw(sql, time.Now().AddDate(-2, 0, 0)).Exec()
+	return
+}
+
 // 修改
 func UpdateResourceDataByItem(item *CygxResourceData) (err error) {
 	o := orm.NewOrm()
@@ -231,3 +239,15 @@ func UpdatecygxResourceDatasearchTitle(searchTitle string, sourceId int) (err er
 
 	return
 }
+
+// 更新搜索标题
+func UpdatecygxResourceDatasearchTitleSource(searchTitle, source string, sourceId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_resource_data SET search_title= ?  WHERE source_id =  ? AND   source =  ?   `
+	_, err = o.Raw(sql, searchTitle, sourceId, source).Exec()
+	if err != nil {
+		return
+	}
+
+	return
+}

+ 133 - 1
services/article.go

@@ -2015,8 +2015,27 @@ func GetUserArticleHistoryIndustrialNewPublishDate(user *models.WxUserItem, indu
 	return
 }
 
+// UpdateResourceDataHYSDSort 两年以后得行业深度排序不优先展示
+func UpdateResourceDataHYSDSort(cont context.Context) (err error) {
+	//func UpdateResourceDataHYSDSort() (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("查研观向-每日更新月阅读飙升榜单失败, ErrMsg: "+err.Error(), 3)
+		}
+	}()
+
+	e := models.UpdateResourceDataHYSDSortBytime()
+	if e != nil {
+		err = errors.New("两年以后得行业深度排序不优先展示失败, UpdateResourceDataHYSDSortBytime Err: " + e.Error())
+		return
+	}
+	//fmt.Println(e)
+	return
+}
+
 //func init() {
-//	initcygx15_0()
+//	UpdateResourceDataHYSDSort()
 //}
 
 func initcygx15_0() {
@@ -2071,3 +2090,116 @@ func initcygx15_0() {
 	}
 	return
 }
+
+func initcygx15_0_0() {
+	var condition string
+	var pars []interface{}
+
+	listActivity, e := models.GetActivityListByCondition(condition, pars)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	mapActivityLabel := make(map[int]string)
+	for _, v := range listActivity {
+		mapActivityLabel[v.ActivityId] = v.Label
+	}
+
+	condition = ` AND    source   IN ('activity')   `
+	//全部都是标题搜索
+	list, e := models.GetResourceDataListCondition(condition, pars, 0, 10000)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+	fmt.Println(len(list))
+
+	//return
+
+	for k, v := range list {
+		fmt.Println(k)
+		sourceId := v.SourceId
+		searchTitle := v.SearchTitle + "{|}" + mapActivityLabel[sourceId]
+		//fmt.Println(searchTitle)
+		e = models.UpdatecygxResourceDatasearchTitleSource(searchTitle, v.Source, sourceId)
+		if e != nil {
+			fmt.Println("UpdatecygxResourceDatasearchTitle", e)
+		}
+	}
+	fmt.Println("enddss")
+	return
+}
+
+func initcygx15_0_0_0() {
+	var condition string
+	var pars []interface{}
+
+	listActivityVideo, e := models.GetActivityVideoListAll15_0()
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	mapActivityLabel := make(map[int]string)
+	for _, v := range listActivityVideo {
+		mapActivityLabel[v.VideoId] = v.Label
+	}
+
+	condition = ` AND    source   IN ('activityvideo')   `
+	//全部都是标题搜索
+	list, e := models.GetResourceDataListCondition(condition, pars, 0, 10000)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+	fmt.Println(len(list))
+
+	//return
+
+	for k, v := range list {
+		fmt.Println(k)
+		sourceId := v.SourceId
+		searchTitle := v.SearchTitle + "{|}" + mapActivityLabel[sourceId]
+		fmt.Println(searchTitle, v.Source, sourceId)
+		fmt.Println(searchTitle)
+		e = models.UpdatecygxResourceDatasearchTitleSource(searchTitle, v.Source, sourceId)
+		if e != nil {
+			fmt.Println("UpdatecygxResourceDatasearchTitle", e)
+		}
+	}
+
+	listActivityVoice, e := models.GetActivityVoiceListAll15_0()
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	mapActivityVocieLabel := make(map[int]string)
+	for _, v := range listActivityVoice {
+		mapActivityVocieLabel[v.ActivityVoiceId] = v.Label
+	}
+
+	condition = ` AND    source   IN ('activityvoice')   `
+	//全部都是标题搜索
+	listVoice, e := models.GetResourceDataListCondition(condition, pars, 0, 10000)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+	fmt.Println(len(listVoice))
+
+	//return
+
+	for k, v := range listVoice {
+		fmt.Println(k)
+		sourceId := v.SourceId
+		searchTitle := v.SearchTitle + "{|}" + mapActivityVocieLabel[sourceId]
+		fmt.Println(searchTitle, v.Source, sourceId)
+		fmt.Println(searchTitle)
+		e = models.UpdatecygxResourceDatasearchTitleSource(searchTitle, v.Source, sourceId)
+		if e != nil {
+			fmt.Println("UpdatecygxResourceDatasearchTitle", e)
+		}
+	}
+
+	fmt.Println("enddss")
+	return
+}

+ 3 - 3
services/es_comprehensive.go

@@ -1695,9 +1695,9 @@ func SqlComprehensiveSearch2(keyWord string, startSize, pageSize int) (result []
 		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)
 	}
-	// 深度报告搜索最近两年的数据
-	conditionTitle += " AND  IF   ( search_tag = '行业深度' , search_order_time > ?  ,1=1 ) "
-	parsTitle = append(parsTitle, time.Now().AddDate(-2, 0, 0).Format(utils.FormatDate))
+	//// 深度报告搜索最近两年的数据
+	//conditionTitle += " AND  IF   ( search_tag = '行业深度' , search_order_time > ?  ,1=1 ) "
+	//parsTitle = append(parsTitle, time.Now().AddDate(-2, 0, 0).Format(utils.FormatDate))
 	totalTitle, e := models.GetResourceDataCount(conditionTitle, parsTitle)
 	if e != nil {
 		err = errors.New("GetResourceDataCount, Err: " + e.Error())

+ 3 - 0
services/task.go

@@ -169,6 +169,9 @@ func Task() {
 
 		getFiccRreportToCygxArticle := task.NewTask("getFiccRreportToCygxArticle", "0 */10 * * * *", GetFiccRreportToCygxArticle)
 		task.AddTask("获取FICC研报到查研观向数据库中", getFiccRreportToCygxArticle) //获取FICC研报到查研观向数据库中
+
+		updateResourceDataHYSDSort := task.NewTask("updateResourceDataHYSDSort", "0 10 1 * * *", UpdateResourceDataHYSDSort) //两年以后得行业深度排序不优先展示
+		task.AddTask("updateResourceDataHYSDSort", updateResourceDataHYSDSort)
 	}
 
 	//UpdateRaiServeBillDate()