Revert "feat(schedule): split team projects into groups like individual projects"
This reverts commit 00a676fcc9.
This commit is contained in:
+27
-63
@@ -124,74 +124,39 @@ public class ParticipantGroupingService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get distinct team names
|
// For team projects, skip gender filter as validation is done at registration time
|
||||||
List<String> teamNames = members.stream()
|
// Team athlete records do not have accurate gender info (they represent the team, not individual members)
|
||||||
|
// members = filterByCategory(members, project);
|
||||||
|
|
||||||
|
long teamCount = members.stream()
|
||||||
.map(MartialAthlete::getTeamName)
|
.map(MartialAthlete::getTeamName)
|
||||||
.filter(t -> t != null && !t.isEmpty())
|
.filter(org -> org != null && !org.isEmpty())
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.count();
|
||||||
|
|
||||||
int teamCount = teamNames.size();
|
|
||||||
String projectName = project.getProjectName();
|
String projectName = project.getProjectName();
|
||||||
String categoryName = getProjectCategoryName(project);
|
String categoryName = getProjectCategoryName(project);
|
||||||
|
|
||||||
// Calculate max teams per group (use maxParticipants as max teams)
|
ScheduleGroupData group = ScheduleGroupData.builder()
|
||||||
int maxTeamsPerGroup = project.getMaxParticipants() != null && project.getMaxParticipants() > 0
|
.groupName(projectName + (categoryName.isEmpty() ? "" : " " + categoryName))
|
||||||
? project.getMaxParticipants() : 10;
|
.projectId(first.getProjectId())
|
||||||
|
.projectType((project.getType() == 2 || project.getType() == 3) ? 2 : 1)
|
||||||
|
.maxParticipants(project.getMaxParticipants())
|
||||||
|
.category(categoryName)
|
||||||
|
.displayOrder(displayOrder++)
|
||||||
|
.totalParticipants(members.size())
|
||||||
|
.totalTeams((int) teamCount)
|
||||||
|
.athletes(members)
|
||||||
|
.build();
|
||||||
|
|
||||||
int durationPerTeam = (project.getEstimatedDuration() != null && project.getEstimatedDuration() > 0)
|
int duration;
|
||||||
? project.getEstimatedDuration() : 5;
|
if (project.getEstimatedDuration() != null && project.getEstimatedDuration() > 0) {
|
||||||
|
duration = (int) teamCount * project.getEstimatedDuration();
|
||||||
if (teamCount <= maxTeamsPerGroup) {
|
|
||||||
// No need to split - single group
|
|
||||||
ScheduleGroupData group = ScheduleGroupData.builder()
|
|
||||||
.groupName(projectName + (categoryName.isEmpty() ? "" : " " + categoryName))
|
|
||||||
.projectId(first.getProjectId())
|
|
||||||
.projectType((project.getType() == 2 || project.getType() == 3) ? 2 : 1)
|
|
||||||
.maxParticipants(project.getMaxParticipants())
|
|
||||||
.category(categoryName)
|
|
||||||
.displayOrder(displayOrder++)
|
|
||||||
.totalParticipants(members.size())
|
|
||||||
.totalTeams(teamCount)
|
|
||||||
.athletes(members)
|
|
||||||
.estimatedDuration(teamCount * durationPerTeam + Math.max(0, teamCount - 1) * 2)
|
|
||||||
.build();
|
|
||||||
groups.add(group);
|
|
||||||
} else {
|
} else {
|
||||||
// Split into multiple groups
|
duration = (int) teamCount * 5 + Math.max(0, (int) teamCount - 1) * 2;
|
||||||
int numGroups = (int) Math.ceil((double) teamCount / maxTeamsPerGroup);
|
|
||||||
|
|
||||||
log.info("Team project {} {} has {} teams, splitting into {} groups (max {} per group)",
|
|
||||||
projectName, categoryName, teamCount, numGroups, maxTeamsPerGroup);
|
|
||||||
|
|
||||||
for (int i = 0; i < numGroups; i++) {
|
|
||||||
int startIdx = i * maxTeamsPerGroup;
|
|
||||||
int endIdx = Math.min(startIdx + maxTeamsPerGroup, teamCount);
|
|
||||||
List<String> subTeamNames = teamNames.subList(startIdx, endIdx);
|
|
||||||
|
|
||||||
// Filter athletes belonging to teams in this sub-group
|
|
||||||
List<MartialAthlete> subMembers = members.stream()
|
|
||||||
.filter(a -> subTeamNames.contains(a.getTeamName()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
int subTeamCount = subTeamNames.size();
|
|
||||||
|
|
||||||
String groupSuffix = " 第" + (i + 1) + "组";
|
|
||||||
ScheduleGroupData group = ScheduleGroupData.builder()
|
|
||||||
.groupName(projectName + " " + categoryName + groupSuffix)
|
|
||||||
.projectId(first.getProjectId())
|
|
||||||
.projectType((project.getType() == 2 || project.getType() == 3) ? 2 : 1)
|
|
||||||
.maxParticipants(project.getMaxParticipants())
|
|
||||||
.category(categoryName)
|
|
||||||
.displayOrder(displayOrder++)
|
|
||||||
.totalParticipants(subMembers.size())
|
|
||||||
.totalTeams(subTeamCount)
|
|
||||||
.athletes(subMembers)
|
|
||||||
.estimatedDuration(subTeamCount * durationPerTeam + Math.max(0, subTeamCount - 1) * 2)
|
|
||||||
.build();
|
|
||||||
groups.add(group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
group.setEstimatedDuration(duration);
|
||||||
|
groups.add(group);
|
||||||
}
|
}
|
||||||
return displayOrder;
|
return displayOrder;
|
||||||
}
|
}
|
||||||
@@ -259,17 +224,16 @@ public class ParticipantGroupingService {
|
|||||||
int totalPeople = members.size();
|
int totalPeople = members.size();
|
||||||
int numSubGroups = (int) Math.ceil((double) totalPeople / maxPeoplePerGroup);
|
int numSubGroups = (int) Math.ceil((double) totalPeople / maxPeoplePerGroup);
|
||||||
|
|
||||||
log.info("Individual project {} {} has {} people, splitting into {} groups (max {} per group)",
|
log.info("Individual project '{}' has {} people, splitting into {} groups (max {} per group)",
|
||||||
projectName, categoryName, totalPeople, numSubGroups, maxPeoplePerGroup);
|
projectName + " " + categoryName, totalPeople, numSubGroups, maxPeoplePerGroup);
|
||||||
|
|
||||||
for (int i = 0; i < numSubGroups; i++) {
|
for (int i = 0; i < numSubGroups; i++) {
|
||||||
int startIdx = i * maxPeoplePerGroup;
|
int startIdx = i * maxPeoplePerGroup;
|
||||||
int endIdx = Math.min(startIdx + maxPeoplePerGroup, totalPeople);
|
int endIdx = Math.min(startIdx + maxPeoplePerGroup, totalPeople);
|
||||||
List<MartialAthlete> subGroupMembers = new ArrayList<>(members.subList(startIdx, endIdx));
|
List<MartialAthlete> subGroupMembers = new ArrayList<>(members.subList(startIdx, endIdx));
|
||||||
|
|
||||||
String groupSuffix = " 第" + (i + 1) + "组";
|
|
||||||
ScheduleGroupData group = ScheduleGroupData.builder()
|
ScheduleGroupData group = ScheduleGroupData.builder()
|
||||||
.groupName(projectName + " " + categoryName + groupSuffix)
|
.groupName(projectName + " " + categoryName + " 第" + (i + 1) + "组")
|
||||||
.projectId(project.getId())
|
.projectId(project.getId())
|
||||||
.projectType(1)
|
.projectType(1)
|
||||||
.maxParticipants(maxPeoplePerGroup)
|
.maxParticipants(maxPeoplePerGroup)
|
||||||
|
|||||||
Reference in New Issue
Block a user