From 0475e15a439599a3225fcced1b3d8a06a7967a2f Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Tue, 19 Aug 2025 14:13:17 +0800 Subject: [PATCH] f --- VOL.Business/Services/Training/I_TrainingDataService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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)} %";