瀏覽代碼

搜索引擎添加摘要核心观点搜索

xingzai 2 年之前
父節點
當前提交
538e924616
共有 8 個文件被更改,包括 118 次插入103 次删除
  1. 11 0
      models/activity_signup.go
  2. 4 80
      models/activity_signup_detail.go
  3. 1 0
      models/article.go
  4. 0 1
      models/db.go
  5. 8 8
      models/yidong.go
  6. 42 8
      services/elastic.go
  7. 14 1
      services/task.go
  8. 38 5
      services/yidong.go

+ 11 - 0
models/activity_signup.go

@@ -581,3 +581,14 @@ func UpdateCygxActivitySignupisMeet(activityId int, mobile string) (err error) {
 	_, err = o.Raw(sql, activityId, mobile).Exec()
 	return
 }
+
+//UpdateCygxActivitySignupisMeetList 批量修改易董的活动,用户已到会
+func UpdateCygxActivitySignupisMeetList(condition string, pars []interface{}) (err error) {
+	if condition == "" {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_activity_signup SET is_meeting=1 WHERE  1= 1 ` + condition
+	_, err = o.Raw(sql, pars).Exec()
+	return
+}

+ 4 - 80
models/activity_signup_detail.go

@@ -142,73 +142,14 @@ func UpdateActivitySignupDetailMulti(items []*CygxActivitySignupDetail) (err err
 	return
 }
 
-type CygxActivitySignupDetailCopy struct {
-	Id                    int       `orm:"column(id);pk"`
-	ActivityId            int       `description:"活动ID"`
-	UserId                int       `description:"用户ID"`
-	CreateTime            time.Time `description:"创建时间"`
-	Mobile                string    `description:"手机号"`
-	Email                 string    `description:"邮箱"`
-	CompanyId             int       `description:"公司id"`
-	CompanyName           string    `description:"公司名称"`
-	FailType              int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
-	SignupType            int       `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
-	DoFailType            int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
-	OutboundMobile        string    `description:"外呼手机号"`
-	CountryCode           string    `description:"手机国家区号"`
-	RealName              string    `description:"用户实际名称"`
-	SellerName            string    `description:"所属销售"`
-	FirstMeetingTime      string    `description:"首次入会时间"`
-	LastMeetingTime       string    `description:"最后退出时间"`
-	Duration              string    `description:"参会时长"`
-	MeetingTypeStr        string    `description:"参会方式"`
-	MeetingAuthentication string    `description:"参会权鉴"`
-	MeetingStatusStr      string    `description:"参会状态"`
-	Position              string    `description:"职位"`
-	IsMeeting             int       `description:"是否到会,1到会,0未到会"`
-	UseridEntity          int       `description:"参会者身份. 1:主讲人, 2:主持人, 3:嘉宾, 4:普通参会者, 5:联席主讲人, 6:会议助理"`
-	ActivityTime          string    `description:"活动时间"`
-	CrmCompanyMapStatusId int       `description:"转换后的对应状态信息:1=正式客户, 2=曾使用客户, 3=其他"`
-}
-
-//添加
-func AddCygxActivitySignupDetailCopy(items []*CygxActivitySignupDetailCopy) (err error) {
-	o, err := orm.NewOrm().Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err == nil {
-			o.Commit()
-		} else {
-			o.Rollback()
-		}
-	}()
-	if len(items) > 0 {
-		//批量添加
-		_, err = o.InsertMulti(len(items), items)
-		if err != nil {
-			return err
-		}
-	}
-	return
-}
-
-// UpdateActivitySignupDetailMulti 批量修改用户报名信息且报名的人
-func UpdateActivitySignupDetailMultiCopy(items []*CygxActivitySignupDetailCopy) (err error) {
+// UpdateActivitySignupDetailMultiByYiDong 易董批量修改用户报名信息且报名的人
+func UpdateActivitySignupDetailMultiByYiDong(items []*CygxActivitySignupDetail) (err error) {
 	o := orm.NewOrm()
-	p, err := o.Raw(` UPDATE cygx_activity_signup_detail_copy SET 
+	p, err := o.Raw(` UPDATE cygx_activity_signup_detail SET 
 							first_meeting_time = ?,
 							last_meeting_time = ?,
 							duration = ?,
-							meeting_type_str = ?,
-							meeting_authentication = ?,
-							meeting_status_str = ?,
-							position = ?,
-							is_meeting = ?,
-							userid_entity = ?,
-							activity_time = ?,
-							crm_company_map_status_id = ?
+							is_meeting = ?
 							WHERE mobile = ? AND activity_id = ? `).Prepare()
 	if err != nil {
 		return
@@ -221,14 +162,7 @@ func UpdateActivitySignupDetailMultiCopy(items []*CygxActivitySignupDetailCopy)
 			v.FirstMeetingTime,
 			v.LastMeetingTime,
 			v.Duration,
-			v.MeetingTypeStr,
-			v.MeetingAuthentication,
-			v.MeetingStatusStr,
-			v.Position,
 			v.IsMeeting,
-			v.UseridEntity,
-			v.ActivityTime,
-			v.CrmCompanyMapStatusId,
 			v.Mobile, v.ActivityId)
 		if err != nil {
 			return
@@ -236,13 +170,3 @@ func UpdateActivitySignupDetailMultiCopy(items []*CygxActivitySignupDetailCopy)
 	}
 	return
 }
-
-// 获取参会记录表列表
-func GetSignupDetailListCopy(condition string, pars []interface{}) (list []*CygxActivitySignupDetail, err error) {
-	sql := `SELECT * FROM cygx_activity_signup_detail_copy  WHERE  1= 1 `
-	if condition != "" {
-		sql += condition
-	}
-	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
-	return
-}

+ 1 - 0
models/article.go

@@ -160,6 +160,7 @@ type ArticleDetail struct {
 	IsShowLinkButton        int    `description:"这种报告类型是否展示查看报告链接"`
 	ArticleTypeId           int    `description:"文章类型ID"`
 	IsSpecialArticle        bool   `description:"是否属于专项调研报告"`
+	Annotation              string `description:"核心观点"`
 }
 
 type ArticleDetailFileLink struct {

+ 0 - 1
models/db.go

@@ -121,7 +121,6 @@ func init() {
 		new(CygxIndustrialArticleGroupManagement),
 		new(ArticleTopHistoryRecord),
 		new(CygxActivitySignupDetail),
-		new(CygxActivitySignupDetailCopy),
 		new(CygxMicroRoadshowVideoHistory),
 		new(MicroRoadshowVideo),
 		new(CygxActivityVideoHistory),

+ 8 - 8
models/yidong.go

@@ -97,14 +97,14 @@ type ApifoxModaluser struct {
 }
 
 type Resultuser struct {
-	DeviceType      *int64  `json:"deviceType"`                // 参会方式,1-PC,2-Mac,3-Android,4-IOS,5-Web,6-iPad,7-Android Pad,8-小程序
-	Duration        *string `json:"duration"`                  // 参会时长
-	EndTime         string  `json:"endTime"`                   // 最后退会时间
-	ID              string  `json:"id,omitempty"`              // 主键id
-	PersonTelephone string  `json:"personTelephone,omitempty"` // 用户手机号
-	StartTime       string  `json:"startTime"`                 // 最早入会时间
-	Status          string  `json:"status"`                    // 状态,D表示被删除
-	UserID          string  `json:"userId,omitempty"`          // 用户id
+	DeviceType      *int64 `json:"deviceType"`                // 参会方式,1-PC,2-Mac,3-Android,4-IOS,5-Web,6-iPad,7-Android Pad,8-小程序
+	Duration        string `json:"duration"`                  // 参会时长
+	EndTime         string `json:"endTime"`                   // 最后退会时间
+	ID              string `json:"id,omitempty"`              // 主键id
+	PersonTelephone string `json:"personTelephone,omitempty"` // 用户手机号
+	StartTime       string `json:"startTime"`                 // 最早入会时间
+	Status          string `json:"status"`                    // 状态,D表示被删除
+	UserID          string `json:"userId,omitempty"`          // 用户id
 }
 
 type ApifoxModalUserTgc struct {

+ 42 - 8
services/elastic.go

@@ -332,6 +332,8 @@ func EsAddOrEditData(indexName, docId string, item *ElasticTestArticleDetail) (e
 			"PublishDate":      item.PublishDate,
 			"CategoryId":       item.CategoryId,
 			"ExpertBackground": item.ExpertBackground,
+			"Abstract":         item.Abstract,
+			"Annotation":       item.Annotation,
 		}).Do(context.Background())
 		if err != nil {
 			return err
@@ -899,7 +901,6 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 		keyWordArr = append(keyWordArr, keyWord)
 		keyWordLen = len(keyWordArr)
 	}
-	//fmt.Println(keyWordArr)
 	mustMap := make([]interface{}, 0)
 	shouldMap := make(map[string]interface{}, 0)
 	//shouldMapquery := make(map[string]interface{}, 0)
@@ -926,7 +927,28 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 					},
 				},
 			})
-
+			shouldMapquery = append(shouldMapquery, map[string]interface{}{
+				"function_score": map[string]interface{}{
+					"query": map[string]interface{}{
+						"multi_match": map[string]interface{}{
+							"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							"fields": []interface{}{"Abstract"},
+							"query":  v,
+						},
+					},
+				},
+			})
+			shouldMapquery = append(shouldMapquery, map[string]interface{}{
+				"function_score": map[string]interface{}{
+					"query": map[string]interface{}{
+						"multi_match": map[string]interface{}{
+							"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							"fields": []interface{}{"Annotation"},
+							"query":  v,
+						},
+					},
+				},
+			})
 			shouldMapquery = append(shouldMapquery, map[string]interface{}{
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
@@ -955,8 +977,10 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 	highlightMap := make(map[string]interface{}, 0)
 	highlightMap = map[string]interface{}{
 		"fields": map[string]interface{}{
-			"BodyText": map[string]interface{}{},
-			"Title":    map[string]interface{}{},
+			"BodyText":   map[string]interface{}{},
+			"Title":      map[string]interface{}{},
+			"Abstract":   map[string]interface{}{},
+			"Annotation": map[string]interface{}{},
 		},
 		//样式 红色
 		"post_tags": []interface{}{"</font>"},
@@ -979,9 +1003,9 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 	queryMap["from"] = startSize
 	queryMap["size"] = pageSize
 	queryMap["highlight"] = highlightMap
-	jsonBytes, _ := json.Marshal(queryMap)
-	fmt.Println(string(jsonBytes))
-	utils.FileLog.Info(string(jsonBytes))
+	//jsonBytes, _ := json.Marshal(queryMap)
+	//fmt.Println(string(jsonBytes))
+	//utils.FileLog.Info(string(jsonBytes))
 	request := client.Search(indexName).Source(queryMap) // sets the JSON request
 	searchByMatch, err := request.Do(context.Background())
 	if searchByMatch != nil {
@@ -999,8 +1023,18 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 				}
 				searchItem := new(models.SearchItem)
 				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				if len(v.Highlight["BodyText"]) > 0 {
+				if len(v.Highlight["BodyText"]) > 0 || len(v.Highlight["Abstract"]) > 0 || len(v.Highlight["Annotation"]) > 0 {
 					searchItem.Body = v.Highlight["BodyText"]
+					if len(v.Highlight["Abstract"]) > 0 {
+						for _, vRed := range v.Highlight["Abstract"] {
+							searchItem.Body = append(searchItem.Body, vRed)
+						}
+					}
+					if len(v.Highlight["Annotation"]) > 0 {
+						for _, vRed := range v.Highlight["Annotation"] {
+							searchItem.Body = append(searchItem.Body, vRed)
+						}
+					}
 				} else {
 					bodyRune := []rune(article.BodyText)
 					bodyRuneLen := len(bodyRune)

+ 14 - 1
services/task.go

@@ -106,7 +106,6 @@ func Task() {
 		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章
 		task.AddTask("getArticleListByApi", getArticleListByApi)
 	}
-
 	//GetCygxActivityAttendanceDetail()
 	//CreateIndexNameArticleHistory()
 	//AddAllArticleHistory()
@@ -160,6 +159,16 @@ func CreateIndex() {
        "term_vector": "with_positions_offsets",
 		"analyzer": "ik_smart"
      },
+     "Abstract": {
+       "type": "text",
+       "term_vector": "with_positions_offsets",
+		"analyzer": "ik_smart"
+     },
+     "Annotation": {
+       "type": "text",
+       "term_vector": "with_positions_offsets",
+		"analyzer": "ik_smart"
+     },
      "TitleEn": {
        "type": "text",
        "term_vector": "with_positions_offsets"
@@ -202,6 +211,8 @@ func AddAllArticle() {
 		item.PublishDate = v.PublishDate
 		item.BodyText = bodyText
 		item.ExpertBackground = v.ExpertBackground
+		item.Annotation, _ = GetReportContentTextSubNew(v.Annotation)
+		item.Abstract, _ = GetReportContentTextSubNew(v.Abstract)
 		item.CategoryId = strconv.Itoa(v.CategoryId)
 		EsAddOrEditData(indexName, strconv.Itoa(v.ArticleId), item)
 		fmt.Println(v.ArticleId)
@@ -271,6 +282,8 @@ type ElasticTestArticleDetail struct {
 	PublishDate      string `description:"发布时间"`
 	ExpertBackground string `description:"专家背景"`
 	CategoryId       string `description:"文章分类"`
+	Abstract         string `description:"摘要"`
+	Annotation       string `description:"核心观点"`
 }
 
 type ElasticTestArticleDetailV4 struct {

+ 38 - 5
services/yidong.go

@@ -556,11 +556,13 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
 	condition += ` AND  activity_time < ` + "'" + endDate + "'"
 	//fmt.Println(startDate)
 	//fmt.Println(endDate)
+	condition = ` `
 	artivityListYidong, err := models.GetActivityListByYidong(condition)
 	if err != nil {
 		fmt.Println("GetActivityListByYidong Err:", err.Error())
 		return err
 	}
+	//fmt.Println("artivityListYidong", artivityListYidong)
 	//return err
 	if len(artivityListYidong) == 0 {
 		return err
@@ -615,6 +617,7 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
 			fmt.Println("UpdateCygxActivitySubmitMeetingByYidong Err:", err.Error())
 			return err
 		}
+		var mobiles []string
 		if len(ApifoxModal.Result) > 0 {
 			itemlog := new(models.CygxYidongActivityMeetingApiLog)
 			itemlog.YidongActivityId = v.YidongActivityId
@@ -625,13 +628,43 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
 				fmt.Println("AddCygxYidongActivityMeetingApiLog Err:", err.Error())
 				return err
 			}
+			var itemsUpdate []*models.CygxActivitySignupDetail
+
 			for _, vresult := range ApifoxModal.Result {
 				if vresult.EndTime != "" {
-					err = models.UpdateCygxActivitySignupisMeet(v.ActivityId, vresult.PersonTelephone)
-					if err != nil {
-						fmt.Println("UpdateCygxActivitySignupisMeet Err:", err.Error())
-						return err
-					}
+					mobiles = append(mobiles, vresult.PersonTelephone)
+					//err = models.UpdateCygxActivitySignupisMeet(v.ActivityId, vresult.PersonTelephone)
+					//if err != nil {
+					//	fmt.Println("UpdateCygxActivitySignupisMeet Err:", err.Error())
+					//	return err
+					//}
+					var itemDetail = new(models.CygxActivitySignupDetail)
+					itemDetail.Mobile = vresult.PersonTelephone
+					itemDetail.OutboundMobile = vresult.PersonTelephone
+					itemDetail.FirstMeetingTime = vresult.StartTime
+					itemDetail.LastMeetingTime = vresult.EndTime
+					itemDetail.Duration = vresult.Duration
+					itemDetail.IsMeeting = 1
+					itemDetail.ActivityId = v.ActivityId
+					itemsUpdate = append(itemsUpdate, itemDetail)
+				}
+			}
+
+			lenmobiles := len(mobiles)
+			if lenmobiles > 0 {
+				var parsYd []interface{}
+				var conditionYd string
+				conditionYd = ` AND mobile  IN (` + utils.GetOrmInReplace(lenmobiles) + `) AND  activity_id=?  `
+				parsYd = append(parsYd, mobiles, v.ActivityId)
+				err = models.UpdateCygxActivitySignupisMeetList(conditionYd, parsYd)
+				if err != nil {
+					fmt.Println("UpdateCygxActivitySignupisMeetList Err:", err.Error())
+					return err
+				}
+				err = models.UpdateActivitySignupDetailMultiByYiDong(itemsUpdate)
+				if err != nil {
+					fmt.Println("UpdateActivitySignupDetailMultiByYiDong Err:", err.Error())
+					return err
 				}
 			}
 		}