|
@@ -1656,6 +1656,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)
|
|
|
|
|
@@ -1757,7 +1761,10 @@ func GetChartPredictEdbInfoDataListByRuleAnnualValueInversion(edbInfoId int, con
|
|
|
avg = sum / float64(len(yearList))
|
|
|
//fmt.Printf("同比年份的余额%.4f\n", avg)
|
|
|
// 同比增速=当年余额/同比年份上一期日期的余额
|
|
|
- tbVal := decimal.NewFromFloat(currYearBalance).Div(decimal.NewFromFloat(avg))
|
|
|
+ tbVal := decimal.NewFromFloat(0)
|
|
|
+ if avg != 0 {
|
|
|
+ tbVal = decimal.NewFromFloat(currYearBalance).Div(decimal.NewFromFloat(avg))
|
|
|
+ }
|
|
|
/*tbVal11, _ := tbVal.Round(4).Float64()
|
|
|
fmt.Printf("同比增速%.4f\n", tbVal11)*/
|
|
|
//(同比增速=余额/同比年份相应日期的余额的平均值,预测值等于同比年份同期值*同比增速);
|