|
@@ -884,6 +884,8 @@ func GetChartPredictEdbInfoDataListByRuleMoveAverageTb(edbInfoId int, nValue, ye
|
|
|
}
|
|
|
|
|
|
decimalN := decimal.NewFromInt(int64(nValue))
|
|
|
+
|
|
|
+ subYear := year - dayList[0].Year()
|
|
|
|
|
|
|
|
|
for k, currentDate := range dayList {
|
|
@@ -895,7 +897,7 @@ func GetChartPredictEdbInfoDataListByRuleMoveAverageTb(edbInfoId int, nValue, ye
|
|
|
|
|
|
tmpDecimalVal := decimal.NewFromFloat(allDataList[tmpIndex].Value)
|
|
|
averageDateList = append(averageDateList, allDataList[tmpIndex].DataTime)
|
|
|
- for tmpK := 2; tmpK <= nValue; tmpK++ {
|
|
|
+ for tmpK := 1; tmpK < nValue; tmpK++ {
|
|
|
tmpIndex2 := tmpIndex - tmpK
|
|
|
tmpDecimalVal2 := decimal.NewFromFloat(allDataList[tmpIndex2].Value)
|
|
|
tmpDecimalVal = tmpDecimalVal.Add(tmpDecimalVal2)
|
|
@@ -913,7 +915,7 @@ func GetChartPredictEdbInfoDataListByRuleMoveAverageTb(edbInfoId int, nValue, ye
|
|
|
tmpHistoryValNum := 0
|
|
|
{
|
|
|
|
|
|
- tmpHistoryCurrentDate := currentDate.AddDate(year-currentDate.Year(), 0, 0)
|
|
|
+ tmpHistoryCurrentDate := currentDate.AddDate(subYear, 0, 0)
|
|
|
for i := 0; i <= 35; i++ {
|
|
|
tmpDate := tmpHistoryCurrentDate.AddDate(0, 0, i)
|
|
|
if val, ok := existMap[tmpDate.Format(utils.FormatDate)]; ok {
|
|
@@ -938,7 +940,7 @@ func GetChartPredictEdbInfoDataListByRuleMoveAverageTb(edbInfoId int, nValue, ye
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- tmpHistoryLastDate := lastDay.AddDate(year-lastDay.Year(), 0, 0)
|
|
|
+ tmpHistoryLastDate := lastDay.AddDate(subYear, 0, 0)
|
|
|
for i := 0; i <= 35; i++ {
|
|
|
tmpDate := tmpHistoryLastDate.AddDate(0, 0, i)
|
|
|
if val, ok := existMap[tmpDate.Format(utils.FormatDate)]; ok {
|
|
@@ -969,8 +971,10 @@ func GetChartPredictEdbInfoDataListByRuleMoveAverageTb(edbInfoId int, nValue, ye
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ tmpHistoryAverageVal := tmpHistoryDecimalVal.Div(decimalN)
|
|
|
|
|
|
- tbVal := tmpAverageVal.Div(tmpHistoryDecimalVal)
|
|
|
+ tbVal := tmpAverageVal.Div(tmpHistoryAverageVal)
|
|
|
|
|
|
|
|
|
val, _ := decimal.NewFromFloat(tmpHistoryCurrentVal).Mul(tbVal).RoundCeil(4).Float64()
|