base_edb_info.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package logic
  2. import (
  3. "errors"
  4. "eta_gn/eta_index_lib/models"
  5. "eta_gn/eta_index_lib/utils"
  6. "strconv"
  7. "time"
  8. )
  9. // RefreshBaseEdbInfo 刷新基础指标
  10. func RefreshBaseEdbInfo(edbInfo *models.EdbInfo, startDate string) (isHandling bool, errMsg string, err error) {
  11. cacheKey := utils.CACHE_EDB_DATA_REFRESH + strconv.Itoa(edbInfo.Source) + "_" + edbInfo.EdbCode
  12. if utils.Rc.IsExist(cacheKey) {
  13. isHandling = true
  14. return
  15. }
  16. utils.Rc.SetNX(cacheKey, 1, 1*time.Minute)
  17. defer func() {
  18. utils.Rc.Delete(cacheKey)
  19. }()
  20. switch edbInfo.Source {
  21. default:
  22. return
  23. }
  24. if err != nil && err.Error() != utils.ErrNoRow() {
  25. errMsg = "刷新指标信息失败!"
  26. err = errors.New("刷新指标信息失败 RefreshEdbDataFromSci,Err:" + err.Error())
  27. return
  28. }
  29. // 更新指标最大最小值
  30. if edbInfo.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  31. dataUpdateTime := time.Now().Format(utils.FormatDateTime)
  32. _, err, errMsg = models.UnifiedModifyEdbInfoMaxAndMinInfoDataUpdate(edbInfo, dataUpdateTime)
  33. if err != nil {
  34. return
  35. }
  36. } else {
  37. err, errMsg = models.UnifiedModifyEdbInfoMaxAndMinInfo(edbInfo)
  38. if err != nil {
  39. return
  40. }
  41. }
  42. // 更新ES
  43. go UpdateEs(edbInfo.EdbInfoId)
  44. return
  45. }