package com.engine.salary.enums.salaryarchive;

import com.engine.salary.util.SalaryI18nUtil;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 薪资档案-个税扣缴义务人调整原因
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum SalaryArchiveTaxAgentAdjustReasonEnum {

    ADJUSTMENT("ADJUSTMENT", "调动", 85899),
    CHANGE("CHANGE", "变更", 85900),
    ONBOARD("ONBOARD", "入职", 85901),
    DIMISSION("DIMISSION", "离职", 85902),
    OTHER("OTHER", "其他", 84500),
    INIT("INIT", "初始化", 85903);

    private String value;

    private String defaultLabel;

    private int labelId;

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

    public String getValue() {
        return value;
    }

    public String getDefaultLabel() {
        return defaultLabel;
    }

    public int getLabelId() {
        return labelId;
    }

    public static String getValueByDefaultLabel(String defaultLabel) {
        Optional<SalaryArchiveTaxAgentAdjustReasonEnum> optionalAdjustReason = Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).filter(r->SalaryI18nUtil.getI18nLabel(r.getLabelId(), r.getDefaultLabel()).equals(defaultLabel)).findFirst();
        return optionalAdjustReason.isPresent()?optionalAdjustReason.get().getValue():"";
    }

    public static String getDefaultLabelByValue(String value) {
        Optional<SalaryArchiveTaxAgentAdjustReasonEnum> optionalAdjustReason = Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).filter(r->r.getValue().equals(value)).findFirst();
        return optionalAdjustReason.isPresent()? SalaryI18nUtil.getI18nLabel(optionalAdjustReason.get().getLabelId(), optionalAdjustReason.get().getDefaultLabel()):"";
    }

    public static List<Map<String, String>> getList(){
        return Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).map(e -> {
            Map<String, String> map = new HashMap<>();
            map.put("id", e.getValue());
            map.put("content", e.getDefaultLabel());
            return map;
        }).collect(Collectors.toList());
    }

}
