package com.sckw.transport.model.enuma;

import lombok.Getter;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zk
 * @desc 车辆运单详情状态查询枚举
 * @date 2024/3/8 0008
 */
@Getter
public enum CarWaybillDetailEnum {
    /**
     * 待接单
     */
    TREAT_CONNECT(100, "101,102,103", "待接单"),
    /**
     * 待出车
     */
    TREAT_OUT(200, "201", "待出车"),
    /**
     * 已出车
     */
    SET_OUT(300, "203,202", "已出车"),
    /**
     * 运输中
     */
    IN_TRANSIT(400, "301,302,401,402", "运输中"),
    /**
     * 待审核
     */
    WAIT_APPROVAL(500, "501,503,504,502", "已核单");

    private final Integer code;
    private final String value;
    private final String name;

    CarWaybillDetailEnum(Integer code, String value, String name) {
        this.code = code;
        this.value = value;
        this.name = name;
    }

    public static String getName(Integer code) {
        for (CarWaybillDetailEnum entity : CarWaybillDetailEnum.values()) {
            if (entity.getCode().equals(code)) {
                return entity.getName();
            }
        }
        return null;
    }

    public static String getValue(Integer code) {
        for (CarWaybillTableTopEnum entity : CarWaybillTableTopEnum.values()) {
            if (entity.getCode().equals(code)) {
                return entity.getValue();
            }
        }
        return null;
    }

    public static String getName1(Integer code) {
        for (CarWaybillTableTopEnum entity : CarWaybillTableTopEnum.values()) {
            if (entity.getValue().contains(String.valueOf(code))) {
                return entity.getName();
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    /**
     * 运单状态
     * @return 状态集
     */
    public static List<Integer> initWaybillStatus() {
        List<Integer> statuses = new ArrayList<>();
        statuses.add(CarWaybillDetailEnum.TREAT_CONNECT.getCode());
        statuses.add(CarWaybillDetailEnum.TREAT_OUT.getCode());
        statuses.add(CarWaybillDetailEnum.SET_OUT.getCode());
        return statuses;
    }
}
