编排导出按照项目组别排序
This commit is contained in:
parent
64ac037bc1
commit
86d2d349a9
@ -331,8 +331,6 @@ namespace YD_Event.Application.Event;
|
|||||||
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
|
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
|
||||||
&& !p.DeleteMark
|
&& !p.DeleteMark
|
||||||
&& p.PersonType == PersonType.Athlete)
|
&& p.PersonType == PersonType.Athlete)
|
||||||
.OrderBy(p => p.GroupName)
|
|
||||||
.OrderBy(p => p.Id)
|
|
||||||
.Select((p, r) => new {
|
.Select((p, r) => new {
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
RegistrationItemId = p.RegistrationItemId,
|
RegistrationItemId = p.RegistrationItemId,
|
||||||
@ -379,16 +377,15 @@ namespace YD_Event.Application.Event;
|
|||||||
|
|
||||||
if (!persons.Any()) continue;
|
if (!persons.Any()) continue;
|
||||||
|
|
||||||
// 计算项目总时长
|
var projGroups = groups.Where(g => g.ProjectId == proj.Id).OrderBy(g => g.Id).ToList();
|
||||||
|
|
||||||
int totalParticipants = 0;
|
int totalParticipants = 0;
|
||||||
var projGroups = groups.Where(g => g.ProjectId == proj.Id).ToList();
|
int totalTeams = 0;
|
||||||
foreach (var group in projGroups)
|
foreach (var group in projGroups)
|
||||||
{
|
{
|
||||||
var countObj = counts.FirstOrDefault(c => c.ProjectId == eventProj.Id && c.GroupName == group.GroupName);
|
var countObj = counts.FirstOrDefault(c => c.ProjectId == eventProj.Id && c.GroupName == group.GroupName);
|
||||||
totalParticipants += countObj?.Count ?? 0;
|
totalParticipants += countObj?.Count ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalTeams = 0;
|
|
||||||
if (proj.IsTeamProject())
|
if (proj.IsTeamProject())
|
||||||
{
|
{
|
||||||
totalTeams = teamCounts
|
totalTeams = teamCounts
|
||||||
@ -412,18 +409,19 @@ namespace YD_Event.Application.Event;
|
|||||||
|
|
||||||
string projectTotalDuration = FormatDurationSymbol(projectTotalDurationSeconds);
|
string projectTotalDuration = FormatDurationSymbol(projectTotalDurationSeconds);
|
||||||
|
|
||||||
// 分组逻辑
|
|
||||||
int currentRound = 1;
|
int currentRound = 1;
|
||||||
int currentVenue = 1;
|
int currentVenue = 1;
|
||||||
|
|
||||||
|
foreach (var group in projGroups)
|
||||||
|
{
|
||||||
|
var groupPersons = persons.Where(p => p.GroupName == group.GroupName).ToList();
|
||||||
|
if (!groupPersons.Any()) continue;
|
||||||
|
|
||||||
if (proj.IsTeamProject())
|
if (proj.IsTeamProject())
|
||||||
{
|
{
|
||||||
// 团队项目:按团队分组,同一团队的运动员姓名用逗号分隔
|
var teamsGroup = groupPersons
|
||||||
// 增加 RegistrationItemId 作为分组条件,确保同一条报名记录的多个小组被正确区分
|
.GroupBy(p => new { p.TeamName, p.RegistrationItemId })
|
||||||
var teamsGroup = persons
|
.OrderBy(g => g.Key.TeamName)
|
||||||
.GroupBy(p => new { p.GroupName, p.TeamName, p.RegistrationItemId })
|
|
||||||
.OrderBy(g => g.Key.GroupName)
|
|
||||||
.ThenBy(g => g.Key.TeamName)
|
|
||||||
.ThenBy(g => g.Key.RegistrationItemId);
|
.ThenBy(g => g.Key.RegistrationItemId);
|
||||||
|
|
||||||
foreach (var teamGroup in teamsGroup)
|
foreach (var teamGroup in teamsGroup)
|
||||||
@ -431,17 +429,16 @@ namespace YD_Event.Application.Event;
|
|||||||
var athleteNames = teamGroup.Select(p => p.Name).Distinct().OrderBy(n => n).ToList();
|
var athleteNames = teamGroup.Select(p => p.Name).Distinct().OrderBy(n => n).ToList();
|
||||||
string combinedAthleteNames = string.Join(", ", athleteNames);
|
string combinedAthleteNames = string.Join(", ", athleteNames);
|
||||||
|
|
||||||
// 获取团队中第一个人的认证信息作为团队单位信息
|
|
||||||
var firstPerson = teamGroup.First();
|
var firstPerson = teamGroup.First();
|
||||||
string displayUnitName = GetDisplayUnitName(firstPerson);
|
string displayUnitName = GetDisplayUnitName(firstPerson);
|
||||||
|
|
||||||
result.Add(new ArrangementPreviewOutput
|
result.Add(new ArrangementPreviewOutput
|
||||||
{
|
{
|
||||||
RegistrationItemId = firstPerson.RegistrationItemId, // 团队项目保持使用 EventRegistrationItem.Id
|
RegistrationItemId = firstPerson.RegistrationItemId,
|
||||||
TimeRange = $"{proj.GetTotalDurationInSeconds()}''",
|
TimeRange = $"{proj.GetTotalDurationInSeconds()}''",
|
||||||
ProjectName = proj.Name,
|
ProjectName = proj.Name,
|
||||||
ProjectType = proj.ProjectType.Description(),
|
ProjectType = proj.ProjectType.Description(),
|
||||||
GroupName = teamGroup.Key.GroupName,
|
GroupName = group.GroupName,
|
||||||
TeamName = teamGroup.Key.TeamName,
|
TeamName = teamGroup.Key.TeamName,
|
||||||
AthleteName = combinedAthleteNames,
|
AthleteName = combinedAthleteNames,
|
||||||
UnitName = displayUnitName,
|
UnitName = displayUnitName,
|
||||||
@ -461,14 +458,13 @@ namespace YD_Event.Application.Event;
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 个人项目:根据认证状态显示单位信息
|
foreach (var person in groupPersons.OrderBy(p => p.TeamName).ThenBy(p => p.Name).ThenBy(p => p.Id))
|
||||||
foreach (var person in persons)
|
|
||||||
{
|
{
|
||||||
string displayUnitName = GetDisplayUnitName(person);
|
string displayUnitName = GetDisplayUnitName(person);
|
||||||
|
|
||||||
result.Add(new ArrangementPreviewOutput
|
result.Add(new ArrangementPreviewOutput
|
||||||
{
|
{
|
||||||
RegistrationItemId = person.Id, // 个人项目使用 EventRegistrationPerson.Id
|
RegistrationItemId = person.Id,
|
||||||
TimeRange = $"{proj.GetTotalDurationInSeconds()}''",
|
TimeRange = $"{proj.GetTotalDurationInSeconds()}''",
|
||||||
ProjectName = proj.Name,
|
ProjectName = proj.Name,
|
||||||
ProjectType = proj.ProjectType.Description(),
|
ProjectType = proj.ProjectType.Description(),
|
||||||
@ -491,6 +487,7 @@ namespace YD_Event.Application.Event;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user