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