|
|
@@ -0,0 +1,71 @@
|
|
|
+package org.dromara.job.business;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.physical.domain.bo.PhysicalTournamentMenuBo;
|
|
|
+import org.dromara.physical.domain.vo.PhysicalLeagueTournamentVo;
|
|
|
+import org.dromara.physical.domain.vo.PhysicalTournamentMenuVo;
|
|
|
+import org.dromara.physical.mapper.PhysicalLeagueTournamentMapper;
|
|
|
+import org.dromara.physical.service.IPhysicalTournamentMenuService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+@EnableScheduling
|
|
|
+@Slf4j
|
|
|
+public class PhysicalTournamentTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PhysicalLeagueTournamentMapper physicalLeagueTournamentMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IPhysicalTournamentMenuService physicalTournamentMenuService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成 线下赛事预报名菜单
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ * 生成 线下赛事预报名菜单
|
|
|
+ */
|
|
|
+ // @Scheduled(fixedRate = 20000)
|
|
|
+ public void generatePreTask() {
|
|
|
+ // 查询联赛列表
|
|
|
+ List<PhysicalLeagueTournamentVo> physicalLeagueTournamentVoList = physicalLeagueTournamentMapper.selectPhysicalLeagueTournamentSelList();
|
|
|
+
|
|
|
+ // 查询一次预报名类型的菜单列表(避免重复查询)
|
|
|
+ PhysicalTournamentMenuBo physicalTournamentMenuBo = new PhysicalTournamentMenuBo();
|
|
|
+ physicalTournamentMenuBo.setMenuKey("pre_registration_type");
|
|
|
+ List<PhysicalTournamentMenuVo> physicalTournamentMenuVos = physicalTournamentMenuService.queryList(physicalTournamentMenuBo);
|
|
|
+
|
|
|
+ // 遍历联赛列表
|
|
|
+ for (PhysicalLeagueTournamentVo physicalLeagueTournamentVo : physicalLeagueTournamentVoList) {
|
|
|
+ Date registrationBeginTime = physicalLeagueTournamentVo.getRegistrationBeginTime();
|
|
|
+ Date registrationEndTime = physicalLeagueTournamentVo.getRegistrationEndTime();
|
|
|
+ Date currentTime = new Date(); // 获取当前时间
|
|
|
+
|
|
|
+ // 判断当前时间是否在预报名时间段内
|
|
|
+ if (currentTime.after(registrationBeginTime) && currentTime.before(registrationEndTime)) {
|
|
|
+ // 如果在预报名时间内,则更新菜单状态
|
|
|
+ for (PhysicalTournamentMenuVo menuVo : physicalTournamentMenuVos) {
|
|
|
+ PhysicalTournamentMenuBo updateBo = new PhysicalTournamentMenuBo();
|
|
|
+ updateBo.setId(menuVo.getId());
|
|
|
+ updateBo.setStatus(1L); // 设置状态为启用
|
|
|
+ updateBo.setMenuKey("pre_registration_type");
|
|
|
+ physicalTournamentMenuService.auditTournamentMenu(updateBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|