From 61ad29d944042a2266cb78b421c96fa3d1eca38b Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Mon, 28 Jul 2025 10:04:44 +0800 Subject: [PATCH] dd --- VOL.Ai/Services/AiAppService.cs | 54 ++++++++++++++++--- .../Ai/Request/Ai_ClassRoomRecordRequest.cs | 5 ++ .../Ai/Response/Ai_HeartRateReportDto.cs | 36 ++++++++++++- .../GetStudentClassReportDetailsModel.cs | 3 +- VOL.WebApi/Controllers/AI/AiAppController.cs | 2 +- 5 files changed, 89 insertions(+), 11 deletions(-) diff --git a/VOL.Ai/Services/AiAppService.cs b/VOL.Ai/Services/AiAppService.cs index 221ad54..18f81e1 100644 --- a/VOL.Ai/Services/AiAppService.cs +++ b/VOL.Ai/Services/AiAppService.cs @@ -1129,6 +1129,28 @@ namespace VOL.Ai.Services await _classRoomRecordRepository.AddAsync(entity); await _classRoomRecordRepository.SaveChangesAsync(); + var classroomSettingList = new List(); + + if (entity.Id > 0) + { + foreach (var item in paramDto.ClassroomSettingList) + { + classroomSettingList.Add(new Ai_ClassroomSetting() + { + ClassRoomRecordId = entity.Id, + ClassroomStageId = item.ClassroomStageId, + Density = item.Density, + Duration = item.Duration + }); + } + + if (classroomSettingList.Count > 0) + { + await _classroomSettingRepository.AddRangeAsync(classroomSettingList); + await _classroomSettingRepository.SaveChangesAsync(); + } + } + return new Ai_ClassRoomRecordDto() { ClassRoomRecordId = entity.Id, @@ -1429,18 +1451,36 @@ namespace VOL.Ai.Services && (paramDto.ClassRoomStageId <= 0 || hrd.ClassroomStageId == paramDto.ClassRoomStageId) select hrd; - var heartRateDataList = await query.ToListAsync(); if (heartRateDataList.Count == 0) return res; var classRoom = await _teacherRepository.DbContext.Set().Include(x => x.ClassroomStudentRecord) - .Where(x => x.SchoolCode == paramDto.SchoolCode && x.Id == paramDto.ClassRoomStageId) - .FirstAsync(); + .Where(x => x.SchoolCode == paramDto.SchoolCode && x.Id == paramDto.ClassRoomRecordId) + .FirstOrDefaultAsync(); + + if (classRoom == null) + { + throw new Exception("未找到对应的班级记录"); + } + + var classroomStageList = await (from s in _classroomSettingRepository.DbContext.Set() + join t in _classroomStageRepository.DbContext.Set() + on s.ClassroomStageId equals t.Id + where s.ClassRoomRecordId == paramDto.ClassRoomRecordId + select new ClassroomStageInfoDto + { + ClassroomStageId = s.ClassroomStageId, + ClassroomStageName = t.Name, + Duration = s.Duration, + Density = s.Density + }).ToListAsync(); + + res.ClassroomStageList = classroomStageList; var classRoomStudent = await _teacherRepository.DbContext.Set() - .Where(x => x.SchoolCode == paramDto.SchoolCode && x.Id == paramDto.ClassRoomStageId) + .Where(x => x.SchoolCode == paramDto.SchoolCode && x.ClassRoomRecordId == paramDto.ClassRoomRecordId) .ToListAsync(); res.GradeAndClass = $"{classRoom.GradeName}-{classRoom.ClassName}"; @@ -1499,10 +1539,8 @@ namespace VOL.Ai.Services { var res = new GetStudentClassReportDetailsModel(); - var schoolCode = UserContext.Current.TenantId; - var query = from hrd in _teacherRepository.DbContext.Set() - where hrd.SchoolCode == schoolCode && + where hrd.SchoolCode == paramDto.SchoolCode && hrd.ClassRoomRecordId == paramDto.ClassRoomRecordId && hrd.StudentNo == paramDto.StudentNo select hrd; @@ -1525,7 +1563,7 @@ namespace VOL.Ai.Services res.Consumption = Math.Abs((int)heartRateDataList.Average(x => x.Consumption ?? 0)); //var baseTime = heartRateDataList.Min(x => x.ScoreTime); - var baseTime = await _teacherRepository.DbContext.Set().Where(x => x.SchoolCode == schoolCode && x.ClassRoomRecordId == paramDto.ClassRoomRecordId).MinAsync(x => x.ScoreTime); + var baseTime = await _teacherRepository.DbContext.Set().Where(x => x.SchoolCode == paramDto.SchoolCode && x.ClassRoomRecordId == paramDto.ClassRoomRecordId).MinAsync(x => x.ScoreTime); var heartRateWithMinutes = heartRateDataList .Select(data => new diff --git a/VOL.Model/Ai/Request/Ai_ClassRoomRecordRequest.cs b/VOL.Model/Ai/Request/Ai_ClassRoomRecordRequest.cs index 8085749..2ce83fc 100644 --- a/VOL.Model/Ai/Request/Ai_ClassRoomRecordRequest.cs +++ b/VOL.Model/Ai/Request/Ai_ClassRoomRecordRequest.cs @@ -66,6 +66,11 @@ namespace VOL.Model.Ai.Request /// 课堂记录学生列表 /// public List ClassroomStudentRecord { get; set; } + + /// + /// 课堂设置列表 + /// + public List ClassroomSettingList { get; set; } } /// diff --git a/VOL.Model/Ai/Response/Ai_HeartRateReportDto.cs b/VOL.Model/Ai/Response/Ai_HeartRateReportDto.cs index dccaa34..f6d53de 100644 --- a/VOL.Model/Ai/Response/Ai_HeartRateReportDto.cs +++ b/VOL.Model/Ai/Response/Ai_HeartRateReportDto.cs @@ -1,5 +1,8 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -62,6 +65,11 @@ namespace VOL.Model.Ai.Response /// public string Consumption { get; set; } + /// + /// 课堂阶段 + /// + public List ClassroomStageList { get; set; } + /// /// 学生运动记录 /// @@ -77,4 +85,30 @@ namespace VOL.Model.Ai.Response /// public List HeartRateTrend { get; set; } = new List(); } + + + /// + /// 课堂阶段 + /// + public class ClassroomStageInfoDto + { + /// + /// 阶段Id + /// + public int ClassroomStageId { get; set; } + /// + /// 阶段名称 + /// + public string ClassroomStageName { get; set; } + + /// + /// 时长 + /// x + public int Duration { get; set; } + + /// + /// 密度 + /// + public int Density { get; set; } + } } diff --git a/VOL.Model/Training/Response/GetStudentClassReportDetailsModel.cs b/VOL.Model/Training/Response/GetStudentClassReportDetailsModel.cs index cbec8a6..d60b41a 100644 --- a/VOL.Model/Training/Response/GetStudentClassReportDetailsModel.cs +++ b/VOL.Model/Training/Response/GetStudentClassReportDetailsModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using VOL.Model.Ai; using VOL.Model.Norm.Response; namespace VOL.Model.Training.Response @@ -27,7 +28,7 @@ namespace VOL.Model.Training.Response /// /// 学生课堂记录详情 /// - public class GetStudentClassReportDetailsDto + public class GetStudentClassReportDetailsDto : Ai_Request { /// /// 课堂Id diff --git a/VOL.WebApi/Controllers/AI/AiAppController.cs b/VOL.WebApi/Controllers/AI/AiAppController.cs index 844b2ea..f0c9365 100644 --- a/VOL.WebApi/Controllers/AI/AiAppController.cs +++ b/VOL.WebApi/Controllers/AI/AiAppController.cs @@ -552,7 +552,7 @@ namespace VOL.WebApi.Controllers } /// - /// 获取学生心率报告 + /// 获取跳绳报告 /// [HttpGet(nameof(JumpRopeReport))] [ServiceFilter(typeof(ValidateDeviceFilter))]