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

/**
 * @desc:
 * @author: Lt
 * @date: 2024-04-29
 */
@AllArgsConstructor
@Getter
public enum WaybillStatusEnums {
    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) {
        WaybillStatusEnums[] enums = WaybillStatusEnums.values();
        for (WaybillStatusEnums instance : enums) {
            if (Objects.equals(instance.getCode(), code)) {
                return instance.getMsg();
            }
        }
        return null;
    }

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