xiug
This commit is contained in:
parent
f527105364
commit
35c2f8c647
@ -28,7 +28,7 @@ namespace YD_YiLu.Commons.Dto.DeviceSync
|
||||
public int TrainCounts { get; set; }
|
||||
public List<GradeListItem> GradeList { get; set; } = new List<GradeListItem>();
|
||||
public List<GraphTrainListItem> GraphTrainList { get; set; } = new List<GraphTrainListItem>();
|
||||
public List<CourseBestListItem> CourseBestList { get; set; } = new List<CourseBestListItem>();
|
||||
//public List<CourseBestListItem> CourseBestList { get; set; } = new List<CourseBestListItem>();
|
||||
}
|
||||
|
||||
public class UserSyncDto
|
||||
|
||||
@ -9,7 +9,7 @@ namespace YD_YiLu.Api.Controllers
|
||||
/// 壹动站/壹体屏/活力课间屏 设备同步 HTTP 接口(小站登录与心跳见 WebSocket:<c>/ws/camera/device</c>)
|
||||
/// </summary>
|
||||
[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<object> TrainPush([FromBody] List<DeviceSyncTrainPushRequestDto> list)
|
||||
{
|
||||
return await _deviceSyncService.TrainPushAsync(list);
|
||||
var res = await _deviceSyncService.TrainPushAsync(list);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -101,7 +102,8 @@ namespace YD_YiLu.Api.Controllers
|
||||
[Route("/device/sync/train/details")]
|
||||
public async Task<object> TrainDetails([FromQuery] int trainId)
|
||||
{
|
||||
return await _deviceSyncService.TrainDetailsAsync(trainId);
|
||||
var res = await _deviceSyncService.TrainDetailsAsync(trainId);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -111,7 +113,8 @@ namespace YD_YiLu.Api.Controllers
|
||||
[Route("/device/sync/grade/order")]
|
||||
public async Task<object> GradeOrder([FromBody] DeviceSyncGradeOrderRequestDto dto)
|
||||
{
|
||||
return await _deviceSyncService.GradeOrderAsync(dto);
|
||||
var res = await _deviceSyncService.GradeOrderAsync(dto);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -121,7 +124,8 @@ namespace YD_YiLu.Api.Controllers
|
||||
[Route("/applet/train/record_app")]
|
||||
public async Task<object> RecordApp([FromBody] DeviceSyncRecordAppRequestDto dto)
|
||||
{
|
||||
return await _deviceSyncService.RecordAppAsync(dto);
|
||||
var res = await _deviceSyncService.RecordAppAsync(dto);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -131,7 +135,8 @@ namespace YD_YiLu.Api.Controllers
|
||||
[Route("/device/sync/train/my_record/ytp")]
|
||||
public async Task<object> MyRecord([FromBody] DeviceSyncMyRecordRequestDto dto)
|
||||
{
|
||||
return await _deviceSyncService.MyRecordAsync(dto);
|
||||
var res = await _deviceSyncService.MyRecordAsync(dto);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -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<CourseType>(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<CourseType>(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<CourseType>(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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user