123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package data
- import (
- "eta_gn/eta_task/models/data_manage"
- "eta_gn/eta_task/utils"
- "strings"
- "sync"
- )
- var manualLock sync.Mutex
- // SyncManualDataBase 同步手工数据
- func SyncManualDataBase() {
- var err error
- errMsgList := make([]string, 0)
- manualLock.Lock()
- defer func() {
- manualLock.Unlock()
- if len(errMsgList) > 0 {
- errMsg := strings.Join(errMsgList, "\n")
- utils.FileLog.Info("SyncManualDataBase Err:" + errMsg)
- go utils.SendEmailByHongze("同步手工数据失败", "同步手工数据失败 Err:"+errMsg, utils.RefreshEdbInfoEmailSendToUsers, "", "")
- }
- }()
- var condition string
- var pars []interface{}
- condition += " AND source=? "
- //condition += " AND edb_code='W000156' "
- pars = append(pars, utils.DATA_SOURCE_MANUAL)
- items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
- if err != nil {
- errMsgList = append(errMsgList, "获取指标失败 ;Err:"+err.Error())
- return
- }
- for _, v := range items {
- startDate := v.StartDate.Format(utils.FormatDate)
- resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
- if err != nil {
- //return errors.New("RefreshEdbData Err:" + err.Error())
- errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
- continue
- }
- if resp.Ret != 200 {
- //return errors.New("RefreshEdbData Err:" + resp.Msg + ";ErrMsg:" + resp.ErrMsg)
- errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
- continue
- }
- }
- }
|