|
@@ -1384,56 +1384,20 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
*/
|
|
*/
|
|
|
private String generateQRCodeData(GameAthleteVo athlete) {
|
|
private String generateQRCodeData(GameAthleteVo athlete) {
|
|
|
try {
|
|
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);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- 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;
|
|
|
|
|
|
|
+ // 构造包含基础信息的运动员二维码数据对象
|
|
|
|
|
+ AthleteQRCodeVo vo = new AthleteQRCodeVo();
|
|
|
|
|
+ vo.setId(athlete.getAthleteId());
|
|
|
|
|
+ vo.setTeamId(athlete.getTeamId());
|
|
|
|
|
+ vo.setName(athlete.getName());
|
|
|
|
|
+ vo.setDuiwu(athlete.getTeamName());
|
|
|
|
|
+ vo.setXuhao(athlete.getTrackIndex());
|
|
|
|
|
+ vo.setNum(athlete.getAthleteCode());
|
|
|
|
|
+
|
|
|
|
|
+ // 直接返回对象序列化后的 JSON 字符串
|
|
|
|
|
+ return JsonUtils.toJsonString(vo);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- // 如果编码失败,返回基本信息
|
|
|
|
|
- log.error("生成二维码数据失败(编码失败): {}", e.getMessage(), e);
|
|
|
|
|
- return String.format("id=%s&name=%s", athlete.getAthleteCode(), athlete.getName());
|
|
|
|
|
|
|
+ log.error("生成二维码数据失败: {}", e.getMessage(), e);
|
|
|
|
|
+ return "";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|