|
@@ -610,8 +610,7 @@ func GetCeLueArticlePv(cont context.Context) (err error) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-//func GetArticleListByApi(cont context.Context) (err error) {
|
|
|
-func GetArticleListByApi() (err error) {
|
|
|
+func GetArticleListByApi(cont context.Context) (err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
//fmt.Println("GetArticleListByApi Err:" + err.Error())
|
|
@@ -629,14 +628,20 @@ func GetArticleListByApi() (err error) {
|
|
|
return err
|
|
|
}
|
|
|
for _, v := range listUpdateArticle {
|
|
|
- go HandleArticleListByApi(v.ArticleId)
|
|
|
+ go HandleArticleListByApi(v.ArticleId, v.Id)
|
|
|
}
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//处理同步过来的文章
|
|
|
-func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
+func HandleArticleListByApi(artcleId, celuePushId int) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendAlarmMsg("处理同步策略平台数据失败", 2)
|
|
|
+ go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetArticleListByApi ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ }
|
|
|
+ }()
|
|
|
var clueApiUrl string
|
|
|
clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", artcleId)
|
|
|
fmt.Println(clueApiUrl)
|
|
@@ -644,15 +649,16 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
authorization := utils.ApiAuthorization
|
|
|
body, err := PublicGetDate(clueApiUrl, authorization)
|
|
|
if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- var articleResult models.ArticleResultApidate
|
|
|
- err = json.Unmarshal(body, &articleResult)
|
|
|
+ var articleResultDate models.ArticleDetailResultApi
|
|
|
+ err = json.Unmarshal(body, &articleResultDate)
|
|
|
if err != nil {
|
|
|
- fmt.Println("Getres.pdfResult Err:", err.Error())
|
|
|
+ fmt.Println("Getres.PublicGetDate Err:", err.Error())
|
|
|
return err
|
|
|
}
|
|
|
+ articleResult := articleResultDate.Data
|
|
|
exitMap := make(map[int]int)
|
|
|
classMap := make(map[int]int)
|
|
|
reportMap := make(map[int]int)
|
|
@@ -685,49 +691,58 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
var listAuthor []*models.CygxArticleAuthor
|
|
|
|
|
|
//状态等于 2 跟 4 的进行同步
|
|
|
- if exitMap[articleResult.SeriesId] > 0 && (v.PublishStatus == 2 || v.PublishStatus == 4) {
|
|
|
- v.PublishDate = time.Date(v.PublishDate.Year(), v.PublishDate.Month(), v.PublishDate.Day(), v.PublishDate.Hour(), v.PublishDate.Minute(), v.PublishDate.Second(), v.PublishDate.Nanosecond(), time.Local)
|
|
|
+ if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) {
|
|
|
+ articleResult.PublishDate = time.Date(articleResult.PublishDate.Year(), articleResult.PublishDate.Month(), articleResult.PublishDate.Day(), articleResult.PublishDate.Hour(), articleResult.PublishDate.Minute(), articleResult.PublishDate.Second(), articleResult.PublishDate.Nanosecond(), time.Local)
|
|
|
item := new(models.Tactics2)
|
|
|
itemAuthor := new(models.CygxArticleAuthor)
|
|
|
- item.ArticleId = v.ArticleId
|
|
|
- item.Title = v.Title
|
|
|
- item.TitleEn = v.TitleEn
|
|
|
- item.File = v.File
|
|
|
- if v.Frequency == "日度" {
|
|
|
+ item.ArticleId = articleResult.ArticleId
|
|
|
+ item.Title = articleResult.Title
|
|
|
+ item.TitleEn = articleResult.TitleEn
|
|
|
+ item.File = articleResult.File
|
|
|
+ if articleResult.Frequency == "日度" {
|
|
|
item.UpdateFrequency = "daily"
|
|
|
- } else if v.Frequency == "周度" {
|
|
|
+ } else if articleResult.Frequency == "周度" {
|
|
|
item.UpdateFrequency = "weekly"
|
|
|
- } else if v.Frequency == "月度" {
|
|
|
+ } else if articleResult.Frequency == "月度" {
|
|
|
item.UpdateFrequency = "monthly"
|
|
|
- } else if v.Frequency == "季度" {
|
|
|
+ } else if articleResult.Frequency == "季度" {
|
|
|
item.UpdateFrequency = "quarterly"
|
|
|
- } else if v.Frequency == "年度" {
|
|
|
+ } else if articleResult.Frequency == "年度" {
|
|
|
item.UpdateFrequency = "yearly"
|
|
|
} else {
|
|
|
item.UpdateFrequency = "unknow"
|
|
|
}
|
|
|
- item.CreateDate = v.CreateDate
|
|
|
- item.PublishDate = v.PublishDate.Add(time.Hour * 8)
|
|
|
+ item.CreateDate = articleResult.CreateDate
|
|
|
+ item.PublishDate = articleResult.PublishDate.Add(time.Hour * 8)
|
|
|
item.PublishStatus = 1
|
|
|
- item.Body = v.Content.Body
|
|
|
- item.Abstract = v.Content.Abstract
|
|
|
- item.CategoryName = v.Industry.Name
|
|
|
- item.CategoryId = exitMap[v.SeriesId]
|
|
|
- item.SubCategoryName = v.Series.Name
|
|
|
- if len(v.Stock) > 0 {
|
|
|
+ item.Body = articleResult.Content.Body
|
|
|
+ item.Abstract = articleResult.Content.Abstract
|
|
|
+ item.CategoryName = articleResult.Industry.Name
|
|
|
+ item.CategoryId = exitMap[articleResult.SeriesId]
|
|
|
+ item.SubCategoryName = articleResult.Series.Name
|
|
|
+ if len(articleResult.Stock) > 0 {
|
|
|
var stock string
|
|
|
- for _, vS := range v.Stock {
|
|
|
+ for _, vS := range articleResult.Stock {
|
|
|
stock += vS + "/"
|
|
|
}
|
|
|
stock = strings.TrimRight(stock, "/")
|
|
|
item.Stock = stock
|
|
|
}
|
|
|
- item.FieldName = v.Field.Name
|
|
|
+ item.FieldName = articleResult.Field.Name
|
|
|
list = append(list, item)
|
|
|
- itemAuthor.ArticleId = v.ArticleId
|
|
|
- itemAuthor.Name = v.Author.Name
|
|
|
- itemAuthor.Mobile = v.Author.PhoneNumber
|
|
|
+ itemAuthor.ArticleId = articleResult.ArticleId
|
|
|
+ itemAuthor.Name = articleResult.Author.Name
|
|
|
+ itemAuthor.Mobile = articleResult.Author.PhoneNumber
|
|
|
listAuthor = append(listAuthor, itemAuthor)
|
|
|
+ } else {
|
|
|
+ // 如果这篇文章没有发布,那么就不作处理。
|
|
|
+ err = models.UpdateArticlePublish(0, artcleId)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("UpdateArticlePublish Err:", err.Error())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return err
|
|
|
+ go models.UpdateCygxArticleCeluePush(celuePushId)
|
|
|
}
|
|
|
|
|
|
//同步作者
|
|
@@ -735,7 +750,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
var count int
|
|
|
count, err = models.GetActivityAuthorCount(v.ArticleId, v.Mobile)
|
|
|
if err != nil {
|
|
|
- fmt.Println("GetCount Err:", err.Error())
|
|
|
+ fmt.Println("GetActivityAuthorCount Err:", err.Error())
|
|
|
return err
|
|
|
}
|
|
|
if count == 0 {
|
|
@@ -956,11 +971,6 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
err = models.ReportArticleClassificationEditNew(int(newId), industrialManagementIdStr, v.ArticleId, industrialSubjectIdStr)
|
|
|
if err != nil {
|
|
|
fmt.Println("ReportArticleClassificationEditNew Err:", err.Error())
|
|
|
- //keyword1 = "新报告产业标签:【" + v.FieldName + "】,个股标签:" + subjectStr
|
|
|
- //keyword2 = "归类失败"
|
|
|
- //keyword3 = v.Title
|
|
|
- //keyword4 = v.PublishDate.Format(utils.FormatDateTime)
|
|
|
- //SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdList, articleIdInt)
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
@@ -984,69 +994,70 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //类型ID 医药(医享会:28 、药调研:301)、消费【渠道新声:32】、科技【科技前言:79】、智造【匠心智造:84】或者是纪要做消息模板推送
|
|
|
- fmt.Println(v.CategoryId)
|
|
|
- if v.IsSummary == 1 || (v.CategoryId == 28 || v.CategoryId == 301 || v.CategoryId == 32 || v.CategoryId == 79 || v.CategoryId == 84) {
|
|
|
- sliceSubjects := strings.Split(v.Stock, "/")
|
|
|
- fmt.Println(sliceSubjects)
|
|
|
- if len(sliceSubjects) > 0 {
|
|
|
- var subjectStr string
|
|
|
- for _, vSubject := range sliceSubjects {
|
|
|
- sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
- sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
- subject := sliceXiahuaxian[0]
|
|
|
- subjectStr += "'" + subject + "',"
|
|
|
+ }
|
|
|
+
|
|
|
+ //类型ID 医药(医享会:28 、药调研:301)、消费【渠道新声:32】、科技【科技前言:79】、智造【匠心智造:84】或者是纪要做消息模板推送
|
|
|
+ fmt.Println(v.CategoryId)
|
|
|
+ if v.IsSummary == 1 || (v.CategoryId == 28 || v.CategoryId == 301 || v.CategoryId == 32 || v.CategoryId == 79 || v.CategoryId == 84) {
|
|
|
+ sliceSubjects := strings.Split(v.Stock, "/")
|
|
|
+ fmt.Println(sliceSubjects)
|
|
|
+ if len(sliceSubjects) > 0 {
|
|
|
+ var subjectStr string
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ subjectStr += "'" + subject + "',"
|
|
|
+ }
|
|
|
+ if subjectStr != "" {
|
|
|
+ subjectStr = strings.TrimRight(subjectStr, ",")
|
|
|
+ activityIdList, err := models.GetActivityIdListBySubjecName(subjectStr)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetActivityIdListBySubjecName Err:", err.Error())
|
|
|
+ return err
|
|
|
}
|
|
|
- if subjectStr != "" {
|
|
|
- subjectStr = strings.TrimRight(subjectStr, ",")
|
|
|
- activityIdList, err := models.GetActivityIdListBySubjecName(subjectStr)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetActivityIdListBySubjecName Err:", err.Error())
|
|
|
- return err
|
|
|
+ if len(activityIdList) > 0 {
|
|
|
+ var activityIdStr string
|
|
|
+ for _, vAct := range activityIdList {
|
|
|
+ activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
|
|
|
}
|
|
|
- if len(activityIdList) > 0 {
|
|
|
- var activityIdStr string
|
|
|
- for _, vAct := range activityIdList {
|
|
|
- activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
|
|
|
+ activityIdStr = strings.TrimRight(activityIdStr, ",")
|
|
|
+ if activityIdStr != "" {
|
|
|
+ appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "1,2,5")
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
+ return err
|
|
|
}
|
|
|
- activityIdStr = strings.TrimRight(activityIdStr, ",")
|
|
|
- if activityIdStr != "" {
|
|
|
- appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "1,2,5")
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- if len(appointmentList) > 0 {
|
|
|
- for _, vApp := range appointmentList {
|
|
|
+ if len(appointmentList) > 0 {
|
|
|
+ for _, vApp := range appointmentList {
|
|
|
|
|
|
- appointmentByMobileList, err := models.GetAppointmentListByActivityIdAndMobile(activityIdStr, vApp.Mobile)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- var appointmentActivityName string
|
|
|
- if len(appointmentByMobileList) > 0 {
|
|
|
- for _, vAppM := range appointmentByMobileList {
|
|
|
- appointmentActivityName += vAppM.ActivityName + ","
|
|
|
- }
|
|
|
- }
|
|
|
- appointmentActivityName = strings.TrimRight(appointmentActivityName, ",")
|
|
|
- if vApp.ActivityTypeId == 5 && v.CategoryId != 301 {
|
|
|
- continue
|
|
|
+ appointmentByMobileList, err := models.GetAppointmentListByActivityIdAndMobile(activityIdStr, vApp.Mobile)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var appointmentActivityName string
|
|
|
+ if len(appointmentByMobileList) > 0 {
|
|
|
+ for _, vAppM := range appointmentByMobileList {
|
|
|
+ appointmentActivityName += vAppM.ActivityName + ","
|
|
|
}
|
|
|
+ }
|
|
|
+ appointmentActivityName = strings.TrimRight(appointmentActivityName, ",")
|
|
|
+ if vApp.ActivityTypeId == 5 && v.CategoryId != 301 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
|
|
|
- if vApp.Mobile != "" {
|
|
|
- openIdListByAppointment, err := models.GetUserRecordListByMobile(4, vApp.Mobile)
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- return err
|
|
|
- }
|
|
|
- keyword1 := "您预约的调研,有关联的纪要发布/更新了"
|
|
|
- keyword2 := appointmentActivityName
|
|
|
- keyword3 := v.Title
|
|
|
- keyword4 := v.PublishDate.Format(utils.FormatDateTime)
|
|
|
- SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, articleIdInt)
|
|
|
+ if vApp.Mobile != "" {
|
|
|
+ openIdListByAppointment, err := models.GetUserRecordListByMobile(4, vApp.Mobile)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return err
|
|
|
}
|
|
|
+ keyword1 := "您预约的调研,有关联的纪要发布/更新了"
|
|
|
+ keyword2 := appointmentActivityName
|
|
|
+ keyword3 := v.Title
|
|
|
+ keyword4 := v.PublishDate.Format(utils.FormatDateTime)
|
|
|
+ SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, artcleId)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1054,63 +1065,65 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //【公司调研】系列纪要发布/更新后
|
|
|
- if v.CategoryId == 45 || v.CategoryId == 74 || v.CategoryId == 86 || v.CategoryId == 88 {
|
|
|
- sliceSubjects := strings.Split(v.Stock, "/")
|
|
|
- if len(sliceSubjects) > 0 {
|
|
|
- var subjectStr string
|
|
|
- for _, vSubject := range sliceSubjects {
|
|
|
- sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
- sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
- subject := sliceXiahuaxian[0]
|
|
|
- subjectStr += "'" + subject + "',"
|
|
|
+ }
|
|
|
+
|
|
|
+ //【公司调研】系列纪要发布/更新后
|
|
|
+ if v.CategoryId == 45 || v.CategoryId == 74 || v.CategoryId == 86 || v.CategoryId == 88 {
|
|
|
+ fmt.Println("处理预约纪要")
|
|
|
+ sliceSubjects := strings.Split(v.Stock, "/")
|
|
|
+ if len(sliceSubjects) > 0 {
|
|
|
+ var subjectStr string
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ subjectStr += "'" + subject + "',"
|
|
|
+ }
|
|
|
+ if subjectStr != "" {
|
|
|
+ subjectStr = strings.TrimRight(subjectStr, ",")
|
|
|
+ activityIdList, err := models.GetActivityIdListBySubjecName(subjectStr)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetActivityIdListBySubjecName Err:", err.Error())
|
|
|
+ return err
|
|
|
}
|
|
|
- if subjectStr != "" {
|
|
|
- subjectStr = strings.TrimRight(subjectStr, ",")
|
|
|
- activityIdList, err := models.GetActivityIdListBySubjecName(subjectStr)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetActivityIdListBySubjecName Err:", err.Error())
|
|
|
- return err
|
|
|
+ if len(activityIdList) > 0 {
|
|
|
+ var activityIdStr string
|
|
|
+ for _, vAct := range activityIdList {
|
|
|
+ activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
|
|
|
}
|
|
|
- if len(activityIdList) > 0 {
|
|
|
- var activityIdStr string
|
|
|
- for _, vAct := range activityIdList {
|
|
|
- activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
|
|
|
+ activityIdStr = strings.TrimRight(activityIdStr, ",")
|
|
|
+ if activityIdStr != "" {
|
|
|
+ appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "3,4")
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
+ return err
|
|
|
}
|
|
|
- activityIdStr = strings.TrimRight(activityIdStr, ",")
|
|
|
- if activityIdStr != "" {
|
|
|
- appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "3,4")
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- if len(appointmentList) > 0 {
|
|
|
- for _, vApp := range appointmentList {
|
|
|
- appointmentByMobileList, err := models.GetAppointmentListByActivityIdAndMobile(activityIdStr, vApp.Mobile)
|
|
|
+ if len(appointmentList) > 0 {
|
|
|
+ for _, vApp := range appointmentList {
|
|
|
+ appointmentByMobileList, err := models.GetAppointmentListByActivityIdAndMobile(activityIdStr, vApp.Mobile)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var appointmentActivityName string
|
|
|
+ if len(appointmentByMobileList) > 0 {
|
|
|
+ for _, vAppM := range appointmentByMobileList {
|
|
|
+ appointmentActivityName += vAppM.ActivityName + ","
|
|
|
+ }
|
|
|
+ }
|
|
|
+ appointmentActivityName = strings.TrimRight(appointmentActivityName, ",")
|
|
|
+ if vApp.Mobile != "" {
|
|
|
+ openIdListByAppointment, err := models.GetUserRecordListByMobile(4, vApp.Mobile)
|
|
|
if err != nil {
|
|
|
- fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
|
|
|
+ fmt.Println(err)
|
|
|
return err
|
|
|
}
|
|
|
- var appointmentActivityName string
|
|
|
- if len(appointmentByMobileList) > 0 {
|
|
|
- for _, vAppM := range appointmentByMobileList {
|
|
|
- appointmentActivityName += vAppM.ActivityName + ","
|
|
|
- }
|
|
|
- }
|
|
|
- appointmentActivityName = strings.TrimRight(appointmentActivityName, ",")
|
|
|
- if vApp.Mobile != "" {
|
|
|
- openIdListByAppointment, err := models.GetUserRecordListByMobile(4, vApp.Mobile)
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- return err
|
|
|
- }
|
|
|
- keyword1 := "您预约的调研,有关联的纪要发布/更新了"
|
|
|
- keyword2 := appointmentActivityName
|
|
|
- keyword3 := v.Title
|
|
|
- keyword4 := v.PublishDate.Format(utils.FormatDateTime)
|
|
|
- SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, articleIdInt)
|
|
|
+ keyword1 := "您预约的调研,有关联的纪要发布/更新了"
|
|
|
+ keyword2 := appointmentActivityName
|
|
|
+ keyword3 := v.Title
|
|
|
+ keyword4 := v.PublishDate.Format(utils.FormatDateTime)
|
|
|
+ SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, artcleId)
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1118,8 +1131,9 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //【公司调研】系列纪要发布/更新后 end
|
|
|
}
|
|
|
+ //【公司调研】系列纪要发布/更新后 end
|
|
|
}
|
|
|
+ go models.UpdateCygxArticleCeluePush(celuePushId)
|
|
|
return err
|
|
|
}
|