|
@@ -218,8 +218,6 @@ func refreshAllPredictCalculatePhaseShift(to orm.TxOrmer, edbInfoId, source, sub
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- latestDate, _ := time.ParseInLocation(utils.FormatDate, fromEdbInfo.LatestDate, time.Local)
|
|
|
-
|
|
|
var dateArr []string
|
|
|
dataMap := make(map[string]*EdbInfoSearchData)
|
|
|
for _, v := range dataList {
|
|
@@ -232,6 +230,7 @@ func refreshAllPredictCalculatePhaseShift(to orm.TxOrmer, edbInfoId, source, sub
|
|
|
|
|
|
resultMap := make(map[string]float64)
|
|
|
dataLen := len(dataList)
|
|
|
+ var moveNum int
|
|
|
for i := 0; i < dataLen; i++ {
|
|
|
// step_1 如果 领先/滞后 之后时间key存在,将该key为目标key,填充
|
|
|
currentIndex := dataList[i]
|
|
@@ -243,13 +242,20 @@ func refreshAllPredictCalculatePhaseShift(to orm.TxOrmer, edbInfoId, source, sub
|
|
|
newIndex := dataList[dataLen-periods-1]
|
|
|
resultMap[newIndex.DataTime] = currentIndex.Value
|
|
|
} else {
|
|
|
+ moveNum = formulaInt - i
|
|
|
+
|
|
|
// 新数据须根据频度补充key
|
|
|
- currentDate, _ := time.ParseInLocation(utils.FormatDate, currentIndex.DataTime, time.Local)
|
|
|
+ currentDate, _ := time.ParseInLocation(utils.FormatDate, dataList[0].DataTime, time.Local)
|
|
|
+
|
|
|
+ shiftDay := CalculateIntervalDays(moveFrequency, moveNum, currentDate, resultMap, moveType)
|
|
|
|
|
|
- shiftDay := CalculateIntervalDays(moveFrequency, formulaInt, currentDate, resultMap, moveType)
|
|
|
+ var newDate time.Time
|
|
|
+ if moveFrequency == "年" {
|
|
|
+ newDate = currentDate.AddDate(moveNum, 0, 0)
|
|
|
+ } else {
|
|
|
+ newDate = currentDate.AddDate(0, 0, shiftDay)
|
|
|
+ }
|
|
|
|
|
|
- latestDateStr = latestDate.AddDate(0, 0, shiftDay).Format(utils.FormatDate)
|
|
|
- newDate := currentDate.AddDate(0, 0, shiftDay)
|
|
|
format := newDate.Format(utils.FormatDate)
|
|
|
resultMap[format] = currentIndex.Value
|
|
|
}
|
|
@@ -260,13 +266,19 @@ func refreshAllPredictCalculatePhaseShift(to orm.TxOrmer, edbInfoId, source, sub
|
|
|
newIndex := dataList[dataLen-periods]
|
|
|
resultMap[newIndex.DataTime] = currentIndex.Value
|
|
|
} else {
|
|
|
+ moveNum = formulaInt + 1 - (dataLen - i)
|
|
|
// 新数据须根据频度补充key
|
|
|
- currentDate, _ := time.ParseInLocation(utils.FormatDate, currentIndex.DataTime, time.Local)
|
|
|
+ currentDate, _ := time.ParseInLocation(utils.FormatDate, dataList[dataLen-1].DataTime, time.Local)
|
|
|
+
|
|
|
+ shiftDay := CalculateIntervalDays(moveFrequency, moveNum, currentDate, resultMap, moveType)
|
|
|
|
|
|
- shiftDay := CalculateIntervalDays(moveFrequency, formulaInt, currentDate, resultMap, moveType)
|
|
|
+ var newDate time.Time
|
|
|
+ if moveFrequency == "年" {
|
|
|
+ newDate = currentDate.AddDate(-moveNum, 0, 0)
|
|
|
+ } else {
|
|
|
+ newDate = currentDate.AddDate(0, 0, -shiftDay)
|
|
|
+ }
|
|
|
|
|
|
- latestDateStr = latestDate.AddDate(0, 0, -shiftDay).Format(utils.FormatDate)
|
|
|
- newDate := currentDate.AddDate(0, 0, -shiftDay)
|
|
|
format := newDate.Format(utils.FormatDate)
|
|
|
resultMap[format] = currentIndex.Value
|
|
|
}
|