|
@@ -5,6 +5,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
|
+ "github.com/olivere/elastic/v7"
|
|
|
"strconv"
|
|
|
|
|
|
|
|
@@ -44,22 +45,24 @@ type ElasticComprehensiveDetail struct {
|
|
|
SubjectNames string `description:"标的名称"`
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+func init() {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
|
|
|
func AddComprehensiveArticle() {
|
|
|
- endDate := time.Now().AddDate(0, 0, -30).Format(utils.FormatDate)
|
|
|
-
|
|
|
- allList, err := models.GetArticleAllDate(endDate)
|
|
|
+
|
|
|
+ allList, err := models.GetArticleAll()
|
|
|
+
|
|
|
if err != nil {
|
|
|
|
|
|
fmt.Println("GetArticleAll Err:", err.Error())
|
|
@@ -100,22 +103,11 @@ func AddComprehensiveChart() {
|
|
|
}
|
|
|
indexName := utils.IndexNameComprehensive
|
|
|
for _, v := range list {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.ChartId
|
|
|
-
|
|
|
item.Source = "newchart"
|
|
|
item.Title = v.Title
|
|
|
item.PublishDate = v.CreateDate
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
EsAddOrEditComprehensiveData(indexName, item)
|
|
|
fmt.Println(v.ChartId)
|
|
|
}
|
|
@@ -123,8 +115,24 @@ func AddComprehensiveChart() {
|
|
|
|
|
|
|
|
|
func AddComprehensiveIndustrialSource() {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("删除数据综合页面数据Es失败"+err.Error(), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
var condition string
|
|
|
-
|
|
|
+ var pars []interface{}
|
|
|
+ mapActivitySubject := make(map[int][]string, 0)
|
|
|
+ listsubject, e := models.GetCygxIndustrialSubjectListCondition(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetIndustrialManagementRepList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range listsubject {
|
|
|
+ mapActivitySubject[v.IndustrialManagementId] = append(mapActivitySubject[v.IndustrialManagementId], v.SubjectName)
|
|
|
+ }
|
|
|
list, err := models.GetSearchResourceList(0, condition, 0, 0)
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
@@ -132,23 +140,12 @@ func AddComprehensiveIndustrialSource() {
|
|
|
}
|
|
|
indexName := utils.IndexNameComprehensive
|
|
|
for _, v := range list {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.IndustrialManagementId
|
|
|
-
|
|
|
item.Source = "industrialsource"
|
|
|
item.IndustryName = v.IndustryName
|
|
|
+ item.SubjectNames = strings.Join(mapActivitySubject[v.IndustrialManagementId], ",")
|
|
|
item.PublishDate = v.PublishDate
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
EsAddOrEditComprehensiveData(indexName, item)
|
|
|
fmt.Println(item)
|
|
|
}
|
|
@@ -158,7 +155,7 @@ func AddComprehensiveIndustrialSource() {
|
|
|
func AddComprehensiveMeetingreviewchapt() {
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
-
|
|
|
+ IndustrialManagementRespMap, _ := GetIndustrialManagementRespMap()
|
|
|
list, err := models.GetCygxMorningMeetingReviewChapterList(condition, pars)
|
|
|
|
|
|
if err != nil {
|
|
@@ -176,14 +173,10 @@ func AddComprehensiveMeetingreviewchapt() {
|
|
|
bodyText := doc.Text()
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.Id
|
|
|
-
|
|
|
item.Source = "meetingreviewchapt"
|
|
|
- item.IndustryName = v.IndustryName
|
|
|
+ item.IndustryName = IndustrialManagementRespMap[v.IndustryId]
|
|
|
item.PublishDate = v.PublishTime
|
|
|
item.BodyText = bodyText
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
EsAddOrEditComprehensiveData(indexName, item)
|
|
|
fmt.Println(item)
|
|
|
}
|
|
@@ -194,6 +187,7 @@ func AddComprehensiveActivity() {
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
condition = ` AND publish_status = 1 `
|
|
|
+
|
|
|
list, err := models.GetCygxActivityList(condition, pars, 0, 100000)
|
|
|
|
|
|
if err != nil {
|
|
@@ -201,19 +195,54 @@ func AddComprehensiveActivity() {
|
|
|
return
|
|
|
}
|
|
|
indexName := utils.IndexNameComprehensive
|
|
|
+ IndustrialManagementRespMap, _ := GetIndustrialManagementRespMap()
|
|
|
+ IndustrialSubjectMap, _ := GetCygxIndustrialSubjectMap()
|
|
|
+ var condition1 string
|
|
|
+ var pars1 []interface{}
|
|
|
+ mapActivityIndustrialManagement := make(map[int][]string)
|
|
|
+ industrialgroupList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+" AND source = 1 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range industrialgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivityIndustrialManagement[v.ActivityId] = append(mapActivityIndustrialManagement[v.ActivityId], IndustrialManagementRespMap[v.IndustrialManagementId])
|
|
|
+ }
|
|
|
+
|
|
|
+ mapActivitySubject := make(map[int][]string)
|
|
|
+ SubjectgroupList, e := models.GetCygxIndustrialActivityGroupSubjectList(condition1+" AND source = 1 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range SubjectgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivitySubject[v.ActivityId] = append(mapActivitySubject[v.ActivityId], IndustrialSubjectMap[v.IndustrialSubjectId])
|
|
|
+ }
|
|
|
+ fmt.Println(mapActivitySubject[141])
|
|
|
+ fmt.Println(mapActivityIndustrialManagement[141])
|
|
|
+
|
|
|
for _, v := range list {
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.ActivityId
|
|
|
|
|
|
item.Source = "activity"
|
|
|
-
|
|
|
+
|
|
|
+ item.SubjectNames = strings.Join(mapActivitySubject[v.ActivityId], ",")
|
|
|
+ item.IndustryName = strings.Join(mapActivityIndustrialManagement[v.ActivityId], ",")
|
|
|
item.Title = v.ActivityName
|
|
|
item.PublishDate = v.ActivityTime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- EsAddOrEditComprehensiveData(indexName, item)
|
|
|
+
|
|
|
+ EsDeleteComprehensiveData(indexName, item)
|
|
|
fmt.Println(item)
|
|
|
}
|
|
|
}
|
|
@@ -230,46 +259,128 @@ func AddComprehensiveActivitySpecial() {
|
|
|
return
|
|
|
}
|
|
|
indexName := utils.IndexNameComprehensive
|
|
|
+ IndustrialManagementRespMap, _ := GetIndustrialManagementRespMap()
|
|
|
+ IndustrialSubjectMap, _ := GetCygxIndustrialSubjectMap()
|
|
|
+ var condition1 string
|
|
|
+ var pars1 []interface{}
|
|
|
+ mapActivityIndustrialManagement := make(map[int][]string)
|
|
|
+ industrialgroupList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+" AND source = 2 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range industrialgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivityIndustrialManagement[v.ActivityId] = append(mapActivityIndustrialManagement[v.ActivityId], IndustrialManagementRespMap[v.IndustrialManagementId])
|
|
|
+ }
|
|
|
+
|
|
|
+ mapActivitySubject := make(map[int][]string)
|
|
|
+ SubjectgroupList, e := models.GetCygxIndustrialActivityGroupSubjectList(condition1+" AND source = 2 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range SubjectgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivitySubject[v.ActivityId] = append(mapActivitySubject[v.ActivityId], IndustrialSubjectMap[v.IndustrialSubjectId])
|
|
|
+ }
|
|
|
for _, v := range list {
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.ActivityId
|
|
|
-
|
|
|
item.Source = "activityspecial"
|
|
|
-
|
|
|
item.Title = v.ResearchTheme
|
|
|
item.PublishDate = v.ActivityTime
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ item.SubjectNames = strings.Join(mapActivitySubject[v.ActivityId], ",")
|
|
|
+ item.IndustryName = strings.Join(mapActivityIndustrialManagement[v.ActivityId], ",")
|
|
|
EsAddOrEditComprehensiveData(indexName, item)
|
|
|
- fmt.Println(item)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
func AddComprehensiveActivityVideo() {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("添加活动视频综合页面数据Es失败"+err.Error(), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
|
- list, err := models.GetActivityVideoListAll(condition, pars, 0, 100000)
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
+ list, e := models.GetActivityVideoListAll(condition, pars, 0, 100000)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetActivityVideoListAll, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(list) == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ var activityIds []int
|
|
|
+ for _, v := range list {
|
|
|
+ activityIds = append(activityIds, v.ActivityId)
|
|
|
+ }
|
|
|
+
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = ` AND publish_status = 1 AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
|
|
|
+ pars = append(pars, activityIds)
|
|
|
+ listArt, e := models.GetCygxActivityList(condition, pars, 0, 100000)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivityList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapActivity := make(map[int]string)
|
|
|
+
|
|
|
+ for _, v := range listArt {
|
|
|
+ mapActivity[v.ActivityId] = v.ActivityName
|
|
|
+ }
|
|
|
+
|
|
|
+ IndustrialManagementRespMap, _ := GetIndustrialManagementRespMap()
|
|
|
+ IndustrialSubjectMap, _ := GetCygxIndustrialSubjectMap()
|
|
|
+ var condition1 string
|
|
|
+ var pars1 []interface{}
|
|
|
+ mapActivityIndustrialManagement := make(map[int][]string)
|
|
|
+ industrialgroupList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+" AND source = 1 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range industrialgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivityIndustrialManagement[v.ActivityId] = append(mapActivityIndustrialManagement[v.ActivityId], IndustrialManagementRespMap[v.IndustrialManagementId])
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ mapActivitySubject := make(map[int][]string)
|
|
|
+ SubjectgroupList, e := models.GetCygxIndustrialActivityGroupSubjectList(condition1+" AND source = 1 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range SubjectgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivitySubject[v.ActivityId] = append(mapActivitySubject[v.ActivityId], IndustrialSubjectMap[v.IndustrialSubjectId])
|
|
|
+ }
|
|
|
+
|
|
|
indexName := utils.IndexNameComprehensive
|
|
|
for _, v := range list {
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.ActivityId
|
|
|
-
|
|
|
item.Source = "activityvideo"
|
|
|
-
|
|
|
item.Title = v.Title
|
|
|
item.PublishDate = v.ActivityTime
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ item.BodyText = mapActivity[v.ActivityId]
|
|
|
+ item.SubjectNames = strings.Join(mapActivitySubject[v.ActivityId], ",")
|
|
|
+ item.IndustryName = strings.Join(mapActivityIndustrialManagement[v.ActivityId], ",")
|
|
|
EsAddOrEditComprehensiveData(indexName, item)
|
|
|
fmt.Println(item)
|
|
|
}
|
|
@@ -277,6 +388,13 @@ func AddComprehensiveActivityVideo() {
|
|
|
|
|
|
|
|
|
func AddComprehensiveActivityVoice() {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("AddComprehensiveActivityVoice"+err.Error(), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
@@ -285,18 +403,70 @@ func AddComprehensiveActivityVoice() {
|
|
|
fmt.Println(err)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ if len(list) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var activityIds []int
|
|
|
+ for _, v := range list {
|
|
|
+ activityIds = append(activityIds, v.ActivityId)
|
|
|
+ }
|
|
|
+
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = ` AND publish_status = 1 AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
|
|
|
+ pars = append(pars, activityIds)
|
|
|
+ listArt, e := models.GetCygxActivityList(condition, pars, 0, 100000)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivityList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapActivity := make(map[int]string)
|
|
|
+
|
|
|
+ for _, v := range listArt {
|
|
|
+ mapActivity[v.ActivityId] = v.ActivityName
|
|
|
+ }
|
|
|
+
|
|
|
+ IndustrialManagementRespMap, _ := GetIndustrialManagementRespMap()
|
|
|
+ IndustrialSubjectMap, _ := GetCygxIndustrialSubjectMap()
|
|
|
+ var condition1 string
|
|
|
+ var pars1 []interface{}
|
|
|
+ mapActivityIndustrialManagement := make(map[int][]string)
|
|
|
+ industrialgroupList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+" AND source = 1 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range industrialgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivityIndustrialManagement[v.ActivityId] = append(mapActivityIndustrialManagement[v.ActivityId], IndustrialManagementRespMap[v.IndustrialManagementId])
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ mapActivitySubject := make(map[int][]string)
|
|
|
+ SubjectgroupList, e := models.GetCygxIndustrialActivityGroupSubjectList(condition1+" AND source = 1 ", pars1)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range SubjectgroupList {
|
|
|
+ if v.ActivityId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapActivitySubject[v.ActivityId] = append(mapActivitySubject[v.ActivityId], IndustrialSubjectMap[v.IndustrialSubjectId])
|
|
|
+ }
|
|
|
indexName := utils.IndexNameComprehensive
|
|
|
for _, v := range list {
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.ActivityId
|
|
|
-
|
|
|
item.Source = "activityvoice"
|
|
|
-
|
|
|
item.Title = v.VoiceName
|
|
|
item.PublishDate = v.ActivityTime
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ item.BodyText = mapActivity[v.ActivityId]
|
|
|
+ item.SubjectNames = strings.Join(mapActivitySubject[v.ActivityId], ",")
|
|
|
+ item.IndustryName = strings.Join(mapActivityIndustrialManagement[v.ActivityId], ",")
|
|
|
EsAddOrEditComprehensiveData(indexName, item)
|
|
|
fmt.Println(item)
|
|
|
}
|
|
@@ -306,7 +476,7 @@ func AddComprehensiveActivityVoice() {
|
|
|
func AddComprehensiveRoadshow() {
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
-
|
|
|
+ IndustrialManagementRespMap, _ := GetIndustrialManagementRespMap()
|
|
|
list, err := models.GetMicroRoadshowVideoListBycondition(condition, pars, 0, 100000)
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
@@ -316,14 +486,10 @@ func AddComprehensiveRoadshow() {
|
|
|
for _, v := range list {
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
item.SourceId = v.VideoId
|
|
|
-
|
|
|
item.Source = "roadshow"
|
|
|
-
|
|
|
+ item.IndustryName = IndustrialManagementRespMap[v.IndustryId]
|
|
|
item.Title = v.VideoName
|
|
|
item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
EsAddOrEditComprehensiveData(indexName, item)
|
|
|
fmt.Println(item)
|
|
|
}
|
|
@@ -334,26 +500,99 @@ func EsAddOrEditComprehensiveData(indexName string, item *ElasticComprehensiveDe
|
|
|
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
- fmt.Println("EsAddOrEditData Err:", err.Error())
|
|
|
+ go utils.SendAlarmMsg("更新综合页面数据Es失败"+err.Error()+fmt.Sprint(item), 2)
|
|
|
}
|
|
|
}()
|
|
|
client := utils.Client
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- resp, err := client.Index().Index(indexName).BodyJson(item).Do(context.Background())
|
|
|
- if err != nil {
|
|
|
- fmt.Println("新增失败:", err.Error())
|
|
|
- return err
|
|
|
+ mustMap := make([]interface{}, 0)
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "SourceId": item.SourceId,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "Source": item.Source,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ fmt.Println(item.SourceId)
|
|
|
+ queryMap := map[string]interface{}{
|
|
|
+ "query": map[string]interface{}{
|
|
|
+ "bool": map[string]interface{}{
|
|
|
+ "must": mustMap,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ requestTotalHits := client.Count(indexName).BodyJson(queryMap)
|
|
|
+ total, e := requestTotalHits.Do(context.Background())
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("requestTotalHits.Do(context.Background()), Err: " + e.Error())
|
|
|
+ return
|
|
|
}
|
|
|
- if resp.Status == 0 && resp.Result == "created" {
|
|
|
- fmt.Println("新增成功")
|
|
|
- err = nil
|
|
|
+
|
|
|
+
|
|
|
+ if total == 0 {
|
|
|
+ resp, e := client.Index().Index(indexName).BodyJson(item).Do(context.Background())
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("client.Index().Index(indexName).BodyJson(item).Do(context.Background()), Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp.Status == 0 && resp.Result == "created" {
|
|
|
+
|
|
|
+
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ err = errors.New(fmt.Sprint(resp))
|
|
|
+ return
|
|
|
+ }
|
|
|
} else {
|
|
|
- fmt.Println("AddData", resp.Status, resp.Result)
|
|
|
+
|
|
|
+ bool_query := elastic.NewBoolQuery()
|
|
|
+ bool_query.Must(elastic.NewTermQuery("SourceId", item.SourceId))
|
|
|
+ bool_query.Must(elastic.NewTermQuery("Source", item.Source))
|
|
|
+
|
|
|
+ var script string
|
|
|
+ script += fmt.Sprint("ctx._source['SubjectNames'] = '", item.SubjectNames, "';")
|
|
|
+ script += fmt.Sprint("ctx._source['PublishDate'] = '", item.PublishDate, "';")
|
|
|
+ script += fmt.Sprint("ctx._source['IsSummary'] = '", item.IsSummary, "';")
|
|
|
+ script += fmt.Sprint("ctx._source['Abstract'] = '", item.Abstract, "';")
|
|
|
+ script += fmt.Sprint("ctx._source['Title'] = '", item.Title, "';")
|
|
|
+ script += fmt.Sprint("ctx._source['BodyText'] = '", item.BodyText, "';")
|
|
|
+ script += fmt.Sprint("ctx._source['Annotation'] = '", item.Annotation, "';")
|
|
|
+ script += fmt.Sprint("ctx._source['IndustryName'] = '", item.IndustryName, "'")
|
|
|
+
|
|
|
+ _, e := client.UpdateByQuery(indexName).
|
|
|
+ Query(bool_query).
|
|
|
+ Script(elastic.NewScriptInline(script)).
|
|
|
+ Refresh("true").
|
|
|
+ Do(context.Background())
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New(" client.UpdateByQuery(indexName), Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func EsDeleteComprehensiveData(indexName string, item *ElasticComprehensiveDetail) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("删除数据综合页面数据Es失败"+err.Error()+fmt.Sprint(item), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ client := utils.Client
|
|
|
+
|
|
|
+ bool_query := elastic.NewBoolQuery()
|
|
|
+ bool_query.Must(elastic.NewTermQuery("SourceId", item.SourceId))
|
|
|
+ bool_query.Must(elastic.NewTermQuery("Source", item.Source))
|
|
|
+ _, e := client.DeleteByQuery(indexName).
|
|
|
+ Query(bool_query).
|
|
|
+ Do(context.Background())
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New(" client.DeleteByQuery(indexName), Err: " + e.Error())
|
|
|
+ return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -500,10 +739,15 @@ func EsComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*S
|
|
|
mustMap = append(mustMap, map[string]interface{}{
|
|
|
"bool": shouldMap,
|
|
|
})
|
|
|
+
|
|
|
mustNotMap = append(mustNotMap, map[string]interface{}{
|
|
|
- "bool": shouldNotMap,
|
|
|
+ "term": shouldNotMap,
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
queryMap := map[string]interface{}{
|
|
|
"query": map[string]interface{}{
|
|
|
"bool": map[string]interface{}{
|
|
@@ -516,9 +760,9 @@ func EsComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*S
|
|
|
queryMap["from"] = startSize
|
|
|
queryMap["size"] = pageSize
|
|
|
queryMap["highlight"] = highlightMap
|
|
|
- jsonBytes, _ := json.Marshal(queryMap)
|
|
|
- fmt.Println(string(jsonBytes))
|
|
|
- utils.FileLog.Info(string(jsonBytes))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
request := client.Search(indexName).Source(queryMap)
|
|
|
searchByMatch, err := request.Do(context.Background())
|
|
|
if searchByMatch != nil {
|
|
@@ -534,7 +778,7 @@ func EsComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*S
|
|
|
if err != nil {
|
|
|
return nil, 0, err
|
|
|
}
|
|
|
- fmt.Println(article.SourceId, article.Title, article.Source)
|
|
|
+
|
|
|
searchItem := new(SearchComprehensiveItem)
|
|
|
searchItem.SourceId = article.SourceId
|
|
|
if len(v.Highlight["Annotation"]) > 0 {
|
|
@@ -552,7 +796,7 @@ func EsComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*S
|
|
|
searchItem.Body = append(searchItem.Body, vText)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ searchItem.IsSummary = article.IsSummary
|
|
|
if len(searchItem.Body) == 0 {
|
|
|
bodyRune := []rune(article.BodyText)
|
|
|
bodyRuneLen := len(bodyRune)
|
|
@@ -586,7 +830,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
uid := user.UserId
|
|
|
-
|
|
|
+ titleHeight := make(map[int]string)
|
|
|
mapItems := make(map[string]*models.CygxResourceDataResp)
|
|
|
for _, v := range list {
|
|
|
|
|
@@ -595,6 +839,8 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
|
|
|
item.Source = v.Source
|
|
|
if v.IsSummary == 1 {
|
|
|
item.BodyHeight = v.Body
|
|
|
+ titleHeight[v.SourceId] = v.Title
|
|
|
+
|
|
|
} else {
|
|
|
item.BodyHeight = make([]string, 0)
|
|
|
}
|
|
@@ -663,6 +909,9 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
|
|
|
for _, v := range listArticle {
|
|
|
v.Body = ""
|
|
|
v.BodyHtml = ""
|
|
|
+ if titleHeight[v.ArticleId] != "" {
|
|
|
+ v.Title = titleHeight[v.ArticleId]
|
|
|
+ }
|
|
|
mapItems[fmt.Sprint("article", v.ArticleId)].Article = v
|
|
|
}
|
|
|
}
|