Browse Source

Merge branch 'cygx_10.6' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 year ago
parent
commit
22ad9c6fd2
2 changed files with 51 additions and 49 deletions
  1. 33 31
      models/activity_special.go
  2. 18 18
      services/es_comprehensive.go

+ 33 - 31
models/activity_special.go

@@ -3,41 +3,43 @@ package models
 import (
 	//"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"time"
 )
 
 // 专项调研活动列表
 type CygxActivitySpecialDetail struct {
-	ActivityId            int    `description:"活动ID "`
-	ActivityTypeName      string `description:"活动名称"`
-	SpecialType           int    `description:"调研形式、 1 线上 , 2 线下"`
-	City                  string `description:"调研城市"`
-	ChartPermissionName   string `description:"行业名称"`
-	ChartPermissionId     int    `description:"行业Id"`
-	ResearchTheme         string `description:"调研主题"`
-	ActivityTimeText      string `description:"活动预期时间带文字"`
-	TripImgLink           string `description:"行程图片链接"`
-	IsSignup              int    `description:"是否感兴趣 1是 ,0 否"`
-	Label                 string `description:"主题标签"`
-	ImgUrl                string `description:"图片链接"`
-	ImgUrlText            string `description:"图片链接文字"`
-	IndustrialName        string `description:"产业名称"`
-	IndustrialSubjectName string `description:"标的名称(相关公司)"`
-	Scale                 string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
-	CustomerTypeIds       string `description:"活动可见的客户类型,多个ID用 , 隔开"`
-	IsTrip                int    `description:"是否报名 1是 ,0 否"`
-	TripNum               int    `description:"已报名人数"`
-	Days                  int    `description:"调研天数"`
-	Host                  string `description:"主持人"`
-	PersonInCharge        string `description:"纪要负责人"`
-	LimitPeopleNum        int    `description:"限制人数数量"`
-	TripImgLinkFix        string `description:"确定行程之后的图片链接"`
-	ActivityTimeTextByDay string `description:"活动预期时间带周日"`
-	ActivityTime          string `description:"活动预期时间"`
-	ActivityTimeEnd       string `description:"活动预期结束时间"`
-	ActiveState           int    `description:"活动进行状态 未开始:1、进行中2、已结束3"`
-	TripStatus            int    `description:"行程进行状态 1:预报名,2:确定行程"`
-	Explain               string `description:"说明"`
-	AdminId               int    `description:"管理员ID"`
+	ActivityId            int       `description:"活动ID "`
+	ActivityTypeName      string    `description:"活动名称"`
+	SpecialType           int       `description:"调研形式、 1 线上 , 2 线下"`
+	City                  string    `description:"调研城市"`
+	ChartPermissionName   string    `description:"行业名称"`
+	ChartPermissionId     int       `description:"行业Id"`
+	ResearchTheme         string    `description:"调研主题"`
+	ActivityTimeText      string    `description:"活动预期时间带文字"`
+	TripImgLink           string    `description:"行程图片链接"`
+	IsSignup              int       `description:"是否感兴趣 1是 ,0 否"`
+	Label                 string    `description:"主题标签"`
+	ImgUrl                string    `description:"图片链接"`
+	ImgUrlText            string    `description:"图片链接文字"`
+	IndustrialName        string    `description:"产业名称"`
+	IndustrialSubjectName string    `description:"标的名称(相关公司)"`
+	Scale                 string    `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
+	CustomerTypeIds       string    `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	IsTrip                int       `description:"是否报名 1是 ,0 否"`
+	TripNum               int       `description:"已报名人数"`
+	Days                  int       `description:"调研天数"`
+	Host                  string    `description:"主持人"`
+	PersonInCharge        string    `description:"纪要负责人"`
+	LimitPeopleNum        int       `description:"限制人数数量"`
+	TripImgLinkFix        string    `description:"确定行程之后的图片链接"`
+	ActivityTimeTextByDay string    `description:"活动预期时间带周日"`
+	ActivityTime          string    `description:"活动预期时间"`
+	ActivityTimeEnd       string    `description:"活动预期结束时间"`
+	ActiveState           int       `description:"活动进行状态 未开始:1、进行中2、已结束3"`
+	TripStatus            int       `description:"行程进行状态 1:预报名,2:确定行程"`
+	Explain               string    `description:"说明"`
+	AdminId               int       `description:"管理员ID"`
+	LastUpdatedTime       time.Time `description:"更新时间"`
 }
 
 // 获取数量

