浏览代码

修改京博的红桃3刷新时间

xyxie 1 年之前
父节点
当前提交
15ea07f49d
共有 2 个文件被更改,包括 12 次插入1 次删除
  1. 1 0
      config/config.go
  2. 11 1
      init_serve/task.go

+ 1 - 0
config/config.go

@@ -23,6 +23,7 @@ type Serve struct {
 	AppEdbLibNameEn string `mapstructure:"app_edb_lib_name_en" json:"app_edb_lib_name_en" yaml:"app_edb_lib_name_en" description:"指标库的英文名称"`
 	EdbLibMd5Key    string `mapstructure:"edb_lib_md5_key" json:"edb_lib_md5_key" yaml:"edb_lib_md5_key" description:"指标库服务秘钥"`
 	TerminalCode    string `mapstructure:"terminal_code" json:"terminal_code" yaml:"terminal_code" description:"终端编码"`
+	RefreshTime     string `mapstructure:"refresh_time" json:"refresh_time" yaml:"refresh_time" description:"刷新服务任务更新时间"`
 }
 
 // Log 日志配置

+ 11 - 1
init_serve/task.go

@@ -11,8 +11,15 @@ 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("0 0 17 * * *", services.RefreshExcel)
+	_, 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())
@@ -21,6 +28,9 @@ func InitTask() {
 	//每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()