This commit is contained in:
tanglong 2025-08-25 14:48:37 +08:00
parent 341f092fa8
commit f5873892e1
24 changed files with 338 additions and 49 deletions

View File

@ -32,7 +32,7 @@ namespace YD_XinWei.Commons.Dto.LargeScreen
/// <summary>
/// 各项目实时数据
/// </summary>
public List<ItemRealTimeResultDto> ItemRealTimeResultList { get; set; } = new List<ItemRealTimeResultDto>();
//public List<ItemRealTimeResultDto> ItemRealTimeResultList { get; set; } = new List<ItemRealTimeResultDto>();
}
/// <summary>
@ -172,7 +172,7 @@ namespace YD_XinWei.Commons.Dto.LargeScreen
/// <summary>
/// 项目名称
/// </summary>
public string ProjectName { get; set; }
public int CategoryValue { get; set; }
/// <summary>
/// 成绩

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_XinWei.Commons")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b4e9670353ddb2f1b79f2b90c3614ce82639d3d6")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+341f092fa8a580c888825be5842538ef8cd736ce")]
[assembly: System.Reflection.AssemblyProductAttribute("YD_XinWei.Commons")]
[assembly: System.Reflection.AssemblyTitleAttribute("YD_XinWei.Commons")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
2c24311f0e88eb1b0fd19f59143c3bad4311678fe29d7fa388424e5852c0c7f5
1708079e145a5349ba8f93613ca137b030746ca998b017e978e57cde07ebdb63

View File

@ -50,5 +50,19 @@ namespace YD_XinWei.Api.Controllers
var res = await _largeScreenService.ItemResultLargeScreenData(orgId);
return res;
}
/// <summary>
/// 各项目实时成绩
/// </summary>
/// <param name="orgId"></param>
/// <param name="lastTime"></param>
/// <returns></returns>
[HttpGet]
[Route("/LargeScreen/{apiVersion}/ItemRealTimeResult")]
public async Task<List<ItemRealTimeResultDto>> ItemRealTimeResult(int orgId, DateTime? lastTime = null)
{
var res = await _largeScreenService.ItemRealTimeResult(orgId, lastTime);
return res;
}
}
}

View File

@ -197,37 +197,107 @@ namespace YD_XinWei.Api.Services.Impl
res.ClassSportsRankList = classRankingList;
var testingProjectKey = $"TestingProject_{orgId}";
//var testingProjectKey = $"TestingProject_{orgId}";
var testingProjects = _caching.Get<List<SportsProjectListDto>>(testingProjectKey) ?? new List<SportsProjectListDto>();
var projectNameDict = testingProjects.ToDictionary(t => t.CategoryValue, t => t.ProjectName);
//var testingProjects = _caching.Get<List<SportsProjectListDto>>(testingProjectKey) ?? new List<SportsProjectListDto>();
//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 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 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();
//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;
//res.ItemRealTimeResultList = realTimeResults;
return res;
}
/// <summary>
/// 各项目实时成绩
/// </summary>
/// <param name="orgId"></param>
/// <param name="lastTime"></param>
/// <returns></returns>
/// <summary>
/// 各项目实时成绩
/// </summary>
public async Task<List<ItemRealTimeResultDto>> 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<List<StudentListDto>>(studentListKey);
var testingProjects = _caching.Get<List<SportsProjectListDto>>(testingProjectKey) ?? new List<SportsProjectListDto>();
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.Score,
s.Rank,
s.ScoreTime
})
.ToListAsync();
// 2. 内存分组取每个学生最新一条
var latestPerStudent = sourceData
.GroupBy(s => s.StudentNo)
.Select(g => g.First()) // 因为前面按 ScoreTime 排过
.OrderBy(s => s.ScoreTime)
.Take(50)
.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.Value,
Score = x.Score,
Rank = string.IsNullOrEmpty(x.Rank) ? "不及格" : x.Rank,
ScoreTime = x.ScoreTime.ToString("yyyy-MM-dd HH:mm:ss")
})
.ToList();
return realTimeResults;
}
}
}

View File

@ -23,5 +23,13 @@ namespace YD_XinWei.Api.Services.Interface
/// <param name="orgId"></param>
/// <returns></returns>
Task<LargeScreenDto> ItemResultLargeScreenData(int orgId);
/// <summary>
/// 各项目实时成绩
/// </summary>
/// <param name="orgId"></param>
/// <param name="lastTime"></param>
/// <returns></returns>
Task<List<ItemRealTimeResultDto>> ItemRealTimeResult(int orgId, DateTime? lastTime = null);
}
}

View File

@ -286,13 +286,13 @@ namespace YD_XinWei.Api
//配置HttpContext
app.UseStaticHttpContext();
//app.UseSwagger();
//app.UseSwaggerUI(c =>
//{
// //2个下拉框选项 选择对应的文档
// c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_XinWei.Api");
// c.RoutePrefix = "";
//});
app.UseSwagger();
app.UseSwaggerUI(c =>
{
//2个下拉框选项 选择对应的文档
c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_XinWei.Api");
c.RoutePrefix = "";
});
app.UseRouting();
app.UseCors();

View File

