年级班级
This commit is contained in:
parent
81e1533243
commit
b2ee87d2d2
@ -59,7 +59,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
Username = s.StudentNo,
|
||||
Nickname = s.StudentName,
|
||||
GradeName = "",
|
||||
OrganizationId = (int)orgId,
|
||||
OrganizationId = s.ClassId ?? 0,
|
||||
OrganizationName = s.ClassName ?? "",
|
||||
FacePictureUrl = s.Photo ?? "",
|
||||
Identity = "学生",
|
||||
@ -74,7 +74,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
var c = await _context.Class.FindAsync(u.OrganizationId);
|
||||
if (c != null)
|
||||
{
|
||||
u.OrganizationName = c.ClassName ?? "";
|
||||
u.OrganizationName = FormatOrganizationName(c, u.OrganizationName);
|
||||
u.GradeName = c.GradeName ?? "";
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
OrganizationId = c.Id,
|
||||
ParentId = g.Id,
|
||||
ParentName = g.GradeName,
|
||||
OrganizationName = c.ClassName ?? "",
|
||||
OrganizationName = FormatOrganizationName(c, c.ClassName ?? ""),
|
||||
OrganizationType = "班级",
|
||||
ChildrenIds = new List<int>()
|
||||
}).ToList(),
|
||||
@ -472,6 +472,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
|
||||
// 5. 课程名称(枚举描述)
|
||||
string courseName = Util.GetEnumDescription<CourseType>(train.CourseId);
|
||||
var trainClass = await _context.Class.FindAsync(student.ClassId);
|
||||
|
||||
// 6. 返回 DTO
|
||||
return new DeviceSyncTrainDetailsDto
|
||||
@ -483,7 +484,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
FacePictureUrl = student.Photo ?? "",
|
||||
Identity = "学生",
|
||||
OrganizationId = (int)student.ClassId,
|
||||
OrganizationName = student.ClassName,
|
||||
OrganizationName = FormatOrganizationName(trainClass, student.ClassName),
|
||||
Gender = student.Sex == 1 ? "男" : "女",
|
||||
Score = train.Score?.ToString("0") ?? "0",
|
||||
UnStandardCounts = train.UnStandardCounts,
|
||||
@ -621,6 +622,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
.GroupBy(x => new { x.s.ClassId, x.s.ClassName, x.t.CourseId })
|
||||
.Select(g => new
|
||||
{
|
||||
g.Key.ClassId,
|
||||
g.Key.ClassName,
|
||||
g.Key.CourseId,
|
||||
SumScore = g.Sum(x => x.t.Score ?? 0),
|
||||
@ -632,9 +634,21 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
.Take(size)
|
||||
.ToListAsync();
|
||||
|
||||
var organizationClassIds = grouped
|
||||
.Select(x => x.ClassId ?? 0)
|
||||
.Where(x => x > 0)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var organizationClassMap = await _context.Class
|
||||
.Where(x => organizationClassIds.Contains(x.Id))
|
||||
.ToDictionaryAsync(x => x.Id);
|
||||
|
||||
return grouped.Select(x => new DeviceSyncOrganizationGradeOrderItemDto
|
||||
{
|
||||
OrganizationName = x.ClassName ?? "",
|
||||
OrganizationName = organizationClassMap.TryGetValue(x.ClassId ?? 0, out var classInfo)
|
||||
? FormatOrganizationName(classInfo, x.ClassName ?? "")
|
||||
: x.ClassName ?? "",
|
||||
SumScore = Math.Round(x.SumScore).ToString("0"),
|
||||
AvgScore = x.AvgScore.ToString("0.##"),
|
||||
SumCount = x.SumCount,
|
||||
@ -703,7 +717,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
UserSerial = best.s.StudentNo,
|
||||
Nickname = best.s.StudentName,
|
||||
OrganizationId = best.s.ClassId ?? 0,
|
||||
OrganizationName = bestClass?.ClassName ?? best.s.ClassName ?? "",
|
||||
OrganizationName = FormatOrganizationName(bestClass, best.s.ClassName ?? ""),
|
||||
Gender = best.s.Sex,
|
||||
Score = best.t.Score?.ToString("0.##") ?? "0",
|
||||
CourseId = best.t.CourseId,
|
||||
@ -727,6 +741,14 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
.ToListAsync();
|
||||
|
||||
var studentSerials = students.Select(s => s.StudentNo).ToList();
|
||||
var lastGradeClassIds = students
|
||||
.Select(x => x.ClassId ?? 0)
|
||||
.Where(x => x > 0)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var lastGradeClassMap = await _context.Class
|
||||
.Where(x => lastGradeClassIds.Contains(x.Id))
|
||||
.ToDictionaryAsync(x => x.Id);
|
||||
|
||||
var trains = await _context.YL_Train
|
||||
.Where(t => studentSerials.Contains(t.UserSerial))
|
||||
@ -759,7 +781,9 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
Username = st?.StudentNo ?? serial,
|
||||
Nickname = st?.StudentName ?? "",
|
||||
OrganizationId = st?.ClassId ?? 0,
|
||||
OrganizationName = st?.ClassName ?? "",
|
||||
OrganizationName = st != null && lastGradeClassMap.TryGetValue(st.ClassId ?? 0, out var lastGradeClass)
|
||||
? FormatOrganizationName(lastGradeClass, st.ClassName ?? "")
|
||||
: st?.ClassName ?? "",
|
||||
GradeName = "", // 没有就空
|
||||
FacePictureUrl = st?.Photo ?? "",
|
||||
Identity = "", // 可选
|
||||
@ -866,6 +890,22 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var recordClassIds = list
|
||||
.Select(x => x.OrganizationId)
|
||||
.Where(x => x > 0)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var recordClassMap = await _context.Class
|
||||
.Where(x => recordClassIds.Contains(x.Id))
|
||||
.ToDictionaryAsync(x => x.Id);
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (recordClassMap.TryGetValue(item.OrganizationId, out var recordClass))
|
||||
item.OrganizationName = FormatOrganizationName(recordClass, item.OrganizationName);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -894,7 +934,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
UserType = 2,
|
||||
Nickname = student.StudentName,
|
||||
OrganizationId = student.ClassId ?? 0,
|
||||
OrganizationName = c?.ClassName ?? "",
|
||||
OrganizationName = FormatOrganizationName(c, ""),
|
||||
FacePictureUrl = student.Photo,
|
||||
Identity = "学生",
|
||||
Gender = student.Sex == 1 ? "男" : "女",
|
||||
@ -990,7 +1030,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
UserType = 2,
|
||||
Nickname = student.StudentName,
|
||||
OrganizationId = student.ClassId ?? 0,
|
||||
OrganizationName = c?.ClassName ?? "",
|
||||
OrganizationName = FormatOrganizationName(c, ""),
|
||||
FacePictureUrl = student.Photo,
|
||||
Identity = "学生",
|
||||
Gender = student.Sex == 1 ? "男" : "女",
|
||||
@ -1041,7 +1081,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
UserType = 2,
|
||||
Nickname = student.StudentName,
|
||||
OrganizationId = student.ClassId ?? 0,
|
||||
OrganizationName = studentClass?.ClassName ?? student.ClassName ?? "",
|
||||
OrganizationName = FormatOrganizationName(studentClass, student.ClassName ?? ""),
|
||||
FacePictureUrl = student.Photo ?? "",
|
||||
Identity = "学生",
|
||||
Gender = student.Sex == 1 ? "男" : "女",
|
||||
@ -1328,7 +1368,7 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
var c = await _context.Class.FindAsync(dto.OrganizationId);
|
||||
if (c != null)
|
||||
{
|
||||
dto.OrganizationName = c.ClassName ?? "";
|
||||
dto.OrganizationName = FormatOrganizationName(c, dto.OrganizationName);
|
||||
dto.GradeName = c.GradeName ?? "";
|
||||
}
|
||||
return dto;
|
||||
@ -1392,6 +1432,15 @@ namespace YD_YiLu.Api.Services.Impl
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string FormatOrganizationName(S_Class classInfo, string fallback = "")
|
||||
{
|
||||
if (classInfo == null)
|
||||
return fallback ?? "";
|
||||
|
||||
var name = $"{classInfo.GradeName ?? ""}{classInfo.ClassName ?? ""}";
|
||||
return string.IsNullOrWhiteSpace(name) ? fallback ?? "" : name;
|
||||
}
|
||||
|
||||
private int CompareVersion(string v1, string v2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(v1) || string.IsNullOrEmpty(v2))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user