1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package services
- import (
- "context"
- "eta/eta_task/services/data"
- "eta/eta_task/utils"
- "fmt"
- "github.com/beego/beego/v2/task"
- "sync"
- "time"
- )
- func Task() {
- fmt.Println("task start")
-
- if utils.RunMode == "release" {
- releaseTask()
- }
- task.StartTask()
- fmt.Println("task end")
- }
- func releaseTask() {
-
- syncHzDataIndex := task.NewTask("syncHzDataIndex", "0 30 0,18,21 * * *", SyncHzDataIndex)
- task.AddTask("syncHzDataIndex", syncHzDataIndex)
-
- initPositionTask := task.NewTask("initPositionTask", "0 0 1,19,22 * * *", data.InitPositionTask)
- task.AddTask("initPositionTask", initPositionTask)
-
- refreshData := task.NewTask("refreshData", "0 30 0,19 * * *", RefreshData)
- task.AddTask("refreshData", refreshData)
- syncBaseDataExt := task.NewTask("syncBaseDataExt", "0 */30 * * * * ", SyncBaseDataExt)
- task.AddTask("syncBaseDataExt", syncBaseDataExt)
-
- resetEdbInfoIsUpdate := task.NewTask("resetEdbInfoIsUpdate", "0 0 0 * * *", data.ResetEdbInfoIsUpdate)
- task.AddTask("resetEdbInfoIsUpdate", resetEdbInfoIsUpdate)
- }
- func RefreshData(cont context.Context) (err error) {
- fmt.Println("Refresh Start")
- wg := sync.WaitGroup{}
- wg.Add(7)
-
- go data.RefreshDataFromThs(&wg)
-
- go data.RefreshDataFromWind(&wg)
-
- go data.RefreshDataFromPb(&wg)
-
- go data.RefreshDataFromPbFinance(&wg)
-
- go data.RefreshDataFromManual(&wg)
-
- go data.RefreshDataFromGoogleTravel(&wg)
-
- go data.RefreshDataFromEiaSteo(&wg)
- wg.Wait()
-
- data.RefreshDataFromCalculateAll()
-
- data.RefreshPredictDataFromCalculateAll()
-
-
-
-
-
-
- fmt.Println("Refresh End")
- return
- }
- 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
- }
|