package com.sckw.core.model.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lfdc
 * @description 车辆运单状态枚举[仅查询使用]
 * @date 2023-07-14 14:07:23
 */
public enum CarWaybillQueryEnum {
    /**
     * 待接单
     */
    PENDING_ORDER(1, "pendingOrder", "1", "待接单"),
    /**
     * 待出车
     */
    PENDING_VEHICLE(2, "pendingVehicle", "2", "待出车"),
    /**
     * 已出车
     */
    EXIT_COMPLETED(3, "exitCompleted", "3", "已出车"),
    /**
     * 到达装货点
     */
    WAIT_LOADING(4, "waitLoading", "4", "到达装货点"),
    /**
     * 已装货
     */
    COMPLETION_LOADING(5, "completionLoading", "5", "已装货"),
    /**
     * 到达卸货点
     */
    WAIT_UNLOADING(6, "waitUnloading", "6", "到达卸货点"),
    /**
     * 已卸货
     */
    COMPLETION_UNLOADING(7, "completionUnloading", "7", "已卸货"),
    /**
     * 已核-通过
     */
    APPROVAL_PASS(8, "approvalPass", "8", "审核通过"),
    /**
     * 拒接单
     */
    REJECT_ORDER(9, "rejectOrder", "9", "拒接单"),
    /**
     * 拒出车
     */
    REFUSE_TRAFFIC(10, "refuseTraffic", "10", "拒出车"),
    /**
     * 已撤销
     */
    REVOKED(11, "revoked", "11", "单趟撤回"),
    /**
     * 已核单-不通过[审核不通过]
     */
    APPROVAL_NO_PASS(12, "revoked", "12", "核单驳回"),
    /**
     * 单证更新审核中
     */
    APPROVAL_IN(13, "approvalIn", "13", "单证更新审核中"),

    /**
     * 单证审核
     */
    DOCUMENT_CHECK(100, "documentCheck", "100", "单证审核"),

    /**
     * 已作废
     */
    ABROGATE(200, "abrogate", "200", "已作废"),
    ;

    private final Integer code;
    private final String value;
    private final String status;
    private final String destination;

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getStatus() {
        return status;
    }

    public String getDestination() {
        return destination;
    }

    CarWaybillQueryEnum(Integer code, String value, String status, String destination) {
        this.code = code;
        this.value = value;
        this.status = status;
        this.destination = destination;
    }

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

    public static String getWaybillOrderDestination(String status) {
        for (CarWaybillQueryEnum waybillEnum : CarWaybillQueryEnum.values()) {
            if (waybillEnum.getStatus().equals(status)) {
                return waybillEnum.getDestination();
            }
        }
        return null;
    }

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

    public static List<Integer> getCodes() {
        List<Integer> codes = new ArrayList<>();
        for (CarWaybillQueryEnum waybillEnum : CarWaybillQueryEnum.values()) {
            codes.add(waybillEnum.getCode());
        }
        return codes;
    }

    public static List<String> getStringCodes() {
        List<String> codes = new ArrayList<>();
        for (CarWaybillQueryEnum waybillEnum : CarWaybillQueryEnum.values()) {
            codes.add(waybillEnum.getStatus());
        }
        return codes;
    }

    /**
     * @param code 状态码
     * @desc 是否可以变更司机/车辆
     * @author zk
     * @date 2023/8/2
     **/
    public static boolean changeDriverAndTruck(int code) {
        if (code == CarWaybillQueryEnum.COMPLETION_UNLOADING.getCode()
                || code == CarWaybillQueryEnum.APPROVAL_PASS.getCode()
                || code == CarWaybillQueryEnum.REJECT_ORDER.getCode()
                || code == CarWaybillQueryEnum.REFUSE_TRAFFIC.getCode()
                || code == CarWaybillQueryEnum.REVOKED.getCode()
                || code == CarWaybillQueryEnum.APPROVAL_NO_PASS.getCode()) {
            return false;
        }
        return true;
    }
}
