diff --git a/YD_YiLu/Services/Impl/DeviceSyncService.cs b/YD_YiLu/Services/Impl/DeviceSyncService.cs index 1da24a3..4b6c65e 100644 --- a/YD_YiLu/Services/Impl/DeviceSyncService.cs +++ b/YD_YiLu/Services/Impl/DeviceSyncService.cs @@ -550,12 +550,28 @@ namespace YD_YiLu.Api.Services.Impl .ToListAsync(); // ✅ 确保在此处完成 // 7️⃣ 返回结果 + var classIds = grouped + .Select(x => x.Key.ClassId ?? 0) + .Where(x => x > 0) + .Distinct() + .ToList(); + + var classMap = await _context.Class + .Where(x => classIds.Contains(x.Id)) + .ToDictionaryAsync(x => x.Id, x => new + { + x.GradeName, + x.ClassName + }); + return grouped.Select(x => new DeviceSyncGradeOrderItemDto { UserId = x.Key.Id, Nickname = x.Key.StudentName, OrganizationId = x.Key.ClassId ?? 0, - OrganizationName = x.Key.ClassName ?? "", + OrganizationName = classMap.TryGetValue(x.Key.ClassId ?? 0, out var classInfo) + ? $"{classInfo.GradeName ?? ""}{classInfo.ClassName ?? ""}" + : x.Key.ClassName ?? "", Gender = x.Key.Sex, Score = Math.Round(x.Score).ToString("0"), CourseId = x.Key.CourseId,