|
@@ -1155,3 +1155,47 @@ func RefreshDataFromFubao(wg *sync.WaitGroup) (err error) {
|
|
|
fmt.Println("Fubao刷新结束")
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+func RefreshDataFromGz(wg *sync.WaitGroup) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("RefreshDataFromGz Err:" + err.Error())
|
|
|
+ go alarm_msg.SendAlarmMsg("RefreshDataFromGz ErrMsg:"+err.Error(), 3)
|
|
|
+ }
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND source=? "
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_GFEX)
|
|
|
+ items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range items {
|
|
|
+ startDate := ""
|
|
|
+ if v.Frequency == "日度" {
|
|
|
+ startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
|
|
|
+ } else if v.Frequency == "周度" {
|
|
|
+ startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
|
|
|
+ } else if v.Frequency == "月度" {
|
|
|
+ startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
|
|
|
+ } else if v.Frequency == "季度" {
|
|
|
+ startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
|
|
|
+ } else if v.Frequency == "年度" {
|
|
|
+ startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
|
|
|
+ } else {
|
|
|
+ startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).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())
|
|
|
+ }
|
|
|
+ if resp.Ret != 200 {
|
|
|
+ return errors.New("RefreshEdbData Err:" + resp.Msg + ";ErrMsg:" + resp.ErrMsg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|