xyxie 3 сар өмнө
parent
commit
d1d3b74be1

+ 2 - 2
logic/predict_edb.go

@@ -172,7 +172,7 @@ func AddPredictEdbInfo(sourceEdbInfoId, classifyId int, edbName, dataDateType st
 			return
 		}
 
-		if v.RuleType == 16 && endDateType != 1 {
+		if v.RuleType == 16 && endDateType == 1 {
 			errMsg = "年度值倒推不支持截止期数"
 			err = errors.New(errMsg)
 			return
@@ -577,7 +577,7 @@ func EditPredictEdbInfo(edbInfoId, classifyId int, edbName, dataDateType string,
 			err = errors.New(errMsg)
 			return
 		}
-		if v.RuleType == 16 && endDateType != 1 {
+		if v.RuleType == 16 && endDateType == 1 {
 			errMsg = "年度值倒推不支持截止期数"
 			err = errors.New(errMsg)
 			return

+ 8 - 1
models/predict_edb_info_rule.go

@@ -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)*/
 	//(同比增速=余额/同比年份相应日期的余额的平均值,预测值等于同比年份同期值*同比增速);