123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package data_manage
- import (
- "fmt"
- "hongze/hongze_task/models/data_manage"
- "hongze/hongze_task/utils"
- "time"
- )
- //刷新同花顺数据
- func RefreshDataFromThs() (err error) {
- defer func() {
- if err != nil {
- fmt.Println("RefreshDataFromThs Err:" + err.Error())
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromThs ErrMsg:"+err.Error(), utils.EmailSendToUsers)
- }
- }()
- var condition string
- var pars []interface{}
- condition += " AND source=? "
- pars = append(pars, utils.DATA_SOURCE_THS)
- items, err := data_manage.GetEdbInfoByCondition(condition, pars)
- if err != nil {
- return err
- }
- for _, v := range items {
- startDate := v.EndDate.AddDate(0, 0, -3).Format(utils.FormatDate)
- endDate := time.Now().Format(utils.FormatDate)
- err = SyncEdbDataByThs(int64(v.EdbInfoId), v.EdbCode, startDate, endDate)
- if err != nil {
- return err
- }
- minDate, maxDate, err := data_manage.GetEdbDataThsMaxOrMinDate(v.EdbInfoId)
- if err != nil {
- return err
- }
- fmt.Println("minDate:" + minDate + ";maxDate:" + maxDate)
- err = data_manage.ModifyEdbDataInfoDate(v.EdbInfoId, maxDate)
- if err != nil {
- return err
- }
- }
- return err
- }
- //刷新万得数据
- func RefreshDataFromWind() (err error) {
- defer func() {
- if err != nil {
- fmt.Println("RefreshDataFromWind Err:" + err.Error())
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromWind ErrMsg:"+err.Error(), utils.EmailSendToUsers)
- }
- }()
- var condition string
- var pars []interface{}
- condition += " AND source=? "
- pars = append(pars, utils.DATA_SOURCE_WIND)
- items, err := data_manage.GetEdbInfoByCondition(condition, pars)
- if err != nil {
- return err
- }
- for _, v := range items {
- startDate := v.EndDate.AddDate(0, 0, -3).Format(utils.FormatDate)
- endDate := time.Now().Format(utils.FormatDate)
- err = SyncEdbDataByWind(int64(v.EdbInfoId), v.EdbCode, startDate, endDate)
- if err != nil {
- return err
- }
- minDate, maxDate, err := data_manage.GetEdbDataWindMaxOrMinDate(v.EdbInfoId)
- if err != nil {
- return err
- }
- fmt.Println("minDate:" + minDate + ";maxDate:" + maxDate)
- err = data_manage.ModifyEdbDataInfoDate(v.EdbInfoId, maxDate)
- if err != nil {
- return err
- }
- }
- return err
- }
|