diff --git a/VOL.Business/Services/Training/I_TrainingDataService.cs b/VOL.Business/Services/Training/I_TrainingDataService.cs index 41adce6..3cf6fa0 100644 --- a/VOL.Business/Services/Training/I_TrainingDataService.cs +++ b/VOL.Business/Services/Training/I_TrainingDataService.cs @@ -2046,8 +2046,8 @@ namespace VOL.Business.Services.Training var heartRateDataList = await query.ToListAsync(); - if (heartRateDataList.Count == 0) - return res; + //if (heartRateDataList.Count == 0) + // return res; var classRoom = await _teacherRepository.DbContext.Set().Include(x => x.ClassroomStudentRecord) .Where(x => x.SchoolCode == schoolCode && x.Id == id) @@ -2064,7 +2064,7 @@ namespace VOL.Business.Services.Training 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.Consumption = $"{Math.Abs(heartRateDataList.Sum(x => x.Consumption ?? 0) / heartRateDataList.Count)} 千卡"; + 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)} %"; res.Density = $"{(int)CalculatePercentage(heartRateDataList.Count(x => x.Strength > 50), heartRateDataList.Count)} %";