package com.ygtx.emcs.util;

import com.ygtx.emcs.activity.StockChangeActivity;
import com.ygtx.emcs.activity.StockInActivity;
import com.ygtx.emcs.activity.StockInNewActivity;
import com.ygtx.emcs.activity.StockItemActivity;
import com.ygtx.emcs.activity.StockOutActivity;
import com.ygtx.emcs.activity.StockOutNewActivity;
import com.ygtx.emcs.activity.StockPackageActivity;
import com.ygtx.emcs.activity.model.MainModel;
import com.ygtx.emcs.activity.model.MenuModel;

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

public class DataUtil {

    public static ArrayList<MainModel> getMenus(List<MenuModel> menuModelList){
        ArrayList<MainModel> shops = new ArrayList<MainModel>();
        addMenu(shops,getMenu(StockInNewActivity.class,"b8","入库单","pda:inStock",0),menuModelList);
        addMenu(shops,getMenu(StockOutNewActivity.class,"b4","出库单","pda:outStock",0),menuModelList);
        addMenu(shops,getMenu(StockPackageActivity.class,"b7","打包区","pda:packaging",0),menuModelList);
        addMenu(shops,getMenu(StockItemActivity.class,"b10","库位信息","pda:stocking",0),menuModelList);
        addMenu(shops,getMenu(StockChangeActivity.class,"b8","物料整理","pda:item",0),menuModelList);
        return shops;
    }

    private static void addMenu(ArrayList<MainModel> shops,MainModel menu,List<MenuModel> menuModelList){
        if(menuModelList!=null){
            menuModelList.forEach(item->{
                if(item.getPerms().equals(menu.getKey())){
                    shops.add(menu);
                }
            });
        }
    }

    private static MainModel getMenu(Class clz,String logo,String title,String key,int header){
        MainModel shop = new MainModel();
        shop.setActionClass(clz);
        shop.setLogo(logo);
        shop.setTitle(title);
        shop.setKey(key);
        shop.setHeaderId(header);
        if(header == 0){
            shop.setGroupName("业务流程");
        }
        if(header == 1){
            shop.setGroupName("基础信息");
        }
        if(header == 2){
            shop.setGroupName("机器人");
        }
        return shop;
    }

    public static void main(String args[]) {
//        String v = DataUtil.getConData("A12");
//        System.out.println(v);
//        byte[] writeDataBytes = Tools.HexString2Bytes("02BB2021060001");
//        System.out.println(writeDataBytes.length);
//        System.out.println(Tools.Bytes2HexString(writeDataBytes,writeDataBytes.length));
//        System.out.println(new String(v));
    }
}
