123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- package services
- import (
- "fmt"
- "github.com/PuerkitoBio/goquery"
- "github.com/beego/beego/v2/task"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- "html"
- "strconv"
- "strings"
- "time"
- )
- func Task() {
- fmt.Println("start")
- if utils.RunMode == "release" && utils.IsTask {
-
-
-
-
-
-
-
- sendEmailFileToExpert := task.NewTask("sendEmailFileToExpert", "0 */5 6-23 * * *", SendEmailFileToExpert)
- task.AddTask("sendEmailFileToExpert", sendEmailFileToExpert)
- sendEmailUserWhiteListChange := task.NewTask("sendEmailUserWhiteListChange", "0 00 17 * * *", SendEmailUserWhiteListChange)
- task.AddTask("白名单发送", sendEmailUserWhiteListChange)
-
-
- getChartListByApi := task.NewTask("getChartListByApi", "0 */10 * * * *", GetChartDetailByChartId)
- task.AddTask("getChartListByApi", getChartListByApi)
- getYiDongActivityMeeting := task.NewTask("getYiDongActivityMeeting", "0 */60 * * * *", GetYiDongActivityMeeting)
- task.AddTask("getYiDongActivityMeeting", getYiDongActivityMeeting)
- yiDongSignAppointmentsForThird := task.NewTask("yiDongSignAppointmentsForThird", "0 */10 * * * *", YiDongSignAppointmentsForThird)
- task.AddTask("yiDongSignAppointmentsForThird", yiDongSignAppointmentsForThird)
- groupingActivityToYiDong := task.NewTask("groupingActivityToYiDong", "0 00 1 * * *", GroupingActivityToYiDong)
- task.AddTask("groupingActivityToYiDong", groupingActivityToYiDong)
- getYiDongActivity := task.NewTask("getYiDongActivity", "0 */10 * * * *", GetYiDongActivity)
- task.AddTask("getYiDongActivity", getYiDongActivity)
- updateYiDongActivityDataToCygx := task.NewTask("updateYiDongActivityDataToCygx", "0 20 1 * * *", UpdateYiDongActivityDataToCygx)
- task.AddTask("updateYiDongActivityDataToCygx", updateYiDongActivityDataToCygx)
- pushVmpRobotMeeting := task.NewTask("pushVmpRobotMeeting", "0 */10 6-23 * * *", PushVmpRobotMeeting)
- task.AddTask("pushVmpRobotMeeting", pushVmpRobotMeeting)
- }
- if utils.IsTask {
-
- sendActivityBeginMsg := task.NewTask("sendActivityBeginMsg", "0 */10 6-23 * * *", SendActivityBeginMsg)
- task.AddTask("sendActivityBeginMsg", sendActivityBeginMsg)
- sendActivityBeginMsgMeeting := task.NewTask("sendActivityBeginMsgMeeting", "0 */5 6-23 * * *", SendActivityBeginMsgMeeting)
- task.AddTask("sendActivityBeginMsgMeeting", sendActivityBeginMsgMeeting)
-
- updateActivitySattus := task.NewTask("syncTacticsListAddreport", "0 */1 6-23 * * *", UpdateActivitySattus)
- task.AddTask("updateActivitySattus", updateActivitySattus)
-
- updateIndustrialManagementLabel := task.NewTask("updateIndustrialManagementLabel", "0 */30 * * * *", UpdateIndustrialManagementLabel)
- task.AddTask("updateIndustrialManagementLabel", updateIndustrialManagementLabel)
-
- chageIndustrialArticleNum := task.NewTask("chageIndustrialArticleNum", "0 01 00 * * *", ChageIndustrialArticleNum)
- task.AddTask("chageIndustrialArticleNum", chageIndustrialArticleNum)
-
-
- groupingActivityToJmcj := task.NewTask("groupingActivityToJmcj", "0 00 1 * * *", GroupingActivityToJmcj)
- task.AddTask("groupingActivityToJmcj", groupingActivityToJmcj)
- getActivityMeetingByJmcj := task.NewTask("getActivityMeetingByJmcj", "0 00 3 * * *", GetActivityMeetingByJmcj)
- task.AddTask("getActivityMeetingByJmcj", getActivityMeetingByJmcj)
- sendEmailFileForAskMsgResearch := task.NewTask("sendEmailFileForAskMsgResearch", "0 */5 6-23 * * *", SendEmailFileForAskMsgResearch)
- task.AddTask("sendEmailFileForAskMsgResearch", sendEmailFileForAskMsgResearch)
- sendEmailFileForAskMsg := task.NewTask("sendEmailFileForAskMsg", "0 */5 6-23 * * *", SendEmailFileForAskMsg)
- task.AddTask("sendEmailFileForAskMsg", sendEmailFileForAskMsg)
- updateWxUserLabel := task.NewTask("updateWxUserLabel", "0 01 0 * * *", UpdateWxUserLabel)
- task.AddTask("updateWxUserLabel", updateWxUserLabel)
- addAllArticleHistory := task.NewTask("addAllArticleHistory", "0 30 2 * * *", AddAllArticleAndYanxuanHistory)
- task.AddTask("addAllArticleHistory", addAllArticleHistory)
- getCeLueArticlePv := task.NewTask("getCeLueArticlePv", "0 */10 * * * *", GetCeLueArticlePv)
- task.AddTask("getCeLueArticlePv", getCeLueArticlePv)
- reportBillboardUpdate := task.NewTask("reportBillboardUpdate", "0 10 0 * * *", ReportBillboardUpdate)
- task.AddTask("reportBillboardUpdate", reportBillboardUpdate)
- doActivityOnenIdWxTemplateMsg := task.NewTask("doActivityOnenIdWxTemplateMsg", "0 30 16 * * 0", DoActivityOnenIdWxTemplateMsg)
- task.AddTask("doActivityOnenIdWxTemplateMsg", doActivityOnenIdWxTemplateMsg)
- updateCygxActivitySpecialSignupNum := task.NewTask("updateCygxActivitySpecialSignupNum", "0 25 0 * * *", UpdateCygxActivitySpecialSignupNum)
- task.AddTask("updateCygxActivitySpecialSignupNum", updateCygxActivitySpecialSignupNum)
- updateDailyMonthReadBillboard := task.NewTask("updateDailyMonthReadBillboard", "0 0 3 * * *", UpdateDailyMonthReadBillboard)
- task.AddTask("updateDailyMonthReadBillboard", updateDailyMonthReadBillboard)
- dotongbuShangHai := task.NewTask("dotongbuShangHai", "0 */20 * * * *", DotongbuShangHai)
- task.AddTask("同步用户到上海", dotongbuShangHai)
- addctivitySignupDetail := task.NewTask("addctivitySignupDetail", "0 0 23 * * *", AddctivitySignupDetail)
- task.AddTask("addctivitySignupDetail", addctivitySignupDetail)
- sendWxMsgActivitySpecialTwoDays := task.NewTask("sendWxMsgActivitySpecialTwoDays", "0 0 8 * * *", SendWxMsgActivitySpecialTwoDays)
- task.AddTask("sendWxMsgActivitySpecialTwoDays", sendWxMsgActivitySpecialTwoDays)
-
-
- makeMorningMeetingReviews := task.NewTask("makeMorningMeetingReviews", "0 30 10 * * *", MakeMorningMeetingReviews)
- task.AddTask("makeMorningMeetingReviews", makeMorningMeetingReviews)
- cygxActivityRestrictSignupByTask := task.NewTask("cygxActivityRestrictSignupByTask", "0 */10 6-23 * * *", CygxActivityRestrictSignupByTask)
- task.AddTask("cygxActivityRestrictSignupByTask", cygxActivityRestrictSignupByTask)
- getStocksFromVmp := task.NewTask("getStocksFromVmp", "0 40 3 * * *", GetStocksFromVmp)
- task.AddTask("getStocksFromVmp", getStocksFromVmp)
- updateIndustrialManagementOneMonthFollowNum := task.NewTask("updateIndustrialManagementOneMonthFollowNum", "0 10 1 * * *", UpdateIndustrialManagementOneMonthFollowNum)
- task.AddTask("updateIndustrialManagementOneMonthFollowNum", updateIndustrialManagementOneMonthFollowNum)
- updateCygxUserYanxuanPermissionToClose := task.NewTask("updateCygxUserYanxuanPermissionToClose", "0 10 1 * * *", UpdateCygxUserYanxuanPermissionToClose)
- task.AddTask("updateCygxUserYanxuanPermissionToClose", updateCygxUserYanxuanPermissionToClose)
- updateYanxuanSpecialAuthoMomentsImg := task.NewTask("updateYanxuanSpecialAuthoMomentsImg", "0 0 1 * * *", UpdateYanxuanSpecialAuthoMomentsImg)
- task.AddTask(" 更新研选专栏作者朋友圈封面图片,并删除老的图片", updateYanxuanSpecialAuthoMomentsImg)
- sendMfyxEmailFileForAskMsgResearch := task.NewTask("sendMfyxEmailFileForAskMsgResearch", "0 */5 6-23 * * *", SendMfyxEmailFileForAskMsgResearch)
- task.AddTask("sendMfyxEmailFileForAskMsgResearch", sendMfyxEmailFileForAskMsgResearch)
- sendMfyxActivityBeginMsgMeeting := task.NewTask("sendMfyxActivityBeginMsgMeeting", "0 */5 6-23 * * *", SendMfyxActivityBeginMsgMeeting)
- task.AddTask("sendMfyxActivityBeginMsgMeeting", sendMfyxActivityBeginMsgMeeting)
- sendMfyxActivityBeginMsg := task.NewTask("sendMfyxActivityBeginMsg", "0 */5 6-23 * * *", SendMfyxActivityBeginMsg)
- task.AddTask("sendMfyxActivityBeginMsg", sendMfyxActivityBeginMsg)
- cancelCygxOrder := task.NewTask("CancelCygxOrder", "0 */1 * * * *", CancelCygxOrder)
- task.AddTask("十分钟内未付款的订单自动取消", cancelCygxOrder)
- getQueryOrderByOutTradeNoTask := task.NewTask("getQueryOrderByOutTradeNoTask", "0 */1 * * * *", GetQueryOrderByOutTradeNoTask)
- task.AddTask("定时任务主动获取订单支付状态", getQueryOrderByOutTradeNoTask)
- handleOrderRefundTask := task.NewTask("handleOrderRefundTask", "0 */1 * * * *", HandleOrderRefundTask)
- task.AddTask("定时任务处理退款回调", handleOrderRefundTask)
- updateRaiServeBillDate := task.NewTask("updateRaiServeBillDate", "0 */10 * * * *", UpdateRaiServeBillDate)
- task.AddTask("定时任务处理权益服务记录明细", updateRaiServeBillDate)
- updateCygxRaiCompanyUserBillDate := task.NewTask("updateCygxRaiCompanyUserBillDate", "0 */10 * * * *", UpdateCygxRaiCompanyUserBillDate)
- task.AddTask("权益正式,试用、X类试用客户近四周互动记录", updateCygxRaiCompanyUserBillDate)
- getYanxuanSpecialLikeCountDifferent := task.NewTask("getYanxuanSpecialLikeCountDifferent", "0 0 */1 * * *", GetYanxuanSpecialLikeCountDifferent)
- task.AddTask("定时任务处理退款回调", getYanxuanSpecialLikeCountDifferent)
- getFiccRreportToCygxArticle := task.NewTask("getFiccRreportToCygxArticle", "0 */10 * * * *", GetFiccRreportToCygxArticle)
- task.AddTask("获取FICC研报到查研观向数据库中", getFiccRreportToCygxArticle)
- }
-
-
-
-
-
- go UserLabelLogReduce()
- go YanXuanActivityPointsBillReduce()
- go UpdateArticleByRedis()
- go UpdateIndustrialManagementTimeLineDateList3ByRedis()
-
-
-
-
-
-
-
-
-
- task.StartTask()
-
- fmt.Println("end")
- }
- func CreateIndex() {
- indexName := utils.IndexName
- mappingJson := `{
- "mappings": {
- "dynamic": true,
- "properties": {
- "ArticleId": {
- "type": "integer"
- },
- "CategoryId": {
- "type": "text"
- },
- "BodyText": {
- "type": "text",
- "term_vector": "with_positions_offsets",
- "analyzer": "ik_smart"
- },
- "PublishDate": {
- "type": "keyword"
- },
- "SubCategoryName": {
- "type": "text",
- "term_vector": "with_positions_offsets",
- "analyzer": "ik_smart"
- },
- "Title": {
- "type": "text",
- "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"
- },
- "UpdateFrequency": {
- "type": "text",
- "term_vector": "with_positions_offsets"
- },
- "ExpertBackground": {
- "type": "text",
- "term_vector": "with_positions_offsets"
- }
- }
- }
- }`
- EsCreateIndex(indexName, mappingJson)
- AddAllArticle()
- }
- func AddAllArticle() {
- endDate := time.Now().AddDate(0, 0, -30).Format(utils.FormatDate)
-
- allList, err := models.GetArticleAllDate(endDate)
- if err != nil {
- fmt.Println("GetArticleAll Err:", err.Error())
- return
- }
- indexName := utils.IndexName
- for _, v := range allList {
- content := html.UnescapeString(v.Body)
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
- if err != nil {
- fmt.Println("create doc err:", err.Error())
- return
- }
- bodyText := doc.Text()
- item := new(ElasticTestArticleDetail)
- item.ArticleId = v.ArticleId
- item.Title = v.Title
- 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)
- }
- }
- func AddAllArticleV4() {
- allList, err := models.GetArticleAll2()
- if err != nil {
- fmt.Println("GetArticleAll Err:", err.Error())
- return
- }
- indexName := "cygx_article_v4"
- for _, v := range allList {
- content := html.UnescapeString(v.Body)
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
- if err != nil {
- fmt.Println("create doc err:", err.Error())
- return
- }
- bodyText := doc.Text()
- item := new(ElasticTestArticleDetailV4)
- item.ArticleId = v.ArticleId
- item.Title = v.Title
- item.PublishDate = v.PublishDate
- item.BodyText = bodyText
- item.IsSummary = v.IsSummary
- item.IsReport = v.IsReport
-
-
-
-
-
-
- EsAddOrEditDataV4(indexName, strconv.Itoa(v.ArticleId), item)
- fmt.Println(v.ArticleId)
- }
- }
- type ElasticArticleDetail struct {
- ArticleId int `description:"报告id"`
- Title string `description:"标题"`
- TitleEn string `description:"英文标题 "`
- UpdateFrequency string `description:"更新周期"`
- CreateDate string `description:"创建时间"`
- PublishDate string `description:"发布时间"`
- Abstract string `description:"摘要"`
- CategoryName string `description:"一级分类"`
- SubCategoryName string `description:"二级分类"`
- InterviewDate string `description:"访谈时间"`
- ExpertBackground string `description:"专家背景"`
- ExpertNumber string `description:"专家编号"`
- Department string `description:"作者"`
- ArticleIdMd5 string `description:"纪要id"`
- BodyText string `description:"内容"`
- }
- type ElasticTestArticleDetail struct {
- ArticleId int `description:"报告id"`
- Title string `description:"标题"`
- BodyText string `description:"内容"`
- PublishDate string `description:"发布时间"`
- ExpertBackground string `description:"专家背景"`
- CategoryId string `description:"文章分类"`
- Abstract string `description:"摘要"`
- Annotation string `description:"核心观点"`
- }
- type ElasticTestArticleDetailV4 struct {
- ArticleId int `description:"报告id"`
- Title string `description:"标题"`
- BodyText string `description:"内容"`
- PublishDate string `description:"发布时间"`
- IsSummary int `description:"是否属于纪要库"`
- IsReport int `description:"是否属于报告"`
- }
- func GetAddpArticle() {
- list, err := models.GetReportList()
- for _, v := range list {
- var articleId int
- maxArticleIdArticleInfo, errMax := models.GetMaxArticleIdInfo()
- if errMax != nil {
- fmt.Println(errMax)
- return
- }
- articleId = maxArticleIdArticleInfo.ArticleId + 1
- item := new(models.CygxArticle)
- item.Title = v.Title
- item.ArticleId = articleId
- item.SellerAndMobile = v.Author
- item.PublishDate = v.PublishTime
- item.Abstract = v.Abstract
- item.Body = html.UnescapeString(v.Content)
- item.BodyText, _ = GetReportContentTextSub(v.Content)
- item.IsReport = 1
- item.Source = 1
- item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleId))
- item.Department = "弘则产品组"
- item.ArticleType = "lyjh"
- item.IsClass = 1
- item.CreateDate = v.CreateTime
- item.UpdateFrequency = "unknow"
- item.CategoryId = 100
- item.SubCategoryName = "路演精华"
- item.HavePublish = 1
- item.PublishStatus = 1
- item.Periods = strconv.Itoa(v.Stage)
- item.VideoUrl = v.VideoUrl
- item.VideoName = v.VideoName
- item.VideoPlaySeconds = v.VideoPlaySeconds
- newId, _ := models.AddCygxArticles(item)
- fmt.Println(articleId)
- fmt.Println(newId)
- fmt.Println(item.ArticleIdMd5)
- }
- fmt.Println(err)
- fmt.Println(list)
- }
- func SynchronizationArthistory() {
- go SynchronizationArtclehistory()
- }
|