package org.nl.acs.device_driver;


import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * 驱动类型
 * https://blog.csdn.net/moneyshi/article/details/82978073
 */
public enum RequestMethodEnum {

    feedback_task_status(1, "feedback_task_status", "反馈任务状态","1"),
    apply_mjxl(2, "MJXLTask", "涂板线满架下料","1"),
    apply_bpsl(3, "BPSLTask", "包片上料","1"),
    apply_tbxbkj(4, "TBXBKJTask", "涂板线补空架","1"),
    apply_kghjrk(5, "KGHJRKTask", "空固化架入库","1");


    //驱动索引
    private int index;
    //驱动编码
    private String code;
    // 驱动名字
    private String name;
    //驱动描述
    private String desc;
    //设备驱动类型
    private String type;
    //是否隐藏显示 0否1是
    private String isHidden;

    // 构造方法
    RequestMethodEnum(int index, String code, String name, String isHidden) {
        this.index = index;
        this.code = code;
        this.name = name;
        this.isHidden = isHidden;
    }


    //只反馈未隐藏的
    public static JSONArray getList() {
        JSONArray arr = new JSONArray();
        for (RequestMethodEnum em : RequestMethodEnum.values()) {
            JSONObject json = new JSONObject();
            if(StrUtil.equals(em.getIsHidden(),"0")){
                json.put("code", em.getCode());
                json.put("name", em.getName());
                arr.add(json);
            }
        }
        return arr;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getIsHidden() {
        return isHidden;
    }

    public void setType(String type) {
        this.type = type;
    }

    public static String getName(String code) {
        for (RequestMethodEnum c : RequestMethodEnum.values()) {
            if ( StrUtil.equals(c.code,code)) {
                return c.name;
            }
        }
        return null;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
