package com.sw.mes.yb.production.enums;

/**
 * 工作中心枚举 SXLJ1009
 */
public enum WorkIndexRangeEnum {
    /**
     * 工作中心枚举通用属性
     * SX L J 1 009
     */
    基地(0, 0, 2, 2),
    产出部门(1, 2, 3, 1),
    定向类别(2, 3, 4, 3),
    车间号(3, 4, 5, 1),
    流水(4, 5, 7, 3);




    /**
     * key:属性位置(支持长度在两位数字的位置,大于两位数无效)
     * beginIndex: 开始位置
     * endIndex: 结束位置
     * length: 长度
     */
    private int key;
    private int beginIndex;
    private int endIndex;
    private int length;

    WorkIndexRangeEnum(int key, int beginIndex, int endIndex, int length) {
        this.key = key;
        this.beginIndex = beginIndex;
        this.endIndex = endIndex;
        this.length = length;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getKey() {
        return key;
    }

    public void setKey(int key) {
        this.key = key;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public void setBeginIndex(int beginIndex) {
        this.beginIndex = beginIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public void setEndIndex(int endIndex) {
        this.endIndex = endIndex;
    }

    public static String getText(int value) {
        WorkIndexRangeEnum[] enums = values();
        for (WorkIndexRangeEnum enumz : enums) {
            if (enumz.getKey() == value) {
                return enumz.name();
            }
        }
        return null;
    }

    public static WorkIndexRangeEnum getEnum(Integer value) {
        WorkIndexRangeEnum[] enums = values();
        for (WorkIndexRangeEnum enumz : enums) {
            if (enumz.getKey() == value) {
                return enumz;
            }
        }
        return null;
    }
}
