From 86e5d2dc8e546e6f8db3cfda236edcda1bf5af62 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Wed, 1 Jul 2026 15:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E5=BE=97=E8=BF=90=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/DeviceSync/DeviceSyncMyRecordDto.cs | 10 +++-- YD_YiLu/Services/Impl/DeviceSyncService.cs | 40 +++++++++++++++---- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs b/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs index 6434f8d..dd7d223 100644 --- a/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs +++ b/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs @@ -13,6 +13,7 @@ namespace YD_YiLu.Commons.Dto.DeviceSync public int DateType { get; set; } public string QueryStartTime { get; set; } public string QueryEndTime { get; set; } + public List CourseIdList { get; set; } = new List(); public int? CourseType { get; set; } } @@ -49,16 +50,17 @@ namespace YD_YiLu.Commons.Dto.DeviceSync public class GradeListItem { - public string Time { get; set; } - public string Duration { get; set; } - public string Count { get; set; } + public int CourseId { get; set; } + public string CourseName { get; set; } + public string BestGrade { get; set; } + public string AvgGrade { get; set; } } public class GraphTrainListItem { public int CourseId { get; set; } public string CourseName { get; set; } - public string Time { get; set; } + public int Time { get; set; } public int Count { get; set; } } diff --git a/YD_YiLu/Services/Impl/DeviceSyncService.cs b/YD_YiLu/Services/Impl/DeviceSyncService.cs index eaf2c8e..3a70e3f 100644 --- a/YD_YiLu/Services/Impl/DeviceSyncService.cs +++ b/YD_YiLu/Services/Impl/DeviceSyncService.cs @@ -872,12 +872,31 @@ namespace YD_YiLu.Api.Services.Impl if (student == null) return result; var c = await _context.Class.FindAsync(student.ClassId); + result.UserSync = new UserSyncDto + { + UserId = student.Id, + UserType = 2, + Nickname = student.StudentName, + OrganizationId = student.ClassId ?? 0, + OrganizationName = c?.ClassName ?? "", + FacePictureUrl = student.Photo, + Identity = "学生", + Gender = student.Sex == 1 ? "男" : "女", + Birthday = student.Birthday?.ToString("yyyy-MM-dd") ?? "", + UserSerial = student.StudentNo, + Height = "0", + Weight = "0" + }; // 👉 2. 时间范围 var (start, end) = GetDateRange(dto.DateType, dto.QueryStartTime, dto.QueryEndTime); var query = _context.YL_Train - .Where(x => x.UserSerial == dto.UserSerial); + .Where(x => x.UserSerial == dto.UserSerial + && x.DeviceSerial == dto.DeviceSerial + && x.DeviceType == dto.DeviceType + && x.Score.HasValue + && x.Score.Value > 0); if (start.HasValue) query = query.Where(x => x.StartTime >= start.Value); @@ -885,7 +904,9 @@ namespace YD_YiLu.Api.Services.Impl if (end.HasValue) query = query.Where(x => x.StartTime < end.Value.AddDays(1)); - if (dto.CourseType > 0) + if (dto.CourseIdList != null && dto.CourseIdList.Count > 0) + query = query.Where(x => dto.CourseIdList.Contains(x.CourseId)); + else if (dto.CourseType > 0) query = query.Where(x => x.CourseId == dto.CourseType); var trains = await query.ToListAsync(); @@ -900,12 +921,13 @@ namespace YD_YiLu.Api.Services.Impl // 👉 4. gradeList(按天统计) var gradeList = trains - .GroupBy(x => x.StartTime.Date) + .GroupBy(x => x.CourseId) .Select(g => new GradeListItem { - Time = g.Key.ToString("yyyy-MM-dd"), - Duration = g.Sum(x => x.Duration).ToString(), - Count = g.Sum(x => x.StandardCounts).ToString() + CourseId = g.Key, + CourseName = Util.GetEnumDescription(g.Key), + BestGrade = (g.Max(x => x.Score) ?? 0).ToString("0.##"), + AvgGrade = (g.Average(x => x.Score) ?? 0).ToString("0.##") }).ToList(); // 👉 5. graphTrainList(课目统计) @@ -915,7 +937,7 @@ namespace YD_YiLu.Api.Services.Impl { CourseId = g.Key, CourseName = Util.GetEnumDescription(g.Key), - Time = g.Sum(x => x.Duration).ToString(), + Time = g.Sum(x => x.Duration), Count = g.Count() }).ToList(); @@ -960,6 +982,10 @@ namespace YD_YiLu.Api.Services.Impl GraphTrainList = graphList, //CourseBestList = courseBestList }; + result.UserSync.Identity = "学生"; + result.UserSync.Gender = student.Sex == 1 ? "男" : "女"; + result.UserSync.Height = "0"; + result.UserSync.Weight = "0"; return result; }