123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- package services
- import (
- "context"
- "eta_gn/eta_task/services/data"
- "eta_gn/eta_task/services/data_stat"
- "eta_gn/eta_task/utils"
- "fmt"
- "sync"
- "time"
- "github.com/beego/beego/v2/task"
- )
- func Task() {
- fmt.Println("task start")
- // 如果开启了需要走生产环境的配置,才需要走这些任务
- if utils.RunMode == "release" || utils.IsStartReleaseTask {
- releaseTask()
- }
- //var ctx context.Context
- //_ = ReportWriteRemind(ctx)
- // 定时发布研报(国能没定时发布了)
- //publishReport := task.NewTask("publishReport", "0 */1 * * * *", PublishReport)
- //task.AddTask("定时发布研报", publishReport)
- // 定时汇总数据源终端指标更新情况
- setEdbSourceStatTask := task.NewTask("setEdbSourceStatTask", "0 20 19,23 * * *", data_stat.SetEdbSourceStatTask)
- task.AddTask("数据源统计表", setEdbSourceStatTask)
- GnTask()
- task.StartTask()
- fmt.Println("task end")
- }
- // 生产环境需要走的任务
- func releaseTask() {
- // 定时统计交易所的持仓分析数据
- //initPositionTask := task.NewTask("initPositionTask", "0 20,40 16-19 * * *", data.InitPositionTask)
- //task.AddTask("initPositionTask", initPositionTask)
- //刷新指标数据
- refreshData := task.NewTask("refreshData", "0 0 8,22 * * *", RefreshData)
- task.AddTask("refreshData", refreshData)
- // 根据配置刷新指标数据
- configRefreshData := task.NewTask("syncBaseDataExt", "0 */30 * * * * ", ConfigRefreshDataGn)
- task.AddTask("configRefreshData", configRefreshData)
- syncBaseDataExt := task.NewTask("syncBaseDataExt", "0 */30 * * * * ", SyncBaseDataExt)
- task.AddTask("syncBaseDataExt", syncBaseDataExt)
- //初始化指标更新状态
- resetEdbInfoIsUpdate := task.NewTask("resetEdbInfoIsUpdate", "0 0 0 * * *", data.ResetEdbInfoIsUpdate)
- task.AddTask("resetEdbInfoIsUpdate", resetEdbInfoIsUpdate)
- //删除日志 report_save_log,ppt_v2_save_log,保留一个月的
- deleteLog := task.NewTask("syncSubStatus", "0 0 2 2 * *", DeleteLog)
- task.AddTask("deleteLog", deleteLog)
- // 定时发布英文研报
- publishEnglishReport := task.NewTask("publishEnglishReport", "0 */1 * * * *", PublishEnglishReport)
- task.AddTask("定时发布英文研报", publishEnglishReport)
- // 每天清理两周前的报告保存日志
- clearReportSaveLog := task.NewTask("clearReportSaveLog", "0 15 23 * * *", ClearReportSaveLog)
- task.AddTask("定时清理报告保存日志", clearReportSaveLog)
- // 每天清理三个月前的用户操作日志
- clearAdminOperateLog := task.NewTask("clearAdminOperateLog", "0 20 23 * * *", ClearAdminOperateLog)
- task.AddTask("定时清理用户操作日志", clearAdminOperateLog)
- }
- func RefreshData(cont context.Context) (err error) {
- wg := sync.WaitGroup{}
- //手工数据
- go func() {
- wg.Add(1)
- data.RefreshDataFromManual(&wg)
- }()
- // 持仓分析
- //go func() {
- // wg.Add(1)
- // _ = data.RefreshDataFromTradeAnalysis(&wg)
- //}()
- // 刷新未配置刷新时间点的来源(可能含未知的来源, 统一在这个时间刷新)
- go func() {
- wg.Add(1)
- data.NoneConfigRefreshDataGn(&wg)
- }()
- wg.Wait()
- ////计算指标
- data.RefreshDataFromCalculateAll()
- // 刷新所有的基础预测指标
- data.RefreshBasePredictDataAll()
- // 预测计算指标
- data.RefreshPredictDataFromCalculateAll()
- // 指标系列计算数据
- _ = data.RefreshFactorEdbCalculateData()
- // 指标系列图表计算数据
- _ = data.RefreshFactorEdbChartCalculateData()
- time.Sleep(5 * time.Second)
- //data.RefreshNotice()
- fmt.Println("Refresh End")
- return
- }
- // SyncBaseDataExt 刷新基础数据
- func SyncBaseDataExt(cont context.Context) (err error) {
- now := time.Now()
- if now.Hour() == 0 || now.Hour() == 19 {
- return nil
- }
- //同步手工数据
- go data.SyncManualDataBase()
- //刷新图表中,指标的最新日期
- go data.SetChartEdbEndDate()
- return
- }
|