diff --git a/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs b/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs index 0209f9a..6434f8d 100644 --- a/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs +++ b/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs @@ -28,7 +28,7 @@ namespace YD_YiLu.Commons.Dto.DeviceSync public int TrainCounts { get; set; } public List GradeList { get; set; } = new List(); public List GraphTrainList { get; set; } = new List(); - public List CourseBestList { get; set; } = new List(); + //public List CourseBestList { get; set; } = new List(); } public class UserSyncDto diff --git a/YD_YiLu/Controllers/DeviceSyncController.cs b/YD_YiLu/Controllers/DeviceSyncController.cs index b6fc3d6..cf31eb9 100644 --- a/YD_YiLu/Controllers/DeviceSyncController.cs +++ b/YD_YiLu/Controllers/DeviceSyncController.cs @@ -9,7 +9,7 @@ namespace YD_YiLu.Api.Controllers /// 壹动站/壹体屏/活力课间屏 设备同步 HTTP 接口(小站登录与心跳见 WebSocket:/ws/camera/device) /// [AllowAnonymous] - public class DeviceSyncController : ControllerBase + public class DeviceSyncController : ControllerBase { private readonly IDeviceSyncService _deviceSyncService; @@ -91,7 +91,8 @@ namespace YD_YiLu.Api.Controllers [Route("/device/sync/train_push")] public async Task TrainPush([FromBody] List list) { - return await _deviceSyncService.TrainPushAsync(list); + var res = await _deviceSyncService.TrainPushAsync(list); + return res; } /// @@ -101,7 +102,8 @@ namespace YD_YiLu.Api.Controllers [Route("/device/sync/train/details")] public async Task TrainDetails([FromQuery] int trainId) { - return await _deviceSyncService.TrainDetailsAsync(trainId); + var res = await _deviceSyncService.TrainDetailsAsync(trainId); + return res; } /// @@ -111,7 +113,8 @@ namespace YD_YiLu.Api.Controllers [Route("/device/sync/grade/order")] public async Task GradeOrder([FromBody] DeviceSyncGradeOrderRequestDto dto) { - return await _deviceSyncService.GradeOrderAsync(dto); + var res = await _deviceSyncService.GradeOrderAsync(dto); + return res; } /// @@ -121,7 +124,8 @@ namespace YD_YiLu.Api.Controllers [Route("/applet/train/record_app")] public async Task RecordApp([FromBody] DeviceSyncRecordAppRequestDto dto) { - return await _deviceSyncService.RecordAppAsync(dto); + var res = await _deviceSyncService.RecordAppAsync(dto); + return res; } /// @@ -131,7 +135,8 @@ namespace YD_YiLu.Api.Controllers [Route("/device/sync/train/my_record/ytp")] public async Task MyRecord([FromBody] DeviceSyncMyRecordRequestDto dto) { - return await _deviceSyncService.MyRecordAsync(dto); + var res = await _deviceSyncService.MyRecordAsync(dto); + return res; } } } diff --git a/YD_YiLu/Services/Impl/DeviceSyncService.cs b/YD_YiLu/Services/Impl/DeviceSyncService.cs index 50467b5..7a3cc1e 100644 --- a/YD_YiLu/Services/Impl/DeviceSyncService.cs +++ b/YD_YiLu/Services/Impl/DeviceSyncService.cs @@ -334,9 +334,6 @@ namespace YD_YiLu.Api.Services.Impl .Select(x => x.SchoolCode) .FirstAsync(); - // 3️⃣ 时间范围 - var (start, end) = GetDateRange(dto.DateType, dto.QueryStartTime, dto.QueryEndTime); - // 4️⃣ 主查询(YL_Train + Student) var query = from t in _context.YL_Train join s in _context.Student on t.UserSerial equals s.StudentNo @@ -347,17 +344,22 @@ namespace YD_YiLu.Api.Services.Impl if (dto.CourseId.HasValue) query = query.Where(x => x.t.CourseId == dto.CourseId.Value); - if (dto.Gender.HasValue) + if (dto.Gender > 0) query = query.Where(x => x.s.Sex == dto.Gender.Value); - if (dto.OrganizeId != null && dto.OrganizeId.Count > 0) + if (dto.OrganizeId != null && dto.OrganizeId.Count > 0 && dto.OrganizeId[0] > 0) query = query.Where(x => dto.OrganizeId.Contains(x.s.ClassId ?? 0)); - if (start.HasValue) - query = query.Where(x => x.t.StartTime >= start.Value); + if (dto.QueryStartTime != null && dto.QueryEndTime != null) + { + var (start, end) = GetDateRange(dto.DateType, dto.QueryStartTime, dto.QueryEndTime); - if (end.HasValue) - query = query.Where(x => x.t.StartTime < end.Value.AddDays(1)); + if (start.HasValue) + query = query.Where(x => x.t.StartTime >= start.Value); + + if (end.HasValue) + query = query.Where(x => x.t.StartTime < end.Value.AddDays(1)); + } // 6️⃣ 分组求总成绩并排序 var grouped = await query @@ -482,7 +484,7 @@ namespace YD_YiLu.Api.Services.Impl StartTime = train?.StartTime.ToString("yyyy-MM-dd HH:mm:ss") ?? "", EndTime = train?.EndTime.ToString("yyyy-MM-dd HH:mm:ss") ?? "", CourseId = train?.CourseId ?? 0, - CourseName = Util.GetEnumDescription(train?.CourseId) + CourseName = Util.GetEnumDescription(train?.CourseId) }); } @@ -514,7 +516,7 @@ namespace YD_YiLu.Api.Services.Impl if (dto.CourseId.HasValue) query = query.Where(x => x.t.CourseId == dto.CourseId.Value); - if (dto.Gender.HasValue) + if (dto.Gender > 0) query = query.Where(x => x.s.Sex == dto.Gender.Value); if (!string.IsNullOrEmpty(dto.UserSerial)) @@ -553,9 +555,8 @@ namespace YD_YiLu.Api.Services.Impl StartTime = x.t.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), EndTime = x.t.EndTime.ToString("yyyy-MM-dd HH:mm:ss"), - CourseId = x.t.CourseId, - CourseName = $"课目{x.t.CourseId}" // 👉 建议后面接字典表 + CourseName = Util.GetEnumDescription(x.t.CourseId), // 👉 建议后面接字典表 }) .ToListAsync(); @@ -623,7 +624,7 @@ namespace YD_YiLu.Api.Services.Impl .Select(g => new GraphTrainListItem { CourseId = g.Key, - CourseName = $"课目{g.Key}", // 👉 可换成字典表 + CourseName = Util.GetEnumDescription(g.Key), Time = g.Sum(x => x.Duration).ToString(), Count = g.Count() }).ToList(); @@ -635,7 +636,7 @@ namespace YD_YiLu.Api.Services.Impl .Select(g => new CourseBestListItem { CourseId = g.Key, - CourseName = $"课目{g.Key}", + CourseName = Util.GetEnumDescription(g.Key), BestGrade = g.Max(x => x.Score).ToString(), AvgGrade = g.Average(x => x.Score).ToString(), WorstGrade = g.Min(x => x.Score).ToString() @@ -667,7 +668,7 @@ namespace YD_YiLu.Api.Services.Impl GradeList = gradeList, GraphTrainList = graphList, - CourseBestList = courseBestList + //CourseBestList = courseBestList }; return result;