From 81e153324399db01cbdd5ac011c49c25e7a98106 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Wed, 15 Jul 2026 15:32:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B4=E7=BA=A7=E7=8F=AD=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YD_YiLu/Services/Impl/DeviceSyncService.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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,