package com.sckw.mine.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author lt
 * @desc: 订单状态枚举
 */
@AllArgsConstructor
@Getter
public enum MineStatusEnum {
    ZERO(0, "已驳回"),
    ONE(1, "已保存"),
    TWO(2, "确认下单"),
    THREE(3, "订单审核"),
    FOUR(4, "计划采掘"),
    FIVE(5, "计划加工"),
    SIX(6, "原料加工"),
    SEVEN(7, "矿料清点"),
    EIGHT(8, "完成订单"),
    NINE(8, "已取消")
    ;

    private final Integer code;
    private final String msg;


    public static String getNameByCode(Integer code) {
        MineStatusEnum[] enums = MineStatusEnum.values();
        for (MineStatusEnum instance : enums) {
            if (Objects.equals(instance.getCode(), code)) {
                return instance.getMsg();
            }
        }
        return null;
    }

    public static List<MineStatusEnum> getSortList() {
        MineStatusEnum[] enums = MineStatusEnum.values();
        return Arrays.stream(enums).sorted(Comparator.comparingInt(MineStatusEnum::getCode)).collect(Collectors.toList());
    }
}
