package com.sw.mes.sap.task;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import cc.cczn.matrix.commons.tasks.queue.TaskProcessor;
import cc.cczn.matrix.commons.tasks.queue.block.LinkedBlockDataQueue;

@Configuration
public class QueueConfig {

    @Autowired
    MaterialDataHandlerTask materialDataHandlerTask;

    @Autowired
    MaterialToStoreHandler materialToStoreHandler;
    
    @Autowired
    MblnrQueryHandler mblnrQueryHandler;
    
//    @Autowired
//    SapGoodsmvtDataHandler sapGoodsmvtDataHandler;


    @Bean
    public LinkedBlockDataQueue queue() {
        LinkedBlockDataQueue queue = new LinkedBlockDataQueue();
        List<TaskProcessor> taskList = new ArrayList<TaskProcessor>();
        taskList.add(materialDataHandlerTask);
        queue.setTaskProcessors(taskList);
        return queue;
    }

    @Bean
    public LinkedBlockDataQueue storeSyncQueue() {
        LinkedBlockDataQueue queue = new LinkedBlockDataQueue();
        List<TaskProcessor> taskList = new ArrayList<>();
        taskList.add(materialToStoreHandler);
        queue.setTaskProcessors(taskList);
        return queue;
    }
    
    @Bean
    public LinkedBlockDataQueue mblnrQueryQueue() {
        LinkedBlockDataQueue queue = new LinkedBlockDataQueue();
        queue.setCoreThreadSize(5);
        List<TaskProcessor> taskList = new ArrayList<>();
        taskList.add(mblnrQueryHandler);
        queue.setTaskProcessors(taskList);
        return queue;
    }
    
//    @Bean
//    public LinkedBlockDataQueue sapGoodsmvtQueue() {
//        LinkedBlockDataQueue queue = new LinkedBlockDataQueue();
//        queue.setCoreThreadSize(1);//单线程 先进先出
//        List<TaskProcessor> taskList = new ArrayList<>();
//        taskList.add(sapGoodsmvtDataHandler);
//        queue.setTaskProcessors(taskList);
//        return queue;
//    }

}
