Selaa lähdekoodia

Merge branch 'cygx/cygx_13.0' of http://8.136.199.33:3000/hongze/hz_crm_api

xingzai 1 vuosi sitten
vanhempi
commit
8d93e82ba8

+ 1 - 2
controllers/cygx/activity.go

@@ -819,10 +819,9 @@ func (this *ActivityCoAntroller) PreserveAndPublish() {
 		if req.DoType == 1 {
 			go cygxService.DoActivityOnenIdWxTemplateMsg(req.ActivityId)
 			//go cygxService.UpdateResourceData(req.ActivityId, "activity", "add", time.Now().Format(utils.FormatDateTime))
-			cygxService.UpdateActivityResourceData(req.ActivityId)                                             //写入首页最新  cygx_resource_data 表
 			go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(activityId, AdminUser.AdminId, 1) //活动发布以及取消发布处理研选扣点
 		}
-
+		cygxService.UpdateActivityResourceData(req.ActivityId) //写入首页最新  cygx_resource_data 表
 		//如果二次编辑的时候,取消了易董办会选项,那么就对易董发送取消发布到广场的通知
 		if req.IsYidongConduct == 0 {
 			go cygxService.YiDongUpdateActivityStatus(activityId)

+ 2 - 2
controllers/cygx/activity_special.go

@@ -276,9 +276,9 @@ func (this *ActivitySpecialCoAntroller) PreserveAndPublish() {
 	if req.DoType == 1 {
 		go services.SendWxMsgWithCygxActivitySpecial(activityId)
 		//go cygxService.UpdateResourceData(activityId, "activityspecial", "add", time.Now().Format(utils.FormatDateTime))
-		go cygxService.UpdateActivitySpecialResourceData(activityId) //写入首页最新  cygx_resource_data 表
 	}
-	go elastic.AddComprehensiveActivitySpecial(activityId) // Es添加活动
+	go cygxService.UpdateActivitySpecialResourceData(activityId) //写入首页最新  cygx_resource_data 表
+	go elastic.AddComprehensiveActivitySpecial(activityId)       // Es添加活动
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 1 - 0
controllers/cygx/minutes_summary.go

@@ -275,6 +275,7 @@ func (this *MinutesSummaryController) PreserveAndPublish() {
 		}
 	}
 	go services.CreateVideoWhithContent(articleId, req.Title, contentVideo, "cygx_minutes_summary")
+	go cygxService.UpdateMinutesSummaryResourceData(articleId) //写入首页最新  cygx_resource_data 表
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 1 - 0
controllers/cygx/product_interior.go

@@ -133,6 +133,7 @@ func (this *ProductInteriorController) PreserveAndPublish() {
 		br.ErrMsg = "保存失败,Err:" + err.Error()
 		return
 	}
+	go cygxService.UpdateProductInteriorResourceData(productInteriorId) //写入首页最新  cygx_resource_data 表
 	br.Ret = 200
 	br.Success = true
 	br.IsAddLog = true

+ 1 - 1
controllers/cygx/research_summary.go

@@ -353,7 +353,7 @@ func (this *ResearchSummaryController) PreserveAndPublish() {
 		}
 	}
 	go services.CreateVideoWhithContent(articleId, req.Title, contentVideo, "cygx_research_summary")
-
+	go cygxService.UpdateResearchSummaryResourceData(articleId) //写入首页最新  cygx_resource_data 表
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 1 - 0
models/cygx/activity_special.go

@@ -95,6 +95,7 @@ type ActivitySpecialDetail struct {
 	DateYmdList           []*DateYmdList `description:"时间年月日"`
 	IsSubmitMeeting       int            `description:"是否提交过到会信息 ,1是,0否"`
 	LastUpdatedTime       time.Time      `description:"更新时间"`
+	PublishDate           string         `description:"发布时间"`
 }
 
 type ActivityDetailSpecialRep struct {

+ 3 - 0
models/cygx/report_article.go

@@ -463,6 +463,7 @@ type ArticleDetail struct {
 	CreateDate           string `description:"创建时间"`
 	PublishDate          string `description:"发布时间"`
 	Body                 string `description:"内容"`
+	Annotation           string `description:"核心观点"`
 	Abstract             string `description:"摘要"`
 	CategoryName         string `description:"一级分类"`
 	SubCategoryName      string `description:"二级分类"`
@@ -485,6 +486,8 @@ type ArticleDetail struct {
 	TypeName             string `description:"策略平台类型字段名称"`
 	ArticleTypeId        int    `description:"文章类型ID"`
 	ArticleTypeName      string `description:"文章类型名称"`
+	Stock                string `description:"个股标签(上海策略品台同步)"`
+	FieldName            string `description:"产业标签(上海策略品台同步)"`
 }
 
 func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {

+ 7 - 1
models/cygx/resource_data.go

@@ -16,12 +16,15 @@ type CygxResourceData struct {
 	Abstract          string    `description:"摘要"`
 	SearchTag         string    `description:"搜索标签"`
 	ChartPermissionId int       `description:"行业id"`
+	SearchTitle       string    `description:"搜索匹配用的标题"`
+	SearchContent     string    `description:"搜索匹配用的内容"`
+	SearchOrderTime   string    `description:"搜索排序时间"`
 }
 
 // 根据资源类型获取列表
 func GetCygxResourceDataListBysource(source string) (items []*CygxResourceData, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT * FROM cygx_resource_data as art WHERE 1= 1  AND  source = ?  AND chart_permission_id = 0   `
+	sql := `SELECT * FROM cygx_resource_data as art WHERE 1= 1  AND  source = ?  AND search_title = ''   `
 	_, err = o.Raw(sql, source).QueryRows(&items)
 	return
 }
@@ -56,6 +59,9 @@ func UpdateResourceDataByItem(item *CygxResourceData) (err error) {
 	updateParams["PublishDate"] = item.PublishDate
 	updateParams["SearchTag"] = item.SearchTag
 	updateParams["ChartPermissionId"] = item.ChartPermissionId
+	updateParams["SearchTitle"] = item.SearchTitle
+	updateParams["SearchContent"] = item.SearchContent
+	updateParams["SearchOrderTime"] = item.SearchOrderTime
 	ptrStructOrTableName := "cygx_resource_data"
 	whereParam := map[string]interface{}{"source_id": item.SourceId, "source": item.Source}
 	qs := o.QueryTable(ptrStructOrTableName)

+ 2 - 0
services/cygx/activity_ocr.go

@@ -219,6 +219,7 @@ func UpdateActivityVideoAndVoice(activityInfo *cygx.ActivityDetail, itemVoice *c
 				err = errors.New("UpdateCygxActivityVoice" + e.Error())
 				return
 			}
+			go UpdateActivityVoiceResourceData(voiceDetail.ActivityVoiceId) //写入首页最新  cygx_resource_data 表
 		}
 	} else {
 		voiceDetail, e := cygx.GetCygxActivityVoiceReqDetail(activityId)
@@ -293,6 +294,7 @@ func UpdateActivityVideoAndVoice(activityInfo *cygx.ActivityDetail, itemVoice *c
 				err = errors.New("UpdateCygxActivityVideo" + e.Error())
 				return
 			}
+			go UpdateActivityVideoResourceData(videoDetail.VideoId) //写入首页最新  cygx_resource_data 表
 		}
 	} else {
 		//删除原有的视频数据

+ 9 - 0
services/cygx/cygx_yanxuan_special.go

@@ -249,12 +249,21 @@ func UpdateYanxuanSpecialResourceData(sourceId int) {
 			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
 			return
 		}
+		detail, e := cygx.GetYanxuanSpecialItemById(sourceId)
+		if e != nil {
+			err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+			return
+		}
+
 		publishDate := time.Now().Format(utils.FormatDateTime)
 		item := new(cygx.CygxResourceData)
 		item.SourceId = sourceId
 		item.Source = source
 		item.PublishDate = publishDate
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		item.SearchContent = ""
+		item.SearchOrderTime = publishDate
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {

+ 302 - 61
services/cygx/resource_data.go

@@ -26,7 +26,7 @@ import (
 //roadshow
 
 //func init() {
-//	UpdateActivityResourceData(2703)
+//	UpdateMicroRoadshowResourceData(7)
 //}
 
 // 更新活动
@@ -75,14 +75,43 @@ func UpdateActivityResourceData(sourceId int) {
 			return
 		}
 		var resourceDataId int
-		publishDate := time.Now().Format(utils.FormatDateTime)
+		publishDate := detail.CreateTime // 活动创建时间作为排序时间
+
 		item := new(cygx.CygxResourceData)
+
+		var industrialName string
+		var subjectName string
+		//建立首页资源表,与产业的关系
+		industrialList, e := cygx.GetIndustrialActivityGroupManagementList(sourceId, 1)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range industrialList {
+			industrialName += v.IndustryName
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := cygx.GetSubjectActivityGroupManagementList(sourceId, 1)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range subjectList {
+			subjectName += v.SubjectName
+		}
+
 		item.SourceId = sourceId
 		item.Source = source
 		//分析师电话会(C类)
 		item.SearchTag = detail.ActivityTypeName
 		item.ChartPermissionId = detail.ChartPermissionId
 		item.PublishDate = publishDate
+		item.SearchTitle = detail.ActivityName
+		item.SearchContent = detail.Label + industrialName + subjectName
+		item.SearchOrderTime = detail.ActivityTime
 		item.CreateTime = time.Now()
 		if totalData == 0 {
 			newId, e := cygx.AddCygxResourceData(item)
@@ -105,12 +134,6 @@ func UpdateActivityResourceData(sourceId int) {
 			resourceDataId = sourceDetail.Id
 		}
 
-		//建立首页资源表,与产业的关系
-		industrialList, e := cygx.GetIndustrialActivityGroupManagementList(sourceId, 1)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
 		for _, v := range industrialList {
 			var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
@@ -123,11 +146,6 @@ func UpdateActivityResourceData(sourceId int) {
 		}
 
 		//建立首页资源表,与标的 的关系
-		subjectList, e := cygx.GetSubjectActivityGroupManagementList(sourceId, 1)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
 		for _, v := range subjectList {
 			var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
@@ -194,7 +212,7 @@ func UpdateActivitySpecialResourceData(sourceId int) {
 			return
 		}
 		var resourceDataId int
-		publishDate := time.Now().Format(utils.FormatDateTime)
+		publishDate := activityInfo.PublishDate
 		item := new(cygx.CygxResourceData)
 		item.SourceId = sourceId
 		item.Source = source
@@ -203,6 +221,15 @@ func UpdateActivitySpecialResourceData(sourceId int) {
 		item.PublishDate = publishDate
 		item.ChartPermissionId = activityInfo.ChartPermissionId
 		item.CreateTime = time.Now()
+		item.SearchTitle = activityInfo.ResearchTheme
+		item.SearchContent = activityInfo.Label + activityInfo.IndustrialName + activityInfo.IndustrialSubjectName
+
+		if activityInfo.Days > 0 {
+			item.SearchOrderTime = activityInfo.ActivityTime
+		} else {
+			item.SearchOrderTime = activityInfo.PublishDate
+		}
+
 		if totalData == 0 {
 			newId, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -313,6 +340,7 @@ func UpdateArticleResourceData(sourceId int) {
 		}
 
 		var resourceDataId int
+		//publishDate := detail.CreateDate
 		publishDate := time.Now().Format(utils.FormatDateTime)
 		item := new(cygx.CygxResourceData)
 		if detail.ArticleTypeId > 0 {
@@ -327,10 +355,47 @@ func UpdateArticleResourceData(sourceId int) {
 			}
 		}
 
+		var industrialName string
+		var subjectName string
+		//建立首页资源表,与产业的关系
+		industrialList, e := cygx.GetIndustrialArticleGroupManagementList(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range industrialList {
+			industrialName += v.IndustryName
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := cygx.GetSubjectArticleGroupManagementList(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range subjectList {
+			subjectName += v.SubjectName
+		}
+
 		item.SourceId = sourceId
 		item.Source = source
 		item.PublishDate = publishDate
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		annotation, e := utils.GetHtmlContentText(detail.Annotation)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+		abstract, e := utils.GetHtmlContentText(detail.Abstract)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+		item.SearchContent = annotation + abstract + detail.FieldName + detail.Stock + industrialName + subjectName
+		item.SearchOrderTime = detail.PublishDate
 		if totalData == 0 {
 			newId, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -341,23 +406,17 @@ func UpdateArticleResourceData(sourceId int) {
 		} else {
 			e = cygx.UpdateResourceDataByItem(item)
 			if e != nil {
-				err = errors.New("UpdateResourceData, Err: " + e.Error())
+				err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
 				return
 			}
 			sourceDetail, e := cygx.GetCygxResourceDataByIdAndSource(sourceId, source)
 			if e != nil {
-				err = errors.New("UpdateResourceData, Err: " + e.Error())
+				err = errors.New("GetCygxResourceDataByIdAndSource, Err: " + e.Error())
 				return
 			}
 			resourceDataId = sourceDetail.Id
 		}
 
-		//建立首页资源表,与产业的关系
-		industrialList, e := cygx.GetIndustrialArticleGroupManagementList(sourceId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
 		for _, v := range industrialList {
 			var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
@@ -367,14 +426,9 @@ func UpdateArticleResourceData(sourceId int) {
 			industrialItem.ResourceDataId = resourceDataId
 			industrialItem.CreateTime = time.Now()
 			industrialItems = append(industrialItems, industrialItem)
+			industrialName += v.IndustryName
 		}
 
-		//建立首页资源表,与标的 的关系
-		subjectList, e := cygx.GetSubjectArticleGroupManagementList(sourceId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
 		for _, v := range subjectList {
 			var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
@@ -384,6 +438,7 @@ func UpdateArticleResourceData(sourceId int) {
 			subjectItem.ResourceDataId = resourceDataId
 			subjectItem.CreateTime = time.Now()
 			subjectItems = append(subjectItems, subjectItem)
+			subjectName += v.SubjectName
 		}
 
 		//插入关联信息
@@ -443,14 +498,42 @@ func UpdateProductInteriorResourceData(sourceId int) {
 		}
 		mapMatchTypeName := GetCygxReportMappingCygxListMap() //报告匹配类型
 		var resourceDataId int
-		publishDate := time.Now().Format(utils.FormatDateTime)
+		publishDate := detail.CreateTime
 		item := new(cygx.CygxResourceData)
+
+		var industrialName string
+		var subjectName string
+		//建立首页资源表,与产业的关系
+		industrialList, e := cygx.GetProductInteriorIndustrialGroupManagementList(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range industrialList {
+			industrialName += v.IndustryName
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := cygx.GetProductInteriorIndustrialGroupSubjecttList(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range subjectList {
+			subjectName += v.SubjectName
+		}
+
 		item.SourceId = sourceId
 		item.Source = source
 		item.SearchTag = mapMatchTypeName[detail.MatchTypeId]
 		item.PublishDate = publishDate
 		item.ChartPermissionId = detail.ChartPermissionId
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		item.SearchContent = detail.Abstract + industrialName + subjectName
+		item.SearchOrderTime = detail.PublishTime
 		if totalData == 0 {
 			newId, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -472,12 +555,6 @@ func UpdateProductInteriorResourceData(sourceId int) {
 			resourceDataId = sourceDetail.Id
 		}
 
-		//建立首页资源表,与产业的关系
-		industrialList, e := cygx.GetProductInteriorIndustrialGroupManagementList(sourceId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
 		for _, v := range industrialList {
 			var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
@@ -489,12 +566,6 @@ func UpdateProductInteriorResourceData(sourceId int) {
 			industrialItems = append(industrialItems, industrialItem)
 		}
 
-		//建立首页资源表,与标的 的关系
-		subjectList, e := cygx.GetProductInteriorIndustrialGroupSubjecttList(sourceId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
 		for _, v := range subjectList {
 			var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
@@ -516,7 +587,7 @@ func UpdateProductInteriorResourceData(sourceId int) {
 	return
 }
 
-// 更新晨会精华
+// 更新晨会精华 (跟踪点评)
 func UpdateMeetingreviewchaptResourceData(sourceId int) {
 	var err error
 	defer func() {
@@ -560,12 +631,54 @@ func UpdateMeetingreviewchaptResourceData(sourceId int) {
 		var resourceDataId int
 		publishDate := time.Now().Format(utils.FormatDateTime)
 		item := new(cygx.CygxResourceData)
+
+		var industrialName string
+		var subjectName string
+		//建立首页资源表,与产业的关系
+		var condition string
+		var pars []interface{}
+		condition = " AND industrial_management_id = ? "
+		pars = append(pars, detail.IndustryId)
+		//建立首页资源表,与产业的关系
+		industrialList, e := cygx.GetTopOneMonthArtReadNumIndustryAll(condition, pars)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range industrialList {
+			industrialName += v.IndustryName
+		}
+
+		if detail.IndustrialSubjectIds != "" {
+			condition = ""
+			pars = make([]interface{}, 0)
+			condition = " AND industrial_subject_id  IN (" + detail.IndustrialSubjectIds + ") "
+			//建立首页资源表,与标的 的关系
+			subjectList, e := cygx.GetCygxIndustrialSubjectListCondition(condition, pars)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("GetCygxIndustrialSubjectListCondition, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+				return
+			}
+			for _, v := range subjectList {
+				subjectName += v.SubjectName
+			}
+		}
+
 		item.SourceId = sourceId
 		item.Source = source
 		item.SearchTag = "晨会精华"
 		item.PublishDate = publishDate
 		item.ChartPermissionId = detail.ChartPermissionId
 		item.CreateTime = time.Now()
+		item.SearchTitle = industrialName + subjectName
+		content, e := utils.GetHtmlContentText(detail.Content)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+		item.SearchContent = content
+		item.SearchOrderTime = detail.MeetingTime.Format(utils.FormatDateTime)
 		if totalData == 0 {
 			newId, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -586,16 +699,7 @@ func UpdateMeetingreviewchaptResourceData(sourceId int) {
 			}
 			resourceDataId = sourceDetail.Id
 		}
-		var condition string
-		var pars []interface{}
-		condition = " AND industrial_management_id = ? "
-		pars = append(pars, detail.IndustryId)
-		//建立首页资源表,与产业的关系
-		industrialList, e := cygx.GetTopOneMonthArtReadNumIndustryAll(condition, pars)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
-			return
-		}
+
 		var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
 		for _, v := range industrialList {
 			var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
@@ -686,6 +790,9 @@ func UpdateReportSelectionResourceData(sourceId int) {
 		item.SearchTag = "重点公司"
 		item.PublishDate = publishDate
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		item.SearchContent = ""
+		item.SearchOrderTime = detail.PublishDate
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -736,6 +843,11 @@ func UpdateResearchSummaryResourceData(sourceId int) {
 			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
 			return
 		}
+		detail, e := cygx.GetCygxResearchSummaryInfoById(sourceId)
+		if e != nil {
+			err = errors.New("GetCygxResearchSummaryInfoById, Err: " + e.Error())
+			return
+		}
 		publishDate := time.Now().Format(utils.FormatDateTime)
 		item := new(cygx.CygxResourceData)
 		item.SourceId = sourceId
@@ -743,6 +855,9 @@ func UpdateResearchSummaryResourceData(sourceId int) {
 		item.SearchTag = "本周研究汇总"
 		item.PublishDate = publishDate
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		item.SearchContent = ""
+		item.SearchOrderTime = detail.PublishDate
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -793,6 +908,12 @@ func UpdateMinutesSummaryResourceData(sourceId int) {
 			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
 			return
 		}
+		detail, e := cygx.GetCygxMinutesSummaryInfoById(sourceId)
+
+		if e != nil {
+			err = errors.New("GetCygxMinutesSummaryInfoById, Err: " + e.Error())
+			return
+		}
 		publishDate := time.Now().Format(utils.FormatDateTime)
 		item := new(cygx.CygxResourceData)
 		item.SourceId = sourceId
@@ -800,6 +921,9 @@ func UpdateMinutesSummaryResourceData(sourceId int) {
 		item.SearchTag = "上周纪要汇总"
 		item.PublishDate = publishDate
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		item.SearchContent = ""
+		item.SearchOrderTime = detail.PublishDate
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -867,6 +991,31 @@ func UpdateActivityVoiceResourceData(sourceId int) {
 		}
 		publishDate := time.Now().Format(utils.FormatDateTime)
 		item := new(cygx.CygxResourceData)
+
+		var industrialName string
+		var subjectName string
+		//建立首页资源表,与产业的关系
+		industrialList, e := cygx.GetIndustrialActivityGroupManagementList(activityId, 1)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
+			return
+		}
+
+		for _, v := range industrialList {
+			industrialName += v.IndustryName
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := cygx.GetSubjectActivityGroupManagementList(activityId, 1)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
+			return
+		}
+
+		for _, v := range subjectList {
+			subjectName += v.SubjectName
+		}
+
 		item.SourceId = sourceId
 		item.Source = source
 		//易董办会的分析师电话会,为路演回放
@@ -878,6 +1027,9 @@ func UpdateActivityVoiceResourceData(sourceId int) {
 		item.PublishDate = publishDate
 		item.ChartPermissionId = activityInfo.ChartPermissionId
 		item.CreateTime = utils.StrDateToDate(activityInfo.ActivityTime)
+		item.SearchTitle = voiceDetail.VoiceName
+		item.SearchContent = activityInfo.Label + industrialName + subjectName
+		item.SearchOrderTime = activityInfo.ActivityTime
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -943,6 +1095,29 @@ func UpdateActivityVideoResourceData(sourceId int) {
 		}
 		publishDate := time.Now().Format(utils.FormatDateTime)
 		item := new(cygx.CygxResourceData)
+		var industrialName string
+		var subjectName string
+		//建立首页资源表,与产业的关系
+		industrialList, e := cygx.GetIndustrialActivityGroupManagementList(activityId, 1)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
+			return
+		}
+
+		for _, v := range industrialList {
+			industrialName += v.IndustryName
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := cygx.GetSubjectActivityGroupManagementList(activityId, 1)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
+			return
+		}
+
+		for _, v := range subjectList {
+			subjectName += v.SubjectName
+		}
 		item.SourceId = sourceId
 		item.Source = source
 		//易董办会的分析师电话会,为路演回放
@@ -955,6 +1130,9 @@ func UpdateActivityVideoResourceData(sourceId int) {
 		item.PublishDate = publishDate
 		item.ChartPermissionId = activityInfo.ChartPermissionId
 		item.CreateTime = utils.StrDateToDate(activityInfo.ActivityTime)
+		item.SearchTitle = videoDetail.VideoName
+		item.SearchContent = activityInfo.Label + industrialName + subjectName
+		item.SearchOrderTime = activityInfo.ActivityTime
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -1018,6 +1196,9 @@ func UpdateMicroRoadshowResourceData(sourceId int) {
 		item.PublishDate = publishDate
 		item.ChartPermissionId = detail.ChartPermissionId
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.VideoName
+		item.SearchContent = detail.IndustryName
+		item.SearchOrderTime = detail.PublishDate.Format(utils.FormatDateTime)
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -1086,6 +1267,9 @@ func UpdateAskserieVideoResourceData(sourceId int) {
 		item.PublishDate = publishDate
 		item.ChartPermissionId = detail.ChartPermissionId
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.VideoName
+		item.SearchContent = detail.IndustryName
+		item.SearchOrderTime = detail.PublishDate
 		if totalData == 0 {
 			_, e := cygx.AddCygxResourceData(item)
 			if e != nil {
@@ -1103,19 +1287,29 @@ func UpdateAskserieVideoResourceData(sourceId int) {
 	return
 }
 
-func init23() {
+func init300() {
 	//var condition string
 	//var pars []interface{}
 	//
+
 	//{
 	//	//活动
-	//	list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITY)
+	//	var condition string
+	//	var pars []interface{}
+	//	condition = " AND publish_status = 1  AND activity_id NOT IN  (SELECT  source_id FROM cygx_resource_data WHERE source  = 'activity') "
+	//	list, err := cygx.GetActivityListAll(condition, pars, 0, 9999)
 	//	if err != nil {
 	//		fmt.Println(err)
 	//	}
+	//
+	//	//list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITY)
+	//	//if err != nil {
+	//	//	fmt.Println(err)
+	//	//}
+	//	fmt.Println(len(list))
 	//	for _, v := range list {
-	//		fmt.Println(v.Source)
-	//		UpdateActivityResourceData(v.SourceId)
+	//		fmt.Println(v.ActivityId)
+	//		UpdateActivityResourceData(v.ActivityId)
 	//	}
 	//}
 
@@ -1161,14 +1355,25 @@ func init23() {
 	//}
 
 	//{
-	//	//文章
-	//	list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ARTICLE)
+	//	var condition string
+	//	var pars []interface{}
+	//	condition = " AND publish_status = 1  AND article_id NOT IN  (SELECT  source_id FROM cygx_resource_data WHERE source  = 'article') "
+	//
+	//	list, err := cygx.GetArticleRoadshowEssenceList(condition, pars, 0, 9999)
 	//	if err != nil {
 	//		fmt.Println(err)
+	//		return
 	//	}
+	//	fmt.Println(len(list))
+	//	//return
+	//	//文章
+	//	//list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ARTICLE)
+	//	//if err != nil {
+	//	//	fmt.Println(err)
+	//	//}
 	//	for _, v := range list {
-	//		fmt.Println(v.Source)
-	//		UpdateArticleResourceData(v.SourceId)
+	//		fmt.Println(v.ArticleId)
+	//		UpdateArticleResourceData(v.ArticleId)
 	//	}
 	//}
 
@@ -1296,7 +1501,7 @@ func init23() {
 	//		fmt.Println(err)
 	//	}
 	//	for _, v := range list {
-	//		fmt.Println(v.Source)
+	//		fmt.Println(v.SourceId)
 	//		UpdateActivityVideoResourceData(v.SourceId)
 	//	}
 	//}
@@ -1313,4 +1518,40 @@ func init23() {
 	//	}
 	//}
 
+	//{
+	//	//问答系列视频
+	//	list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ASKSERIEVIDEO)
+	//	if err != nil {
+	//		fmt.Println(err)
+	//	}
+	//	for _, v := range list {
+	//		fmt.Println(v.SourceId)
+	//		UpdateAskserieVideoResourceData(v.SourceId)
+	//	}
+	//}
+
+	//{
+	//	//晨会精华
+	//	list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_MEETINGREVIEWCHAPT)
+	//	if err != nil {
+	//		fmt.Println(err)
+	//	}
+	//	for _, v := range list {
+	//		fmt.Println(v.SourceId)
+	//		UpdateMeetingreviewchaptResourceData(v.SourceId)
+	//	}
+	//}
+
+	//{
+	//	//研选专栏
+	//	list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_YANXUANSPECIAL)
+	//	if err != nil {
+	//		fmt.Println(err)
+	//	}
+	//	for _, v := range list {
+	//		fmt.Println(v.SourceId)
+	//		UpdateYanxuanSpecialResourceData(v.SourceId)
+	//	}
+	//}
+
 }

+ 45 - 1
services/elastic/es_comprehensive.go

@@ -113,6 +113,49 @@ func EsAddOrEditComprehensiveData(item *ElasticComprehensiveDetail) (err error)
 	return
 }
 
+// 更新产业资源包
+func UpdateComprehensiveIndustrialResourceData(itemSource *ElasticComprehensiveDetail) {
+	var err error
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("更新产业资源包到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(itemSource.SourceId), 3)
+		}
+	}()
+	sourceId := itemSource.SourceId
+	var source = itemSource.Source
+
+	//判断是否存在,如果不存在就新增,存在就更新
+	totalData, e := cygx.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
+	if e != nil {
+		err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
+		return
+	}
+
+	item := new(cygx.CygxResourceData)
+	item.SourceId = sourceId
+	item.Source = source
+	item.PublishDate = itemSource.PublishDate
+	item.CreateTime = time.Now()
+	item.SearchTitle = itemSource.IndustryName + itemSource.SubjectNames
+	item.SearchContent = ""
+	item.SearchOrderTime = itemSource.PublishDate
+
+	if totalData == 0 {
+		_, e = cygx.AddCygxResourceData(item)
+		if e != nil {
+			err = errors.New("AddCygxResourceData, Err: " + e.Error())
+			return
+		}
+	} else {
+		e = cygx.UpdateResourceDataByItem(item)
+		if e != nil {
+			err = errors.New("UpdateResourceData, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}
+
 // 删除数据
 func EsDeleteComprehensiveData(item *ElasticComprehensiveDetail) (err error) {
 	indexName := utils.IndexNameComprehensive // 避免调用错别的项目的索引 ,这里写死
@@ -502,7 +545,7 @@ func AddComprehensiveIndustrialSource(sourceType string, articleId int) {
 	mapActivitySubject := make(map[int][]string, 0)
 	listsubject, e := cygx.GetCygxIndustrialSubjectListCondition(condition, pars)
 	if e != nil {
-		err = errors.New("GetIndustrialManagementRepList, Err: " + e.Error())
+		err = errors.New("GetCygxIndustrialSubjectListCondition, Err: " + e.Error())
 		return
 	}
 	for _, v := range listsubject {
@@ -535,6 +578,7 @@ func AddComprehensiveIndustrialSource(sourceType string, articleId int) {
 		item.SubjectNames = strings.Join(mapActivitySubject[v.IndustrialManagementId], ",")
 		item.PublishDate = v.PublishDate + " 00:00:00"
 		EsAddOrEditComprehensiveData(item)
+		UpdateComprehensiveIndustrialResourceData(item)
 	}
 }
 

+ 18 - 0
utils/common.go

@@ -2151,3 +2151,21 @@ func RemoveFileSuffixName(fileName string) (removedName string) {
 	}
 	return
 }
+
+// 提取的纯文本内容
+func GetHtmlContentText(content string) (contentSub string, err error) {
+	if content == "" {
+		return
+	}
+	content = html.UnescapeString(content)
+	doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
+	if err != nil {
+		return
+	}
+	docText := doc.Text()
+	bodyRune := []rune(docText)
+	bodyRuneLen := len(bodyRune)
+	body := string(bodyRune[:bodyRuneLen])
+	contentSub = body
+	return
+}