|
@@ -25,9 +25,11 @@ func RefreshDataFromThs(wg *sync.WaitGroup) (err error) {
|
|
|
var pars []interface{}
|
|
|
condition += " AND source=? "
|
|
|
pars = append(pars, utils.DATA_SOURCE_THS)
|
|
|
+
|
|
|
items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
if err != nil {
|
|
|
- return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ err = errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
var endDate string
|
|
@@ -49,27 +51,21 @@ func RefreshDataFromThs(wg *sync.WaitGroup) (err error) {
|
|
|
}
|
|
|
err = SyncEdbDataByThs(int64(v.EdbInfoId), v.EdbCode, startDate, endDate)
|
|
|
if err != nil {
|
|
|
- return errors.New("SyncEdbDataByThs:" + err.Error())
|
|
|
+ err = errors.New("SyncEdbDataByThs Err:" + err.Error())
|
|
|
+ return err
|
|
|
}
|
|
|
item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode)
|
|
|
if err != nil {
|
|
|
+ err = errors.New("GetEdbInfoMaxAndMinInfo Err:" + err.Error())
|
|
|
return err
|
|
|
}
|
|
|
if item != nil {
|
|
|
err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item)
|
|
|
if err != nil {
|
|
|
+ err = errors.New("ModifyEdbInfoMaxAndMinInfo Err:" + err.Error())
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
- //minDate, maxDate, err := data.GetEdbDataThsMaxOrMinDate(v.EdbInfoId)
|
|
|
- //if err != nil {
|
|
|
- // return errors.New("GetEdbDataThsMaxOrMinDate:" + err.Error())
|
|
|
- //}
|
|
|
- //fmt.Println("minDate:" + minDate + ";maxDate:" + maxDate)
|
|
|
- //err = data.ModifyEdbDataInfoDate(v.EdbInfoId, maxDate)
|
|
|
- //if err != nil {
|
|
|
- // return errors.New("ModifyEdbDataInfoDate:" + err.Error())
|
|
|
- //}
|
|
|
}
|
|
|
return err
|
|
|
}
|
|
@@ -245,8 +241,7 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
condition += " AND edb_type=? "
|
|
|
pars = append(pars, 2)
|
|
|
|
|
|
- //condition += " AND source=? "
|
|
|
- //pars = append(pars, utils.DATA_SOURCE_CALCULATE_BP)
|
|
|
+ condition += " AND is_update=1 "
|
|
|
|
|
|
items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
if err != nil {
|
|
@@ -256,7 +251,7 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
edbInfoId := v.EdbInfoId
|
|
|
edbCode := v.EdbCode
|
|
|
source := v.Source
|
|
|
- fmt.Println(v.EdbInfoId, v.EdbCode, v.EdbName, v.SourceName)
|
|
|
+ fmt.Println(v.EdbInfoId, v.EdbCode, v.EdbName, v.SourceName, source)
|
|
|
if source == utils.DATA_SOURCE_CALCULATE {
|
|
|
startDate := ""
|
|
|
if v.Frequency == "日度" {
|
|
@@ -302,7 +297,7 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
}
|
|
|
year := time.Now().Year() - 1
|
|
|
startDate := strconv.Itoa(year) + "-01" + "-01"
|
|
|
- endDate := ""//time.Now().Format(utils.FormatDate)
|
|
|
+ endDate := "" //time.Now().Format(utils.FormatDate)
|
|
|
err = data_manage.RefreshCalculateLjzzy(edbInfoId, fromEdbInfo, edbCode, startDate, endDate)
|
|
|
if err != nil {
|
|
|
return errors.New("RefreshCalculateLjzzy Err:" + err.Error())
|
|
@@ -317,7 +312,7 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
return errors.New("GetEdbInfoById Err:" + err.Error())
|
|
|
}
|
|
|
startDate := time.Now().AddDate(-2, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate := ""//time.Now().Format(utils.FormatDate)
|
|
|
+ endDate := "" //time.Now().Format(utils.FormatDate)
|
|
|
err = data_manage.RefreshCalculateTbz(edbInfoId, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
if err != nil {
|
|
|
return errors.New("RefreshCalculateTbz Err:" + err.Error())
|
|
@@ -332,7 +327,7 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
return errors.New("GetEdbInfoById Err:" + err.Error())
|
|
|
}
|
|
|
startDate := time.Now().AddDate(-2, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate := ""//time.Now().Format(utils.FormatDate)
|
|
|
+ endDate := "" //time.Now().Format(utils.FormatDate)
|
|
|
err = data_manage.RefreshCalculateTcz(edbInfoId, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
if err != nil {
|
|
|
return errors.New("RefreshCalculateTcz Err:" + err.Error())
|
|
@@ -360,9 +355,10 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
if err != nil {
|
|
|
return errors.New("GetEdbInfoById Err:" + err.Error())
|
|
|
}
|
|
|
- startDate := time.Now().AddDate(-2, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate := ""//time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateHbz(edbInfoId, source, fromEdbInfo, calculateHbz.EdbCode, startDate, endDate)
|
|
|
+ //startDate := time.Now().AddDate(-2, -2, 0).Format(utils.FormatDate)
|
|
|
+ //endDate := "" //time.Now().Format(utils.FormatDate)
|
|
|
+ formulaInt, _ := strconv.Atoi(v.CalculateFormula)
|
|
|
+ err = data_manage.RefreshCalculateHbz(edbInfoId, source, fromEdbInfo, calculateHbz.EdbCode, formulaInt)
|
|
|
if err != nil {
|
|
|
return errors.New("RefreshCalculateTbz Err:" + err.Error())
|
|
|
}
|
|
@@ -376,7 +372,7 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
return errors.New("GetEdbInfoById Err:" + err.Error())
|
|
|
}
|
|
|
startDate := time.Now().AddDate(-2, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate := ""//time.Now().Format(utils.FormatDate)
|
|
|
+ endDate := "" //time.Now().Format(utils.FormatDate)
|
|
|
err = data_manage.RefreshCalculateHcz(edbInfoId, source, fromEdbInfo, calculateHcz.EdbCode, startDate, endDate)
|
|
|
if err != nil {
|
|
|
return errors.New("RefreshCalculateTbz Err:" + err.Error())
|
|
@@ -392,12 +388,39 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
return errors.New("GetEdbInfoById Err:" + err.Error())
|
|
|
}
|
|
|
startDate := time.Now().AddDate(-2, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate := ""//time.Now().Format(utils.FormatDate)
|
|
|
+ endDate := "" //time.Now().Format(utils.FormatDate)
|
|
|
err = data_manage.RefreshCalculateBp(edbInfoId, fromEdbInfo, calculateBp.EdbCode, startDate, endDate)
|
|
|
if err != nil {
|
|
|
return errors.New("RefreshCalculateTbz Err:" + err.Error())
|
|
|
}
|
|
|
}
|
|
|
+ } else if source == utils.DATA_SOURCE_CALCULATE_TIME_SHIFT {
|
|
|
+ calculate, err := data_manage.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("GetEdbInfoCalculateTbzDetail Err:" + err.Error())
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := data_manage.GetEdbInfoById(calculate.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("GetEdbInfoById Err:" + err.Error())
|
|
|
+ }
|
|
|
+ startDate := v.StartDate.Format(utils.FormatDate)
|
|
|
+ endDate := time.Now().Format(utils.FormatDate)
|
|
|
+ formulaInt, _ := strconv.Atoi(calculate.CalculateFormula)
|
|
|
+ err = data_manage.RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, calculate.MoveType, fromEdbInfo, calculate.EdbCode, startDate, endDate, calculate.MoveFrequency)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("RefreshAllCalculateTimeShift Err:" + err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if source == utils.DATA_SOURCE_CALCULATE_ZJPJ { //刷新直接拼接
|
|
|
+ err = data_manage.RefreshAllCalculateZjpj(v)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("RefreshAllCalculateZjpj Err:" + err.Error())
|
|
|
+ }
|
|
|
+ } else if source == utils.DATA_SOURCE_CALCULATE_LJZTBPJ { //刷新累计值同比拼接
|
|
|
+ err = data_manage.RefreshAllCalculateLjztbpj(v)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("RefreshAllCalculateLjztbpj Err:" + err.Error())
|
|
|
+ }
|
|
|
} else {
|
|
|
msg := "刷新失败,无效的指标渠道:source:" + strconv.Itoa(source) + " EdbCode:" + v.EdbCode
|
|
|
err = errors.New(msg)
|
|
@@ -406,6 +429,8 @@ func RefreshDataFromCalculateAll() (err error) {
|
|
|
|
|
|
maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
if err != nil {
|
|
|
+ fmt.Println("GetEdbInfoMaxAndMinInfo Err:" + err.Error() + ";source:" + strconv.Itoa(source) + ";edbCode:" + edbCode)
|
|
|
+ err = errors.New("GetEdbInfoMaxAndMinInfo Err:" + err.Error() + ";source:" + strconv.Itoa(source) + ";edbCode:" + edbCode)
|
|
|
return err
|
|
|
}
|
|
|
if maxAndMinItem != nil {
|
|
@@ -431,6 +456,7 @@ func RefreshDataFromManual(wg *sync.WaitGroup) (err error) {
|
|
|
var pars []interface{}
|
|
|
condition += " AND source=? "
|
|
|
pars = append(pars, utils.DATA_SOURCE_MANUAL)
|
|
|
+
|
|
|
items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
if err != nil {
|
|
|
return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
@@ -484,6 +510,7 @@ func RefreshDataFromLz(wg *sync.WaitGroup) (err error) {
|
|
|
var pars []interface{}
|
|
|
condition += " AND source=? "
|
|
|
pars = append(pars, utils.DATA_SOURCE_LZ)
|
|
|
+
|
|
|
items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
if err != nil {
|
|
|
return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
@@ -538,6 +565,7 @@ func RefreshDataFromYs(wg *sync.WaitGroup) (err error) {
|
|
|
var pars []interface{}
|
|
|
condition += " AND source=? "
|
|
|
pars = append(pars, utils.DATA_SOURCE_YS)
|
|
|
+
|
|
|
items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
if err != nil {
|
|
|
return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
@@ -633,6 +661,276 @@ func RefreshDataFromGl(wg *sync.WaitGroup) (err error) {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
+// RefreshDataFromSh 刷新上期所数据
|
|
|
+func RefreshDataFromSh(wg *sync.WaitGroup) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("RefreshDataFromSh Err:" + err.Error())
|
|
|
+ go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromSh ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ }
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND source=? "
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_SH)
|
|
|
+ items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ var endDate string
|
|
|
+ endDate = time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ fmt.Println(startDate, endDate)
|
|
|
+ err = data_manage.RefreshEdbDataBySh(v.EdbInfoId, v.EdbCode, startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("RefreshEdbDataBySh:" + err.Error())
|
|
|
+ }
|
|
|
+ item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if item != nil {
|
|
|
+ err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// RefreshDataFromDl 刷新大商所数据
|
|
|
+func RefreshDataFromDl(wg *sync.WaitGroup) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("RefreshDataFromDl Err:" + err.Error())
|
|
|
+ go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromDl ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ }
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND source=? "
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_DL)
|
|
|
+ items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ var endDate string
|
|
|
+ endDate = time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ fmt.Println(startDate, endDate)
|
|
|
+ err = data_manage.RefreshEdbDataByDl(v.EdbInfoId, v.EdbCode, startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("RefreshEdbDataByDl:" + err.Error())
|
|
|
+ }
|
|
|
+ item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if item != nil {
|
|
|
+ err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// RefreshDataFromShfe 刷新上期能源数据
|
|
|
+func RefreshDataFromShfe(wg *sync.WaitGroup) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("RefreshDataFromShfe Err:" + err.Error())
|
|
|
+ go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromShfe ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ }
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND source=? "
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_SHFE)
|
|
|
+ items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ var endDate string
|
|
|
+ endDate = time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ fmt.Println(startDate, endDate)
|
|
|
+ err = data_manage.RefreshEdbDataByShfe(v.EdbInfoId, v.EdbCode, startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("RefreshEdbDataByShfe:" + err.Error())
|
|
|
+ }
|
|
|
+ item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if item != nil {
|
|
|
+ err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// RefreshDataFromCffex 刷新中金所数据
|
|
|
+func RefreshDataFromCffex(wg *sync.WaitGroup) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("RefreshDataFromCffex Err:" + err.Error())
|
|
|
+ go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromCffex ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ }
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND source=? "
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_CFFEX)
|
|
|
+ items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ var endDate string
|
|
|
+ endDate = time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ fmt.Println(startDate, endDate)
|
|
|
+ err = data_manage.RefreshEdbDataByCffex(v.EdbInfoId, v.EdbCode, startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("RefreshEdbDataByCffex:" + err.Error())
|
|
|
+ }
|
|
|
+ item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if item != nil {
|
|
|
+ err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// RefreshDataFromZz 刷新郑商所数据
|
|
|
+func RefreshDataFromZz(wg *sync.WaitGroup) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("RefreshDataFromZz Err:" + err.Error())
|
|
|
+ go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromZz ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ }
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND source=? "
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_ZZ)
|
|
|
+ items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("GetEdbInfoByCondition:" + err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ var endDate string
|
|
|
+ endDate = time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ fmt.Println(startDate, endDate)
|
|
|
+ err = data_manage.RefreshEdbDataByZz(v.EdbInfoId, v.EdbCode, startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New("RefreshEdbDataByZz:" + err.Error())
|
|
|
+ }
|
|
|
+ item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if item != nil {
|
|
|
+ err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
func ResetEdbInfoIsUpdate(cont context.Context) (err error) {
|
|
|
go data_manage.ResetEdbInfoIsUpdate()
|
|
|
return nil
|