fix: 集体项目选手姓名合并显示在一行
集体项目按单位分组,选手姓名用顿号连接显示在一行 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot]
parent
4ca5d93877
commit
c799eb194f
+29
-1
@@ -841,7 +841,34 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
|
||||
|
||||
List<org.springblade.modules.martial.pojo.vo.DispatchDataVO.DispatchParticipant> participantVOs;
|
||||
|
||||
// 所有项目都返回全部参赛者
|
||||
// 集体项目按单位分组,选手姓名合并显示
|
||||
if (group.getProjectType() != null && group.getProjectType() == 2) {
|
||||
java.util.Map<String, List<MartialScheduleParticipant>> orgMap = new java.util.LinkedHashMap<>();
|
||||
for (MartialScheduleParticipant p : participants) {
|
||||
String org = p.getOrganization() != null ? p.getOrganization() : "未知单位";
|
||||
orgMap.computeIfAbsent(org, k -> new ArrayList<>()).add(p);
|
||||
}
|
||||
participantVOs = new ArrayList<>();
|
||||
int order = 1;
|
||||
for (java.util.Map.Entry<String, List<MartialScheduleParticipant>> entry : orgMap.entrySet()) {
|
||||
List<MartialScheduleParticipant> teamMembers = entry.getValue();
|
||||
MartialScheduleParticipant first = teamMembers.get(0);
|
||||
String playerNames = teamMembers.stream()
|
||||
.map(MartialScheduleParticipant::getPlayerName)
|
||||
.collect(Collectors.joining("、"));
|
||||
org.springblade.modules.martial.pojo.vo.DispatchDataVO.DispatchParticipant pVO =
|
||||
new org.springblade.modules.martial.pojo.vo.DispatchDataVO.DispatchParticipant();
|
||||
pVO.setId(first.getId());
|
||||
pVO.setParticipantId(first.getParticipantId());
|
||||
pVO.setOrganization(first.getOrganization());
|
||||
pVO.setPlayerName(playerNames);
|
||||
pVO.setProjectName(first.getProjectName());
|
||||
pVO.setCategory(first.getCategory());
|
||||
pVO.setPerformanceOrder(order++);
|
||||
participantVOs.add(pVO);
|
||||
}
|
||||
} else {
|
||||
// 单人项目返回全部参赛者
|
||||
participantVOs = participants.stream().map(p -> {
|
||||
org.springblade.modules.martial.pojo.vo.DispatchDataVO.DispatchParticipant pVO =
|
||||
new org.springblade.modules.martial.pojo.vo.DispatchDataVO.DispatchParticipant();
|
||||
@@ -854,6 +881,7 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
|
||||
pVO.setPerformanceOrder(p.getPerformanceOrder());
|
||||
return pVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
groupVO.setParticipants(participantVOs);
|
||||
groups.add(groupVO);
|
||||
|
||||
Reference in New Issue
Block a user