@ -102,6 +102,42 @@
}
]
},
{
"ContainingType": "YD_XinWei.Api.Controllers.LargeScreenController",
"Method": "ItemRealTimeResult",
"RelativePath": "LargeScreen/{apiVersion}/ItemRealTimeResult",
"HttpMethod": "GET",
"IsController": true,
"Order": 0,
"Parameters": [
{
"Name": "orgId",
"Type": "System.Int32",
"IsRequired": false
},
{
"Name": "lastTime",
"Type": "System.Nullable\u00601[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]",
"IsRequired": false
},
{
"Name": "apiVersion",
"Type": "",
"IsRequired": true
}
],
"ReturnTypes": [
{
"Type": "System.Collections.Generic.List\u00601[[YD_XinWei.Commons.Dto.LargeScreen.ItemRealTimeResultDto, YD_XinWei.Commons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]",
"MediaTypes": [
"text/plain",
"application/json",
"text/json"
],
"StatusCode": 200
}
]
},
{
"ContainingType": "YD_XinWei.Api.Controllers.LargeScreenController",
"Method": "ItemResultLargeScreenData",
@ -164,6 +200,32 @@
}
]
},
{
"ContainingType": "YD_XinWei.Api.Controllers.XinWeiController",
"Method": "GetProjectInfo",
"RelativePath": "screen/sports/getProjectInfo",
"HttpMethod": "GET",
"IsController": true,
"Order": 0,
"Parameters": [
{
"Name": "orgId",
"Type": "System.Int32",
"IsRequired": false
}
],
"ReturnTypes": [
{
"Type": "System.Collections.Generic.List\u00601[[YD_XinWei.Commons.Dto.Open.ProjectVo, YD_XinWei.Commons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]",
"MediaTypes": [
"text/plain",
"application/json",
"text/json"
],
"StatusCode": 200
}
]
},
{
"ContainingType": "YD_XinWei.Api.Controllers.XinWeiController",
"Method": "GetOrgSportsProjectList",

View File

@ -111,6 +111,73 @@
}
}
},
"/LargeScreen/{apiVersion}/ItemRealTimeResult": {
"get": {
"tags": [
"LargeScreen"
],
"summary": "各项目实时成绩",
"parameters": [
{
"name": "orgId",
"in": "query",
"description": "",
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "lastTime",
"in": "query",
"description": "",
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "apiVersion",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ItemRealTimeResultDto"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ItemRealTimeResultDto"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ItemRealTimeResultDto"
}
}
}
}
}
}
}
},
"/basic/{apiVersion}/device/open/getDeviceInfo": {
"get": {
"tags": [
@ -1099,6 +1166,56 @@
}
}
}
},
"/screen/sports/getProjectInfo": {
"get": {
"tags": [
"XinWei"
],
"summary": "获取成绩榜中显示的体育项目",
"parameters": [
{
"name": "orgId",
"in": "query",
"description": "",
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ProjectVo"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ProjectVo"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ProjectVo"
}
}
}
}
}
}
}
}
},
"components": {
@ -1849,9 +1966,9 @@
"type": "string",
"nullable": true
},
"projectName": {
"type": "string",
"nullable": true
"categoryValue": {
"type": "integer",
"format": "int32"
},
"value": {
"type": "number",
@ -1891,13 +2008,6 @@
"$ref": "#/components/schemas/ClassSportsRankingDto"
},
"nullable": true
},
"itemRealTimeResultList": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ItemRealTimeResultDto"
},
"nullable": true
}
},
"additionalProperties": false
@ -1969,6 +2079,30 @@
},
"additionalProperties": false
},
"ProjectVo": {
"type": "object",
"properties": {
"projectKind": {
"type": "integer",
"format": "int32",
"nullable": true
},
"projectId": {
"type": "integer",
"format": "int32",
"nullable": true
},
"projectName": {
"type": "string",
"nullable": true
},
"modelType": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false
},
"RankingVo": {
"type": "object",
"properties": {

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_XinWei.Api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b4e9670353ddb2f1b79f2b90c3614ce82639d3d6")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+341f092fa8a580c888825be5842538ef8cd736ce")]
[assembly: System.Reflection.AssemblyProductAttribute("YD_XinWei.Api")]
[assembly: System.Reflection.AssemblyTitleAttribute("YD_XinWei.Api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
8d9084e95ff89cc8775a8b9ff2aff389a0ebb354f2b316f99c401d9b7932b06f
8ce3d5257b77dd9e592a416ee265e34ae00f20179d1a5c89fc4b381f454e6dd5

View File

@ -707,6 +707,7 @@ C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\staticweb
C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\staticwebassets\msbuild.buildMultiTargeting.YD_XinWei.Api.props
C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\staticwebassets\msbuild.buildTransitive.YD_XinWei.Api.props
C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\staticwebassets.pack.json
C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\staticwebassets.upToDateCheck.txt
C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\YD_XinWe.7845F25F.Up2Date
C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\YD_XinWei.Api.dll
C:\Users\tangl\Desktop\Git\YD_XinWei\Server\YD_XinWei\obj\Debug\net6.0\refint\YD_XinWei.Api.dll

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_XinWei.Api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b4e9670353ddb2f1b79f2b90c3614ce82639d3d6")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+341f092fa8a580c888825be5842538ef8cd736ce")]
[assembly: System.Reflection.AssemblyProductAttribute("YD_XinWei.Api")]
[assembly: System.Reflection.AssemblyTitleAttribute("YD_XinWei.Api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
7365383a4f57a1d9c95092bdc0c66afe10599261f60959284d35398fcfa379f1
fb3ed6757d82f6f5b1248fabde49b4f166fe3361bbb119bc3d24fdc1b69a10cc