|
|
@@ -1179,36 +1179,41 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
*/
|
|
|
@NotNull
|
|
|
private static String getQrDataStr(String eventName, String groupName, Map<Long, String> teamNameMap, Map<Long, String> projectMap, GameAthleteVo athlete) {
|
|
|
- //处理参加项目
|
|
|
- StringBuilder joinProject = new StringBuilder();
|
|
|
- StringJoiner joiner = new StringJoiner("、"); // 指定分隔符
|
|
|
- athlete.getProjectList().forEach(projectId -> {
|
|
|
- String projectName = projectMap.getOrDefault(Long.valueOf(projectId),"");
|
|
|
- if (projectName != null) {
|
|
|
- joiner.add(projectName);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // 生成二维码
|
|
|
- String qrData = String.format(
|
|
|
- """
|
|
|
- {
|
|
|
- 赛事名称:%s,
|
|
|
- 运动员序号:%d,
|
|
|
- 运动员编号:%s,
|
|
|
- 参与项目:%s,
|
|
|
- 队伍名称:%s,
|
|
|
- 运动员姓名:%s,
|
|
|
- 性别:%s,
|
|
|
- 年龄:%d
|
|
|
- 组别:%s
|
|
|
- }
|
|
|
- """,
|
|
|
- eventName, athlete.getAthleteId(), athlete.getAthleteCode(),
|
|
|
- joinProject, teamNameMap.getOrDefault(athlete.getTeamId(),""), athlete.getName(),
|
|
|
- athlete.getGender(), athlete.getAge(), groupName
|
|
|
- );
|
|
|
- return qrData;
|
|
|
+ try {
|
|
|
+ // 处理参加项目
|
|
|
+ StringJoiner joiner = new StringJoiner("、"); // 指定分隔符
|
|
|
+ athlete.getProjectList().forEach(projectId -> {
|
|
|
+ String projectName = projectMap.getOrDefault(Long.valueOf(projectId),"");
|
|
|
+ if (projectName != null && !projectName.isEmpty()) {
|
|
|
+ joiner.add(projectName);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ String xiangmu = joiner.toString();
|
|
|
+
|
|
|
+ // 获取运动员姓名并进行URL编码
|
|
|
+ String encodedName = java.net.URLEncoder.encode(athlete.getName(), "UTF-8");
|
|
|
+
|
|
|
+ // 获取赛事ID(从athlete对象中获取)
|
|
|
+ Long shId = athlete.getEventId();
|
|
|
+
|
|
|
+ // 生成符合要求格式的URL查询参数字符串
|
|
|
+ String qrData = String.format(
|
|
|
+ "id=%s&name=%s&gender=%s&shId=%d&shName=%s&dwName=%s&xiangmu=%s",
|
|
|
+ athlete.getAthleteCode(), // 队员号码(唯一ID)
|
|
|
+ encodedName, // 队员姓名(URL编码)
|
|
|
+ athlete.getGender(), // 性别
|
|
|
+ shId, // 赛事ID
|
|
|
+ eventName, // 赛事名称
|
|
|
+ teamNameMap.getOrDefault(athlete.getTeamId(), ""), // 队伍名称
|
|
|
+ xiangmu // 参与项目
|
|
|
+ );
|
|
|
+
|
|
|
+ return qrData;
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 如果编码失败,返回基本信息
|
|
|
+ log.error("生成二维码数据失败(编码失败): {}", e.getMessage(), e);
|
|
|
+ return String.format("id=%s&name=%s", athlete.getAthleteCode(), athlete.getName());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 工具方法:添加文本
|
|
|
@@ -2043,72 +2048,58 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
* 生成二维码数据
|
|
|
*/
|
|
|
private String generateQRCodeData(GameAthleteVo athlete) {
|
|
|
- StringBuilder joinProject = new StringBuilder();
|
|
|
- StringJoiner joiner = new StringJoiner(",");
|
|
|
-
|
|
|
- // 添加调试日志
|
|
|
- log.debug("生成二维码数据 - 运动员: {}, projectValue: {}, projectList: {}",
|
|
|
- athlete.getName(), athlete.getProjectValue(), athlete.getProjectList());
|
|
|
-
|
|
|
- // 检查projectList是否为null或空
|
|
|
- if (athlete.getProjectList() == null || athlete.getProjectList().isEmpty()) {
|
|
|
- log.warn("运动员 {} 的参与项目列表为空,projectValue: {}", athlete.getName(), athlete.getProjectValue());
|
|
|
- return String.format(
|
|
|
- """
|
|
|
- {
|
|
|
- 赛事名称:%s,
|
|
|
- 号码:%s,
|
|
|
- 姓名:%s,
|
|
|
- 性别:%s,
|
|
|
- 年龄:%d
|
|
|
- 队伍名称:%s,
|
|
|
- 参与项目:无项目,
|
|
|
- }
|
|
|
- """,
|
|
|
- athlete.getEventName(),
|
|
|
- athlete.getAthleteCode(),
|
|
|
- athlete.getName(),
|
|
|
- athlete.getGender(),
|
|
|
- athlete.getAge(),
|
|
|
- athlete.getTeamName() != null ? athlete.getTeamName() : "未知队伍");
|
|
|
- }
|
|
|
-
|
|
|
- Map<Long, String> projectMap = gameEventProjectService.queryNameByEventIdAndProjectIds(athlete.getEventId(), athlete.getProjectList());
|
|
|
- log.debug("项目映射结果: {}", projectMap);
|
|
|
-
|
|
|
- // 添加额外的null检查
|
|
|
- if (projectMap == null) {
|
|
|
- log.warn("项目映射结果为空,返回空字符串,逻辑上不可能为空,如果有空项目,应该在运动员表中删除");
|
|
|
- projectMap = new HashMap<>();
|
|
|
- }
|
|
|
-
|
|
|
- for (Long projectId : athlete.getProjectList()) {
|
|
|
- String projectName = projectMap.get(projectId) != null ? projectMap.get(projectId).toString() : "未知项目";
|
|
|
- joiner.add(projectName);
|
|
|
- }
|
|
|
-
|
|
|
- String projectNames = joiner.toString();
|
|
|
- log.debug("最终项目名称: {}", projectNames);
|
|
|
-
|
|
|
- return String.format(
|
|
|
- """
|
|
|
- {
|
|
|
- 赛事名称:%s,
|
|
|
- 号码:%s,
|
|
|
- 姓名:%s,
|
|
|
- 性别:%s,
|
|
|
- 年龄:%d
|
|
|
- 队伍名称:%s,
|
|
|
- 参与项目:%s,
|
|
|
+ try {
|
|
|
+ // 添加调试日志
|
|
|
+ log.debug("生成二维码数据 - 运动员: {}, projectValue: {}, projectList: {}",
|
|
|
+ athlete.getName(), athlete.getProjectValue(), athlete.getProjectList());
|
|
|
+
|
|
|
+ // 处理参加项目
|
|
|
+ StringJoiner joiner = new StringJoiner("、"); // 指定分隔符
|
|
|
+ if (athlete.getProjectList() != null && !athlete.getProjectList().isEmpty()) {
|
|
|
+ Map<Long, String> projectMap = gameEventProjectService.queryNameByEventIdAndProjectIds(athlete.getEventId(), athlete.getProjectList());
|
|
|
+ log.debug("项目映射结果: {}", projectMap);
|
|
|
+
|
|
|
+ // 添加额外的null检查
|
|
|
+ if (projectMap == null) {
|
|
|
+ log.warn("项目映射结果为空,返回空字符串,逻辑上不可能为空,如果有空项目,应该在运动员表中删除");
|
|
|
+ projectMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Long projectId : athlete.getProjectList()) {
|
|
|
+ String projectName = projectMap.getOrDefault(projectId, "未知项目");
|
|
|
+ joiner.add(projectName);
|
|
|
}
|
|
|
- """,
|
|
|
- athlete.getEventName(),
|
|
|
- athlete.getAthleteCode(),
|
|
|
- athlete.getName(),
|
|
|
- athlete.getGender(),
|
|
|
- athlete.getAge(),
|
|
|
- athlete.getTeamName() != null ? athlete.getTeamName() : "未知队伍",
|
|
|
- projectNames);
|
|
|
+ }
|
|
|
+ String xiangmu = joiner.toString();
|
|
|
+
|
|
|
+ // 获取运动员姓名并进行URL编码
|
|
|
+ String encodedName = java.net.URLEncoder.encode(athlete.getName(), "UTF-8");
|
|
|
+
|
|
|
+ // 获取赛事ID(从athlete对象中获取)
|
|
|
+ Long shId = athlete.getEventId();
|
|
|
+
|
|
|
+ // 获取赛事名称和队伍名称
|
|
|
+ String shName = athlete.getEventName();
|
|
|
+ String dwName = athlete.getTeamName() != null ? athlete.getTeamName() : "未知队伍";
|
|
|
+
|
|
|
+ // 生成符合要求格式的URL查询参数字符串
|
|
|
+ String qrData = String.format(
|
|
|
+ "id=%s&name=%s&gender=%s&shId=%d&shName=%s&dwName=%s&xiangmu=%s",
|
|
|
+ athlete.getAthleteCode(), // 队员号码(唯一ID)
|
|
|
+ encodedName, // 队员姓名(URL编码)
|
|
|
+ athlete.getGender(), // 性别
|
|
|
+ shId, // 赛事ID
|
|
|
+ shName, // 赛事名称
|
|
|
+ dwName, // 队伍名称
|
|
|
+ xiangmu // 参与项目
|
|
|
+ );
|
|
|
+
|
|
|
+ return qrData;
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 如果编码失败,返回基本信息
|
|
|
+ log.error("生成二维码数据失败(编码失败): {}", e.getMessage(), e);
|
|
|
+ return String.format("id=%s&name=%s", athlete.getAthleteCode(), athlete.getName());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|