+ 18 - 18
services/es_comprehensive.go

@@ -46,16 +46,7 @@ type ElasticComprehensiveDetail struct {
 }
 
 //func init() {
-//AddComprehensiveChart(5502)
-//AddComprehensiveActivity()
-//AddComprehensiveIndustrialSource()
-// AddComprehensiveMeetingreviewchapt()
-// AddComprehensiveActivity()
-//
-// AddComprehensiveActivitySpecial()
-// AddComprehensiveActivityVideo()
-// AddComprehensiveActivityVoice()
-// AddComprehensiveRoadshow()
+//	AddComprehensiveRoadshow()
 //}
 
 // 添加文章:报告、纪要
@@ -69,7 +60,7 @@ func AddComprehensiveArticle(articleId int) {
 	}()
 	var condition string
 	var pars []interface{}
-	condition += ` AND publish_status  = 1 `
+	condition += ` AND publish_status  = 1  `
 	if articleId > 0 {
 		condition = ` AND article_id = ? `
 		pars = append(pars, articleId)
@@ -316,6 +307,11 @@ func AddComprehensiveActivitySpecial() {
 		item.Source = "activityspecial"
 		item.Title = v.ResearchTheme
 		item.PublishDate = v.ActivityTime
+		if v.ActivityTime == utils.FormatDateTimeInit {
+			item.PublishDate = v.LastUpdatedTime.Format(utils.FormatDateTime)
+		} else {
+			item.PublishDate = v.ActivityTime
+		}
 		item.SubjectNames = strings.Join(mapActivitySubject[v.ActivityId], ",")
 		item.IndustryName = strings.Join(mapActivityIndustrialManagement[v.ActivityId], ",")
 		EsAddOrEditComprehensiveData(item)
@@ -523,8 +519,8 @@ func EsAddOrEditComprehensiveData(item *ElasticComprehensiveDetail) (err error)
 	//return
 	defer func() {
 		if err != nil {
-			fmt.Println(err)
-			go utils.SendAlarmMsg("更新综合页面数据Es失败"+err.Error()+fmt.Sprint(item), 2)
+			fmt.Println(err, item.SourceId)
+			//go utils.SendAlarmMsg("更新综合页面数据Es失败"+err.Error()+fmt.Sprint(item), 2)
 		}
 	}()
 	client := utils.Client
@@ -539,7 +535,6 @@ func EsAddOrEditComprehensiveData(item *ElasticComprehensiveDetail) (err error)
 			"Source": item.Source,
 		},
 	})
-	fmt.Println(item.SourceId)
 	queryMap := map[string]interface{}{
 		"query": map[string]interface{}{
 			"bool": map[string]interface{}{
@@ -566,7 +561,8 @@ func EsAddOrEditComprehensiveData(item *ElasticComprehensiveDetail) (err error)
 			//err = nil
 			return
 		} else {
-			err = errors.New(fmt.Sprint(resp))
+			//err = errors.New(fmt.Sprint(resp))
+			err = errors.New(fmt.Sprint("articleId", item.SourceId))
 			return
 		}
 	} else {
@@ -585,13 +581,17 @@ func EsAddOrEditComprehensiveData(item *ElasticComprehensiveDetail) (err error)
 		script += fmt.Sprint("ctx._source['Annotation'] = '", item.Annotation, "';")
 		script += fmt.Sprint("ctx._source['IndustryName'] = '", item.IndustryName, "'")
 
-		_, e := client.UpdateByQuery(indexName).
+		_, 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())
+
+		if e != nil && e.Error() != "elastic: Error 400 (Bad Request): compile error [type=script_exception]" {
+			//文本内容过长的时候,修改会报 400 的错误,暂时先不处理
+			//fmt.Println("err", e.Error())
+			////err = e
+			//err = errors.New("client.UpdateByQuery(indexName), Err: " + e.Error())
 			return
 		}
 	}