123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- package services
- import (
- "context"
- "fmt"
- "github.com/beego/beego/v2/task"
- "hongze/hongze_task/services/company_contract"
- "hongze/hongze_task/services/data"
- "hongze/hongze_task/utils"
- "sync"
- )
- func Task() {
- fmt.Println("task start")
-
- if utils.RunMode == "release" {
- releaseTask()
- }
-
- handleCompanyContract := task.NewTask("handleCompanyContract", "0 1 0 * * *", company_contract.HandleCompanyContract)
- task.AddTask("每日定时合同处理", handleCompanyContract)
-
- companyTryOut := task.NewTask("companyTryOut", "0 5 0 * * *", CompanyTryOut)
- task.AddTask("正式->试用", companyTryOut)
-
- companyFreeze := task.NewTask("companyFreeze", "0 10 0 * * *", CompanyFreeze)
- task.AddTask("试用->冻结", companyFreeze)
-
- companyLoss := task.NewTask("companyLoss", "0 20 0 * * *", CompanyLoss)
- task.AddTask("冻结->流失", companyLoss)
-
- companyReportPermissionClose := task.NewTask("companyReportPermissionClose", "0 30 0 * * *", CompanyReportPermissionClose)
- task.AddTask("用户产品权限试用-->关闭", companyReportPermissionClose)
-
-
-
-
- stackCompanyStatistic := task.NewTask("stackCompanyStatistic", "0 35 0 * * *", StackCompanyStatistic)
- task.AddTask("存量客户数据统计", stackCompanyStatistic)
-
- sendWaitReport := task.NewTask("sendWaitReport", "0 */1 * * * * ", SendWaitReport)
- task.AddTask("定时往同花顺推送报告", sendWaitReport)
- task.StartTask()
-
-
-
-
-
- fmt.Println("task end")
- }
- func releaseTask() {
-
-
-
-
-
-
-
-
-
-
-
-
-
- getLzSurveyProduct := task.NewTask("getLzSurveyProduct", "0 5 11-19/1 * * * ", GetLzSurveyProduct)
- task.AddTask("getLzSurveyProduct", getLzSurveyProduct)
-
- getLzSurveyProductData := task.NewTask("getLzSurveyProductData", "0 10 11-19/1 * * * ", GetLzSurveyProductData)
- task.AddTask("getLzSurveyProductData", getLzSurveyProductData)
-
- sendEmail := task.NewTask("sendEmail", "0 0 12 * * 0 ", SendEmail)
- task.AddTask("sendEmail", sendEmail)
- oneMinute := task.NewTask("oneMinute", "0 */1 7-23 * * * ", OneMinute)
- task.AddTask("oneMinute", oneMinute)
-
- companyRemind := task.NewTask("companyRemind", "0 30 08 * * *", CompanyRemind)
- task.AddTask("companyRemind", companyRemind)
-
- freeViewerDetail := task.NewTask("freeViewerDetail", "0 0 9 * * 1 ", FreeViewerDetail)
- task.AddTask("潜在客户", freeViewerDetail)
-
- refreshData := task.NewTask("refreshData", "0 1 0,19 * * *", RefreshData)
- task.AddTask("refreshData", refreshData)
-
- syncThsWxGroupEveryDay := task.NewTask("syncThsWxGroupEveryDay", "0 1 4 * * * ", SyncWxGroupEveryDay)
- task.AddTask("定时往同花顺同步微信群的截止日期", syncThsWxGroupEveryDay)
-
-
-
- checkDataInterface := task.NewTask("checkDataInterface", "0 */2 * * * * ", data.CheckDataInterface)
- task.AddTask("checkDataInterface", checkDataInterface)
- checkPbDataInterface := task.NewTask("checkPbDataInterface", "0 */5 * * * * ", data.CheckPbDataInterface)
- task.AddTask("checkPbDataInterface", checkPbDataInterface)
- }
- func TaskTest() {
- fmt.Println("The task is start")
-
- companyReportPermissionClose := task.NewTask("companyReportPermissionClose", "0/30 * * * * *", CompanyReportPermissionClose)
- task.AddTask("用户产品权限试用-->关闭", companyReportPermissionClose)
- task.StartTask()
- fmt.Println("The task is end")
- }
- func SendEmail(cont context.Context) (err error) {
-
- go ReportViewTimes()
-
- go ReportViewDetail()
-
- go HongzeUsers()
- return
- }
- func OneMinute(cont context.Context) (err error) {
-
-
-
- FrequencyByWeek()
-
- FrequencyByMonth()
- return
- }
- func RefreshData(cont context.Context) (err error) {
- wg := sync.WaitGroup{}
- wg.Add(4)
-
- go data.RefreshDataFromWind(&wg)
-
- go data.RefreshDataFromThs(&wg)
-
- go data.RefreshDataFromPb(&wg)
-
- go data.RefreshDataFromManual(&wg)
- wg.Wait()
- go data.RefreshDataFromCalculateAll()
- return
- }
|