package cn.estsh.i3plus.pojo.base.enumutil;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author Wynne.Lu
 * @date 2020/2/12 17:41
 * @desc
 */

public class PtlEnumUtil {

    /**
     * 方法类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_METHOD_TYPE {
        INTERFACE(10, "界面方法"),
        MONITOR(20, "监听方法");

        private int value;
        private String description;

        PTL_METHOD_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }
    }

    /**
     * 流程状态-触发类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ROUTE_STATUS_TRIGGER_TYPE {
        INNER_TRIGGER(10, "内部触发"),
        OUTER_TRIGGER(20, "外部触发");

        private int value;
        private String description;

        ROUTE_STATUS_TRIGGER_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }
    }

    /**
     * 触发事件
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ROUNT_STATUS_TRIGGER_EVENT {
        SUCCESS("SUCCESS", "是"),
        FAILURE("FAILURE", "否");

        private String value;
        private String description;

        ROUNT_STATUS_TRIGGER_EVENT(String value, String description) {
            this.value = value;
            this.description = description;
        }

        public static ROUNT_STATUS_TRIGGER_EVENT getByValue(String value) {
            for (ROUNT_STATUS_TRIGGER_EVENT triggerEvent : values()) {
                if (triggerEvent.getValue().equals(value)) {
                    return triggerEvent;
                }
            }
            return null;
        }

        public String getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }
    }

    /**
     * 组件状态类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ROUTE_STATUS_TYPE {
        START(10, "START", "开始状态"),
        EXECUTING(20, "EXECUTING", "执行中状态"),
        FINISH(30, "FINISH", "完成状态");

        private int value;
        private String code;
        private String description;

        ROUTE_STATUS_TYPE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }

    /**
     * 作业流程类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ACTION_ROUTE_TYPE {
        GEN_TASK(10, "GEN_TASK", "生成任务"),
        OFF_TAG(20, "OFF_TAG", "灭灯");

        private int value;
        private String code;
        private String description;

        ACTION_ROUTE_TYPE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }

    /**
     * 状态机执行方法
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ROUTE_STATUS_ACTION_TYPE {
        TRIGGER("10", "trigger", "触发"),
        ENTRY("20", "entry", "进入状态"),
        EXIT("30", "exit", "离开状态");

        private String value;
        private String code;
        private String description;

        ROUTE_STATUS_ACTION_TYPE(String value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public static ROUTE_STATUS_ACTION_TYPE getByValue(String value) {
            for (ROUTE_STATUS_ACTION_TYPE actionType : values()) {
                if (actionType.getValue().equals(value)) {
                    return actionType;
                }
            }
            return null;
        }

        public String getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }

    /**
     * 组件参数类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ACTION_MODULE_PARAM_TYPE {

        QUALIFIED(10, "number", "数字"),
        DEFECTED(20, "text", "字符串"),
        SCRAPED(30, "select", "可选值"),
        BUTTON(40, "button", "按钮");

        private int value;
        private String code;
        private String description;

        ACTION_MODULE_PARAM_TYPE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 标签类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_TAG_TYPE {
        LOCATION_TAG(10, "库位标签"),
        COMPLATE_TAG(20, "完成器标签"),
        TAG_MONITOR(30, "标签显示器"),
        TAG_SCAN_INTERFACE(40, "标签扫描接口");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_TAG_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 亮灯状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_LIGHT_STATUS {
        LIGHT_OFF(10, "灭灯"),
        COMPLATE_ON(20, "亮点");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_LIGHT_STATUS(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 标签状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_TAG_STATUS {
        NORMAL(10, "正常"),
        UNAVAILABLE(20, "不可用");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_TAG_STATUS(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 亮灯方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_LIGHT_MODE {
        LIGHT(10, "常亮"),
        TWINKLE(20, "闪烁");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_LIGHT_MODE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 亮灯颜色
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_LIGHT_COLOR {
        WHITE(10, "白色"),
        RED(20, "红色"),
        GREEN(30, "绿色"),
        BLUE(40, "蓝色"),
        YELLOW(50, "黄色");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_LIGHT_COLOR(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 是否蜂鸣
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_IS_BUZZING {
        YES(1, "是"),
        NO(2, "否");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_IS_BUZZING(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 控制器类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_CONTROL_TYPE {
        ATOP(10, "上尚"),
        AIOI(20, "爱欧");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_CONTROL_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 控制器状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_CONTROL_STATUS {
        CONNECT(10, "连接"),
        BREAK(20, "断开");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_CONTROL_STATUS(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 物料类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_PART_TYPE {
        RAW_MATERIAL("10", "原材料"),
        PARTIALLY_PREPARED_PRODUCTS("20", "半成品"),
        FINISHED_PRODUCT("30", "成品");

        private String value;
        private String description;

        private PTL_PART_TYPE(String value, String description) {
            this.value = value;
            this.description = description;
        }

        public String getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(String val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value.equals(val)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String descriptionOfValue(String val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(val)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 任务类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_TASK_TYPE {
        JIT_TASK("10", "JIT任务"),
        BILL_TASK("20", "单据任务"),
        SINGLE_POINT_TASK("30", "单点任务");

        private String value;
        private String description;

        private PTL_TASK_TYPE(String value, String description) {
            this.value = value;
            this.description = description;
        }

        public String getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(String val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value.equals(val)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String descriptionOfValue(String val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(val)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 任务状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_TASK_STATUS {
        CREATE(10, "创建"),
        COMPLETE(20, "完成"),
        CLOSE(30, "关闭"),
        EXECUTION(40, "执行中");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PTL_TASK_STATUS(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * PCN同步PTL主数据同步类型枚举
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SYNC_TYPE {

        GET_PTL_DATA(1, "pcn获取Ptl数据"),
        DATA_TO_PTL(2, "pcn推送数据至ptl");

        private int value;
        private String description;

        SYNC_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static Integer descriptionOfValue(String description) {
            Integer tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(description)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * PCN同步PTL主数据同步方式枚举
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SYNC_PATTERN {

        UPDATE(1, "新增或修改"),
        INSERT(2, "新增");

        private int value;
        private String description;

        SYNC_PATTERN(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static Integer descriptionOfValue(String description) {
            Integer tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(description)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum TRUE_OR_FALSE {
        TRUE(1, "是"),
        FALSE(2, "否");

        private int value;
        private String description;

        TRUE_OR_FALSE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * ptl-pcn定时任务状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PTL_PCN_TASK_STATUS {

        OPEN(1, "开启"),
        CLOSE(2, "关闭");

        private int value;
        private String description;

        PTL_PCN_TASK_STATUS(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

}
