package com.zswl.cloud.springBtach.server.core.config;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author wy
 */
@EnableBatchProcessing
@Configuration
public class SpringBatchConfig {

    @Resource
    private JobBuilderFactory jobBuilderFactory;

    @Resource
    private OrderBatchConfig orderBatchConfig;

    @Resource
    private ChannelOrderBatchConfig channelOrderBatchConfig;

    @Bean
    public Job orderJob(){
        return  jobBuilderFactory
                .get("orderJob")
                .start(orderBatchConfig.orderStepA())
                .next(orderBatchConfig.orderStepB())
                .next(orderBatchConfig.orderStepC())
                .incrementer(new RunIdIncrementer())
                .build();
    }

    @Bean
    public Job chanelOrderJob(){
        return  jobBuilderFactory
                .get("chanelOrderJob")
                .start(channelOrderBatchConfig.channelOrderStepA())
                .next(channelOrderBatchConfig.channelOrderStepB())
                .next(channelOrderBatchConfig.channelOrderStepC())
                .incrementer(new RunIdIncrementer())
                .build();
    }



}
