package com.sckw.usual.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;

@AllArgsConstructor
@Getter
public enum WayBillStatusEnum {
    ONE(1, "待接单"),
    TWO(2, "待出车"),
    THREE(3,"运输中"),
    FOUR(4, "带核验"),
    FIVE(5, "已完成"),
    SIX(6, "拒接单"),
    SEVEN(7, "已驳回"),
    ;

    private final Integer code;
    private final String msg;


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

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