package com.sckw.usual.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

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

/**
 * @author lfdc
 * @description 车辆运单状态枚举
 * @date 2023-07-14 14:07:23
 */
@AllArgsConstructor
@Getter
public enum CarWaybillEnum {
    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) {
        CarWaybillEnum[] enums = CarWaybillEnum.values();
        for (CarWaybillEnum instance : enums) {
            if (Objects.equals(instance.getCode(), code)) {
                return instance.getMsg();
            }
        }
        return null;
    }

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