base_from_ths_hf.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package data
  2. import (
  3. "context"
  4. "eta/eta_task/models/data_manage"
  5. "eta/eta_task/services/alarm_msg"
  6. "eta/eta_task/utils"
  7. "fmt"
  8. )
  9. // RefreshBaseFromThsHfIndex 同花顺高频数据
  10. func RefreshBaseFromThsHfIndex(cont context.Context) (err error) {
  11. defer func() {
  12. if err != nil {
  13. tips := fmt.Sprintf("RefreshBaseFromThsHfIndex-刷新同花顺高频数据失败, %v", err)
  14. utils.FileLog.Info(tips)
  15. go alarm_msg.SendAlarmMsg(tips, 3)
  16. }
  17. }()
  18. indexOb := new(data_manage.BaseFromThsHfIndex)
  19. indexes, e := indexOb.GetItemsByCondition(``, make([]interface{}, 0), []string{indexOb.Cols().PrimaryId, indexOb.Cols().IndexCode}, "")
  20. if e != nil {
  21. err = fmt.Errorf("获取源指标列表失败, %v", e)
  22. return
  23. }
  24. if len(indexes) == 0 {
  25. return
  26. }
  27. refreshUrl := "ths/hf/base/refresh"
  28. for _, v := range indexes {
  29. param := make(map[string]interface{})
  30. param["BaseIndexCode"] = v.IndexCode
  31. param["RefreshType"] = 1 // 默认刷6小时前的
  32. res, e := postRefreshEdbData(param, refreshUrl)
  33. if e != nil {
  34. utils.FileLog.Info(fmt.Sprintf("RefreshBaseFromThsHfIndex-postRefreshEdbData, code: %s, err: %v", v.IndexCode, e))
  35. continue
  36. }
  37. if res != nil && res.Ret != 200 {
  38. utils.FileLog.Info(fmt.Sprintf("RefreshBaseFromThsHfIndex-postRefreshEdbData, code: %s, Ret: %d, ErrMsg: %s", v.IndexCode, res.Ret, res.ErrMsg))
  39. continue
  40. }
  41. }
  42. return
  43. }