This commit is contained in:
tanglong 2026-01-06 10:40:28 +08:00
parent 782af8743b
commit eb79cf936a
41 changed files with 100 additions and 56 deletions

View File

@ -10,5 +10,6 @@ namespace YD_XinWei.Commons.Dto.Open
{
public string Rating { get; set; }
public string MonthRanking { get; set; }
public string Score { get; set; }
}
}

View File

@ -46,12 +46,12 @@ namespace YD_XinWei.Commons.Dto.Open
/// <summary>
/// 项目编号
/// </summary>
public string ProjectKind { get; set; }
public int ProjectKind { get; set; }
/// <summary>
/// 项目模式
/// </summary>
public string ModelType { get; set; }
public int ModelType { get; set; }
}

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+a1173508afe9193b840696102a5b4f261f20a55a")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+782af8743bef71ca7e5f90325feac2f11e237ba5")]
[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 @@
20b8b26495fdcda45bea4597d4544bd154fa2c1a4e9944d41cec5df9feccc6a4
447043ac812b4df2d70deda46e4a67dbde0640288a02436e158cbdcbef673673

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_XinWei.Commons")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+32db9af2bbc4c31c298fce80234adce84e90d69b")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+782af8743bef71ca7e5f90325feac2f11e237ba5")]
[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 @@
518d6f70096eb885b0d5bad19702a61cff387bf95c524f17ec886acfa3efd5d3
69251adfa64a9b3b7fb3d391959c24ebf8b50dfa3951efbe3b21fe9890d5cf9d

View File

@ -88,7 +88,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.100-rc.2.25502.107\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.101\\RuntimeIdentifierGraph.json"
}
}
}

View File

@ -962,7 +962,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.100-rc.2.25502.107\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.101\\RuntimeIdentifierGraph.json"
}
}
}

View File

@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "XAH+BsWUwUU=",
"dgSpecHash": "7dDdLmz/tD4=",
"success": true,
"projectFilePath": "C:\\Users\\tangl\\Desktop\\Git\\YD_XinWei\\Server\\YD_XinWei.Commons\\YD_XinWei.Commons.csproj",
"expectedPackageFiles": [

View File

@ -185,6 +185,12 @@ namespace YD_XinWei.Api.Controllers
[Route("/sports/{apiVersion}/trainAnalysis/history/person/list")]
public async Task<TableDataPersonAnalysisVo> HistoryPersonListGet(HistoryPersonListDto dto)
{
if (dto.ModelType==7)
{
dto.IsAsc = "asc";
dto.OrderByColumn = "Achievement";
}
var res = await _xinWeiService.HistoryPersonListGet(dto);
return res;
}

View File

@ -19,7 +19,7 @@ namespace YD_XinWei.Api
{
serverOptions.Limits.MaxRequestBodySize = 10485760;
});
webBuilder.UseKestrel().UseUrls("http://*:9995");
webBuilder.UseKestrel().UseUrls("http://*:9994");
webBuilder.UseIIS();
webBuilder.UseStartup<Startup>();
}).UseServiceProviderFactory(new AutofacServiceProviderFactory());

View File

@ -83,18 +83,25 @@ namespace YD_XinWei.Api.Services.Impl
var sportsTestDataKey = $"SportsTestData_{schoolCode}";
var studentListKey = $"StudentList_{schoolCode}";
var studentList = _caching.Get<List<StudentListDto>>(studentListKey);
//var studentList = _caching.Get<List<StudentListDto>>(studentListKey);
if (studentList == null || studentList.Count == 0)
//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
{
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);
}
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);
@ -123,7 +130,7 @@ namespace YD_XinWei.Api.Services.Impl
Score = x.Score,
Rank = x.Rank
}).ToListAsync();
_caching.AddObject(sportsTestDataKey, sportsTestData, 60);
//_caching.AddObject(sportsTestDataKey, sportsTestData, 60);
}
var bestScoreData = sportsTestData
@ -264,7 +271,14 @@ namespace YD_XinWei.Api.Services.Impl
var schoolCode = _caching.Get(schoolKeyKey);
var testingProjectKey = $"TestingProject_{orgId}";
var studentListKey = $"StudentList_{schoolCode}";
var studentList = _caching.Get<List<StudentListDto>>(studentListKey);
//var studentList = _caching.Get<List<StudentListDto>>(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<List<SportsProjectListDto>>(testingProjectKey) ?? new List<SportsProjectListDto>();
var projectNameDict = testingProjects.ToDictionary(t => t.CategoryValue, t => t.ProjectName);
@ -295,10 +309,10 @@ namespace YD_XinWei.Api.Services.Impl
.ToListAsync();
// 2. 内存分组取每个学生最新一条
var latestPerStudent = sourceData.OrderBy(x => x.ScoreTime).ToList();
// 3. 映射到 DTO
var realTimeResults = latestPerStudent
var realTimeResults = sourceData
.GroupBy(x => x.StudentNo) // 按学生分组
.Select(g => g.MaxBy(x => x.ScoreTime)) // 每组取最新一条
.Where(x => x != null) // 避免空值
.Select(x => new ItemRealTimeResultDto
{
StudentNo = x.StudentNo,
@ -306,7 +320,9 @@ namespace YD_XinWei.Api.Services.Impl
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()}",
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")
@ -315,6 +331,5 @@ namespace YD_XinWei.Api.Services.Impl
return realTimeResults;
}
}
}

