定时任务

This commit is contained in:
liukang 2025-02-12 14:56:32 +08:00
parent d44071565e
commit eab0cdfa16
2 changed files with 10 additions and 0 deletions

View File

@ -3,6 +3,9 @@ package com.ruoyi.web.task;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.quartz.domain.SysJob;
import com.ruoyi.quartz.service.ISysJobService;
import com.ruoyi.system.domain.Perform;
import com.ruoyi.system.mapper.PerformMapper;
import com.ruoyi.system.service.IPerformService;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -22,6 +25,10 @@ import java.util.concurrent.CompletableFuture;
public class RyTask {
@Autowired
private ISysJobService jobService;
@Autowired
private IPerformService performService;
@Autowired
private PerformMapper performMapper;
/**
* 抢票
@ -29,6 +36,8 @@ public class RyTask {
* @param pid
*/
public void rob(Long pid, Long jobId) throws SchedulerException {
Perform perform = performService.selectPerformById(pid);
System.out.println(pid + "," + jobId);
for (int i = 0; i < 100; i++) {

View File

@ -96,6 +96,7 @@ public class PerformServiceImpl implements IPerformService {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -1);
calendar.add(Calendar.MINUTE, 9);
// 获取年
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1; // 月份从0开始所以加1