Browse Source

指标期数位移-bug修改

gmy 5 months ago
parent
commit
73fe0c20a7
1 changed files with 6 additions and 3 deletions
  1. 6 3
      models/edb_data_calculate_phase_shift.go

+ 6 - 3
models/edb_data_calculate_phase_shift.go

@@ -297,6 +297,7 @@ func refreshAllCalculatePhaseShift(to orm.TxOrmer, edbInfoId, source, subSource,
 
 	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]
@@ -308,10 +309,12 @@ func refreshAllCalculatePhaseShift(to orm.TxOrmer, edbInfoId, source, subSource,
 				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, formulaInt, currentDate, resultMap, moveType)
+				shiftDay := CalculateIntervalDays(moveFrequency, moveNum, currentDate, resultMap, moveType)
 
 				var newDate time.Time
 				if moveFrequency == "年" {
@@ -331,7 +334,7 @@ func refreshAllCalculatePhaseShift(to orm.TxOrmer, edbInfoId, source, subSource,
 				resultMap[newIndex.DataTime] = currentIndex.Value
 			} else {
 				// 新数据须根据频度补充key
-				currentDate, _ := time.ParseInLocation(utils.FormatDate, currentIndex.DataTime, time.Local)
+				currentDate, _ := time.ParseInLocation(utils.FormatDate, dataList[dataLen-1].DataTime, time.Local)
 
 				shiftDay := CalculateIntervalDays(moveFrequency, formulaInt, currentDate, resultMap, moveType)