View File

@ -538,6 +538,7 @@ namespace YD_XinWei.Api.Services.Impl
res.Rating = student.Score.GetRankStr();
res.MonthRanking = studentRank;
res.Score = student.Score.ToString();
return res;
}
@ -796,7 +797,7 @@ namespace YD_XinWei.Api.Services.Impl
TrainStudentId = x.Id,
ClassName = x.ClassName,
CreateTime = x.CreateTime ?? "无数据",
Achievement = x.Achievement.ToString() ?? "无数据",
Achievement = dto.ModelType == 7 ? (x.Achievement.HasValue ? $"{x.Achievement.Value / 1000}.{x.Achievement.Value % 1000}" : "无数据") : (x.Achievement.HasValue ? x.Achievement.Value.ToString() : "无数据"),
Rating = x.Score.GetRankStr(),
Score = x.Score.ToString() ?? "无数据",
Sex = x.Sex == 1 ? "男" : "女",
@ -853,8 +854,8 @@ namespace YD_XinWei.Api.Services.Impl
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)), // 本月
"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),
@ -864,7 +865,7 @@ namespace YD_XinWei.Api.Services.Impl
_ => (DateTime.MinValue, DateTime.MaxValue)
};
// 先从数据库查询基本数据(不带时间过滤)
// 基础数据
var rawResults = await _sportsContext.XW_TrainStudents
.Where(x => trainIds.Contains(x.XW_SportsTestDataId) && x.GradeId == dto.GradeId)
.Select(x => new
@ -874,27 +875,42 @@ namespace YD_XinWei.Api.Services.Impl
x.Achievement,
x.CreateTime,
x.Sex
}).OrderByDescending(x => x.Achievement)
.ToListAsync(); // 先加载到内存
// 在内存中进行时间和性别过滤
var studentResults = 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) // 过滤性别
.Select(x => new RankingVo()
{
Name = x.StudentName,
ClassName = x.ClassName,
Achievement = x.Achievement.ToString() ?? "无数据"
})
.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.Value % 1000}"
: "无数据")
: (x.Achievement.HasValue
? x.Achievement.Value.ToString()
: "无数据")
}).ToList();
res.Times = dto.Times;
res.Lists = studentResults;
return res;
}
/// <summary>
/// 获取成绩榜中显示的体育项目
/// </summary>

View File

@ -753,12 +753,12 @@
},
{
"Name": "ProjectKind",
"Type": "System.String",
"Type": "System.Int32",
"IsRequired": false
},
{
"Name": "ModelType",
"Type": "System.String",
"Type": "System.Int32",
"IsRequired": false
},
{

View File

@ -1124,14 +1124,16 @@
"name": "ProjectKind",
"in": "query",
"schema": {
"type": "string"
"type": "integer",
"format": "int32"
}
},
{
"name": "ModelType",
"in": "query",
"schema": {
"type": "string"
"type": "integer",
"format": "int32"
}
},
{
@ -2004,6 +2006,10 @@
"monthRanking": {
"type": "string",
"nullable": true
},
"score": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false

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+a1173508afe9193b840696102a5b4f261f20a55a")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+782af8743bef71ca7e5f90325feac2f11e237ba5")]
[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 @@
53184c88660f11f158e1cec1c81ab2f75f3195e42c94f3f8406c7473cfe3a229
6717e2e379a38b048ebb8caed4fe5b735e1362513cda51c914771a1e1cf058f6

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+a1173508afe9193b840696102a5b4f261f20a55a")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+782af8743bef71ca7e5f90325feac2f11e237ba5")]
[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 @@
a4635297654a4096ef6260683aa2d346cf4522536fdc28e22e0cbed84fe7b68f
7553d3a5ba1bd3869f0000b8e3dd2c02f16ecdfc233ab9c15be111fe83a5f3aa

View File

@ -88,7 +88,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.100-rc.2.25502.107\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.101\\RuntimeIdentifierGraph.json"
}
}
},
@ -215,7 +215,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.100-rc.2.25502.107\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.101\\RuntimeIdentifierGraph.json"
}
}
}

View File

@ -3370,7 +3370,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.100-rc.2.25502.107\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.101\\RuntimeIdentifierGraph.json"
}
}
}

View File

@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "rUIewyaOqRM=",
"dgSpecHash": "B2QD71mhhms=",
"success": true,
"projectFilePath": "C:\\Users\\tangl\\Desktop\\Git\\YD_XinWei\\Server\\YD_XinWei\\YD_XinWei.Api.csproj",
"expectedPackageFiles": [