|
@@ -1,6 +1,7 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.img.FontUtil;
|
|
|
+import cn.hutool.core.io.resource.ClassPathResource;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -351,12 +352,6 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 使用poi生成号码对照表
|
|
|
- *
|
|
|
- * @param response
|
|
|
- * @param eventId
|
|
|
- */
|
|
|
/**
|
|
|
* 使用poi生成号码对照表
|
|
|
*
|
|
@@ -579,13 +574,10 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
gameAthleteBo.setEventId(defaultEventId);
|
|
|
List<GameAthleteVo> athleteVoList = gameAthleteService.queryList(gameAthleteBo);
|
|
|
//2.提前查询队员队伍名称缓存
|
|
|
- Set<Long> teamIds = athleteVoList.stream()
|
|
|
- .map(GameAthleteVo::getTeamId)
|
|
|
- .collect(Collectors.toSet());
|
|
|
+ Set<Long> teamIds = athleteVoList.stream().map(GameAthleteVo::getTeamId).collect(Collectors.toSet());
|
|
|
Map<Long, String> teamNameMap = gameTeamService.queryTeamIdAndName(teamIds);
|
|
|
//3.查询赛事所有项目缓存
|
|
|
- Map<Long, String> projectMap = gameEventProjectService.queryListByEventId(defaultEventId)
|
|
|
- .stream().collect(Collectors.toMap(GameEventProjectVo::getProjectId, GameEventProjectVo::getProjectName));
|
|
|
+ Map<Long, String> projectMap = gameEventProjectService.queryListByEventId(defaultEventId).stream().collect(Collectors.toMap(GameEventProjectVo::getProjectId, GameEventProjectVo::getProjectName));
|
|
|
//4.根据参数生成号码布
|
|
|
GameEventVo eventVo = baseMapper.selectVoById(defaultEventId);
|
|
|
generateBib(response, bgImage, logo, eventVo.getEventName(), athleteVoList, teamNameMap, projectMap, bibParam);
|
|
@@ -604,14 +596,7 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
* @param bibParam 布局参数(位置、字体等)
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public void generateBib(HttpServletResponse response,
|
|
|
- MultipartFile backgroundImage,
|
|
|
- MultipartFile logo,
|
|
|
- String eventName,
|
|
|
- List<GameAthleteVo> athleteList,
|
|
|
- Map<Long, String> teamNameMap,
|
|
|
- Map<Long, String> projectMap,
|
|
|
- GenerateBibBo bibParam) {
|
|
|
+ public void generateBib(HttpServletResponse response, MultipartFile backgroundImage, MultipartFile logo, String eventName, List<GameAthleteVo> athleteList, Map<Long, String> teamNameMap, Map<Long, String> projectMap, GenerateBibBo bibParam) {
|
|
|
try {
|
|
|
// 提取布局参数
|
|
|
Double logoX = bibParam.getLogoX();
|
|
@@ -639,9 +624,9 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
}
|
|
|
|
|
|
// 设置响应头(返回 ZIP 压缩包)
|
|
|
- response.reset();
|
|
|
- response.setContentType("application/zip");
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename=\"athlete_bibs.zip\"");
|
|
|
+ // response.reset();
|
|
|
+ // response.setContentType("application/zip");
|
|
|
+ // response.setHeader("Content-Disposition", "attachment; filename=\"athlete_bibs.zip\"");
|
|
|
|
|
|
try (java.util.zip.ZipOutputStream zos = new java.util.zip.ZipOutputStream(response.getOutputStream())) {
|
|
|
|
|
@@ -719,8 +704,7 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
});
|
|
|
|
|
|
// 生成二维码 - 更精确的位置调整
|
|
|
- String qrData = String.format(
|
|
|
- """
|
|
|
+ String qrData = String.format("""
|
|
|
赛事名称:%s,
|
|
|
运动员序号:%d,
|
|
|
运动员编号:%s,
|
|
@@ -730,11 +714,7 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
运动员姓名:%s,
|
|
|
性别:%s,
|
|
|
年龄:%d
|
|
|
- """,
|
|
|
- eventName, athlete.getAthleteId(), athlete.getAthleteCode(),
|
|
|
- joinProject.toString(),
|
|
|
- athlete.getTeamId(), teamNameMap.get(athlete.getTeamId()), athlete.getName(), athlete.getGender(), athlete.getAge()
|
|
|
- );
|
|
|
+ """, eventName, athlete.getAthleteId(), athlete.getAthleteCode(), joinProject.toString(), athlete.getTeamId(), teamNameMap.get(athlete.getTeamId()), athlete.getName(), athlete.getGender(), athlete.getAge());
|
|
|
|
|
|
byte[] qrBytes = generateQRCode(qrData, 150, 150);
|
|
|
Image qrImage = Image.getInstance(qrBytes);
|
|
@@ -807,11 +787,7 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
// 工具方法:解析颜色 (0xRRGGBB)
|
|
|
private static BaseColor parseColor(Integer colorInt) {
|
|
|
if (colorInt == null) return BaseColor.BLACK;
|
|
|
- return new BaseColor(
|
|
|
- (colorInt >> 16) & 0xFF,
|
|
|
- (colorInt >> 8) & 0xFF,
|
|
|
- colorInt & 0xFF
|
|
|
- );
|
|
|
+ return new BaseColor((colorInt >> 16) & 0xFF, (colorInt >> 8) & 0xFF, colorInt & 0xFF);
|
|
|
}
|
|
|
|
|
|
// 工具方法:获取中文字体(推荐将字体文件打包进 resources)
|