Browse Source

fix:修复空指针的问题

Roc 1 week ago
parent
commit
16b84063d2
2 changed files with 13 additions and 1 deletions
  1. 1 1
      controllers/data_manage/chart_info.go
  2. 12 0
      services/data/chart_info.go

+ 1 - 1
controllers/data_manage/chart_info.go

@@ -1435,7 +1435,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 					value, err := data.MarkerLineCalculate(markerLines[i], edbList[0].DataList, chartInfo)
 					if err != nil {
 						br.Msg = "标识线配置异常"
-						br.ErrMsg = "标识线配置异常" + err.Error()
+						br.ErrMsg = "标识线配置异常," + err.Error()
 						return
 					}
 					markerLines[i].Value = value

+ 12 - 0
services/data/chart_info.go

@@ -4329,6 +4329,10 @@ func SeasonChartData(dataList []*data_manage.ChartEdbInfoMapping, seasonExtraCon
 
 			for _, v := range dataTimeMap {
 				valueList := dataTimeValueMap[v]
+				if len(valueList) <= 0 {
+					err = errors.New(`数据为空`)
+					return
+				}
 				stdev := utils.CalculateStandardDeviation(valueList)
 				stdev, _ = decimal.NewFromFloat(stdev).Round(4).Float64()
 
@@ -4556,6 +4560,10 @@ func MarkerLineCalculate(markerLine data_manage.MarkersLine, dataList interface{
 					}
 				}
 				averge = averge / float64(length)
+				if len(faloatList) <= 0 {
+					err = errors.New(`数据为空`)
+					return
+				}
 				stdev := utils.CalculateStandardDeviation(faloatList)
 				stdev, _ = decimal.NewFromFloat(stdev).Round(4).Float64()
 
@@ -4607,6 +4615,10 @@ func MarkerLineCalculate(markerLine data_manage.MarkersLine, dataList interface{
 			}
 			averge = averge / float64(length)
 
+			if len(floatList) <= 0 {
+				err = errors.New(`数据为空`)
+				return
+			}
 			stdev := utils.CalculateStandardDeviation(floatList)
 			stdev, _ = decimal.NewFromFloat(stdev).Round(4).Float64()