123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package init_serve
- import (
- "github.com/robfig/cron/v3"
- "hongze/hongtao3_watch/global"
- "hongze/hongtao3_watch/services"
- "hongze/hongtao3_watch/watch"
- )
- func InitTask() {
- //services.RefreshExcel()
- c := cron.New(cron.WithSeconds())
- // 定时统一更新(日度、周度指标)
- if global.CONFIG.Serve.RefreshTime == "" {
- //panic("未配置数据统一刷新时间")
- // 未配置时间的话,那么默认每天17点更新一次
- global.CONFIG.Serve.RefreshTime = "0 0 17 * * *"
- }
- //fmt.Println(global.CONFIG.Serve.RefreshTime)
- // 每天下午5点开始刷新excel表格
- _, err := c.AddFunc(global.CONFIG.Serve.RefreshTime, services.RefreshExcel)
- //_, err := c.AddFunc("0 55 13 * * *", services.RefreshExcel)
- if err != nil {
- global.LOG.Info("RefreshExcel err" + err.Error())
- }
- //每2分钟检测一次指标文件是否更新
- _, err = c.AddFunc("0 */1 * * * *", watch.ReadWatchIndexFile)
- //_, err = c.AddFunc("*/30 * * * * *", watch.ReadWatchIndexFile)
- if err != nil {
- global.LOG.Info("watch.ReadWatchIndexFile err" + err.Error())
- }
- c.Start()
- // 监听文件
- //go watch.ListenFolderNew()
- // 处理excel
- go services.HandleFileUpdate()
- // 处理调用刷新excel的服务(调用python)
- go services.HandleRefreshExcel()
- ////redis 队列刷新指标
- //go services.AutoRefresh()
- //CheckIndexCreate()
- //services.Merge()
- //yearFile="year.xlsx"
- //filePath := utils.IndexMsergeSaveDir + "season.xlsx"
- //services.DataAnalysis(filePath)
- //services.Merge()
- }
- //检测指标数据是否生成
- //func CheckIndexCreate() {
- // var err error
- // defer func() {
- // if err != nil && err.Error() != "record not found" {
- // global.LOG.Info(utils.APPNAME + " 定时任务 出错" + time.Now().Format("2006-01-02 15:04:05") + ";Err:" + err.Error())
- // go alarm_msg.SendAlarmMsg(utils.APPNAME+" 定时任务 出错"+time.Now().Format("2006-01-02 15:04:05")+";Err:"+err.Error(), 3)
- // }
- // }()
- // err = services.IndexCreateCheck()
- //}
|