|
@@ -1,5 +1,6 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.img.FontUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -19,6 +20,7 @@ import jakarta.annotation.Resource;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.io.output.ByteArrayOutputStream;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
@@ -50,7 +52,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -708,9 +710,13 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
cb.endText();
|
|
|
}
|
|
|
StringBuilder joinProject = new StringBuilder();
|
|
|
- athlete.getProjectList().forEach(
|
|
|
- projectId -> joinProject.append(projectMap.get(Long.valueOf(projectId))).append(" ")
|
|
|
- );
|
|
|
+ StringJoiner joiner = new StringJoiner("、"); // 指定分隔符
|
|
|
+ athlete.getProjectList().forEach(projectId -> {
|
|
|
+ String projectName = projectMap.get(Long.valueOf(projectId));
|
|
|
+ if (projectName != null) {
|
|
|
+ joiner.add(projectName);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
// 生成二维码 - 更精确的位置调整
|
|
|
String qrData = String.format(
|
|
@@ -720,11 +726,11 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
运动员编号:%s,
|
|
|
参与项目:%s,
|
|
|
队伍id:%d,
|
|
|
- 队伍名称:%s
|
|
|
- 运动员姓名:%s
|
|
|
+ 队伍名称:%s,
|
|
|
+ 运动员姓名:%s,
|
|
|
性别:%s,
|
|
|
年龄:%d
|
|
|
- """,
|
|
|
+ """,
|
|
|
eventName, athlete.getAthleteId(), athlete.getAthleteCode(),
|
|
|
joinProject.toString(),
|
|
|
athlete.getTeamId(), teamNameMap.get(athlete.getTeamId()), athlete.getName(), athlete.getGender(), athlete.getAge()
|
|
@@ -812,13 +818,18 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
private static BaseFont getChineseFont(String fontName) throws Exception {
|
|
|
// 方式1:使用系统字体(Windows)
|
|
|
// return BaseFont.createFont("C:/Windows/Fonts/simhei.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
|
|
+ String filePath;
|
|
|
switch (fontName) {
|
|
|
- case "simhei":
|
|
|
- return BaseFont.createFont("classpath:fonts/simhei.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
|
|
- case "simsun":
|
|
|
- return BaseFont.createFont("classpath:fonts/simsun.ttc", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
|
|
- default:
|
|
|
- return BaseFont.createFont("classpath:fonts/msyhbd.ttc", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
|
|
+ case "simhei" -> filePath = "fonts/simhei.ttf";
|
|
|
+ case "simsun" -> filePath = "fonts/simsun.ttf";
|
|
|
+ default -> filePath = "fonts/yahei.ttf";
|
|
|
+ }
|
|
|
+ try (InputStream in = FontUtil.class.getClassLoader().getResourceAsStream(filePath)) {
|
|
|
+ if (in == null) throw new FileNotFoundException(filePath);
|
|
|
+ File temp = File.createTempFile("font_", ".ttf");
|
|
|
+ temp.deleteOnExit();
|
|
|
+ IOUtils.copy(in, new FileOutputStream(temp));
|
|
|
+ return BaseFont.createFont(temp.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
|
|
}
|
|
|
}
|
|
|
}
|