|
@@ -21,6 +21,7 @@ import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
+import org.dromara.job.business.ScheduleTask;
|
|
|
import org.dromara.system.domain.vo.SysOssVo;
|
|
import org.dromara.system.domain.vo.SysOssVo;
|
|
|
import org.dromara.system.service.ISysOssService;
|
|
import org.dromara.system.service.ISysOssService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -30,6 +31,7 @@ import java.text.ParseException;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.time.format.DateTimeParseException;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
/**
|
|
/**
|
|
@@ -68,6 +70,8 @@ public class TournamentsTemplateServiceImpl implements ITournamentsTemplateServi
|
|
|
|
|
|
|
|
private final TournamentCategoryTagTemplateMapper tournamentCategoryTagTemplateMapper;
|
|
private final TournamentCategoryTagTemplateMapper tournamentCategoryTagTemplateMapper;
|
|
|
|
|
|
|
|
|
|
+ private final ScheduleTask scheduleTask;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询【请填写功能名称】
|
|
* 查询【请填写功能名称】
|
|
|
*
|
|
*
|
|
@@ -571,7 +575,48 @@ public class TournamentsTemplateServiceImpl implements ITournamentsTemplateServi
|
|
|
return baseMapper.selectTournamentsVoListTemplateList();
|
|
return baseMapper.selectTournamentsVoListTemplateList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean generateTournamentByTemplate(Long templateId, String beginTime) {
|
|
|
|
|
+ // 参数校验
|
|
|
|
|
+ if (templateId == null) {
|
|
|
|
|
+ log.error("模板ID不能为空");
|
|
|
|
|
+ throw new IllegalArgumentException("模板ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (beginTime == null || beginTime.trim().isEmpty()) {
|
|
|
|
|
+ log.error("开始时间不能为空");
|
|
|
|
|
+ throw new IllegalArgumentException("开始时间不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询模板信息
|
|
|
|
|
+ TournamentsVo tournamentsVo = baseMapper.selectVoByIdInfoTemplate(templateId);
|
|
|
|
|
+ if (tournamentsVo == null) {
|
|
|
|
|
+ log.error("未找到模板ID为 {} 的赛事模板", templateId);
|
|
|
|
|
+ throw new IllegalArgumentException("未找到指定的赛事模板");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime localBeginTime;
|
|
|
|
|
+ try {
|
|
|
|
|
+ localBeginTime = LocalDateTime.parse(beginTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ } catch (DateTimeParseException e) {
|
|
|
|
|
+ log.error("时间格式错误: {}, 格式应为 yyyy-MM-dd HH:mm:ss", beginTime, e);
|
|
|
|
|
+ throw new IllegalArgumentException("开始时间格式错误,应为 yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 调用任务调度服务创建赛事
|
|
|
|
|
+ boolean success = scheduleTask.autowiredTournamentData(null, tournamentsVo.getId(), localBeginTime, null);
|
|
|
|
|
+ if (!success) {
|
|
|
|
|
+ log.warn("赛事生成失败,模板ID: {}, 开始时间: {}", templateId, beginTime);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ log.info("赛事生成成功,模板ID: {}, 开始时间: {}", templateId, beginTime);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
+ public static LocalDateTime parseToLocalDateTime(String timeStr) {
|
|
|
|
|
+ return LocalDateTime.parse(timeStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ }
|
|
|
private List<ItemsPrizeDto> parsePrizeList(String itemsPrizeListJson, ObjectMapper mapper) throws Exception {
|
|
private List<ItemsPrizeDto> parsePrizeList(String itemsPrizeListJson, ObjectMapper mapper) throws Exception {
|
|
|
if (itemsPrizeListJson == null || itemsPrizeListJson.isBlank()) {
|
|
if (itemsPrizeListJson == null || itemsPrizeListJson.isBlank()) {
|
|
|
throw new IllegalArgumentException("itemsPrizeList 不能为空");
|
|
throw new IllegalArgumentException("itemsPrizeList 不能为空");
|