From f5451816800533b8931987a2c97c83e7fced9e3a Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Tue, 30 Jun 2026 15:12:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=BE=9B=E6=9C=AA=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YD_YiLu/AutoMappers/MappingProfile.cs | 10 - YD_YiLu/Context/SmartSportsContext.cs | 6 - YD_YiLu/Controllers/LargeScreenController.cs | 68 -- YD_YiLu/Controllers/XinWeiController.cs | 250 ---- YD_YiLu/Services/Impl/LargeScreenService.cs | 362 ------ YD_YiLu/Services/Impl/XinWeiService.cs | 1067 ----------------- .../Services/Interface/ILargeScreenService.cs | 35 - YD_YiLu/Services/Interface/IXinWeiService.cs | 137 --- YD_YiLu/SmartSportsEntitys/XW_ProjectMode.cs | 48 - .../SmartSportsEntitys/XW_SportsTestData.cs | 604 ---------- .../SmartSportsEntitys/XW_TestingProject.cs | 80 -- YD_YiLu/SmartSportsEntitys/XW_TrainSetting.cs | 108 -- .../SmartSportsEntitys/XW_TrainStudents.cs | 361 ------ .../XW_TrainViolationsBO.cs | 53 - YD_YiLu/Startup.cs | 2 - 15 files changed, 3191 deletions(-) delete mode 100644 YD_YiLu/Controllers/LargeScreenController.cs delete mode 100644 YD_YiLu/Controllers/XinWeiController.cs delete mode 100644 YD_YiLu/Services/Impl/LargeScreenService.cs delete mode 100644 YD_YiLu/Services/Impl/XinWeiService.cs delete mode 100644 YD_YiLu/Services/Interface/ILargeScreenService.cs delete mode 100644 YD_YiLu/Services/Interface/IXinWeiService.cs delete mode 100644 YD_YiLu/SmartSportsEntitys/XW_ProjectMode.cs delete mode 100644 YD_YiLu/SmartSportsEntitys/XW_SportsTestData.cs delete mode 100644 YD_YiLu/SmartSportsEntitys/XW_TestingProject.cs delete mode 100644 YD_YiLu/SmartSportsEntitys/XW_TrainSetting.cs delete mode 100644 YD_YiLu/SmartSportsEntitys/XW_TrainStudents.cs delete mode 100644 YD_YiLu/SmartSportsEntitys/XW_TrainViolationsBO.cs diff --git a/YD_YiLu/AutoMappers/MappingProfile.cs b/YD_YiLu/AutoMappers/MappingProfile.cs index b73cfc0..6d1b899 100644 --- a/YD_YiLu/AutoMappers/MappingProfile.cs +++ b/YD_YiLu/AutoMappers/MappingProfile.cs @@ -16,16 +16,6 @@ namespace YD_YiLu.Api.AutoMappers //CreateMap(); CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); } } } diff --git a/YD_YiLu/Context/SmartSportsContext.cs b/YD_YiLu/Context/SmartSportsContext.cs index e9f3d99..058f251 100644 --- a/YD_YiLu/Context/SmartSportsContext.cs +++ b/YD_YiLu/Context/SmartSportsContext.cs @@ -24,12 +24,6 @@ namespace YD_YiLu.Api.Context public DbSet SportsTestCategory { get; set; } public DbSet SportsTestValue { get; set; } - public DbSet XW_ProjectMode { get; set; } - public DbSet XW_TestingProject { get; set; } - public DbSet XW_SportsTestData { get; set; } - public DbSet XW_TrainStudents { get; set; } - public DbSet XW_TrainSetting { get; set; } - public DbSet XW_TrainViolationsBO { get; set; } public DbSet YL_Device { get; set; } public DbSet YL_Train { get; set; } public DbSet YL_DeviceVideo { get; set; } diff --git a/YD_YiLu/Controllers/LargeScreenController.cs b/YD_YiLu/Controllers/LargeScreenController.cs deleted file mode 100644 index b0710b5..0000000 --- a/YD_YiLu/Controllers/LargeScreenController.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using YD_YiLu.Api.Services.Impl; -using YD_YiLu.Api.Services.Interface; -using YD_YiLu.Commons.Dto; -using YD_YiLu.Commons.Dto.LargeScreen; -using YD_YiLu.Commons.Dto.Open; - -namespace YD_YiLu.Api.Controllers -{ - /// - /// 大屏数据 - /// - [ApiVersion("1.0")] - [AllowAnonymous] - public class LargeScreenController : ControllerBase - { - private readonly ILargeScreenService _largeScreenService; - - /// - /// 构造函数 - /// - /// - public LargeScreenController(ILargeScreenService largeScreenService) - { - _largeScreenService = largeScreenService; - } - - /// - /// 获取项目列表 - /// - /// - [HttpGet] - [Route("/LargeScreen/{apiVersion}/SportsProjectList")] - public async Task> SportsProjectList(int orgId) - { - var res = await _largeScreenService.SportsProjectList(orgId); - return res; - } - - /// - /// 项目成绩大屏数据 - /// - /// - [HttpGet] - [Route("/LargeScreen/{apiVersion}/ItemResultLargeScreenData")] - public async Task ItemResultLargeScreenData(int orgId) - { - var res = await _largeScreenService.ItemResultLargeScreenData(orgId); - return res; - } - - /// - /// 各项目实时成绩 - /// - /// - /// - /// - [HttpGet] - [Route("/LargeScreen/{apiVersion}/ItemRealTimeResult")] - public async Task> ItemRealTimeResult(int orgId, DateTime? lastTime = null) - { - var res = await _largeScreenService.ItemRealTimeResult(orgId, lastTime); - return res; - } - } -} diff --git a/YD_YiLu/Controllers/XinWeiController.cs b/YD_YiLu/Controllers/XinWeiController.cs deleted file mode 100644 index 6e05590..0000000 --- a/YD_YiLu/Controllers/XinWeiController.cs +++ /dev/null @@ -1,250 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using YD_YiLu.Api.Services.Impl; -using YD_YiLu.Api.Services.Interface; -using YD_YiLu.Commons.Dto.Common; -using YD_YiLu.Commons.Dto.Open; -using YD_YiLu.Commons.Dto.School; - -namespace YD_YiLu.Api.Controllers -{ - /// - /// 芯未 - /// - [ApiVersion("1.0")] - [AllowAnonymous] - public class XinWeiController : ControllerBase - { - private readonly IXinWeiService _xinWeiService; - public XinWeiController(IXinWeiService xinWeiService) - { - _xinWeiService = xinWeiService; - } - - /// - /// 获取设备信息 - /// - /// - [HttpGet] - [Route("/basic/{apiVersion}/device/open/getDeviceInfo")] - public async Task GetDeviceInfo(string deviceSerial) - { - var res = await _xinWeiService.DeviceInfo(deviceSerial); - return res; - } - - /// - /// 获取项目模式列表 - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/common/getSportsModelTypeList")] - public async Task> GetSportsModelTypeList() - { - var res = await _xinWeiService.SportsModelTypeList(); - return res; - } - - /// - /// 获取体育项目列表 - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/common/getOrgSportsProjectList")] - public async Task> GetOrgSportsProjectList(int orgId) - { - var res = await _xinWeiService.OrgSportsProjectList(orgId); - return res; - } - - /// - /// 获取学生信息 - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/roster/getMinimumOfStudentInfoList")] - public async Task> GetMinimumOfStudentInfoList(int orgId) - { - var res = await _xinWeiService.MinimumOfStudentInfoList(orgId); - return res; - } - - /// - /// 获取名单列表 - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/roster/getSportsRosterList")] - public async Task> GetSportsRosterList(int orgId, int userId) - { - var res = await _xinWeiService.SportsRosterList(orgId, userId); - return res; - } - - /// - /// 获取人脸信息 - /// - /// - /// - [HttpGet] - [Route("/basic/{apiVersion}/open/getFaceListOfDevicePage")] - public async Task GetFaceListOfDevicePage([FromQuery] FaceListOfDeviceDto dto) - { - var res = await _xinWeiService.FaceListOfDevicePage(dto); - return res; - } - - /// - /// 查询训练评分规则 - /// - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/project/getScoreRules")] - public async Task> GetScoreRules(int orgId) - { - var res = await _xinWeiService.ScoreRules(orgId); - return res; - } - - /// - /// 新增训练 - /// - /// - /// - [HttpPost] - [Route("/sports/{apiVersion}/train/addTrain")] - public async Task AddTrain([FromBody] AddTrainDto dto) - { - Console.WriteLine("开始上传"); - var res = await _xinWeiService.AddTrain(dto); - return res; - } - - - /// - /// 年级排名 - /// - /// - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/trainAnalysis/gradeRankingGet")] - public async Task GradeRankingGet(int studentId, int trainId) - { - var res = await _xinWeiService.GradeRankingGet(studentId, trainId); - return res; - } - - /// - /// 全部历史记录 - /// - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/trainAnalysis/history/get")] - public async Task HistoryGet(HistoryGetDto dto) - { - var res = await _xinWeiService.HistoryGet(dto); - return res; - } - - /// - /// 历史记录详细 - /// - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/trainAnalysis/history/detail")] - public async Task TrainAnalysisHistoryDetail(HistoryDetailRequestDto dto) - { - var res = await _xinWeiService.TrainAnalysisHistoryDetail(dto); - return res; - } - - /// - /// 个人历史记录-历史成绩 - /// - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/trainAnalysis/history/person/get")] - public async Task HistoryPersonGet(HistoryPersonGetDto dto) - { - var res = await _xinWeiService.HistoryPersonGet(dto); - return res; - } - - /// - /// 个人历史记录-记录列表 - /// - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/trainAnalysis/history/person/list")] - public async Task HistoryPersonListGet(HistoryPersonListDto dto) - { - if (dto.ModelType==7) - { - dto.IsAsc = "asc"; - dto.OrderByColumn = "Achievement"; - } - - var res = await _xinWeiService.HistoryPersonListGet(dto); - return res; - } - - /// - /// 成绩榜-年级列表 - /// - /// - /// - [HttpGet] - [Route("/basic/{apiVersion}/open/getGradeListByOrg")] - public async Task> GetGradeListByOrg(int orgId) - { - var res = await _xinWeiService.GetGradeListByOrg(orgId); - return res; - } - - /// - /// 个人历史记录-榜单列表 - /// - /// - /// - [HttpGet] - [Route("/sports/{apiVersion}/trainAnalysis/scoreRanking/list")] - public async Task ScoreRanking(ScoreRankingDto dto) - { - var res = await _xinWeiService.ScoreRanking(dto); - return res; - } - - /// - /// 获取成绩榜中显示的体育项目 - /// - /// - /// - [HttpGet] - [Route("/screen/sports/getProjectInfo")] - public async Task> GetProjectInfo(int orgId) - { - var res = await _xinWeiService.GetProjectInfo(orgId); - return res; - } - - /// - /// 设备端人脸录入 - /// - /// - [HttpPut] - [Route("/basic/{apiVersion}/open/addWeBankUserFace")] - public async Task AddWeBankUserFace([FromForm] IFormFile picUrlA, [FromForm] int userId) - { - Console.WriteLine($"picUrlA == null? {picUrlA == null}, userId={userId}"); - var res = await _xinWeiService.AddWeBankUserFace(new AddWeBankUserFaceDto() { PicUrlA = picUrlA, UserId = userId }); - return res; - } - } -} diff --git a/YD_YiLu/Services/Impl/LargeScreenService.cs b/YD_YiLu/Services/Impl/LargeScreenService.cs deleted file mode 100644 index 8a791cc..0000000 --- a/YD_YiLu/Services/Impl/LargeScreenService.cs +++ /dev/null @@ -1,362 +0,0 @@ -using AutoMapper; -using Microsoft.EntityFrameworkCore; -using VOL.Commons; -using YD_YiLu.Api.Context; -using YD_YiLu.Api.Services.Interface; -using YD_YiLu.Api.SmartSportsEntitys; -using YD_YiLu.Api.Utilities; -using YD_YiLu.Commons; -using YD_YiLu.Commons.Dto.LargeScreen; - -namespace YD_YiLu.Api.Services.Impl -{ - /// - /// 大屏服务 - /// - public class LargeScreenService : ILargeScreenService - { - public SmartSportsContext _sportsContext; - private readonly IMapper _mapper; - private readonly ICacheService _caching; - - /// - /// 构造 - /// - /// - /// - public LargeScreenService(SmartSportsContext sportsContext, IMapper mapper, ICacheService caching) - { - _sportsContext = sportsContext; - _mapper = mapper; - _caching = caching; - } - - /// - /// 获取项目列表 - /// - /// - /// - public async Task> SportsProjectList(int orgId) - { - var testingProjectKey = $"TestingProject_{orgId}"; - - var res = _caching.Get>(testingProjectKey); - - if (res == null || res.Count == 0) - { - res = await _sportsContext.XW_TestingProject.Where(x => x.OrgId == orgId) - .Select(x => new SportsProjectListDto() - { - ProjectId = x.ProjectId, - ProjectName = x.ProjectName, - CategoryValue = x.CategoryValue, - CategoryEnum = x.CategoryEnum, - Unit = ((SportsTestItemType)x.CategoryValue).GetUnit() - }).ToListAsync(); - } - - return res; - } - - /// - /// 项目成绩大屏数据 - /// - /// - /// - public async Task ItemResultLargeScreenData(int orgId) - { - var res = new LargeScreenDto(); - - var schoolKeyKey = $"School_{orgId}"; - - var schoolCode = _caching.Get(schoolKeyKey); - - if (string.IsNullOrWhiteSpace(schoolCode)) - { - schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync(); - _caching.Add(schoolKeyKey, schoolCode); - } - - var sportsTestDataKey = $"SportsTestData_{schoolCode}"; - var studentListKey = $"StudentList_{schoolCode}"; - - var studentList = _caching.Get>(studentListKey); - - if (studentList == null || studentList.Count == 0) - { - studentList = await _sportsContext.Student.Where(x => x.SchoolCode == schoolCode).Select(x => new StudentListDto - { - StudentNo = x.StudentNo, - Sex = x.Sex, - Photo = x.Photo ?? "" - }).ToListAsync(); - _caching.AddObject(studentListKey, studentList, 3600); - } - - //var studentList = await _sportsContext.Student.Where(x => x.SchoolCode == schoolCode).Select(x => new StudentListDto - //{ - // StudentNo = x.StudentNo, - // Sex = x.Sex, - // Photo = x.Photo ?? "" - //}).ToListAsync(); - - res.BasicInfo.FemaleCount = studentList.Count(x => x.Sex == 2); - res.BasicInfo.MaleCount = studentList.Count(x => x.Sex == 1); - - var sportsTestData = _caching.Get>(sportsTestDataKey); - - if (sportsTestData == null || sportsTestData.Count == 0) - { - sportsTestData = await _sportsContext.SportsTestValue.Where(x => x.SchoolCode == schoolCode && x.DataSource == DataSource.XW) - .Select(x => new SportsTestDataDto() - { - SchoolCode = x.SchoolCode, - CategoryValue = x.CategoryValue, - ClassId = x.ClassId, - ClassName = x.ClassName, - GradeId = x.GradeId, - GradeName = x.GradeName, - TeacherId = x.TeacherId, - StudentNo = x.StudentNo, - StudentName = x.StudentName, - Sex = x.Sex, - ScoreTime = x.ScoreTime, - Height = x.Height, - Weight = x.Weight, - Value = x.Value, - Score = x.Score, - Rank = x.Rank - }).ToListAsync(); - _caching.AddObject(sportsTestDataKey, sportsTestData, 60); - } - - //var sportsTestData = _caching.Get>(sportsTestDataKey); - - //if (sportsTestData == null || sportsTestData.Count == 0) - //{ - // sportsTestData = await _sportsContext.SportsTestValue.Where(x => x.SchoolCode == schoolCode && x.DataSource == DataSource.XW) - // .Select(x => new SportsTestDataDto() - // { - // SchoolCode = x.SchoolCode, - // CategoryValue = x.CategoryValue, - // ClassId = x.ClassId, - // ClassName = x.ClassName, - // GradeId = x.GradeId, - // GradeName = x.GradeName, - // TeacherId = x.TeacherId, - // StudentNo = x.StudentNo, - // StudentName = x.StudentName, - // Sex = x.Sex, - // ScoreTime = x.ScoreTime, - // Height = x.Height, - // Weight = x.Weight, - // Value = x.Value, - // Score = x.Score, - // Rank = x.Rank - // }).ToListAsync(); - // //_caching.AddObject(sportsTestDataKey, sportsTestData, 60); - //} - - var bestScoreData = sportsTestData - .GroupBy(x => x.StudentNo) - .Select(g => g.OrderByDescending(x => x.Score).First()) - .ToList(); - - var projectResults = sportsTestData - .GroupBy(x => x.CategoryValue) - .Select(g => new ItemDataDto - { - CategoryValue = g.Key, - - // 优良率计算:分数 > 80 的人数 ÷ 总人数 - ExcellentRate = (int)Math.Round( - sportsTestData.Count(x => x.CategoryValue == g.Key && x.Score > 80) * 100.0 / - Math.Max(sportsTestData.Count(x => x.CategoryValue == g.Key), 1), - MidpointRounding.AwayFromZero - ), - - // 男生前十名 - MaleRankList = (g.Where(x => x.Sex == 1) - .OrderBy(x => g.Key == 3 ? x.Value : -x.Value) // 条件排序 - .Take(10) - .Select((x, index) => new StudentScoreRankingDto - { - Rank = index + 1, - StudentNo = x.StudentNo, - StudentName = x.StudentName, - Value = x.CategoryValue == 1 ? $"{x.Height}cm/{x.Weight}kg" : $"{x.Value}{((SportsTestItemType)x.CategoryValue).GetUnit()}" - })).ToList(), - - // 女生前十名 - FemaleRankList = (g.Where(x => x.Sex == 2) - .OrderBy(x => g.Key == 3 ? x.Value : -x.Value) // 条件排序 - .Take(10) - .Select((x, index) => new StudentScoreRankingDto - { - Rank = index + 1, - StudentNo = x.StudentNo, - StudentName = x.StudentName, - Value = x.CategoryValue == 1 ? $"{x.Height}cm/{x.Weight}kg" : $"{x.Value}{((SportsTestItemType)x.CategoryValue).GetUnit()}" - })).ToList() - }) - .ToList(); - - - res.ItemDatalist = projectResults; - - var classListKey = $"ClassList_{schoolCode}"; - - var classList = _caching.Get>(classListKey); - - if (classList == null || classList.Count == 0) - { - classList = await _sportsContext.Class.Where(x => x.SchoolCode == schoolCode).ToListAsync(); - _caching.AddObject(classListKey, classList, 3600); - } - - var classRankingList = sportsTestData - .GroupBy(x => new { x.ClassId }) - .Select(g => new ClassSportsRankingDto - { - ClassId = g.Key.ClassId, - ClassName = classList.Where(c => c.Id == g.Key.ClassId).Select(x => $"{x.GradeName}-{x.ClassName}").FirstOrDefault() ?? "", - Count = g.Count() - }) - .OrderByDescending(x => x.Count) - .Take(5) - .Select((x, index) => - { - x.Rank = index + 1; - return x; - }) - .ToList(); - - res.ClassSportsRankList = classRankingList; - - //var testingProjectKey = $"TestingProject_{orgId}"; - - //var testingProjects = _caching.Get>(testingProjectKey) ?? new List(); - //var projectNameDict = testingProjects.ToDictionary(t => t.CategoryValue, t => t.ProjectName); - - //var studentPhotoDict = studentList.Where(s => !string.IsNullOrEmpty(s.StudentNo)).ToDictionary(s => s.StudentNo, s => s.Photo ?? string.Empty); - - //var latestPerStudent = sportsTestData - // .GroupBy(x => x.StudentNo) - // .Select(g => g.OrderByDescending(x => x.ScoreTime).First()) - // .ToList(); - - //var realTimeResults = latestPerStudent - // .OrderByDescending(x => x.ScoreTime) - // .Take(50) - // .Select(x => new ItemRealTimeResultDto - // { - // StudentNo = x.StudentNo, - // StudentName = x.StudentName, - // Photo = studentPhotoDict.TryGetValue(x.StudentNo, out var photo) ? photo : string.Empty, - // GradeAndClassName = $"{x.GradeName}-{x.ClassName}", - // //ProjectName = projectNameDict.TryGetValue(x.CategoryValue, out var projectName) ? projectName : string.Empty, - // Value = x.Value, - // Score = x.Score, - // Rank = x.Rank ?? "不及格", - // ScoreTime = x.ScoreTime.ToString("yyyy-MM-dd HH:mm:ss") - // }).Reverse().ToList(); - - //res.ItemRealTimeResultList = realTimeResults; - - var today = DateTime.Today; - - // 本周一 - var startOfThisWeek = today.AddDays(-(int)today.DayOfWeek + 1); - - // 下周一(= 本周结束时间) - var startOfNextWeek = startOfThisWeek.AddDays(7); - - // 上周一 - var startOfLastWeek = startOfThisWeek.AddDays(-7); - - // 本周数据 - var thisWeekCount = sportsTestData - .Count(x => x.ScoreTime >= startOfThisWeek && x.ScoreTime < startOfNextWeek); - - // 上周数据 - var lastWeekCount = sportsTestData - .Count(x => x.ScoreTime >= startOfLastWeek && x.ScoreTime < startOfThisWeek); - - res.BasicInfo.WeekTrainingCount = thisWeekCount; - res.BasicInfo.Increase = thisWeekCount - lastWeekCount; - - return res; - } - - /// - /// 各项目实时成绩 - /// - /// - /// - /// - public async Task> ItemRealTimeResult(int orgId, DateTime? lastTime = null) - { - var schoolKeyKey = $"School_{orgId}"; - var schoolCode = _caching.Get(schoolKeyKey); - var testingProjectKey = $"TestingProject_{orgId}"; - var studentListKey = $"StudentList_{schoolCode}"; - //var studentList = _caching.Get>(studentListKey); - - var studentList = await _sportsContext.Student.Where(x => x.SchoolCode == schoolCode).Select(x => new StudentListDto - { - StudentNo = x.StudentNo, - Sex = x.Sex, - Photo = x.Photo ?? "" - }).ToListAsync(); - - var testingProjects = _caching.Get>(testingProjectKey) ?? new List(); - var projectNameDict = testingProjects.ToDictionary(t => t.CategoryValue, t => t.ProjectName); - var studentPhotoDict = studentList - .Where(s => !string.IsNullOrEmpty(s.StudentNo)) - .ToDictionary(s => s.StudentNo, s => s.Photo ?? string.Empty); - - // 1. 查询时只拉取需要的字段 - var sourceData = await _sportsContext.SportsTestValue - .Where(s => s.SchoolCode == schoolCode && s.DataSource == DataSource.XW - && (!lastTime.HasValue || s.ScoreTime > lastTime.Value)) - .OrderByDescending(s => s.ScoreTime) - .Select(s => new - { - s.StudentNo, - s.StudentName, - s.GradeName, - s.ClassName, - s.CategoryValue, - s.Value, - s.Weight, - s.Height, - s.Score, - s.Rank, - s.ScoreTime - }) - .Take(50) - .ToListAsync(); - - // 2. 内存分组取每个学生最新一条 - var latestPerStudent = sourceData.OrderBy(x => x.ScoreTime).ToList(); - - // 3. 映射到 DTO - var realTimeResults = latestPerStudent - .Select(x => new ItemRealTimeResultDto - { - StudentNo = x.StudentNo, - StudentName = x.StudentName, - Photo = studentPhotoDict.TryGetValue(x.StudentNo, out var photo) ? photo : string.Empty, - GradeAndClassName = $"{x.GradeName}-{x.ClassName}", - CategoryValue = x.CategoryValue, - Value = x.CategoryValue == 1 ? $"{x.Height}cm/{x.Weight}kg" : $"{x.Value}{((SportsTestItemType)x.CategoryValue).GetUnit()}", - Score = x.Score, - Rank = string.IsNullOrEmpty(x.Rank) ? "不及格" : x.Rank, - ScoreTime = x.ScoreTime.ToString("yyyy-MM-dd HH:mm:ss") - }) - .ToList(); - - return realTimeResults; - } - } -} diff --git a/YD_YiLu/Services/Impl/XinWeiService.cs b/YD_YiLu/Services/Impl/XinWeiService.cs deleted file mode 100644 index 48d355f..0000000 --- a/YD_YiLu/Services/Impl/XinWeiService.cs +++ /dev/null @@ -1,1067 +0,0 @@ -using AutoMapper; -using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json; -using System.Collections.Generic; -using System.Security.Cryptography; -using VOL.Entity.DomainModels.XinWei; -using YD_YiLu.Api.Context; -using YD_YiLu.Api.Services.Interface; -using YD_YiLu.Api.SmartSportsEntitys; -using YD_YiLu.Api.Utilities; -using YD_YiLu.Commons.Dto.Common; -using YD_YiLu.Commons.Dto.Open; -using YD_YiLu.Commons.Utils; -using System.Text.Json; -using VOL.Commons; - -namespace YD_YiLu.Api.Services.Impl -{ - /// - /// 服务实现 - /// - public class XinWeiService : IXinWeiService - { - public SmartSportsContext _sportsContext; - private readonly IMapper _mapper; - - /// - /// 构造 - /// - /// - /// - public XinWeiService(SmartSportsContext sportsContext, IMapper mapper) - { - _sportsContext = sportsContext; - _mapper = mapper; - } - - /// - /// 获取设备信息 - /// - /// - /// - /// - public async Task DeviceInfo(string deviceSerial) - { - var deviceInfo = await _sportsContext.YL_Device.FirstOrDefaultAsync(x => x.AndroidId == deviceSerial); - var res = _mapper.Map(deviceInfo); - return res; - } - - /// - /// 项目模式 - /// - /// - public async Task> SportsModelTypeList() - { - var res = await _sportsContext.XW_ProjectMode.Select(x => new ProjectModeDto() - { - Id = x.Id, - ProjectKind = x.ProjectKind, - Name = x.Name - }).ToListAsync(); - - return res; - } - - /// - /// 体育项目 - /// - /// 学校Id - /// - - public async Task> OrgSportsProjectList(int orgId) - { - //var res = await _sportsContext.XW_TestingProject.Where(x => x.OrgId == orgId).Select(x => new TestingProjectDto() - var res = await _sportsContext.XW_TestingProject.Select(x => new TestingProjectDto() - { - ProjectId = x.ProjectId, - IsOpen = x.IsOpen, - IsShow = x.IsShow, - ProjectName = x.ProjectName - }).ToListAsync(); - - return res; - } - - /// - /// 获取学生信息 - /// - /// 学校Id - /// - public async Task> MinimumOfStudentInfoList(int orgId) - { - string schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync(); - - var res = await (from s in _sportsContext.Student - join c in _sportsContext.Class on s.ClassId equals c.Id - join g in _sportsContext.Grade on c.GradeId equals g.Id - where s.SchoolCode == schoolCode - select new StudentInfoDto() - { - Id = s.Id, - OrgId = orgId, - UserId = s.Id, - StudentNo = s.StudentNo, - Name = s.StudentName, - Sex = s.Sex == 1 ? "男" : "女", - ClassId = c.Id, - GradeId = g.Id, - RuleGradeId = g.Id, - ClassName = c.ClassName, - GradeName = g.GradeName, - CardNo = new List() - }).ToListAsync(); - - return res; - } - - /// - /// 获取名单列表 - /// - /// - /// - /// - /// - public async Task> SportsRosterList(int orgId, int userId = 0) - { - string schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync(); - var studentList = await _sportsContext.Student.Where(x => x.SchoolCode == schoolCode).ToListAsync(); - - var list = await (from c in _sportsContext.Class - join g in _sportsContext.Grade on c.GradeId equals g.Id - where c.SchoolCode == schoolCode - select new SportsRosterDto() - { - Id = c.Id, - OrgId = orgId, - Name = c.ClassName, - GradeId = g.Id, - RuleGradeId = g.Id, - GradeName = g.GradeName, - Status = 1, - Type = 1 - }).ToListAsync(); - - - foreach (var item in list) - { - var stuList = studentList.Where(x => x.ClassId == item.Id).ToList(); - List sportList1 = new List(); - - foreach (var sport in stuList) - { - sportList1.Add(new SportsRosterStudentDto() - { - Id = sport.Id, - GroupName = item.Name, - ClassId = item.Id, - ClassName = item.Name, - GradeId = item.GradeId, - GradeName = item.GradeName, - OrgId = orgId, - Sex = sport.Sex, - UserName = sport.StudentName, - StudentNo = sport.StudentNo, - UserId = sport.Id, - GroupOrder = sport.Id, - RosterId = 1, - }); - } - - item.RosterGroupList.Add(new SportsRosterGroupDto() - { - GroupName = item.Name, - RosterStudentList = sportList1 - }); - } - - //var list1 = list.Select(x => new SportsRosterDto - //{ - // Type = 2 - //}).ToList(); - - - //var mergedList = list.Concat(list1).ToList(); - - return list; - } - - /// - /// 获取人脸信息 - /// - /// - /// - public async Task FaceListOfDevicePage(FaceListOfDeviceDto dto) - { - string schoolCode = await _sportsContext.School.Where(x => x.Id == dto.OrgId).Select(x => x.SchoolCode).FirstAsync(); - - var total = await _sportsContext.Student.CountAsync(x => x.SchoolCode == schoolCode && !string.IsNullOrWhiteSpace(x.Photo)); - - var list = await _sportsContext.Student - .Where(x => x.SchoolCode == schoolCode && !string.IsNullOrWhiteSpace(x.Photo)) - .Select(s => new DeviceUserFaceVo() - { - FaceId = s.StudentNo, - FaceType = 1, - FaceUrl = s.Photo, - PersonId = s.StudentNo, - UserId = s.Id - }) - .Skip((dto.PageNo - 1) * dto.PageSize) - .Take(dto.PageSize) - .ToListAsync(); - - return new FaceListOfDevicePageDto() - { - Total = total, - PageNum = dto.PageNo, - PageSize = dto.PageSize, - Pages = (int)Math.Ceiling((double)total / dto.PageSize), - List = list - }; - } - - /// - /// 获取训练评分规则 - /// - /// 学校Id - /// - public async Task> ScoreRules(int orgId) - { - var scoreRules = await _sportsContext.HealthStandards.ToListAsync(); - var projects = await _sportsContext.XW_TestingProject.ToListAsync(); - var projectModels = await _sportsContext.XW_ProjectMode.ToListAsync(); - - var scoreRuleItemsByType = scoreRules - .GroupBy(x => x.CategoryEnum) - .ToDictionary(g => g.Key, g => g.ToList()); - - List res = new List(); - - foreach (var projectModel in projectModels) - { - var project = projects.FirstOrDefault(x => x.ProjectId == projectModel.ProjectKind); - if (project == null) continue; // Skip if project doesn't exist - - var scoreRuleTypes = projectModel.CategoryEnum.Split(','); - var scoreRuleItems = scoreRuleTypes.SelectMany(type => scoreRuleItemsByType.GetValueOrDefault(type, new List())).ToList(); - - var groupedItemsData = scoreRuleItems.GroupBy(x => x.GradeId).ToList(); - - foreach (var grouped in groupedItemsData) - { - var maleItems = grouped.Where(x => x.Sex == 1).ToList(); - var femaleItems = grouped.Where(x => x.Sex == 2).ToList(); - - var maleMax = maleItems.DefaultIfEmpty().Max(x => x?.MaxValue ?? 0); - var maleMin = maleItems.DefaultIfEmpty().Max(x => x?.MinValue ?? 0); - var maleMaxScore = maleItems.DefaultIfEmpty().Max(x => x?.Score ?? 0); - - var femaleMax = femaleItems.DefaultIfEmpty().Max(x => x?.MaxValue ?? 0); - var femaleMin = femaleItems.DefaultIfEmpty().Max(x => x?.MinValue ?? 0); - var femaleMaxScore = femaleItems.DefaultIfEmpty().Max(x => x?.Score ?? 0); - - ScoreRuleDto scoreRuleDto = new ScoreRuleDto - { - GradeId = grouped.Key, - OrgId = orgId, - ProjectKind = project.ProjectId, - ProjectName = project.ProjectName, - ModelType = projectModel.Id, - RuleType = 1, - ProjectId = project.ProjectId, - Items = grouped.Select(item => new ScoreRuleItemDto - { - Id = item.Id, - Sex = item.Sex, - Name = item.Score.GetRank().ToString(), - Score = item.Score, - Max = item.MaxValue, - Min = item.MinValue - }).OrderByDescending(x => x.Min).ToList() - }; - - scoreRuleDto.Pluses = new List - { - //new ScoreRulePlusDto() - //{ - // Id = grouped.FirstOrDefault()?.Id ?? 0, - // Sex = 1, - // Max = maleMax, - // Min = maleMin, - // MaxScore = maleMaxScore, - // Score = maleMaxScore - //}, - //new ScoreRulePlusDto() - //{ - // Id = grouped.FirstOrDefault()?.Id ?? 0, - // Sex = 2, - // Max = femaleMax, - // Min = femaleMin, - // MaxScore = femaleMaxScore, - // Score = femaleMaxScore - //} - }; - - scoreRuleDto.ScoreScopes = new List - { - //new ScoreScope() - //{ - // Gender = 1, - // MaxScore = maleMaxScore, - // MaxCount = maleMax - //}, - //new ScoreScope() - //{ - // Gender = 2, - // MaxScore = femaleMaxScore, - // MaxCount = femaleMax - //} - }; - - res.Add(scoreRuleDto); - } - } - - return res; - } - - /// - /// 新增训练 - /// - /// - /// - public async Task AddTrain(AddTrainDto dto) - { - var jsonOptions = new JsonSerializerOptions - { - WriteIndented = true, - Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }; - - string dtoJson = System.Text.Json.JsonSerializer.Serialize(dto, jsonOptions); - - await File.WriteAllTextAsync( - $"/tmp/xwlog/add_train_{DateTime.Now:yyyyMMdd_HHmmss}.json", - dtoJson - ); - - var xwProject = await _sportsContext.XW_TestingProject.ToListAsync(); - var healthStandards = await _sportsContext.HealthStandards.ToListAsync(); - - try - { - var entity = _mapper.Map(dto); - - entity.StudentList.ForEach(stu => - { - var project = xwProject.Where(x => x.ProjectId == dto.ProjectId).FirstOrDefault(); - string categoryEnum = project?.CategoryEnum ?? ""; - - if (dto.ProjectId == 4 || dto.ProjectId == 11) - { - // 只除以10,保留两位小数 - stu.Achievement = stu.Achievement.HasValue ? Math.Round(stu.Achievement.Value / 10.0, 2) : 0; - stu.Achievement2 = stu.Achievement2.HasValue ? Math.Round(stu.Achievement2.Value / 10.0, 2) : 0; - } - - if (dto.ProjectId == 3) - { - // 除以1000再除以10,即除以10000,保留两位小数 - stu.Achievement = stu.Achievement.HasValue ? Math.Round(stu.Achievement.Value / 1000.0, 2) - 0.5 : 0; - } - - - if (dto.ProjectId == 21) - { - var value = stu.Achievement2; - - var standard = healthStandards.Where(x => - x.CategoryEnum.Equals(categoryEnum) && - x.GradeId == x.GradeId && - x.Sex == x.Sex && - value >= x.MinValue && - value < x.MaxValue - ).FirstOrDefault(); - - if (standard != null) - { - stu.Score = standard.Score; - stu.Rating = standard.Score.GetRank(); - } - } - else - { - var standard = healthStandards.Where(x => - x.CategoryEnum.Equals(categoryEnum) && - x.GradeId == x.GradeId && - x.Sex == x.Sex && - stu.Achievement >= x.MinValue && - stu.Achievement < x.MaxValue - ).FirstOrDefault(); - - if (standard != null) - { - stu.Score = standard.Score; - stu.Rating = standard.Score.GetRank(); - } - } - - stu.OrgId = dto.OrgId; - stu.CreateTime = dto.EndTime; - }); - - - await _sportsContext.XW_SportsTestData.AddAsync(entity); - - var sportsTestValueEntinys = await AddSportsTestValueEntity(dto, healthStandards, xwProject); - await _sportsContext.SportsTestValue.AddRangeAsync(sportsTestValueEntinys); - - await _sportsContext.SaveChangesAsync(); - - var res = _mapper.Map(entity); - - Console.WriteLine("新增成功"); - - return res; - } - catch (Exception e) - { - Console.WriteLine(e.Message + "/n" + e.InnerException); - } - - return null; - } - - private async Task> AddSportsTestValueEntity(AddTrainDto dto, List healthStandards, List xwProject) - { - var sportsTestValueEntinys = new List(); - - string schoolCode = await _sportsContext.School.Where(x => x.Id == dto.OrgId).Select(x => x.SchoolCode).FirstAsync(); - - var nowTime = DateTime.Now; - - foreach (var data in dto.StudentList) - { - if (data.Achievement == 0) - continue; - - var sportsTestValueEntity = new N_SportsTestValue(); - - var project = xwProject.Where(x => x.ProjectId == dto.ProjectId).FirstOrDefault(); - - string categoryEnum = project?.CategoryEnum ?? ""; - - float value = data.Achievement ?? 0; - - if (dto.ProjectId == 4 || dto.ProjectId == 11) - { - // 只除以10,保留两位小数 - value = (float)(data.Achievement.HasValue ? Math.Round(data.Achievement.Value / 10.0, 2) : 0); - } - - if (dto.ProjectId == 3) - { - // 除以1000再除以10,即除以10000,保留两位小数,再减0.5 - value = (float)((data.Achievement.HasValue ? Math.Round(data.Achievement.Value / 1000.0, 2) : 0) - 0.5); - } - - if (dto.ProjectId == 21) - { - // Achievement2 除以10,保留两位小数 - value = (float)(data.Achievement2.HasValue ? Math.Round(data.Achievement2.Value / 10.0, 2) : 0); - // Height 除以10 - sportsTestValueEntity.Height = (float)(data.Achievement.HasValue ? Math.Round(data.Achievement.Value / 10.0, 2) : 0); - // Weight 除以100 - sportsTestValueEntity.Weight = (float)(data.OriginalAchievement.HasValue ? Math.Round(data.OriginalAchievement.Value / 100.0, 2) : 0); - } - - - var standard = healthStandards.Where(x => - x.CategoryEnum.Equals(categoryEnum) && - x.GradeId == data.GradeId && - x.Sex == data.Sex && - value >= x.MinValue && - value < x.MaxValue - ).FirstOrDefault(); - - if (standard != null) - { - sportsTestValueEntity.Score = standard.Score; - sportsTestValueEntity.Rank = standard.Rank; - } - - - sportsTestValueEntity.Score = (float)(data.Score ?? 0); - sportsTestValueEntity.SchoolCode = schoolCode; - sportsTestValueEntity.Sex = (int)data.Sex; - sportsTestValueEntity.DataSource = DataSource.XW; - sportsTestValueEntity.CategoryValue = project?.CategoryValue ?? 0; - sportsTestValueEntity.CategoryEnum = categoryEnum; - sportsTestValueEntity.GradeId = data.GradeId; - sportsTestValueEntity.GradeName = data.GradeName; - sportsTestValueEntity.ClassId = data.ClassId; - sportsTestValueEntity.ClassName = data.ClassName; - sportsTestValueEntity.TeacherId = data.TeacherId ?? 0; - sportsTestValueEntity.TeacherName = data.Teacher; - sportsTestValueEntity.StudentNo = data.StudentNo; - sportsTestValueEntity.StudentName = data.StudentName; - sportsTestValueEntity.Value = value; - sportsTestValueEntity.Creator = dto.OrgId ?? 0; - sportsTestValueEntity.CreateDate = nowTime; - sportsTestValueEntity.ScoreTime = Convert.ToDateTime(dto.EndTime); - sportsTestValueEntity.AdditionalScore = (float)(data.PlusesScore ?? 0); - - SemesterDto semesterDto = new SemesterDto(); - sportsTestValueEntity.Year = semesterDto.Year; - sportsTestValueEntity.Semester = semesterDto.Semester; - sportsTestValueEntity.IsDisplay = true; - - sportsTestValueEntinys.Add(sportsTestValueEntity); - } - - return sportsTestValueEntinys; - } - - - /// - /// 年级排名 - /// - /// - /// - /// - public async Task GradeRankingGet(int studentId, int trainId) - { - var res = new GradeRankingVo(); - - var now = DateTime.UtcNow; - var firstDayOfMonth = new DateTime(now.Year, now.Month, 1); - var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); - - var studentResults = await _sportsContext.XW_TrainStudents.Where(x => x.XW_SportsTestDataId == trainId) - .Select(x => new - { - x.GradeId, - x.StudentId, - x.StudentName, - x.Rating, - x.CreateTime, - x.Score - }).ToListAsync(); - - var student = studentResults.FirstOrDefault(x => x.StudentId == studentId); - - if (student == null) - { - return res; - } - - - var rankedResults = studentResults - .Where(x => x.GradeId == student.GradeId && - DateTime.TryParse(x.CreateTime, out var createTime) && - createTime >= firstDayOfMonth && createTime <= lastDayOfMonth) - .OrderByDescending(x => x.Score) - .Select((x, index) => new { x.StudentId, Rank = index + 1 }) - .ToList(); - - var studentRank = rankedResults.FirstOrDefault(x => x.StudentId == student.StudentId)?.Rank.ToString() ?? "无数据"; - - res.Rating = student.Score.GetRankStr(); - res.MonthRanking = studentRank; - res.Score = student.Score.ToString(); - - return res; - } - - /// - /// 全部历史记录 - /// - /// - /// - public async Task HistoryGet(HistoryGetDto dto) - { - var res = new TrainHistoryResponseDto(); - - var trainList = await _sportsContext.XW_SportsTestData - .Where(x => - x.OrgId == dto.OrgId && - x.ProjectKind == Convert.ToInt32(dto.ProjectKind) && - x.ModelType == dto.ModelType) - .ToListAsync(); - - if (trainList == null || !trainList.Any()) - return res; - - var trainIds = trainList.Select(t => t.Id).ToList(); - - var query = _sportsContext.XW_TrainStudents - .Where(x => trainIds.Contains(x.XW_SportsTestDataId)) - .AsQueryable(); - - // 动态排序 - if (!string.IsNullOrEmpty(dto.OrderByColumn)) - { - bool isAsc = dto.IsAsc?.ToLower() == "asc"; - query = isAsc - ? query.OrderBy(x => EF.Property(x, dto.OrderByColumn)) - : query.OrderByDescending(x => EF.Property(x, dto.OrderByColumn)); - } - else - { - query = query.OrderByDescending(x => x.Id); // 默认排序 - } - - var total = await query.CountAsync(); - - var list = await query - .Skip((dto.PageNo - 1) * dto.PageSize) - .Take(dto.PageSize) - .Select(x => new TrainHistoryVo() - { - TrainStudentId = x.Id, - ClassName = x.ClassName, - CreateTime = x.CreateTime ?? "无数据", - Achievement = x.Achievement.ToString() ?? "无数据", - Rating = x.Score.GetRankStr(), - Score = x.Score.ToString() ?? "无数据", - Sex = x.Sex == 1 ? "男" : "女", - StudentName = x.StudentName, - TouristFlag = false, - DoubleFlag = false, - }).OrderByDescending(x => x.CreateTime) - .ToListAsync(); - - res.Total = total; - res.Rows = list; - - return res; - } - - - /// - /// 历史记录详细 - /// - /// - /// - public async Task TrainAnalysisHistoryDetail(HistoryDetailRequestDto dto) - { - var trainModel = await _sportsContext.XW_TrainStudents.Where(x => x.Id == dto.TrainStudentId).Select(x => new { x.XW_SportsTestDataId, x.StudentId, x.GradeId }).FirstAsync(); - - var stuHeadUrl = await _sportsContext.Student.Where(x => x.Id == trainModel.StudentId).Select(x => x.Photo).FirstOrDefaultAsync(); - - var train = await _sportsContext.XW_SportsTestData.Where(x => x.Id == trainModel.XW_SportsTestDataId).Select(x => new { x.ProjectName, x.ProjectId }).FirstOrDefaultAsync(); - - var now = DateTime.UtcNow; - var firstDayOfMonth = new DateTime(now.Year, now.Month, 1); - var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); - var trainIds = await _sportsContext.XW_SportsTestData.Where(x => x.ProjectId == train.ProjectId).Select(x => x.Id).ToListAsync(); - - var studentResults = await _sportsContext.XW_TrainStudents.Where(x => trainIds.Contains(x.XW_SportsTestDataId)) - .Select(x => new - { - x.Id, - x.GradeId, - x.StudentId, - x.StudentName, - x.Rating, - x.CreateTime, - x.Score, - x.Achievement - }).ToListAsync(); - - var student = studentResults.Where(x => x.Id == dto.TrainStudentId).OrderByDescending(x => x.Score).FirstOrDefault(); - - if (student == null) - { - return null; - } - - var rankedResults = studentResults - .Where(x => x.GradeId == student.GradeId && - DateTime.TryParse(x.CreateTime, out var createTime) && - createTime >= firstDayOfMonth && createTime <= lastDayOfMonth) - .OrderByDescending(x => x.Achievement) - .Select((x, index) => new { x.Id, Rank = index + 1 }) - .ToList(); - - var studentRank = rankedResults.FirstOrDefault(x => x.Id == dto.TrainStudentId)?.Rank.ToString() ?? "无数据"; - - var res = await _sportsContext.XW_TrainStudents.Where(x => x.Id == dto.TrainStudentId).Include(x => x.TrainViolationsBO).Select(x => new TrainAnalusisVo() - { - Achievement = x.Achievement.ToString() ?? "无数据", - ClassName = x.ClassName, - GradeRanking = studentRank, - HeadImgUrl = stuHeadUrl, - ProjectName = train.ProjectName, - Rating = x.Score.GetRankStr(), - Score = x.Score.ToString() ?? "无数据", - Sex = x.Sex == 1 ? "男" : "女", - StudentName = x.StudentName, - Times = x.Times.ToString(), - VideoRecord = x.VideoRecord, - ViolationsNumber = x.TrainViolationsBO.Count(), - TrainViolationsVo = x.TrainViolationsBO.Select(x => new TrainViolationsVo() - { - CreateTime = x.TrainTime, - TrainTime = x.TrainTime, - PicUrl = x.PicUrl, - ViolationId = x.ViolationId, - ViolationName = "", - }).ToList(), - - }).FirstOrDefaultAsync(); - - return res; - } - - /// - /// 个人历史记录-历史成绩 - /// - /// - /// - public async Task HistoryPersonGet(HistoryPersonGetDto dto) - { - // 1️⃣ 获取该机构、项目、模型类型的训练数据 - var trainList = await _sportsContext.XW_SportsTestData - .Where(x => - x.OrgId == dto.OrgId && - x.ProjectKind == Convert.ToInt32(dto.ProjectKind) && - x.ModelType == dto.ModelType) - .ToListAsync(); - - if (!trainList.Any()) - return new TrainHistoryPersonVo(); - - var trainIds = trainList.Select(t => t.Id).ToList(); - - // 2️⃣ 获取学生成绩数据 - var studentResults = await _sportsContext.XW_TrainStudents - .Where(x => trainIds.Contains(x.XW_SportsTestDataId)) - .Select(x => new - { - x.Id, - x.ClassName, - x.StudentId, - x.StudentName, - x.GradeId, - x.Sex, - x.Score, - x.Achievement, - x.CreateTime - }) - .ToListAsync(); - - if (!studentResults.Any()) - return new TrainHistoryPersonVo(); - - // ⭐ 是否按升序(ModelType = 7) - bool isAsc = dto.ModelType == 7; - - // 3️⃣ 获取指定学生(按成绩最优的一次) - var student = isAsc - ? studentResults - .Where(x => x.StudentId == dto.StudentId) - .OrderBy(x => x.Achievement) - .FirstOrDefault() - : studentResults - .Where(x => x.StudentId == dto.StudentId) - .OrderByDescending(x => x.Achievement) - .FirstOrDefault(); - - if (student == null) - return new TrainHistoryPersonVo(); - - // 4️⃣ 历史排名 - var rankedResults = (isAsc - ? studentResults - .Where(x => x.GradeId == student.GradeId) - .OrderBy(x => x.Achievement) - : studentResults - .Where(x => x.GradeId == student.GradeId) - .OrderByDescending(x => x.Achievement) - ) - .Select((x, index) => new { x, Rank = index + 1 }) - .ToList(); - - // 5️⃣ 当月数据 - var monthList = studentResults - .Where(x => DateTime.TryParse(x.CreateTime, out var date) - && date.Year == DateTime.Now.Year - && date.Month == DateTime.Now.Month) - .ToList(); - - // 6️⃣ 当月排名 - var monthRankedResults = (isAsc - ? monthList - .Where(x => x.GradeId == student.GradeId) - .OrderBy(x => x.Achievement) - : monthList - .Where(x => x.GradeId == student.GradeId) - .OrderByDescending(x => x.Achievement) - ) - .Select((x, index) => new { x, Rank = index + 1 }) - .ToList(); - - // 7️⃣ 获取学生头像 - var stuHeadUrl = await _sportsContext.Student - .Where(x => x.Id == student.StudentId) - .Select(x => x.Photo) - .FirstOrDefaultAsync(); - - // 8️⃣ 历史最佳成绩 - var bestStudentOverall = isAsc - ? studentResults.OrderBy(x => x.Achievement).FirstOrDefault() - : studentResults.OrderByDescending(x => x.Achievement).FirstOrDefault(); - - // 9️⃣ 当月最佳成绩 - var bestStudentMonth = isAsc - ? monthList.OrderBy(x => x.Achievement).FirstOrDefault() - : monthList.OrderByDescending(x => x.Achievement).FirstOrDefault(); - - // 🔟 构建返回对象 - return new TrainHistoryPersonVo - { - ClassName = student.ClassName, - HeadImgUrl = stuHeadUrl, - Sex = student.Sex == 1 ? "男" : "女", - StudentName = student.StudentName, - - // 历史最佳成绩 - HistoryBestScore = bestStudentOverall?.Achievement?.ToString("0.###") ?? "无数据", - - // 历史排名 - HistoryRanking = rankedResults - .FirstOrDefault(x => x.x.Id == student.Id)?.Rank.ToString() ?? "1", - - // 当月最佳成绩 - MonthBestScore = bestStudentMonth?.Achievement?.ToString("0.###") ?? "无数据", - - // 当月排名 - MonthRanking = monthRankedResults - .FirstOrDefault(x => x.x.Id == student.Id)?.Rank.ToString() ?? "1" - }; - } - - - /// - /// 个人历史记录-记录列表 - /// - /// - /// - public async Task HistoryPersonListGet(HistoryPersonListDto dto) - { - var res = new TableDataPersonAnalysisVo(); - - var trainList = await _sportsContext.XW_SportsTestData - .Where(x => - x.OrgId == dto.OrgId && - x.ProjectKind == Convert.ToInt32(dto.ProjectKind) && - x.ModelType == dto.ModelType) - .ToListAsync(); - - if (trainList == null || !trainList.Any()) - return res; - - var trainIds = trainList.Select(t => t.Id).ToList(); - - var query = _sportsContext.XW_TrainStudents - .Where(x => trainIds.Contains(x.XW_SportsTestDataId) && x.StudentId == dto.StudentId) - .AsQueryable(); - - // 动态排序 - if (!string.IsNullOrEmpty(dto.OrderByColumn)) - { - bool isAsc = dto.IsAsc?.ToLower() == "asc"; - query = isAsc - ? query.OrderBy(x => EF.Property(x, dto.OrderByColumn)) - : query.OrderByDescending(x => EF.Property(x, dto.OrderByColumn)); - } - else - { - query = query.OrderByDescending(x => x.Id); // 默认排序 - } - - var total = await query.CountAsync(); - - var list = await query - .Skip((dto.PageNo - 1) * dto.PageSize) - .Take(dto.PageSize) - .Select(x => new PersonAnalysisVo() - { - TrainStudentId = x.Id, - ClassName = x.ClassName, - CreateTime = x.CreateTime ?? "无数据", - //Achievement = dto.ModelType == 7 ? (x.Achievement.HasValue ? $"{x.Achievement.Value / 1000}.{x.Achievement.Value % 1000}" : "无数据") : (x.Achievement.HasValue ? x.Achievement.Value.ToString() : "无数据"), - Achievement = x.Achievement.HasValue ? x.Achievement.Value.ToString("0.###") : "无数据", - Rating = x.Score.GetRankStr(), - Score = x.Score.ToString() ?? "无数据", - Sex = x.Sex == 1 ? "男" : "女", - StudentName = x.StudentName, - DoubleFlag = false, - }).OrderByDescending(x => x.CreateTime) - .ToListAsync(); - - res.Total = total; - res.Rows = list; - - return res; - } - - /// - /// 成绩榜-年级列表 - /// - /// - /// - public async Task> GetGradeListByOrg(int orgId) - { - string schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync(); - - var res = await (from s in _sportsContext.SchoolAssocGrade - join g in _sportsContext.Grade on s.GradeId equals g.Id - where s.SchoolCode == schoolCode - select new GradeVo() - { - GradeId = g.Id, - GradeName = g.GradeName - }).ToListAsync(); - - return res; - } - - /// - /// 成绩榜-年级列表 - /// - /// - /// - public async Task ScoreRanking(ScoreRankingDto dto) - { - var jsonOptions = new JsonSerializerOptions - { - WriteIndented = true, - Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }; - - string dtoJson = System.Text.Json.JsonSerializer.Serialize(dto, jsonOptions); - - //await File.WriteAllTextAsync( - // $"/tmp/xwlog/ScoreRanking{DateTime.Now:yyyyMMdd_HHmmss}.json", - // dtoJson - //); - - var res = new ScoreRankingVo(); - - var trainList = await _sportsContext.XW_SportsTestData - .Where(x => - x.OrgId == dto.OrgId && - x.ProjectKind == Convert.ToInt32(dto.ProjectKind) && - x.ModelType == Convert.ToInt32(dto.ModelType)) - .ToListAsync(); - - var trainIds = trainList.Select(t => t.Id).ToList(); - - var today = DateTime.UtcNow.Date; - var (startDate, endDate) = dto.Times switch - { - "1" => (today.AddDays(-(int)today.DayOfWeek + 1), today.AddDays(7 - (int)today.DayOfWeek)), - "2" => (new DateTime(today.Year, today.Month, 1), new DateTime(today.Year, today.Month, 1).AddMonths(1).AddDays(-1)), - "3" => - today.Month >= 9 || today.Month <= 2 - ? (new DateTime(today.Month >= 9 ? today.Year : today.Year - 1, 9, 1), - new DateTime(today.Month >= 9 ? today.Year + 1 : today.Year, 2, DateTime.DaysInMonth(today.Month >= 9 ? today.Year + 1 : today.Year, 2))) - : (new DateTime(today.Year, 3, 1), - new DateTime(today.Year, 8, DateTime.DaysInMonth(today.Year, 8))), - _ => (DateTime.MinValue, DateTime.MaxValue) - }; - - // 基础数据 - var rawResults = await _sportsContext.XW_TrainStudents - .Where(x => trainIds.Contains(x.XW_SportsTestDataId) && x.GradeId == dto.GradeId) - .Select(x => new - { - x.StudentName, - x.ClassName, - x.Achievement, - x.CreateTime, - x.Sex - }) - .ToListAsync(); - - // 过滤时间与性别 - var filtered = rawResults - .Where(x => DateTime.TryParse(x.CreateTime, out var date) && date >= startDate && date <= endDate) - .Where(x => dto.Sex == "1" ? x.Sex == 1 : dto.Sex == "2" ? x.Sex == 2 : true) - .ToList(); - - // ⭐ 根据 ModelType == 7 决定排序方式 ⭐ - var sorted = (dto.ModelType == 7 - ? filtered.OrderBy(x => x.Achievement ?? int.MaxValue) - : filtered.OrderByDescending(x => x.Achievement ?? int.MinValue) - ).ToList(); - - // ⭐ 输出格式处理 ⭐ - var studentResults = sorted.Select(x => new RankingVo() - { - Name = x.StudentName, - ClassName = x.ClassName, - //Achievement = dto.ModelType == 7 - // ? (x.Achievement.HasValue - // ? $"{x.Achievement.Value / 1000}" - // : "无数据") - // : (x.Achievement.HasValue - // ? x.Achievement.Value.ToString() - // : "无数据") - - Achievement = x.Achievement.HasValue ? x.Achievement.Value.ToString("0.###") : "无数据" - - }).ToList(); - - res.Times = dto.Times; - res.Lists = studentResults; - - return res; - } - - /// - /// 获取成绩榜中显示的体育项目 - /// - /// - /// - public async Task> GetProjectInfo(int orgId) - { - var res = await _sportsContext.XW_ProjectMode.Select(x => new ProjectVo() - { - ProjectKind = x.ProjectKind, - ProjectId = x.ProjectKind, - ModelType = x.Id, - ProjectName = x.Name - }).ToListAsync(); - - return res; - } - - /// - /// 设备端人脸录入 - /// - /// - /// - public async Task AddWeBankUserFace(AddWeBankUserFaceDto dto) - { - if (dto == null || dto.PicUrlA.Length == 0 || dto.UserId == 0) - return false; - - var student = await _sportsContext.Student.Where(x => x.Id == dto.UserId).FirstOrDefaultAsync(); - if (student == null) - return false; - - var gradeId = await _sportsContext.Class.Where(x => x.Id == student.ClassId).Select(x => x.GradeId).FirstOrDefaultAsync(); - var url = ALiYunOss.Upload(dto.PicUrlA, $"Upload/{student.SchoolCode}/Photo/Student/{gradeId}/{student.ClassId}/", student.StudentNo); - - student.Photo = url; - _sportsContext.Student.Update(student); - - return await _sportsContext.SaveChangesAsync() > 0; - } - } -} diff --git a/YD_YiLu/Services/Interface/ILargeScreenService.cs b/YD_YiLu/Services/Interface/ILargeScreenService.cs deleted file mode 100644 index fd3a8cf..0000000 --- a/YD_YiLu/Services/Interface/ILargeScreenService.cs +++ /dev/null @@ -1,35 +0,0 @@ -using YD_YiLu.Commons.Dto.Common; -using YD_YiLu.Commons.Dto.LargeScreen; -using YD_YiLu.Commons.Dto.Open; - -namespace YD_YiLu.Api.Services.Interface -{ - /// - /// 大屏服务接口 - /// - public interface ILargeScreenService - { - - /// - /// 体育项目 - /// - /// 学校Id - /// - Task> SportsProjectList(int orgId); - - /// - /// 项目成绩大屏数据 - /// - /// - /// - Task ItemResultLargeScreenData(int orgId); - - /// - /// 各项目实时成绩 - /// - /// - /// - /// - Task> ItemRealTimeResult(int orgId, DateTime? lastTime = null); - } -} diff --git a/YD_YiLu/Services/Interface/IXinWeiService.cs b/YD_YiLu/Services/Interface/IXinWeiService.cs deleted file mode 100644 index fb5551d..0000000 --- a/YD_YiLu/Services/Interface/IXinWeiService.cs +++ /dev/null @@ -1,137 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using VOL.Entity.DomainModels.XinWei; -using YD_YiLu.Api; -using YD_YiLu.Api.Entitys; -using YD_YiLu.Commons; -using YD_YiLu.Commons.Dto.Common; -using YD_YiLu.Commons.Dto.Open; -using YD_YiLu.Commons.Dto.School; - -namespace YD_YiLu.Api.Services.Interface -{ - /// - /// 服务接口 - /// - public interface IXinWeiService - { - /// - /// 获取设备信息 - /// - /// - /// - Task DeviceInfo(string deviceSerial); - - /// - /// 项目模式 - /// - /// - Task> SportsModelTypeList(); - - /// - /// 体育项目 - /// - /// 学校Id - /// - Task> OrgSportsProjectList(int orgId); - - /// - /// 获取学生信息 - /// - /// 学校Id - /// - Task> MinimumOfStudentInfoList(int orgId); - - /// - /// 获取名单列表 - /// - /// 学校Id - /// 用户Id - /// - Task> SportsRosterList(int orgId, int userId = 0); - - /// - /// 获取人脸信息 - /// - /// - /// - Task FaceListOfDevicePage(FaceListOfDeviceDto dto); - - /// - /// 获取训练评分规则 - /// - /// 学校Id - /// - Task> ScoreRules(int orgId); - - /// - /// 新增训练 - /// - /// - /// - Task AddTrain(AddTrainDto dto); - - /// - /// 年级排名 - /// - /// - /// - /// - Task GradeRankingGet(int studentId, int trainId); - - /// - /// 全部历史记录 - /// - /// - /// - Task HistoryGet(HistoryGetDto dto); - - /// - /// 历史记录详细 - /// - /// - /// - Task TrainAnalysisHistoryDetail(HistoryDetailRequestDto dto); - - /// - /// 个人历史记录-历史成绩 - /// - /// - /// - Task HistoryPersonGet(HistoryPersonGetDto dto); - - /// - /// 个人历史记录-记录列表 - /// - /// - /// - Task HistoryPersonListGet(HistoryPersonListDto dto); - - /// - /// 成绩榜-年级列表 - /// - /// - /// - Task> GetGradeListByOrg(int orgId); - - /// - /// 成绩榜-榜单列表 - /// - /// - /// - Task ScoreRanking(ScoreRankingDto dto); - - /// - /// 获取成绩榜中显示的体育项目 - /// - /// - /// - Task> GetProjectInfo(int orgId); - - /// - /// 设备端人脸录入 - /// - /// - /// - Task AddWeBankUserFace(AddWeBankUserFaceDto dto); - } -} diff --git a/YD_YiLu/SmartSportsEntitys/XW_ProjectMode.cs b/YD_YiLu/SmartSportsEntitys/XW_ProjectMode.cs deleted file mode 100644 index b25b155..0000000 --- a/YD_YiLu/SmartSportsEntitys/XW_ProjectMode.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using YD_YiLu.Api.Entitys; -namespace YD_YiLu.Api.SmartSportsEntitys -{ - /// - /// 芯未项目模式表 - /// - [Table("XW_ProjectMode")] - public class XW_ProjectMode - { - /// - /// Id - /// - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Display(Description = "主键Id")] - [Comment("Id")] - public int Id { get; set; } - - /// - /// ProjectKind - /// - [Display(Name = "ProjectKind")] - [Comment("ProjectKind")] - [Column(TypeName = "int")] - public int ProjectKind { get; set; } - - /// - ///名称 - /// - [Display(Name = "名称")] - [Comment("名称")] - [Column(TypeName = "nvarchar(100)")] - public string Name { get; set; } - - /// - ///枚举 - /// - [Display(Name = "枚举")] - [Comment("枚举")] - [Column(TypeName = "nvarchar(100)")] - public string CategoryEnum { get; set; } - } -} diff --git a/YD_YiLu/SmartSportsEntitys/XW_SportsTestData.cs b/YD_YiLu/SmartSportsEntitys/XW_SportsTestData.cs deleted file mode 100644 index d35ec03..0000000 --- a/YD_YiLu/SmartSportsEntitys/XW_SportsTestData.cs +++ /dev/null @@ -1,604 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using YD_YiLu.Api.Entitys; - -namespace VOL.Entity.DomainModels.XinWei -{ - [Table("XW_SportsTestData")] - public class XW_SportsTestData - { - /// - /// 编号 - /// - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Display(Description = "主键Id")] - [Comment("Id")] - public int Id { get; set; } - - /// - /// 考试id - /// - [Display(Name = "ExaminationId")] - [Comment("考试id")] - public int? ExaminationId { get; set; } - - /// - /// 考试名称 - /// - [Display(Name = "ExaminationName")] - [Comment("考试名称")] - public string? ExaminationName { get; set; } - - /// - /// 项目类型(1体检 2体质) - /// - [Display(Name = "ProjectType")] - [Comment("项目类型(1体检 2体质)")] - public int? ProjectType { get; set; } - - /// - /// 项目ID - /// - [Display(Name = "ProjectId")] - [Comment("项目ID")] - public int? ProjectId { get; set; } - - /// - /// 项目名称 - /// - [Display(Name = "ProjectName")] - [Comment("项目名称")] - public string ProjectName { get; set; } - - /// - /// 模式类型(1随堂模式2名单模式3刷卡或手动录入) - /// - [Display(Name = "RosterType")] - [Comment("模式类型(1随堂模式2名单模式3刷卡或手动录入)")] - public int? RosterType { get; set; } - - /// - /// 学校ID - /// - [Display(Name = "OrgId")] - [Comment("学校ID")] - public int? OrgId { get; set; } - - /// - /// 年级ID - /// - [Display(Name = "GradeId")] - [Comment("年级ID")] - public int? GradeId { get; set; } - - /// - /// 年级名称 - /// - [Display(Name = "GradeName")] - [Comment("年级名称")] - public string GradeName { get; set; } - - /// - /// 班级或者名单id(根据roster_type来判断) - /// - [Display(Name = "ClassId")] - [Comment("班级或者名单id(根据roster_type来判断)")] - public int? ClassId { get; set; } - - /// - /// 班级名称 - /// - [Display(Name = "ClassName")] - [Comment("班级名称")] - public string ClassName { get; set; } - - /// - /// 组别 - /// - [Display(Name = "GroupId")] - [Comment("组别")] - public string GroupId { get; set; } - - /// - /// 老师ID - /// - [Display(Name = "TeacherId")] - [Comment("老师ID")] - public int? TeacherId { get; set; } - - /// - /// 老师名称 - /// - [Display(Name = "TeacherName")] - [Comment("老师名称")] - public string? TeacherName { get; set; } - - /// - /// 训练模式 - /// - [Display(Name = "ModelType")] - [Comment("训练模式")] - public int? ModelType { get; set; } - - /// - /// 评分标准类型(1国家标准2地方标准3自定义标准) - /// - [Display(Name = "MarkType")] - [Comment("评分标准类型(1国家标准2地方标准3自定义标准)")] - public int? MarkType { get; set; } - - /// - /// 项目类型(1跳绳2跑步) - /// - [Display(Name = "ProjectKind")] - [Comment("项目类型(1跳绳2跑步)")] - public int? ProjectKind { get; set; } - - /// - /// 训练标准ID - /// - [Display(Name = "ProjectRuleId")] - [Comment("训练标准ID")] - public int? ProjectRuleId { get; set; } - - /// - /// 项目类型名称 - /// - [Display(Name = "ProjectKindName")] - [Comment("项目类型名称")] - public string? ProjectKindName { get; set; } - - /// - /// 评分标准类型名称 - /// - [Display(Name = "MarkTypeName")] - [Comment("评分标准类型名称")] - public string? MarkTypeName { get; set; } - - /// - /// 项目模式名称 - /// - [Display(Name = "ModelTypeName")] - [Comment("项目模式名称")] - public string? ModelTypeName { get; set; } - - /// - /// 训练人数 - /// - [Display(Name = "TrainCount")] - [Comment("训练人数")] - public int? TrainCount { get; set; } - - /// - /// 开始时间 - /// - [Display(Name = "StartTime")] - [Comment("开始时间")] - public string StartTime { get; set; } - - /// - /// 结束时间 - /// - [Display(Name = "EndTime")] - [Comment("结束时间")] - public string EndTime { get; set; } - - /// - /// 男生总数 - /// - [Display(Name = "MaleTotal")] - [Comment("男生总数")] - public int? MaleTotal { get; set; } - - /// - /// 女生总数 - /// - [Display(Name = "FemaleTotal")] - [Comment("女生总数")] - public int? FemaleTotal { get; set; } - - /// - /// 男生总成绩 - /// - [Display(Name = "MaleCount")] - [Comment("男生总成绩")] - public double? MaleCount { get; set; } - - /// - /// 男生最大值 - /// - [Display(Name = "MaleMaxCount")] - [Comment("男生最大值")] - public int? MaleMaxCount { get; set; } - - /// - /// 男生最小值 - /// - [Display(Name = "MaleMinCount")] - [Comment("男生最小值")] - public int? MaleMinCount { get; set; } - - /// - /// 女生总成绩 - /// - [Display(Name = "FemaleCount")] - [Comment("女生总成绩")] - public double? FemaleCount { get; set; } - - /// - /// 女生最大值 - /// - [Display(Name = "FemaleMaxCount")] - [Comment("女生最大值")] - public int? FemaleMaxCount { get; set; } - - /// - /// 女生最小值 - /// - [Display(Name = "FemaleMinCount")] - [Comment("女生最小值")] - public int? FemaleMinCount { get; set; } - - /// - /// 男生总分数 - /// - [Display(Name = "MaleScore")] - [Comment("男生总分数")] - public double? MaleScore { get; set; } - - /// - /// 男生最大分数 - /// - [Display(Name = "MaleMaxScore")] - [Comment("男生最大分数")] - public double? MaleMaxScore { get; set; } - - /// - /// 男生最小分数 - /// - [Display(Name = "MaleMinScore")] - [Comment("男生最小分数")] - public double? MaleMinScore { get; set; } - - /// - /// 女生总分数 - /// - [Display(Name = "FemaleScore")] - [Comment("女生总分数")] - public double? FemaleScore { get; set; } - - /// - /// 女生最大分数 - /// - [Display(Name = "FemaleMaxScore")] - [Comment("女生最大分数")] - public double? FemaleMaxScore { get; set; } - - /// - /// 女生最小分数 - /// - [Display(Name = "FemaleMinScore")] - [Comment("女生最小分数")] - public double? FemaleMinScore { get; set; } - - /// - /// 男生优秀人数 - /// - [Display(Name = "MaleFine")] - [Comment("男生优秀人数")] - public int? MaleFine { get; set; } - - /// - /// 男生良好人数 - /// - [Display(Name = "MaleGood")] - [Comment("男生良好人数")] - public int? MaleGood { get; set; } - - /// - /// 男生及格人数 - /// - [Display(Name = "MalePass")] - [Comment("男生及格人数")] - public int? MalePass { get; set; } - - /// - /// 男生不及格人数 - /// - [Display(Name = "MaleFail")] - [Comment("男生不及格人数")] - public int? MaleFail { get; set; } - - /// - /// 女生优秀人数 - /// - [Display(Name = "FemaleFine")] - [Comment("女生优秀人数")] - public int? FemaleFine { get; set; } - - /// - /// 女生良好人数 - /// - [Display(Name = "FemaleGood")] - [Comment("女生良好人数")] - public int? FemaleGood { get; set; } - - /// - /// 女生及格人数 - /// - [Display(Name = "FemalePass")] - [Comment("女生及格人数")] - public int? FemalePass { get; set; } - - /// - /// 女生不及格人数 - /// - [Display(Name = "FemaleFail")] - [Comment("女生不及格人数")] - public int? FemaleFail { get; set; } - - /// - /// 及格率 - /// - [Display(Name = "PassingRate")] - [Comment("及格率")] - public double? PassingRate { get; set; } - - /// - /// 男生平均个数 - /// - [Display(Name = "MaleAvgCount")] - [Comment("男生平均个数")] - public double? MaleAvgCount { get; set; } - - /// - /// 女生平均个数 - /// - [Display(Name = "FemaleAvgCount")] - [Comment("女生平均个数")] - public double? FemaleAvgCount { get; set; } - - /// - /// 男生平均分数 - /// - [Display(Name = "MaleAvgScore")] - [Comment("男生平均分数")] - public double? MaleAvgScore { get; set; } - - /// - /// 女生平均分数 - /// - [Display(Name = "FemaleAvgScore")] - [Comment("女生平均分数")] - public double? FemaleAvgScore { get; set; } - - /// - /// 男生中位数 - /// - [Display(Name = "MaleMedianCount")] - [Comment("男生中位数")] - public double? MaleMedianCount { get; set; } - - /// - /// 女生中位数 - /// - [Display(Name = "FemaleMedianCount")] - [Comment("女生中位数")] - public double? FemaleMedianCount { get; set; } - - /// - /// 男生平均值 - /// - [Display(Name = "MaleAvgImproveCount")] - [Comment("男生平均值")] - public int? MaleAvgImproveCount { get; set; } - - /// - /// 男生最大值 - /// - [Display(Name = "MaleMaxImproveCount")] - [Comment("男生最大值")] - public int? MaleMaxImproveCount { get; set; } - - /// - /// 男生最小值 - /// - [Display(Name = "MaleMinImproveCount")] - [Comment("男生最小值")] - public int? MaleMinImproveCount { get; set; } - - /// - /// 女生平均值 - /// - [Display(Name = "FemaleAvgImproveCount")] - [Comment("女生平均值")] - public int? FemaleAvgImproveCount { get; set; } - - /// - /// 女生最大值 - /// - [Display(Name = "FemaleMaxImproveCount")] - [Comment("女生最大值")] - public int? FemaleMaxImproveCount { get; set; } - - /// - /// 女生最小值 - /// - [Display(Name = "FemaleMinImproveCount")] - [Comment("女生最小值")] - public int? FemaleMinImproveCount { get; set; } - - /// - /// 男生平均分数 - /// - [Display(Name = "MaleAvgImproveScore")] - [Comment("男生平均分数")] - public double? MaleAvgImproveScore { get; set; } - - /// - /// 男生最大分数 - /// - [Display(Name = "MaleMaxImproveScore")] - [Comment("男生最大分数")] - public double? MaleMaxImproveScore { get; set; } - - /// - /// 男生最小分数 - /// - [Display(Name = "MaleMinImproveScore")] - [Comment("男生最小分数")] - public double? MaleMinImproveScore { get; set; } - - /// - /// 女生平均分数 - /// - [Display(Name = "FemaleAvgImproveScore")] - [Comment("女生平均分数")] - public double? FemaleAvgImproveScore { get; set; } - - /// - /// 女生最大分数 - /// - [Display(Name = "FemaleMaxImproveScore")] - [Comment("女生最大分数")] - public double? FemaleMaxImproveScore { get; set; } - - /// - /// 女生最小分数 - /// - [Display(Name = "FemaleMinImproveScore")] - [Comment("女生最小分数")] - public double? FemaleMinImproveScore { get; set; } - - /// - /// 失误最少的同学次数 - /// - [Display(Name = "MinErrorCount")] - [Comment("失误最少的同学次数")] - public int? MinErrorCount { get; set; } = 99999; // 默认值 - - /// - /// 进入状态最快的同学耗时(心率借用这个字段。班级运动时间) - /// - [Display(Name = "MinIntoStateTime")] - [Comment("进入状态最快的同学耗时(心率借用这个字段。班级运动时间)")] - public int? MinIntoStateTime { get; set; } = 999999; - - /// - /// 第一名平均耗时 - /// - [Display(Name = "MinAvgTime")] - [Comment("第一名平均耗时")] - public int? MinAvgTime { get; set; } = 999999; - - /// - /// 失误总次数 - /// - [Display(Name = "TotalErrorCount")] - [Comment("失误总次数")] - public int? TotalErrorCount { get; set; } = 0; - - /// - /// 失误损失次数 - /// - [Display(Name = "LossesCount1")] - [Comment("失误损失次数")] - public int? LossesCount1 { get; set; } = 0; - - /// - /// 甩绳速度偏慢损失次数 - /// - [Display(Name = "LossesCount2")] - [Comment("甩绳速度偏慢损失次数")] - public int? LossesCount2 { get; set; } = 0; - - /// - /// 进入状态过慢损失次数 - /// - [Display(Name = "LossesCount3")] - [Comment("进入状态过慢损失次数")] - public int? LossesCount3 { get; set; } = 0; - - /// - /// 提交标识 - /// - [Display(Name = "CheckCode")] - [Comment("提交标识")] - public string CheckCode { get; set; } - - /// - /// 班级明细 - /// - //[Display(Name = "DetailInfo")] - //[Comment("班级明细")] - //public object DetailInfo { get; set; } - - /// - /// 创建时间 - /// - [Display(Name = "CreateTime")] - [Comment("创建时间")] - public string? CreateTime { get; set; } - - /// - /// 创建人 - /// - [Display(Name = "CreateBy")] - [Comment("创建人")] - public string? CreateBy { get; set; } - - /// - /// 修改时间 - /// - [Display(Name = "UpdateTime")] - [Comment("修改时间")] - public string? UpdateTime { get; set; } - - /// - /// 修改人 - /// - [Display(Name = "UpdateBy")] - [Comment("修改人")] - public string? UpdateBy { get; set; } - - /// - /// 是否双人模式 - /// - [Display(Name = "DoubleFlag")] - [Comment("是否双人模式")] - public bool? DoubleFlag { get; set; } - - /// - /// 数据来源(1:pad, 2:微信小程序) - /// - [Display(Name = "Source")] - [Comment("数据来源(1:pad, 2:微信小程序)")] - public int? Source { get; set; } - - /// - /// 学生姓名 - /// - [Display(Name = "StudentName")] - [Comment("学生姓名")] - public string? StudentName { get; set; } - - /// - /// 学生列表 - /// - [Display(Name = "StudentList")] - [Comment("学生列表")] - public List StudentList { get; set; } = new List(); - - - /// - /// 训练设置 - /// - [Display(Name = "TrainSetting")] - [Comment("训练设置")] - public XW_TrainSetting TrainSetting { get; set; } - } -} diff --git a/YD_YiLu/SmartSportsEntitys/XW_TestingProject.cs b/YD_YiLu/SmartSportsEntitys/XW_TestingProject.cs deleted file mode 100644 index ae0818b..0000000 --- a/YD_YiLu/SmartSportsEntitys/XW_TestingProject.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using YD_YiLu.Api.Entitys; -namespace YD_YiLu.Api.SmartSportsEntitys -{ - /// - /// 芯未体测项目表 - /// - [Table("XW_TestingProject")] - public class XW_TestingProject - { - /// - /// Id - /// - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Display(Description = "主键Id")] - [Comment("Id")] - public int Id { get; set; } - - /// - /// 学校Id - /// - [Display(Name = "OrgId")] - [Comment("OrgId")] - [Column(TypeName = "int")] - public int OrgId { get; set; } - - /// - /// ProjectId - /// - [Display(Name = "ProjectId")] - [Comment("ProjectId")] - [Column(TypeName = "int")] - public int ProjectId { get; set; } - - /// - ///名称 - /// - [Display(Name = "名称")] - [Comment("名称")] - [Column(TypeName = "nvarchar(100)")] - public string ProjectName { get; set; } - - /// - ///枚举 - /// - [Display(Name = "枚举")] - [Comment("枚举")] - [Column(TypeName = "nvarchar(100)")] - public string CategoryEnum { get; set; } - - /// - ///枚举 - /// - [Display(Name = "枚举")] - [Comment("枚举")] - [Column(TypeName = "int")] - public int CategoryValue { get; set; } - - /// - ///IsOpen - /// - [Display(Name = "IsOpen")] - [Comment("IsOpen")] - [Column(TypeName = "bit")] - public bool IsOpen { get; set; } - - /// - ///IsShow - /// - [Display(Name = "IsShow")] - [Comment("IsShow")] - [Column(TypeName = "bit")] - public bool IsShow { get; set; } - } -} diff --git a/YD_YiLu/SmartSportsEntitys/XW_TrainSetting.cs b/YD_YiLu/SmartSportsEntitys/XW_TrainSetting.cs deleted file mode 100644 index 829be55..0000000 --- a/YD_YiLu/SmartSportsEntitys/XW_TrainSetting.cs +++ /dev/null @@ -1,108 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using YD_YiLu.Api.Entitys; - -namespace VOL.Entity.DomainModels.XinWei -{ - [Table("XW_TrainSetting")] - public class XW_TrainSetting - { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Display(Description = "主键Id")] - [Comment("Id")] - public int? Id { get; set; } - - /// - /// 训练ID - /// - [Display(Name = "TrainId")] - [Comment("训练ID")] - public int? TrainId { get; set; } - - /// - /// 圈数 - /// - [Display(Name = "CircleCount")] - [Comment("圈数")] - public int? CircleCount { get; set; } - - /// - /// 每圈时间间隔 - /// - [Display(Name = "CircleInterval")] - [Comment("每圈时间间隔")] - public int? CircleInterval { get; set; } - - /// - /// 首圈是否整圈(1-不完整,2-完整) - /// - [Display(Name = "FirstCircleWhole")] - [Comment("首圈是否整圈(1-不完整,2-完整)")] - public decimal? FirstCircleWhole { get; set; } - - /// - /// 首圈时间间隔 - /// - [Display(Name = "FirstCircleInterval")] - [Comment("首圈时间间隔")] - public int? FirstCircleInterval { get; set; } - - /// - /// 保留秒以下的小数位数(1:保留百分之一秒,0:保留十分之一秒) - /// - [Display(Name = "DecimalPlace")] - [Comment("保留秒以下的小数位数")] - public decimal? DecimalPlace { get; set; } - - /// - /// 女生圈数 - /// - [Display(Name = "CircleCountGirl")] - [Comment("女生圈数")] - public int? CircleCountGirl { get; set; } - - /// - /// 女生每圈时间间隔 - /// - [Display(Name = "CircleIntervalGirl")] - [Comment("女生每圈时间间隔")] - public int? CircleIntervalGirl { get; set; } - - /// - /// 女生首圈是否整圈(1-不完整,2-完整) - /// - [Display(Name = "FirstCircleWholeGirl")] - [Comment("女生首圈是否整圈(1-不完整,2-完整)")] - public decimal? FirstCircleWholeGirl { get; set; } - - /// - /// 女生首圈时间间隔 - /// - [Display(Name = "FirstCircleIntervalGirl")] - [Comment("女生首圈时间间隔")] - public int? FirstCircleIntervalGirl { get; set; } - - /// - /// 创建时间 - /// - [Display(Name = "CreateTime")] - [Comment("创建时间")] - public string CreateTime { get; set; } - - /// - /// 创建人 - /// - [Display(Name = "CreateBy")] - [Comment("创建人")] - public string CreateBy { get; set; } - - public int XW_SportsTestDataId { get; set; } - - - public XW_SportsTestData XW_SportsTestData { get; set; } - } -} diff --git a/YD_YiLu/SmartSportsEntitys/XW_TrainStudents.cs b/YD_YiLu/SmartSportsEntitys/XW_TrainStudents.cs deleted file mode 100644 index 4a7de12..0000000 --- a/YD_YiLu/SmartSportsEntitys/XW_TrainStudents.cs +++ /dev/null @@ -1,361 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations.Schema; -using System.ComponentModel.DataAnnotations; -using YD_YiLu.Api.Entitys; - -namespace VOL.Entity.DomainModels.XinWei -{ - [Table("XW_TrainStudents")] - public class XW_TrainStudents - { - /// - /// 编号 - /// - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Display(Description = "主键Id")] - [Comment("Id")] - public int Id { get; set; } - - - /// - /// 训练ID - /// - [Display(Name = "TrainId")] - [Comment("训练ID")] - public int? TrainId { get; set; } - - /// - /// 项目ID - /// - [Display(Name = "ProjectId")] - [Comment("项目ID")] - public int? ProjectId { get; set; } - - /// - /// 项目类型(1跳绳2跑步) - /// - [Display(Name = "ProjectKind")] - [Comment("项目类型(1跳绳2跑步)")] - public int? ProjectKind { get; set; } - - /// - /// 学校ID - /// - [Display(Name = "OrgId")] - [Comment("学校ID")] - public int? OrgId { get; set; } - - /// - /// 年级ID - /// - [Display(Name = "GradeId")] - [Comment("年级ID")] - public int GradeId { get; set; } - - /// - /// 年级名称 - /// - [Display(Name = "GradeName")] - [Comment("年级名称")] - public string GradeName { get; set; } - - /// - /// 班级ID - /// - [Display(Name = "ClassId")] - [Comment("班级ID")] - public int ClassId { get; set; } - - /// - /// 班级名称 - /// - [Display(Name = "ClassName")] - [Comment("班级名称")] - public string ClassName { get; set; } - - /// - /// 组别 - /// - [Display(Name = "GroupName")] - [Comment("组别")] - public string GroupName { get; set; } - - /// - /// 组号 - /// - [Display(Name = "GroupOrder")] - [Comment("组号")] - public int? GroupOrder { get; set; } - - /// - /// 老师ID - /// - [Display(Name = "TeacherId")] - [Comment("老师ID")] - public int? TeacherId { get; set; } - - /// - /// 设备ID - /// - [Display(Name = "DeviceId")] - [Comment("设备ID")] - public string? DeviceId { get; set; } - - /// - /// 学生ID - /// - [Display(Name = "StudentId")] - [Comment("学生ID")] - public int StudentId { get; set; } - - /// - /// 学生名称 - /// - [Display(Name = "StudentName")] - [Comment("学生名称")] - public string StudentName { get; set; } - - /// - /// 性别(1男2女) - /// - [Display(Name = "Sex")] - [Comment("性别(1男2女)")] - public int Sex { get; set; } - - /// - /// 学号 - /// - [Display(Name = "StudentNo")] - [Comment("学号")] - public string StudentNo { get; set; } - - /// - /// 标准成绩 - /// - [Display(Name = "Achievement")] - [Comment("标准成绩")] - public double? Achievement { get; set; } - - /// - /// 原始标准成绩(被格式化小数点之前的) - /// - [Display(Name = "OriginalAchievement")] - [Comment("原始标准成绩(被格式化小数点之前的)")] - public int? OriginalAchievement { get; set; } - - /// - /// 标准成绩2 - /// - [Display(Name = "Achievement2")] - [Comment("标准成绩2")] - public double? Achievement2 { get; set; } - - /// - /// 原始标准成绩2(被格式化小数点之前的) - /// - [Display(Name = "OriginalAchievement2")] - [Comment("原始标准成绩2(被格式化小数点之前的)")] - public int? OriginalAchievement2 { get; set; } - - /// - /// 得分 - /// - [Display(Name = "Score")] - [Comment("得分")] - public double Score { get; set; } - - /// - /// 加分项得分 - /// - [Display(Name = "PlusesScore")] - [Comment("加分项得分")] - public double? PlusesScore { get; set; } - - /// - /// 评分等级 - /// - [Display(Name = "Rating")] - [Comment("评分等级")] - public int? Rating { get; set; } - - /// - /// 男生或女生排名 - /// - [Display(Name = "RankingInGender")] - [Comment("男生或女生排名")] - public int? RankingInGender { get; set; } - - /// - /// 全体排名 - /// - [Display(Name = "Ranking")] - [Comment("全体排名")] - public int? Ranking { get; set; } - - /// - /// 失误总次数 - /// - [Display(Name = "ErrorCount")] - [Comment("失误总次数")] - public int? ErrorCount { get; set; } = 0; - - /// - /// 失误总耗时 - /// - [Display(Name = "ErrorTime")] - [Comment("失误总耗时")] - public int? ErrorTime { get; set; } = 0; - - /// - /// 平均耗时 - /// - [Display(Name = "AvgTime")] - [Comment("平均耗时")] - public int? AvgTime { get; set; } = 0; - - /// - /// 有效平均值(中位数) - /// - [Display(Name = "MedianTime")] - [Comment("有效平均值(中位数)")] - public int? MedianTime { get; set; } = 0; - - /// - /// 失误损失次数 - /// - [Display(Name = "LossesCount1")] - [Comment("失误损失次数")] - public int? LossesCount1 { get; set; } = 0; - - /// - /// 甩绳速度偏慢损失次数 - /// - [Display(Name = "LossesCount2")] - [Comment("甩绳速度偏慢损失次数")] - public int? LossesCount2 { get; set; } = 0; - - /// - /// 进入状态过慢损失次数 - /// - [Display(Name = "LossesCount3")] - [Comment("进入状态过慢损失次数")] - public int? LossesCount3 { get; set; } = 0; - - /// - /// 高一档分数段 - /// - [Display(Name = "HigherScore")] - [Comment("高一档分数段")] - public int? HigherScore { get; set; } = 0; - - /// - /// 进入状态耗时 - /// - [Display(Name = "进入状态耗时")] - [Comment("进入状态耗时")] - public int? IntoStateTime { get; set; } = 0; - - /// - /// 次数提升空间 - /// - [Display(Name = "次数提升空间")] - [Comment("次数提升空间")] - public int? ImproveCount { get; set; } = 0; - - /// - /// 分数提升空间 - /// - [Display(Name = "分数提升空间")] - [Comment("分数提升空间")] - public double? ImproveScore { get; set; } = 0.0; - - /// - /// 家长消息发送标识 - /// - [Display(Name = "家长消息发送标识")] - [Comment("家长消息发送标识")] - public int? FamilySendFlag { get; set; } - - /// - /// 是否已经完成 - /// - [Display(Name = "是否已经完成")] - [Comment("是否已经完成")] - public bool? Completed { get; set; } - - /// - /// 实际完成的数量(圈数 - /// - [Display(Name = "实际完成的数量(圈数")] - [Comment("实际完成的数量(圈数)")] - public int? QuantityCompleted { get; set; } - - /// - /// 报表显示 - /// - [Display(Name = "报表显示")] - [Comment("报表显示")] - public int? ModelType { get; set; } - - /// - /// 开始时间 - /// - [Display(Name = "开始时间")] - [Comment("开始时间")] - public string? StartTime { get; set; } - - /// - /// 教师 - /// - [Display(Name = "教师")] - [Comment("教师")] - public string? Teacher { get; set; } - - /// - /// 用时 - /// - public int Times { get; set; } - - /// - /// 视频路径 - /// - public string VideoRecord { get; set; } - - - /// - /// 创建时间 - /// - [Display(Name = "创建时间")] - [Comment("创建时间")] - public string? CreateTime { get; set; } - - - /// - /// 创建人 - /// - [Display(Name = "创建人")] - [Comment("创建人")] - public string? CreateBy { get; set; } - - /// - /// 修改时间 - /// - [Display(Name = "修改时间")] - [Comment("修改时间")] - public string? UpdateTime { get; set; } - - /// - /// 修改人 - /// - [Display(Name = "修改人")] - [Comment("修改人")] - public string? UpdateBy { get; set; } - - public int XW_SportsTestDataId { get; set; } - - public XW_SportsTestData XW_SportsTestData { get; set; } - - public List TrainViolationsBO { get; set; } = new List(); - } -} diff --git a/YD_YiLu/SmartSportsEntitys/XW_TrainViolationsBO.cs b/YD_YiLu/SmartSportsEntitys/XW_TrainViolationsBO.cs deleted file mode 100644 index d857939..0000000 --- a/YD_YiLu/SmartSportsEntitys/XW_TrainViolationsBO.cs +++ /dev/null @@ -1,53 +0,0 @@ -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 VOL.Entity.DomainModels.XinWei -{ - [Table("XW_TrainViolationsBO")] - public class XW_TrainViolationsBO - { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Display(Description = "主键Id")] - [Comment("Id")] - public int? Id { get; set; } - - /// - /// 违规动作编号 - /// - [Display(Name = "ViolationId")] - [Comment("违规动作编号")] - public int? ViolationId { get; set; } - - - /// - /// 违规动图地址 - /// - [Display(Name = "违规动图地址")] - [Comment("违规动图地址")] - public string PicUrl { get; set; } - - /// - /// 跳绳绊脚次数 - /// - [Display(Name = "SkipStumblingNumber")] - [Comment("跳绳绊脚次数")] - public int? SkipStumblingNumber { get; set; } - - /// - /// 违规动作训练时间 - /// - [Display(Name = "违规动作训练时间")] - [Comment("违规动作训练时间")] - public string TrainTime { get; set; } - - - public XW_TrainStudents XW_TrainStudents { get; set; } - } -} diff --git a/YD_YiLu/Startup.cs b/YD_YiLu/Startup.cs index 9ecdad2..48fcfb2 100644 --- a/YD_YiLu/Startup.cs +++ b/YD_YiLu/Startup.cs @@ -63,8 +63,6 @@ namespace YD_YiLu.Api services.AddSingleton(); - services.AddScoped(); - services.AddScoped(); services.AddScoped(); services.AddSingleton();