package com.example.bpa.app;

import com.example.bpa.Model.IThread;
import com.example.bpa.db.QueryDB;
import com.example.bpa.helper.ThreadManager;
import com.example.bpa.view.mode.ResGoodsRecipe;

import java.util.ArrayList;
import java.util.concurrent.ConcurrentLinkedQueue;

public class BusinessServer {
    private static volatile BusinessServer _instance;

    public static BusinessServer get() {
        if (_instance == null)
            _instance = new BusinessServer();
        return _instance;
    }

    private BusinessServer() {
    }

    ConcurrentLinkedQueue<String> Commoditys = new ConcurrentLinkedQueue<String>();

    /**
     * 添加配方
     *
     * @param info 配方信息
     */
    public void AddCommodity(String info) {
        Commoditys.offer(info);
    }

    public void Start() {
        ThreadManager.Get().StartLong("配方执行业务流程", true, new IThread() {
            @Override
            public void Run() throws InterruptedException {
                while (Commoditys.size() > 0) {
                    Commoditys.poll();

                    ArrayList<ResGoodsRecipe> goods = QueryDB.GetGoodsSrecipeList("");
                }
                Thread.sleep(1000);
            }

            @Override
            public void RunComplete() throws InterruptedException {

            }
        });
    }

}
