package com.engine.salary.enums.push;

import com.engine.salary.enums.BaseEnum;

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

/**
 * 推送记录状态
 * <p>Copyright: Copyright (c) 2024</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum PushRecordStatusEnum implements BaseEnum<Integer> {
    DATA_PREPARE(0, "准备中", 87625),
    DATA_FINISH(1, "准备完毕", 87625),
    RUN_PROGRESS(2, "推送中", 85393),
    RUN_SUCCESS(3, "推送成功", 85393),
    RUN_FAIL(4, "推送失败", 85393),
    WITHDRAW(5, "撤回中", 85393),
    WITHDRAW_SUCCESS(6, "已撤回", 85393),
    WITHDRAW_FAIL(7, "撤回失败", 85393);

    private int value;

    private String defaultLabel;

    private int labelId;

    PushRecordStatusEnum(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 PushRecordStatusEnum parseByValue(int value) {
        for (PushRecordStatusEnum salaryDataSourceEnum : PushRecordStatusEnum.values()) {
            if (Objects.equals(salaryDataSourceEnum.getValue(), value)) {
                return salaryDataSourceEnum;
            }
        }
        return DATA_PREPARE;
    }

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