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 { //syncTacticsListAddreport := task.NewTask("syncTacticsListAddreport", "0 */5 * * * *", SyncTacticsListAddreport) //同步文章 //task.AddTask("syncTacticsListAddreport", syncTacticsListAddreport) //getSummarytoEs := task.NewTask("getSummarytoEs", "0 */30 * * * *", GetSummarytoEs) //同步纪要库内容到Es //task.AddTask("getSummarytoEs", getSummarytoEs) //getArticleListByApi := task.NewTask("getArticleListByApi", "0 */5 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章 //task.AddTask("getArticleListByApi", getArticleListByApi) //预约外呼名单,会前1小时自动发送邮件给专家组 sendEmailFileToExpert := task.NewTask("sendEmailFileToExpert", "0 */5 6-23 * * *", SendEmailFileToExpert) //预约外呼名单,会前1小时自动发送邮件给专家组 task.AddTask("sendEmailFileToExpert", sendEmailFileToExpert) sendEmailUserWhiteListChange := task.NewTask("sendEmailUserWhiteListChange", "0 00 17 * * *", SendEmailUserWhiteListChange) //新增 和冻结的客户白名单 task.AddTask("白名单发送", sendEmailUserWhiteListChange) //dotongbuShangHaiSendEmail := task.NewTask("dotongbuShangHaiSendEmail", "0 00 4 * * *", DotongbuShangHaiSendEmail) //发送上海策略品台同步结果名单的邮件附件 //task.AddTask("发送上海策略品台同步结果名单的邮件附件", dotongbuShangHaiSendEmail) 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) //研选活动会前15分钟推送给上海那边的机器人 task.AddTask("pushVmpRobotMeeting", pushVmpRobotMeeting) } if utils.IsTask { //会议提醒模板消息推送 sendActivityBeginMsg := task.NewTask("sendActivityBeginMsg", "0 */10 6-23 * * *", SendActivityBeginMsg) //会议前60分钟的提醒 task.AddTask("sendActivityBeginMsg", sendActivityBeginMsg) sendActivityBeginMsgMeeting := task.NewTask("sendActivityBeginMsgMeeting", "0 */5 6-23 * * *", SendActivityBeginMsgMeeting) //会议前15分钟的提醒 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) //activityAttendanceDetail := task.NewTask("activityAttendanceDetail", "0 00 3 * * *", ActivityAttendanceDetail) //同步进门财经的路演信息 //task.AddTask("activityAttendanceDetail", activityAttendanceDetail) 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) //研选系列专家电话会,会前1小时将问题列表发送给邮箱 task.AddTask("sendEmailFileForAskMsgResearch", sendEmailFileForAskMsgResearch) sendEmailFileForAskMsg := task.NewTask("sendEmailFileForAskMsg", "0 */5 6-23 * * *", SendEmailFileForAskMsg) //非研选系列专家电话会,根据主持人姓名,会前15分钟将问题列表发送给至该主持人对应邮箱 task.AddTask("sendEmailFileForAskMsg", sendEmailFileForAskMsg) updateWxUserLabel := task.NewTask("updateWxUserLabel", "0 01 0 * * *", UpdateWxUserLabel) //更新用户的标签 task.AddTask("updateWxUserLabel", updateWxUserLabel) addAllArticleHistory := task.NewTask("addAllArticleHistory", "0 30 2 * * *", AddAllArticleAndYanxuanHistory) //把前一天的用户阅读记录同步到ES 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) dotongbuShangHai := task.NewTask("dotongbuShangHai", "0 */20 * * * *", DotongbuShangHai) //把信息同步到上海策略品台 task.AddTask("同步用户到上海", dotongbuShangHai) updateDailyMonthReadBillboard := task.NewTask("updateDailyMonthReadBillboard", "0 0 3 * * *", UpdateDailyMonthReadBillboard) // 每日3:00更新阅读飙升榜单 task.AddTask("updateDailyMonthReadBillboard", updateDailyMonthReadBillboard) addctivitySignupDetail := task.NewTask("addctivitySignupDetail", "0 0 23 * * *", AddctivitySignupDetail) // 获取当天已结束的活动的报名信息。添加到到会详情 task.AddTask("addctivitySignupDetail", addctivitySignupDetail) sendWxMsgActivitySpecialTwoDays := task.NewTask("sendWxMsgActivitySpecialTwoDays", "0 0 8 * * *", SendWxMsgActivitySpecialTwoDays) task.AddTask("sendWxMsgActivitySpecialTwoDays", sendWxMsgActivitySpecialTwoDays) //活动开始前两天08:00,提醒报名客户 \提醒报名客户的对口销售 //sendWxMsgActivitySpecialCancel := task.NewTask("sendWxMsgActivitySpecialCancel", "0 0 8 * * *", SendWxMsgActivitySpecialCancel) //task.AddTask("sendWxMsgActivitySpecialCancel", sendWxMsgActivitySpecialCancel) // 线下活动前4天08:00报名人数不足7人,线上活动前3天08:00报名人数不足10人,活动自动取消发布,并推送模板消息至报名客户及对口销售 makeMorningMeetingReviews := task.NewTask("makeMorningMeetingReviews", "0 30 10 * * *", MakeMorningMeetingReviews) task.AddTask("makeMorningMeetingReviews", makeMorningMeetingReviews) //每天10::30定时生成晨会精华汇总 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) //研选系列专家电话会,会前1小时将问题列表发送给邮箱 task.AddTask("sendMfyxEmailFileForAskMsgResearch", sendMfyxEmailFileForAskMsgResearch) sendMfyxActivityBeginMsgMeeting := task.NewTask("sendMfyxActivityBeginMsgMeeting", "0 */5 6-23 * * *", SendMfyxActivityBeginMsgMeeting) //会议前15分钟的提醒 task.AddTask("sendMfyxActivityBeginMsgMeeting", sendMfyxActivityBeginMsgMeeting) sendMfyxActivityBeginMsg := task.NewTask("sendMfyxActivityBeginMsg", "0 */5 6-23 * * *", SendMfyxActivityBeginMsg) //会议前60分钟的提醒 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) //// 权益正式,试用、X类试用客户近四周互动记录 getYanxuanSpecialLikeCountDifferent := task.NewTask("getYanxuanSpecialLikeCountDifferent", "0 0 */1 * * *", GetYanxuanSpecialLikeCountDifferent) task.AddTask("定时任务处理退款回调", getYanxuanSpecialLikeCountDifferent) // 专栏文章获得点赞时,模板消息通知作者(每个整点发送,不同文章分多条发送) //getFiccRreportToCygxArticle := task.NewTask("getFiccRreportToCygxArticle", "0 */10 * * * *", GetFiccRreportToCygxArticle) //task.AddTask("获取FICC研报到查研观向数据库中", getFiccRreportToCygxArticle) //获取FICC研报到查研观向数据库中 } //UpdateRaiServeBillDate() //if utils.RunMode != "release" { // getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章 // task.AddTask("getArticleListByApi", getArticleListByApi) //} //go UserLabelLogReduce() // 处理用户标签的队列消息 //go YanXuanActivityPointsBillReduce() // 处理研选活动扣点 //go UpdateArticleByRedis() // 处理策略平台同步过来的文章 //GetCygxActivityAttendanceDetail() //CreateIndexNameArticleHistory() //AddAllArticleHistory() //DoCompany() //ActivityAttendanceDetail() //SynchronizationArthistory()//同步原有的阅读记录 //GetAddpArticle() //同步日度点评数据 //SendEmailAllUserWithRAI() //发送当前所有权益用户到沈大爷的邮箱 //SendEmailAllUserWithCompany() //发送这些公司下的用户到沈大爷的邮箱 task.StartTask() //StatisticalReport()//导出报表 fmt.Println("end") } ////白名单发送 //sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 27 17 * * *", SendEmailUserWhiteList) //白名单发送 //task.AddTask("sendEmailUserWhiteList", sendEmailUserWhiteList) //editOutboundMobile := task.NewTask("editOutboundMobile", "0 */1 8-22 * * *", EditOutboundMobile) //同步外呼号码与手机号 //task.AddTask("sendEmailFileToExpert", editOutboundMobile) //editUserOutboundMobile := task.NewTask("editUserOutboundMobile", "0 27 14 * * * ", EditUserOutboundMobile) //同步外呼号码与手机号 //task.AddTask("editUserOutboundMobile", editUserOutboundMobile) 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.GetArticleAll() 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 //if v.IsReport == 1 { // item.IsReport = true //} //if v.IsSummary == 1 { // item.IsSummary = true //} EsAddOrEditDataV4(indexName, strconv.Itoa(v.ArticleId), item) fmt.Println(v.ArticleId) } } // "term_vector": "with_positions_offsets" 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 // 100是路演精华对应ID 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() } //func init() { // // var newActivityName string // list, err := models.GetActivityList() // if err != nil { // fmt.Println(err) // } // for _, v := range list { // // fmt.Println("原来的", v.ActivityName) // newActivityName = v.ActivityName // newActivityName = strings.Replace(newActivityName, "【", "", -1) // newActivityName = strings.Replace(newActivityName, "】", "", -1) // newActivityName = strings.Replace(newActivityName, "-", "", -1) // newActivityName = strings.Replace(newActivityName, "—", "", -1) // newActivityName = strings.Replace(newActivityName, " ", "", -1) // newActivityName = strings.Replace(newActivityName, ":", "", -1) // fmt.Println("处理的", newActivityName) // err = models.UpdateCygxActivityName(v.ActivityId, newActivityName) // if err != nil { // fmt.Println(err) // } // } //} //func init() { // fmt.Println("init start") // go UpdateDailyMonthReadBillboardV2() // fmt.Println("init end") //}