sic.go 981 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package logic
  2. import (
  3. "errors"
  4. "hongze/hongze_edb_lib/models"
  5. "hongze/hongze_edb_lib/utils"
  6. "strconv"
  7. "time"
  8. )
  9. // RefreshSci 卓创(红桃3)刷新
  10. func RefreshSci(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. err = models.RefreshEdbDataFromSci(edbInfo.EdbInfoId, edbInfo.EdbCode, startDate)
  21. if err != nil && err.Error() != utils.ErrNoRow() {
  22. errMsg = "刷新指标信息失败!"
  23. err = errors.New("刷新指标信息失败 RefreshEdbDataFromSci,Err:" + err.Error())
  24. return
  25. }
  26. // 更新指标最大最小值
  27. err, errMsg = models.UnifiedModifyEdbInfoMaxAndMinInfo(edbInfo)
  28. if err != nil {
  29. return
  30. }
  31. // 更新ES
  32. go UpdateEs(edbInfo.EdbInfoId)
  33. return
  34. }