package com.engine.salary.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * 薪资账目取值方式
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum SalaryDataSourceEnum implements BaseEnum<Integer> {

    INPUT_IMPORT(0, "输入/导入", 92004),
    CUSTOM_FORMULA(1, "自定义公式", 92001),
    SALARY_ITEM(2, "薪资项目", 84960),
    EMPLOYEE_INFO(3, "员工基本信息", 85366),
    SALARY_ARCHIVES(4, "薪资档案", 85368),
    CUMULATIVE_SITUATION(5, "累计情况（工资、薪金）", 87521),
    SPE_ADDI_DEDUCTIONS(6, "累计专项附加扣除", 85380),
    SOCIAL_SECURITY(7, "社保福利", 87522),
    OTHER_DEDUCTION(8, "其他扣除", 85831),
    ;

    private int value;

    private String defaultLabel;

    private int labelId;

    SalaryDataSourceEnum(int value, String defaultLabel, int labelId) {
        this.value = value;
        this.defaultLabel = defaultLabel;
        this.labelId = labelId;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getDefaultLabel() {
        return defaultLabel;
    }

    @Override
    public Integer getLabelId() {
        return labelId;
    }

    public static SalaryDataSourceEnum parseByValue(int value) {
        for (SalaryDataSourceEnum salaryDataSourceEnum : SalaryDataSourceEnum.values()) {
            if (Objects.equals(salaryDataSourceEnum.getValue(), value)) {
                return salaryDataSourceEnum;
            }
        }
        return null;
    }

    public static String getDefaultLabelByValue(Integer value) {
        if (value == null) {
            return "";
        }
        SalaryDataSourceEnum[] enumAry = SalaryDataSourceEnum.values();
        for(int i = 0; i < Arrays.asList(enumAry).size(); i++){
            if (Integer.valueOf(enumAry[i].getValue()).equals(value)) {
                return enumAry[i].getDefaultLabel();
            }
        }
        return "";
    }
}
