123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package logic
- import (
- "errors"
- "eta/eta_index_lib/models"
- "eta/eta_index_lib/utils"
- "strconv"
- "time"
- )
- // RefreshBaseEdbInfo 刷新基础指标
- func RefreshBaseEdbInfo(edbInfo *models.EdbInfo, startDate string) (isHandling bool, errMsg string, err error) {
- cacheKey := utils.CACHE_EDB_DATA_REFRESH + strconv.Itoa(edbInfo.Source) + "_" + edbInfo.EdbCode
- if utils.Rc.IsExist(cacheKey) {
- isHandling = true
- return
- }
- utils.Rc.SetNX(cacheKey, 1, 1*time.Minute)
- defer func() {
- utils.Rc.Delete(cacheKey)
- }()
- switch edbInfo.Source {
- case utils.DATA_SOURCE_SCI:
- err = models.RefreshEdbDataFromSci(edbInfo.EdbInfoId, edbInfo.EdbCode, startDate)
- case utils.DATA_SOURCE_BAIINFO:
- err = models.RefreshEdbDataFromBaiinfo(edbInfo.EdbInfoId, edbInfo.EdbCode, startDate)
- case utils.DATA_SOURCE_MYSTEEL_CHEMICAL:
- err = models.RefreshEdbDataFromMysteelChemical(edbInfo.EdbInfoId, edbInfo.EdbCode, startDate)
- default:
- return
- }
- if err != nil && err.Error() != utils.ErrNoRow() {
- errMsg = "刷新指标信息失败!"
- err = errors.New("刷新指标信息失败 RefreshEdbDataFromSci,Err:" + err.Error())
- return
- }
- // 更新指标最大最小值
- err, errMsg = models.UnifiedModifyEdbInfoMaxAndMinInfo(edbInfo)
- if err != nil {
- return
- }
- // 更新ES
- go UpdateEs(edbInfo.EdbInfoId)
- return
- }
|