package com.yunzhupaas.flowable.job;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 类的描述
 *
 * @author YUNZHUPAASYUNZHUPAAS开发组
 * @version 5.0.x
 * @since 2024/5/23 18:16
 */
@Configuration
public class FlowJobConfig {
    @Bean
    public JobDetail autoAuditDetail() {
        JobDetail jobDetail = JobBuilder.newJob(AutoAuditJob.class)
                .storeDurably() // 必须调用该方法，添加任务
                .build();
        return jobDetail;
    }

    @Bean
    public Trigger autoAuditTrigger() {
        // 任务频率
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/5 * * * * ?");
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .forJob(autoAuditDetail())
                .withSchedule(cronScheduleBuilder)
                .build();
        return trigger;
    }

    @Bean
    public JobDetail autoTransferDetail() {
        JobDetail jobDetail = JobBuilder.newJob(AutoTransferJob.class)
                .storeDurably() // 必须调用该方法，添加任务
                .build();
        return jobDetail;
    }

    @Bean
    public Trigger autoTransferTrigger() {
        // 任务频率
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/8 * * * * ?");
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .forJob(autoTransferDetail())
                .withSchedule(cronScheduleBuilder)
                .build();
        return trigger;
    }
}
