From 345e1d0928dd5fedb387b9b55d017dd7c2d55ffb Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Wed, 11 Jun 2025 11:45:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WeChatApplet/Context/SmartSportsContext.cs | 4 + WeChatApplet/Controllers/TeacherController.cs | 38 +++ .../Services/Impl/ClientSideService.cs | 102 +------- WeChatApplet/Services/Impl/TeacherService.cs | 223 +++++++++++++++++ WeChatApplet/Services/Impl/UserService.cs | 1 - .../Services/Interface/ITeacherService.cs | 23 ++ .../SmartSportsEntitys/Ai_ClassRoomRecord.cs | 183 ++++++++++++++ .../Ai_ClassroomStudentRecord.cs | 127 ++++++++++ .../SmartSportsEntitys/Ai_FastJumpRopeData.cs | 230 ++++++++++++++++++ .../SmartSportsEntitys/Ai_HeartRateData.cs | 174 +++++++++++++ WeChatApplet/Startup.cs | 16 +- .../ClassRoomRecord/ClassReportDetailsDto.cs | 70 ++++++ .../Dto/ClassRoomRecord/ClassRoomRecordDto.cs | 19 ++ .../ClassRoomRecord/ClassRoomRecordPageDto.cs | 34 +++ .../StudentClassRoomReportDto.cs | 62 +++++ .../MemoryCaches/AddMemoryCacheSetup.cs | 21 -- .../MemoryCaches/ICaching.cs | 23 -- .../MemoryCaches/MemoryCaching.cs | 52 ---- .../YD_WeChatApplet.Commons.csproj | 1 - 19 files changed, 1195 insertions(+), 208 deletions(-) create mode 100644 WeChatApplet/SmartSportsEntitys/Ai_ClassRoomRecord.cs create mode 100644 WeChatApplet/SmartSportsEntitys/Ai_ClassroomStudentRecord.cs create mode 100644 WeChatApplet/SmartSportsEntitys/Ai_FastJumpRopeData.cs create mode 100644 WeChatApplet/SmartSportsEntitys/Ai_HeartRateData.cs create mode 100644 YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassReportDetailsDto.cs create mode 100644 YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordDto.cs create mode 100644 YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordPageDto.cs create mode 100644 YD_WeChatApplet.Commons/Dto/ClassRoomRecord/StudentClassRoomReportDto.cs delete mode 100644 YD_WeChatApplet.Commons/MemoryCaches/AddMemoryCacheSetup.cs delete mode 100644 YD_WeChatApplet.Commons/MemoryCaches/ICaching.cs delete mode 100644 YD_WeChatApplet.Commons/MemoryCaches/MemoryCaching.cs diff --git a/WeChatApplet/Context/SmartSportsContext.cs b/WeChatApplet/Context/SmartSportsContext.cs index 286d794..f566b1a 100644 --- a/WeChatApplet/Context/SmartSportsContext.cs +++ b/WeChatApplet/Context/SmartSportsContext.cs @@ -23,6 +23,10 @@ namespace YD_WeChatApplet.Context public DbSet Sys_User { get; set; } public DbSet Ai_Special { get; set; } + public DbSet Ai_ClassRoomRecord { get; set; } + public DbSet Ai_ClassroomStudentRecord { get; set; } + public DbSet Ai_FastJumpRopeData { get; set; } + public DbSet Ai_HeartRateData { get; set; } public DbSet Article { get; set; } public DbSet Ai_SpecialAction { get; set; } public DbSet Ai_SpecialLevel { get; set; } diff --git a/WeChatApplet/Controllers/TeacherController.cs b/WeChatApplet/Controllers/TeacherController.cs index 86139fd..b7520e1 100644 --- a/WeChatApplet/Controllers/TeacherController.cs +++ b/WeChatApplet/Controllers/TeacherController.cs @@ -1,6 +1,8 @@ using System.ComponentModel.Design; using Microsoft.AspNetCore.Mvc; using YD_WeChatApplet.Api.Services.Impl; +using YD_WeChatApplet.Commons.Dto; +using YD_WeChatApplet.Commons.Dto.ClassRoomRecord; using YD_WeChatApplet.Commons.Dto.HomeWork; using YD_WeChatApplet.Commons.Dto.Resource; using YD_WeChatApplet.Commons.Dto.Teacher; @@ -93,5 +95,41 @@ namespace YD_WeChatApplet.Api.Controllers return res; } + /// + /// 课堂记录 + /// + /// + /// + [HttpGet("ClassRoomRecord")] + public async Task> ClassRoomRecord([FromQuery] ClassRoomRecordDto dto) + { + var res = await _teacherService.ClassRoomRecord(dto); + return res; + } + + /// + /// 课堂详情 + /// + /// + /// + [HttpGet("ClassRoomReportDetails")] + public async Task ClassRoomReportDetails(int classRoomId) + { + var res = await _teacherService.ClassRoomReportDetails(classRoomId); + return res; + } + + /// + /// 学员课堂报告 + /// + /// + /// + /// + [HttpGet("StudentClassRoomReport")] + public async Task StudentClassRoomReport(int classRoomId, string studentNo) + { + var res = await _teacherService.StudentClassRoomReport(classRoomId, studentNo); + return res; + } } } diff --git a/WeChatApplet/Services/Impl/ClientSideService.cs b/WeChatApplet/Services/Impl/ClientSideService.cs index c48f391..749955d 100644 --- a/WeChatApplet/Services/Impl/ClientSideService.cs +++ b/WeChatApplet/Services/Impl/ClientSideService.cs @@ -20,7 +20,6 @@ using YD_WeChatApplet.Commons.Dto.School; using YD_WeChatApplet.Commons.Dto.SportsTest; using YD_WeChatApplet.Commons.Dto.Teacher; using YD_WeChatApplet.Commons.Enum; -using YD_WeChatApplet.Commons.MemoryCaches; using YD_WeChatApplet.Commons.Utils; using YD_WeChatApplet.Context; using YD_WeChatApplet.Services; @@ -36,13 +35,11 @@ namespace YD_WeChatApplet.Api.Services.Impl public UserContext _userContext; public SmartSportsContext _sportsContext; private readonly IMapper _mapper; - private readonly ICaching _caching; - public ClientSideService(UserContext userContext, SmartSportsContext sportsContext, IMapper mapper, ICaching caching) + public ClientSideService(UserContext userContext, SmartSportsContext sportsContext, IMapper mapper) { _userContext = userContext; _sportsContext = sportsContext; _mapper = mapper; - _caching = caching; } /// @@ -302,103 +299,6 @@ namespace YD_WeChatApplet.Api.Services.Impl return res; } - // 获取 access_token - public async Task GetAccessTokenAsync() - { - var userId = UserLoginContext.Current.UserId; - - var key = $"access_token_{userId}"; - - var token = _caching.Get(key).ToString(); - - if (!string.IsNullOrWhiteSpace(token)) - { - return token; - } - - // 2. 缓存不存在,请求微信接口 - var url = $"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={AppSettings.WeChatQA.Appid}&secret={AppSettings.WeChatQA.Secret}"; - var response = await HttpManager.HttpGetAsync(url, null); - - dynamic data = JsonConvert.DeserializeObject(response); - if (data?.access_token != null) - { - token = data.access_token; - - // 微信官方返回中有 expires_in,一般是7200秒(2小时) - int expiresInSeconds = data.expires_in ?? 7200; - - // 3. 写入缓存,提前1分钟过期 - _caching.Set(key, token, expiresInSeconds); - - return token; - } - - throw new Exception("获取 access_token 失败"); - } - - // 获取文章列表 - public async Task GetArticlesAsync(string accessToken, int offset, int count = 20) - { - var userId = UserLoginContext.Current.UserId; - - var key = $"articles_{userId}_{offset}"; - - var articlesData = _caching.Get(key).ToString(); - - if (articlesData != null && articlesData.Count() > 0) - { - return articlesData; - } - - //var url = $"https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token={accessToken}"; - var url = $"https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token={accessToken}"; - - var postData = JsonConvert.SerializeObject(new - { - //type = "news", - offset = offset, - count = count - }); - - var response = await HttpManager.HttpPostAsync(url, postData, "application/json"); - - // 解析并过滤掉content字段 - dynamic data = JsonConvert.DeserializeObject(response); - if (data?.item != null) - { - var filteredItems = new List(); - foreach (var item in data.item) - { - if (item["update_time"] is JValue timeValue && timeValue.Type == JTokenType.Integer) - { - item["update_time"] = DateTimeOffset.FromUnixTimeSeconds((long)timeValue) - .ToString("yyyy-MM-dd HH:mm:ss"); - } - - foreach (var newitem in item.content.news_item) - { - filteredItems.Add(new - { - newitem.title, - newitem.author, - newitem.digest, - newitem.url, - newitem.thumb_url, - item.update_time - }); - } - } - - int expiresInSeconds = data.expires_in ?? 7200; - _caching.Set(key, filteredItems, expiresInSeconds); - - return filteredItems; - } - - throw new Exception("获取文章列表失败"); - } - /// /// 创建群组 /// diff --git a/WeChatApplet/Services/Impl/TeacherService.cs b/WeChatApplet/Services/Impl/TeacherService.cs index 9b7f784..83e255e 100644 --- a/WeChatApplet/Services/Impl/TeacherService.cs +++ b/WeChatApplet/Services/Impl/TeacherService.cs @@ -2,9 +2,12 @@ using System; using System.Threading.Tasks; using AutoMapper; +using CSRedis; using Microsoft.EntityFrameworkCore; using YD_WeChatApplet.Api.SmartSportsEntitys; using YD_WeChatApplet.Api.Utilities; +using YD_WeChatApplet.Commons.Dto; +using YD_WeChatApplet.Commons.Dto.ClassRoomRecord; using YD_WeChatApplet.Commons.Dto.HomeWork; using YD_WeChatApplet.Commons.Dto.SportsTest; using YD_WeChatApplet.Commons.Dto.Teacher; @@ -313,5 +316,225 @@ namespace YD_WeChatApplet.Services res.ComprehensiveScore = totalScore.ToString("F0"); return res; } + + /// + /// 课堂记录 + /// + /// + /// + public async Task> ClassRoomRecord(ClassRoomRecordDto dto) + { + var res = new PageDataDto(); + + if (string.IsNullOrWhiteSpace(dto.StudentNo)) + { + var phoneNo = UserLoginContext.Current.PhoneNo; + + var teacherId = await _sportsContext.Teacher.Where(x => x.TeacherPhoneNo == phoneNo).Select(x => x.Id).FirstOrDefaultAsync(); + var query = from td in _sportsContext.Ai_ClassRoomRecord + where td.TeacherId == teacherId + select new ClassRoomRecordPageDto() + { + Id = td.Id, + ClassId = td.ClassId, + Name = td.Name, + StartingEndingTime = $"{(td.StartTime.HasValue ? td.StartTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}{(td.EndTime.HasValue ? " - " + td.EndTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}" + }; + + res.Total = await query.CountAsync(); + + var list = await query + .OrderByDescending(c => c.Id) + .Skip((dto.PageIndex - 1) * dto.PageSize) + .Take(dto.PageSize) + .ToListAsync(); + + res.Datas = list; + } + else + { + var query = from s in _sportsContext.Ai_ClassroomStudentRecord + join c in _sportsContext.Ai_ClassRoomRecord on s.ClassRoomRecordId equals c.Id + where s.StudentName == dto.StudentNo + select new ClassRoomRecordPageDto() + { + Id = c.Id, + ClassId = c.ClassId, + Name = c.Name, + StartingEndingTime = $"{(c.StartTime.HasValue ? c.StartTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}{(c.EndTime.HasValue ? " - " + c.EndTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}" + }; + + res.Total = await query.CountAsync(); + + var list = await query + .OrderByDescending(c => c.Id) + .Skip((dto.PageIndex - 1) * dto.PageSize) + .Take(dto.PageSize) + .ToListAsync(); + + res.Datas = list; + } + + return res; + } + + /// + /// 课堂详情 + /// + /// + /// + public async Task ClassRoomReportDetails(int classRoomId) + { + var res = new ClassReportDetailsDto(); + + var query = from hrd in _sportsContext.Ai_HeartRateData + where hrd.ClassRoomRecordId == classRoomId + select hrd; + + var heartRateDataList = await query.ToListAsync(); + + if (heartRateDataList.Count == 0) + return res; + + var classRoom = await _sportsContext.Ai_ClassRoomRecord.Include(x => x.ClassroomStudentRecord) + .Where(x => x.Id == classRoomId) + .FirstAsync(); + + var classRoomStudent = await _sportsContext.Ai_ClassroomStudentRecord + .Where(x => x.ClassRoomRecordId == classRoomId) + .ToListAsync(); + + res.MaxHR = (int)heartRateDataList.Max(x => x.Value); + res.MinHR = (int)heartRateDataList.Min(x => x.Value); + res.AvgHR = (int)heartRateDataList.Average(x => x.Value); + + res.HighIntensity = heartRateDataList.Where(x => x.Strength > 50).Sum(x => x.MotionDuration); + + var studentTrainingRecordList = classRoom.ClassroomStudentRecord.ToList(); + List studentList = new List(); + + foreach (var item in studentTrainingRecordList) + { + var studentTrainingData = heartRateDataList.Where(x => x.StudentNo == item.StudentNo).ToList(); + + if (studentTrainingData.Count > 0) + { + var student = new StudentTrainingRecordDto() + { + StudentNo = item.StudentNo, + Age = item.Age, + Sex = item.Sex + }; + + student.StudentName = studentTrainingData[0].StudentName; + + studentList.Add(student); + } + } + + res.HeartRateTrend = GetHeartRateTrend(heartRateDataList); + res.StudentTrainingRecordList = studentList; + + return res; + } + + /// + /// 学员报告 + /// + /// + /// + /// + public async Task StudentClassRoomReport(int classRoomId, string studentNo) + { + var res = new StudentClassRoomReportDto(); + + var query = from hrd in _sportsContext.Ai_HeartRateData + where hrd.ClassRoomRecordId == classRoomId && + hrd.StudentNo == studentNo + select hrd; + + var heartRateDataList = await query.ToListAsync(); + + if (heartRateDataList.Count == 0) + return res; + + var student = heartRateDataList[0]; + + res.MaxHR = (int)heartRateDataList.Max(x => x.Value); + res.MinHR = (int)heartRateDataList.Min(x => x.Value); + res.AvgHR = (int)heartRateDataList.Average(x => x.Value); + + res.HighIntensity = heartRateDataList.Where(x => x.Strength > 50).Sum(x => x.MotionDuration); + + var baseTime = await _sportsContext.Ai_HeartRateData.Where(x => x.ClassRoomRecordId == classRoomId).MinAsync(x => x.ScoreTime); + + var heartRateWithMinutes = heartRateDataList + .Select(data => new + { + Data = data, + MinuteBucket = (int)(data.ScoreTime - baseTime).TotalMinutes + }) + .ToList(); + + var maxMinute = heartRateWithMinutes.Max(x => x.MinuteBucket); + + for (int minute = 0; minute <= maxMinute; minute++) + { + var minuteData = heartRateWithMinutes + .Where(x => x.MinuteBucket == minute) + .Select(x => x.Data) + .ToList(); + + if (minuteData.Any()) + { + res.HeartRateTrend.AxisX.Add($"{minute + 1} 分钟"); + res.HeartRateTrend.AxisY.Add((int)minuteData.Average(x => x.Value)); + } + } + + return res; + } + + + /// + /// 心率变化趋势 + /// + /// + /// + public ChartDataDto GetHeartRateTrend(List heartRateDataList) + { + var result = new ChartDataDto(); + + if (heartRateDataList == null || !heartRateDataList.Any()) + return result; + + var baseTime = heartRateDataList.Min(x => x.ScoreTime); + + var heartRateWithMinutes = heartRateDataList + .Select(data => new + { + Data = data, + MinuteBucket = (int)(data.ScoreTime - baseTime).TotalMinutes + }) + .ToList(); + + var maxMinute = heartRateWithMinutes.Max(x => x.MinuteBucket); + + for (int minute = 0; minute <= maxMinute; minute++) + { + var minuteData = heartRateWithMinutes + .Where(x => x.MinuteBucket == minute) + .Select(x => x.Data) + .ToList(); + + if (minuteData.Any()) + { + result.AxisX.Add($"{minute + 1} 分钟"); + result.AxisY.Add((int)minuteData.Average(x => x.Value)); + } + } + + return result; + } } } diff --git a/WeChatApplet/Services/Impl/UserService.cs b/WeChatApplet/Services/Impl/UserService.cs index eb4d2ce..f3b8c2e 100644 --- a/WeChatApplet/Services/Impl/UserService.cs +++ b/WeChatApplet/Services/Impl/UserService.cs @@ -19,7 +19,6 @@ using YD_WeChatApplet.Api.SmartSportsEntitys; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Authorization; using System.Text.Json; -using YD_WeChatApplet.Commons.MemoryCaches; using Microsoft.EntityFrameworkCore.Metadata.Internal; using YD_WeChatApplet.Commons.Dto.ClientSide; using System.Reflection; diff --git a/WeChatApplet/Services/Interface/ITeacherService.cs b/WeChatApplet/Services/Interface/ITeacherService.cs index 09b0fd2..f1670d0 100644 --- a/WeChatApplet/Services/Interface/ITeacherService.cs +++ b/WeChatApplet/Services/Interface/ITeacherService.cs @@ -3,6 +3,8 @@ using TGJ.NetworkFreight.SeckillAggregateServices.Pos.UserService; using YD_WeChatApplet.Api; using YD_WeChatApplet.Api.Entitys; using YD_WeChatApplet.Commons; +using YD_WeChatApplet.Commons.Dto; +using YD_WeChatApplet.Commons.Dto.ClassRoomRecord; using YD_WeChatApplet.Commons.Dto.HomeWork; using YD_WeChatApplet.Commons.Dto.Teacher; @@ -48,5 +50,26 @@ namespace YD_WeChatApplet.Services /// /// Task DataStatisticsDetails(DataStatisticsDetailsFilterDto dto); + + /// + /// 课堂记录 + /// + /// + /// + Task> ClassRoomRecord(ClassRoomRecordDto dto); + + /// + /// 课堂详情 + /// + /// + /// + Task ClassRoomReportDetails(int classRoomId); + + /// + /// 学员课堂报告 + /// + /// + /// + Task StudentClassRoomReport(int classRoomId, string studentNo); } } diff --git a/WeChatApplet/SmartSportsEntitys/Ai_ClassRoomRecord.cs b/WeChatApplet/SmartSportsEntitys/Ai_ClassRoomRecord.cs new file mode 100644 index 0000000..c02327b --- /dev/null +++ b/WeChatApplet/SmartSportsEntitys/Ai_ClassRoomRecord.cs @@ -0,0 +1,183 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace YD_WeChatApplet.Api.SmartSportsEntitys +{ + [Table("Ai_ClassRoomRecord")] + public class Ai_ClassRoomRecord + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Display(Description = "主键Id")] + [Comment("Id")] + public int Id { get; set; } + + /// + ///学校Code + /// + [Display(Name = "学校Code")] + [Comment("学校Code")] + [Column(TypeName = "nvarchar(100)")] + public string SchoolCode { get; set; } + + /// + /// AI设备的唯一编码 + /// + [Display(Name = "AI设备的唯一编码")] + [Comment("AI设备的唯一编码")] + [Column(TypeName = "nvarchar(100)")] + public string Code { get; set; } + + /// + /// 名称 + /// + [Display(Name = "名称")] + [Comment("名称")] + [Column(TypeName = "nvarchar(200)")] + public string Name { get; set; } + + /// + /// 年级编号 + /// + [Display(Name = "年级编号")] + [Comment("年级编号")] + [Column(TypeName = "int")] + public int GradeId { get; set; } + + /// + ///班级Id + /// + [Display(Name = "班级Id")] + [Comment("班级Id")] + [Column(TypeName = "int")] + public int ClassId { get; set; } + + /// + /// 年级名称 + /// + [Display(Name = "年级名称")] + [Comment("年级名称")] + [Column(TypeName = "nvarchar(100)")] + public string GradeName { get; set; } + + /// + /// 班级名称 + /// + [Display(Name = "班级名称")] + [Comment("班级名称")] + [Column(TypeName = "nvarchar(100)")] + public string ClassName { get; set; } + + /// + /// 训练模块枚举 + /// + [Display(Name = "训练模块枚举")] + [Comment("训练模块枚举")] + [Column(TypeName = "int")] + public int TrainingModuleEnum { get; set; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + [Comment("开始时间")] + [Column(TypeName = "datetime")] + public DateTime? StartTime { get; set; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + [Comment("结束时间")] + [Column(TypeName = "datetime")] + public DateTime? EndTime { get; set; } + + /// + ///老师Id + /// + [Display(Name = "老师Id")] + [Comment("老师Id")] + [Column(TypeName = "int")] + public int TeacherId { get; set; } + + /// + /// 老师姓名 + /// + [Display(Name = "老师姓名")] + [Comment("老师姓名")] + [Column(TypeName = "nvarchar(200)")] + public string TeacherName { get; set; } + + /// + /// 参与人数 + /// + [Display(Name = "参与人数")] + [Comment("参与人数")] + [Column(TypeName = "int")] + public int ParticipateCount { get; set; } + + /// + /// 班级下学生人数 + /// + [Display(Name = "班级下学生人数")] + [Comment("班级下学生人数")] + [Column(TypeName = "int")] + public int StudentCount { get; set; } + + /// + /// 缺勤人数 + /// + [Display(Name = "缺勤人数")] + [Comment("缺勤人数")] + [Column(TypeName = "int")] + public int NoParticipateCount { get; set; } + + /// + /// 新增人数 + /// + [Display(Name = "新增人数")] + [Comment("新增人数")] + [Column(TypeName = "int")] + public int AddCount { get; set; } + + /// + ///备注 + /// + [Display(Name = "备注")] + [Comment("备注")] + [Column(TypeName = "text")] + public string? Remarks { get; set; } + + /// + /// 当前年份 + /// + [Display(Name = "当前年份")] + [Comment("当前年份")] + [Column(TypeName = "int)")] + public int Year { get; set; } + + /// + /// 学期 + /// + [Display(Name = "学期")] + [Comment("学期")] + [Column(TypeName = "int)")] + public int Semester { get; set; } + + /// + /// 是否显示 + /// + [Display(Name = "是否显示")] + [Comment("是否显示")] + [Column(TypeName = "bit")] + [Editable(true)] + public bool IsDisplay { get; set; } + + public List ClassroomStudentRecord { get; set; } + } +} diff --git a/WeChatApplet/SmartSportsEntitys/Ai_ClassroomStudentRecord.cs b/WeChatApplet/SmartSportsEntitys/Ai_ClassroomStudentRecord.cs new file mode 100644 index 0000000..4c23ffd --- /dev/null +++ b/WeChatApplet/SmartSportsEntitys/Ai_ClassroomStudentRecord.cs @@ -0,0 +1,127 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace YD_WeChatApplet.Api.SmartSportsEntitys +{ + [Table("Ai_ClassroomStudentRecord")] + public class Ai_ClassroomStudentRecord + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Display(Description = "主键Id")] + [Comment("Id")] + public int Id { get; set; } + + /// + ///学校Code + /// + [Display(Name = "学校Code")] + [Comment("学校Code")] + [Column(TypeName = "nvarchar(100)")] + public string SchoolCode { get; set; } + + /// + /// AI设备的唯一编码 + /// + [Display(Name = "AI设备的唯一编码")] + [Comment("AI设备的唯一编码")] + [Column(TypeName = "nvarchar(100)")] + public string Code { get; set; } + + /// + /// 课堂记录Id + /// + [Display(Name = "课堂记录Id")] + [Comment("课堂记录Id")] + [Column(TypeName = "int")] + public int ClassRoomRecordId { get; set; } + + /// + /// 年级编号 + /// + [Display(Name = "年级编号")] + [Comment("年级编号")] + [Column(TypeName = "int")] + public int GradeId { get; set; } + + /// + ///班级Id + /// + [Display(Name = "班级Id")] + [Comment("班级Id")] + [Column(TypeName = "int")] + public int ClassId { get; set; } + + /// + /// 年级名称 + /// + [Display(Name = "年级名称")] + [Comment("年级名称")] + [Column(TypeName = "nvarchar(100)")] + public string? GradeName { get; set; } + + /// + /// 班级名称 + /// + [Display(Name = "班级名称")] + [Comment("班级名称")] + [Column(TypeName = "nvarchar(100)")] + public string? ClassName { get; set; } + + /// + ///老师Id + /// + [Display(Name = "老师Id")] + [Comment("老师Id")] + [Column(TypeName = "int")] + public int TeacherId { get; set; } + + /// + ///学号 + /// + [Display(Name = "学号")] + [Comment("学号")] + [Column(TypeName = "nvarchar(100)")] + public string StudentNo { get; set; } + + /// + ///姓名 + /// + [Display(Name = "姓名")] + [Comment("姓名")] + [Column(TypeName = "nvarchar(100)")] + public string? StudentName { get; set; } + + /// + ///性别 + /// + [Display(Name = "性别")] + [Comment("学校Co性别de")] + [Column(TypeName = "int")] + public int Sex { get; set; } + + /// + ///年龄 + /// + [Display(Name = "年龄")] + [Comment("年龄")] + [Column(TypeName = "int")] + public int Age { get; set; } + + /// + /// 是否显示 + /// + [Display(Name = "是否显示")] + [Comment("是否显示")] + [Column(TypeName = "bit")] + [Editable(true)] + public bool IsDisplay { get; set; } + + public Ai_ClassRoomRecord ClassRoomRecord { get; set; } + } +} diff --git a/WeChatApplet/SmartSportsEntitys/Ai_FastJumpRopeData.cs b/WeChatApplet/SmartSportsEntitys/Ai_FastJumpRopeData.cs new file mode 100644 index 0000000..dfb9044 --- /dev/null +++ b/WeChatApplet/SmartSportsEntitys/Ai_FastJumpRopeData.cs @@ -0,0 +1,230 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace YD_WeChatApplet.Api.SmartSportsEntitys +{ + [Table("Ai_FastJumpRopeData")] + public class Ai_FastJumpRopeData + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Display(Description = "主键Id")] + [Comment("Id")] + public int Id { get; set; } + + /// + ///学校Code + /// + [Display(Name = "学校Code")] + [Comment("学校Code")] + [Column(TypeName = "nvarchar(100)")] + public string SchoolCode { get; set; } + + /// + /// AI设备的唯一编码 + /// + [Display(Name = "AI设备的唯一编码")] + [Comment("AI设备的唯一编码")] + [Column(TypeName = "nvarchar(100)")] + public string Code { get; set; } + + /// + /// 课堂记录Id + /// + [Display(Name = "课堂记录Id")] + [Comment("课堂记录Id")] + [Column(TypeName = "int")] + public int ClassRoomRecordId { get; set; } + + /// + /// GroupId + /// + [Display(Name = "GroupId")] + [Comment("GroupId")] + [Column(TypeName = "nvarchar(100)")] + public string GroupId { get; set; } + + /// + /// 设备上传成绩时唯一标识, 重复时服务端不保存数据 + /// + [Display(Name = "设备上传成绩时唯一标识, 重复时服务端不保存数据")] + [Comment("设备上传成绩时唯一标识, 重复时服务端不保存数据")] + public long UniqueId { get; set; } + + /// + /// 模式类型 + /// + [Display(Name = "模式类型")] + [Comment("模式类型")] + [Column(TypeName = "int")] + public int ModeType { get; set; } + + /// + /// 模式名称 + /// + [Display(Name = "模式名称")] + [Comment("模式名称")] + [Column(TypeName = "nvarchar(100)")] + public string ModelName { get; set; } + + /// + /// 年级编号 + /// + [Display(Name = "年级编号")] + [Comment("年级编号")] + [Column(TypeName = "int")] + public int GradeId { get; set; } + + /// + ///班级Id + /// + [Display(Name = "班级Id")] + [Comment("班级Id")] + [Column(TypeName = "int")] + public int ClassId { get; set; } + + /// + /// 年级名称 + /// + [Display(Name = "年级名称")] + [Comment("年级名称")] + [Column(TypeName = "nvarchar(100)")] + public string GradeName { get; set; } + + /// + /// 班级名称 + /// + [Display(Name = "班级名称")] + [Comment("班级名称")] + [Column(TypeName = "nvarchar(100)")] + public string ClassName { get; set; } + + /// + /// 测试人数 + /// + [Display(Name = "测试人数")] + [Comment("测试人数")] + [Column(TypeName = "int")] + public int? StudentCount { get; set; } + + /// + ///老师Id + /// + [Display(Name = "老师Id")] + [Comment("老师Id")] + [Column(TypeName = "int")] + public int TeacherId { get; set; } + + /// + /// 训练模块[[1:专项教学/2:测评考级/3:AI赛场/4:AI体测/5:速度跳绳] + /// + [Display(Name = "训练模块[[1:专项教学/2:测评考级/3:AI赛场/4:AI体测/5:速度跳绳]")] + [Comment("训练模块[[1:专项教学/2:测评考级/3:AI赛场/4:AI体测]/5:速度跳绳")] + [Column(TypeName = "int")] + public int TrainingModule { get; set; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + [Comment("开始时间")] + [Column(TypeName = "datetime")] + public DateTime? StartTime { get; set; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + [Comment("结束时间")] + [Column(TypeName = "datetime")] + public DateTime? EndTime { get; set; } + + /// + ///测试时间 + /// + [Display(Name = "测试时间")] + [Comment("测试时间")] + [Column(TypeName = "datetime")] + [Editable(true)] + public DateTime ScoreTime { get; set; } + + /// + ///学号 + /// + [Display(Name = "学号")] + [Comment("学号")] + [Column(TypeName = "nvarchar(100)")] + public string StudentNo { get; set; } + + /// + ///姓名 + /// + [Display(Name = "姓名")] + [Comment("姓名")] + [Column(TypeName = "nvarchar(100)")] + public string StudentName { get; set; } + + /// + ///性别 + /// + [Display(Name = "性别")] + [Comment("学校Co性别de")] + [Column(TypeName = "int")] + public int Sex { get; set; } + + /// + ///运动时长/分钟 + /// + [Display(Name = "运动时长/秒")] + [Comment("运动时长/秒")] + [Column(TypeName = "int")] + public int? MotionDuration { get; set; } + + /// + /// 训练成绩等级[1:优秀,2:良好,3:及格,4:不及格] + /// 心率项目[1:达标,2:未达标] + /// + [Display(Name = "训练成绩等级")] + [Comment("训练成绩等级")] + [Column(TypeName = "int")] + public int RankEnum { get; set; } + + /// + /// 等级 + /// + [Display(Name = "等级")] + [Comment("等级")] + [Column(TypeName = "nvarchar(100)")] + public string Rank { get; set; } + + /// + ///错误个数[敏捷:错误个数] + /// + [Display(Name = "错误个数")] + [Comment("错误个数")] + [Column(TypeName = "int")] + public int? ErrorNumber { get; set; } + + /// + ///正确个数[敏捷:正确个数] + /// + [Display(Name = "正确个数")] + [Comment("正确个数")] + [Column(TypeName = "int")] + public int? JumpValue { get; set; } + + /// + /// 是否显示 + /// + [Display(Name = "是否显示")] + [Comment("是否显示")] + [Column(TypeName = "bit")] + [Editable(true)] + public bool IsDisplay { get; set; } + } +} diff --git a/WeChatApplet/SmartSportsEntitys/Ai_HeartRateData.cs b/WeChatApplet/SmartSportsEntitys/Ai_HeartRateData.cs new file mode 100644 index 0000000..7a8a2a5 --- /dev/null +++ b/WeChatApplet/SmartSportsEntitys/Ai_HeartRateData.cs @@ -0,0 +1,174 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace YD_WeChatApplet.Api.SmartSportsEntitys +{ + [Table("Ai_HeartRateData")] + public class Ai_HeartRateData + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Display(Description = "主键Id")] + [Comment("Id")] + public int Id { get; set; } + + /// + ///学校Code + /// + [Display(Name = "学校Code")] + [Comment("学校Code")] + [Column(TypeName = "nvarchar(100)")] + public string SchoolCode { get; set; } + + /// + /// AI设备的唯一编码 + /// + [Display(Name = "AI设备的唯一编码")] + [Comment("AI设备的唯一编码")] + [Column(TypeName = "nvarchar(100)")] + public string Code { get; set; } + + /// + /// 课堂记录Id + /// + [Display(Name = "课堂记录Id")] + [Comment("课堂记录Id")] + [Column(TypeName = "int")] + public int ClassRoomRecordId { get; set; } + + /// + /// 年级编号 + /// + [Display(Name = "年级编号")] + [Comment("年级编号")] + [Column(TypeName = "int")] + public int GradeId { get; set; } + + /// + ///班级Id + /// + [Display(Name = "班级Id")] + [Comment("班级Id")] + [Column(TypeName = "int")] + public int ClassId { get; set; } + + /// + /// 年级名称 + /// + [Display(Name = "年级名称")] + [Comment("年级名称")] + [Column(TypeName = "nvarchar(100)")] + public string GradeName { get; set; } + + /// + /// 班级名称 + /// + [Display(Name = "班级名称")] + [Comment("班级名称")] + [Column(TypeName = "nvarchar(100)")] + public string ClassName { get; set; } + + /// + /// 班级人数 + /// + //[Display(Name = "班级人数")] + //[Comment("班级人数")] + //[Column(TypeName = "int")] + //public int StudentCount { get; set; } + + /// + ///老师Id + /// + [Display(Name = "老师Id")] + [Comment("老师Id")] + [Column(TypeName = "int")] + public int TeacherId { get; set; } + + /// + ///学号 + /// + [Display(Name = "学号")] + [Comment("学号")] + [Column(TypeName = "nvarchar(100)")] + public string StudentNo { get; set; } + + /// + ///姓名 + /// + [Display(Name = "姓名")] + [Comment("姓名")] + [Column(TypeName = "nvarchar(100)")] + public string StudentName { get; set; } + + /// + ///性别 + /// + [Display(Name = "性别")] + [Comment("学校Co性别de")] + [Column(TypeName = "int")] + public int Sex { get; set; } + + /// + ///测试时间 + /// + [Display(Name = "测试时间")] + [Comment("测试时间")] + [Column(TypeName = "datetime")] + [Editable(true)] + public DateTime ScoreTime { get; set; } + + /// + ///运动时长/分钟 + /// + [Display(Name = "运动时长/分钟")] + [Comment("运动时长/分钟")] + [Column(TypeName = "int")] + public int MotionDuration { get; set; } + + /// + ///运动消耗 + /// + [Display(Name = "运动消耗")] + [Comment("运动消耗")] + [Column(TypeName = "int")] + public int? Consumption { get; set; } + + /// + ///运动强度 + /// + [Display(Name = "运动强度")] + [Comment("运动强度")] + [Column(TypeName = "double")] + public double Strength { get; set; } + + /// + ///心率 + /// + [Display(Name = "心率")] + [Comment("心率")] + [Column(TypeName = "double")] + public double Value { get; set; } + + /// + ///备注 + /// + [Display(Name = "备注")] + [Comment("备注")] + [Column(TypeName = "text")] + public string? Remarks { get; set; } + + /// + /// 是否显示 + /// + [Display(Name = "是否显示")] + [Comment("是否显示")] + [Column(TypeName = "bit")] + [Editable(true)] + public bool IsDisplay { get; set; } + } +} diff --git a/WeChatApplet/Startup.cs b/WeChatApplet/Startup.cs index 41c3cf6..2bb5f87 100644 --- a/WeChatApplet/Startup.cs +++ b/WeChatApplet/Startup.cs @@ -8,7 +8,6 @@ using YD_WeChatApplet.Context; using Microsoft.EntityFrameworkCore; using YD_WeChatApplet.Services; using YD_WeChatApplet.Commons.Filters; -using YD_WeChatApplet.Commons.MemoryCaches; using YD_WeChatApplet.Commons.Users; using Newtonsoft.Json.Serialization; using Microsoft.AspNetCore.Authentication.JwtBearer; @@ -68,7 +67,6 @@ namespace YD_WeChatApplet services.AddScoped(); services.AddScoped(); - services.AddScoped(); services.AddScoped(); services.AddSession(); services.AddMemoryCache(); @@ -281,13 +279,13 @@ namespace YD_WeChatApplet //配置HttpContext app.UseStaticHttpContext(); - //app.UseSwagger(); - //app.UseSwaggerUI(c => - //{ - // //2个下拉框选项 选择对应的文档 - // c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api"); - // c.RoutePrefix = ""; - //}); + app.UseSwagger(); + app.UseSwaggerUI(c => + { + //2个下拉框选项 选择对应的文档 + c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api"); + c.RoutePrefix = ""; + }); app.UseRouting(); app.UseCors(); diff --git a/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassReportDetailsDto.cs b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassReportDetailsDto.cs new file mode 100644 index 0000000..3ad5298 --- /dev/null +++ b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassReportDetailsDto.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YD_WeChatApplet.Commons.Dto.ClassRoomRecord +{ + /// + /// 课堂详情 + /// + public class ClassReportDetailsDto + { + /// + /// 最大心率 + /// + public int MaxHR { get; set; } + + /// + /// 最小心率 + /// + public int MinHR { get; set; } + + /// + /// 平均心率 + /// + public int AvgHR { get; set; } + + /// + /// 中高强度时长 + /// + public int HighIntensity { get; set; } + + /// + /// 学生运动记录 + /// + public List StudentTrainingRecordList { get; set; } = new List(); + + /// + /// 心率变化趋势 + /// + public ChartDataDto HeartRateTrend { get; set; } = new ChartDataDto(); + } + + /// + /// 学生训练记录 + /// + public class StudentTrainingRecordDto + { + /// + ///学号 + /// + public string? StudentNo { get; set; } + + /// + ///姓名 + /// + public string? StudentName { get; set; } + + /// + ///性别 + /// + public int Sex { get; set; } + + /// + ///年龄 + /// + public int Age { get; set; } + } +} diff --git a/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordDto.cs b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordDto.cs new file mode 100644 index 0000000..eb0cee5 --- /dev/null +++ b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordDto.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YD_WeChatApplet.Commons.Dto.ClassRoomRecord +{ + /// + /// 课堂列表 + /// + public class ClassRoomRecordDto : PageDto + { + /// + /// 学号 + /// + public string StudentNo { get; set; } + } +} diff --git a/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordPageDto.cs b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordPageDto.cs new file mode 100644 index 0000000..cf22b34 --- /dev/null +++ b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/ClassRoomRecordPageDto.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YD_WeChatApplet.Commons.Dto.ClassRoomRecord +{ + /// + /// 课堂记录 + /// + public class ClassRoomRecordPageDto + { + /// + /// 课堂记录ID + /// + public int? Id { get; set; } + + /// + ///课堂名称 + /// + public string Name { get; set; } + + /// + /// 班级Id + /// + public int? ClassId { get; set; } + + /// + /// 课程起止时间 + /// + public string StartingEndingTime { get; set; } + } +} diff --git a/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/StudentClassRoomReportDto.cs b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/StudentClassRoomReportDto.cs new file mode 100644 index 0000000..a82303e --- /dev/null +++ b/YD_WeChatApplet.Commons/Dto/ClassRoomRecord/StudentClassRoomReportDto.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YD_WeChatApplet.Commons.Dto.ClassRoomRecord +{ + /// + /// 学员课堂报告 + /// + public class StudentClassRoomReportDto + { + /// + /// 最大心率 + /// + public int MaxHR { get; set; } + + /// + /// 最小心率 + /// + public int MinHR { get; set; } + + /// + /// 平均心率 + /// + public int AvgHR { get; set; } + + /// + /// 中高强度时长 + /// + public int HighIntensity { get; set; } + + /// + /// 跳绳记录 + /// + public List JumpRecordList { get; set; } = new List(); + + /// + /// 心率变化趋势 + /// + public ChartDataDto HeartRateTrend { get; set; } = new ChartDataDto(); + } + + public class JumpRecordListDto + { + /// + /// 跳绳类型 + /// + public string JumpType { get; set; } + + /// + /// 总个数 + /// + public int TotalCount { get; set; } + + /// + /// 总时长 + /// + public int TotalDuration { get; set; } + } +} diff --git a/YD_WeChatApplet.Commons/MemoryCaches/AddMemoryCacheSetup.cs b/YD_WeChatApplet.Commons/MemoryCaches/AddMemoryCacheSetup.cs deleted file mode 100644 index ef0f278..0000000 --- a/YD_WeChatApplet.Commons/MemoryCaches/AddMemoryCacheSetup.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.DependencyInjection; -using System; - -namespace YD_WeChatApplet.Commons.MemoryCaches -{ - public static class MemoryCacheSetup - { - public static void AddMemoryCacheSetup(this IServiceCollection services) - { - if (services == null) throw new ArgumentNullException(nameof(services)); - - services.AddScoped(); - services.AddScoped(factory => - { - var cache = new MemoryCache(new MemoryCacheOptions()); - return cache; - }); - } - } -} diff --git a/YD_WeChatApplet.Commons/MemoryCaches/ICaching.cs b/YD_WeChatApplet.Commons/MemoryCaches/ICaching.cs deleted file mode 100644 index 28cc27f..0000000 --- a/YD_WeChatApplet.Commons/MemoryCaches/ICaching.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace YD_WeChatApplet.Commons.MemoryCaches -{ - /// - /// 缓存接口 - /// - public interface ICaching - { - object Get(string cacheKey); - - void Set(string cacheKey, object cacheValue, int seconds); - - void Set(string cacheKey, object cacheValue); - - void Update(string cacheKey, object cacheValue, int seconds); - - void Remove(string cacheKey); - } -} diff --git a/YD_WeChatApplet.Commons/MemoryCaches/MemoryCaching.cs b/YD_WeChatApplet.Commons/MemoryCaches/MemoryCaching.cs deleted file mode 100644 index 1a15870..0000000 --- a/YD_WeChatApplet.Commons/MemoryCaches/MemoryCaching.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.Extensions.Caching.Memory; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace YD_WeChatApplet.Commons.MemoryCaches -{ - /// - /// 实例化缓存接口ICaching - /// - public class MemoryCaching : ICaching - { - private readonly IMemoryCache _cache; - - /// - /// 构造函数 - /// - /// - public MemoryCaching(IMemoryCache cache) - { - _cache = cache; - } - - public object Get(string cacheKey) - { - return _cache.Get(cacheKey); - } - - public void Update(string cacheKey, object cacheValue, int seconds) - { - _cache.Remove(cacheKey); - - _cache.Set(cacheKey, cacheValue, TimeSpan.FromSeconds(seconds)); - } - - public void Set(string cacheKey, object cacheValue, int seconds) - { - _cache.Set(cacheKey, cacheValue, TimeSpan.FromSeconds(seconds)); - } - - public void Set(string cacheKey, object cacheValue) - { - _cache.Set(cacheKey, cacheValue); - } - - public void Remove(string cacheKey) - { - _cache.Remove(cacheKey); - } - } -} diff --git a/YD_WeChatApplet.Commons/YD_WeChatApplet.Commons.csproj b/YD_WeChatApplet.Commons/YD_WeChatApplet.Commons.csproj index 45c1d8d..dbbb1e9 100644 --- a/YD_WeChatApplet.Commons/YD_WeChatApplet.Commons.csproj +++ b/YD_WeChatApplet.Commons/YD_WeChatApplet.Commons.csproj @@ -12,7 +12,6 @@ -