我得运动
This commit is contained in:
parent
70a067cb6e
commit
86e5d2dc8e
@ -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<int> CourseIdList { get; set; } = new List<int>();
|
||||
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; }
|
||||
}
|
||||
|
||||
|
||||
@ -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<CourseType>(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<CourseType>(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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user