diff --git a/VOL.Ai/Services/AiAppService.cs b/VOL.Ai/Services/AiAppService.cs index e7b078a..bfdf96e 100644 --- a/VOL.Ai/Services/AiAppService.cs +++ b/VOL.Ai/Services/AiAppService.cs @@ -1865,7 +1865,10 @@ namespace VOL.Ai.Services res.PeopleNumber = $"{heartRateDataList.GroupBy(x => x.StudentNo).Count()}/{classRoomStudent.Count}"; res.PeopleNumberBySex = $"{classRoomStudent.Count(x => x.Sex == SexType.Male)}/{classRoomStudent.Count(x => x.Sex == SexType.Female)}"; - res.AvgHR = $"{(int)(heartRateDataList.Sum(x => x.Value) / heartRateDataList.Count)} 次/分"; + res.AvgHR = heartRateDataList.Count > 0 + ? $"{(int)(heartRateDataList.Sum(x => x.Value) / heartRateDataList.Count)} 次/分" + : "0 次/分"; + res.Consumption = heartRateDataList.Count > 0 ? $"{Math.Abs(heartRateDataList.Sum(x => x.Consumption ?? 0) / heartRateDataList.Count)} 千卡" : ""; //res.Density = $"{(int)(heartRateDataList.Where(x => x.Strength > 50).Sum(x => x.Strength) / heartRateDataList.Count)} %";