2 天以前 300cf495c6a708df63621ff70e6d5408abc2912a
src/main/java/com/ruoyi/inspectiontask/service/impl/TimingTaskScheduler.java
@@ -52,19 +52,8 @@
                        ? Date.from(task.getNextExecutionTime().atZone(ZoneId.systemDefault()).toInstant())
                        : new Date())
                .build();
        // 构建新触发器
//        Trigger newTrigger = TriggerBuilder.newTrigger()
//                .withIdentity(triggerKey)
//                .withDescription(task.getTaskName())
//                .withSchedule(CronScheduleBuilder.cronSchedule(convertToCronExpression(task)))
//                .startAt(Date.from(task.getNextExecutionTime().atZone(ZoneId.systemDefault()).toInstant()))
//                .forJob(oldTrigger.getJobKey())
//                .build();
        scheduler.rescheduleJob(triggerKey, newTrigger);
    }
    /**
     * 暂停任务
     */
@@ -84,12 +73,12 @@
    /**
     * 删除任务
     */
    public void unscheduleTimingTask(Long taskId){
    public void unscheduleTimingTask(Long taskId) {
        try {
            JobKey jobKey = new JobKey("timingTask_" + taskId);
            scheduler.deleteJob(jobKey);
        }catch (SchedulerException e){
            throw new RuntimeException(e);
        }catch (Exception e){
            throw new RuntimeException(e.getMessage());
        }
    }
@@ -114,6 +103,7 @@
                .build();
    }
    private Trigger buildJobTrigger(TimingTask task, JobDetail jobDetail) {
        // 1. 构建唯一TriggerKey(基于任务ID)
        TriggerKey triggerKey = new TriggerKey("trigger_" + task.getId());
@@ -136,6 +126,7 @@
                        : new Date())
                .build();
    }
    private String convertToCronExpression(TimingTask task) {
        // 参数校验
        if (task == null || task.getFrequencyType() == null || task.getFrequencyDetail() == null) {