package com.ruoyi.warehouseBusiness.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

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

/**
 * @author caifc
 * @date 2021-10-22 17:19
 */
@Getter
@AllArgsConstructor
public enum WarehouseTypeEnum {

    // 仓储业务类型


    KCZZ("KCZZ", "库存总帐"),

    SJRK("SJRK", "入库"),

    SJCK("SJCK", "出库"),

    HQZY("HQZY", "货转"),

    CKDB("CKDB", "调拨"),

    HWTG("HWTG", "货物通关"),


    //是否已计算仓储费

    CALCULATE("T", "已计算"),

    NOT_CALCULATE("F", "未计算"),

    JSCCF("JSCCF", "计算仓储费"),


    // 状态
    INIT("1", "新建"),
    SAVE("2", "保存"),
    DISMISS("3", "请核驳回"),
    SUBMIT("4", "请核"),
    UNDER_REVIEW("5", "请核中"),
    APPROVE("6", "请核完成"),


    // 仓库主表明细状态
    DETAILED_STATUS_PLAN("1", "计划"),
    DETAILED_STATUS_WAITING("2", "待xx"),
    DETAILED_STATUS_PROCESSING("3", "xx中"),
    DETAILED_STATUS_PROCESSED("4", "已xx"),


    // 编号生成简写

    SJRK_NO("RK", "费用变更"),
    SJCK_NO("CK", "入库"),
    CKDB_NO("DB", "出库"),
    HQZY_NO("HZ", "货转"),

    FYBG_NO("FYBG", "费用变更"),


    // 件数
    BOX_NUM("1", "件"),
    // 毛重
    GROSS_WEIGHT("2", "吨"),
    // 净重
    NET_WEIGHT("3", "吨"),
    // 尺码
    MEASURE("4", "吨"),
    // 统一
    FIXED("5", "吨"),

    // 是否计入库存总帐
    INVENTORY("0", "计入库存总帐"),
    NOT_INVENTORY("1", "计入库存总帐"),

    // 根据提单号、客户、仓库查询商品信息类型
    BY_MBLNO("mblno", "根据提单号查询"),
    BY_CPRP("corp", "根据客户查询"),
    BY_WAREHOUSE("warehouse", "根据仓库查询"),


    ;

    private final String type;
    private final String name;

    public static WarehouseTypeEnum fromType(String tp) {
        for (WarehouseTypeEnum type : WarehouseTypeEnum.values()) {
            if (Objects.equals(type.getType(), tp)) {
                return type;
            }
        }
        throw new IllegalArgumentException("warehouse type not exist");
    }

    // 获取业务类型集合
    public static List<String> getWarehousingType() {
        List<String> typList = new ArrayList<>();
        typList.add(SJRK.type);
        typList.add(SJCK.type);
        typList.add(HQZY.type);
        typList.add(CKDB.type);
        typList.add(HWTG.type);
        return typList;
    }

    /**
     * 获取计费单位信息
     *
     * @param unit
     * @return
     */
    public static String getUnitCharging(Long unit) {
        if (Objects.equals(Long.parseLong(BOX_NUM.type), unit)) {
            return BOX_NUM.name;
        } else if (Objects.equals(Long.parseLong(GROSS_WEIGHT.type), unit)) {
            return GROSS_WEIGHT.name;
        } else if (Objects.equals(Long.parseLong(NET_WEIGHT.type), unit)) {
            return NET_WEIGHT.name;
        } else if (Objects.equals(Long.parseLong(MEASURE.type), unit)) {
            return MEASURE.name;
        } else if (Objects.equals(Long.parseLong(FIXED.type), unit)) {
            return FIXED.name;
        }
        throw new IllegalArgumentException("warehouse Billing unit does not exist");
    }

}
