package com.qy.agv.util;

import com.qy.agv.activity.ControlActivity;
import com.qy.agv.activity.model.MainModel;

import java.math.BigInteger;
import java.util.ArrayList;

public class DataUtil {

    public static ArrayList<MainModel> getDir(String author){
        ArrayList<MainModel> shops = new ArrayList<MainModel>();
        addMenu(shops,getMenu(ControlActivity.class,"up2","升高","",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"up","前进","up",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"down2","降低","",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"left","左转","left",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"stop","停止","",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"right","右转","right",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"empty","","",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"down","后退","down",0),author);
        addMenu(shops,getMenu(ControlActivity.class,"empty","","",0),author);
        return shops;
    }

    private static void addMenu(ArrayList<MainModel> shops,MainModel menu,String author){
        String abilitys = "";
        if(menu.getKey().contains("_")){
            shops.add(menu);
            return;
        }
        if(!StringUtils.isEmpty(abilitys) && !StringUtils.isEmpty(author)){
            if(abilitys.contains(menu.getKey())){
                shops.add(menu);
            }
            if(abilitys.contains(author)){
                shops.add(menu);
            }
        }else{
            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));
    }
}
