|
@@ -1726,6 +1726,10 @@ func GetChartPredictEdbInfoDataListByRuleAnnualValueInversion(edbInfoId int, con
|
|
|
//兼容历史数据
|
|
|
yearList = append(yearList, annualValueInversionConf.Year)
|
|
|
}
|
|
|
+ if len(yearList) == 0 {
|
|
|
+ err = errors.New("同比年份不能为空")
|
|
|
+ return
|
|
|
+ }
|
|
|
// 每年截止到当前日期的累计值
|
|
|
dateTotalMap := make(map[time.Time]float64)
|
|
|
|
|
@@ -1823,11 +1827,17 @@ func GetChartPredictEdbInfoDataListByRuleAnnualValueInversion(edbInfoId int, con
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if sum == 0 {
|
|
|
+ err = errors.New("同比年份的累计值为0")
|
|
|
+ return
|
|
|
+ }
|
|
|
//fmt.Printf("同比年份的余额%.4f\n", sum)
|
|
|
avg = sum / float64(len(yearList))
|
|
|
//fmt.Printf("同比年份的余额%.4f\n", avg)
|
|
|
// 同比增速=当年余额/同比年份上一期日期的余额
|
|
|
+
|
|
|
tbVal := decimal.NewFromFloat(currYearBalance).Div(decimal.NewFromFloat(avg))
|
|
|
+
|
|
|
/*tbVal11, _ := tbVal.Round(4).Float64()
|
|
|
fmt.Printf("同比增速%.4f\n", tbVal11)*/
|
|
|
//(同比增速=余额/同比年份相应日期的余额的平均值,预测值等于同比年份同期值*同比增速);
|