package com.ruoyi.warehouseBusiness.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.compress.utils.Lists;

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

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

    //仓库审批活动号
    INSTOCK(110, "SJRK", "入库"),
    OUTSTOCK(120, "SJCK", "出库"),
    FORWARDING(130, "HQZY", "货转"),
    TRANSFER(140, "CKDB", "调拨"),
    CALCULATE_COST(150, "JSCCF", "计算仓储费"),
    CLEARANCE(160, "HWTG", "货物通关"),
    DIRECT_LOADING(190, "CDZZ", "场地直装"),
    INSTOCK_ITEM(170, "RKMX", "入库明细审核"),
    OUTSTOCK_ITEM(180, "RKMX", "入库明细审核"),


    FEE_CHANGES(1000, "", "费用变更"),

    //财务审批活动号
    RECONCILIATION(210, "", "对账"),
    TOLL(220, "", "收费"),
    PAID(230, "", "付费"),
    INVOICE(260, "", "发票"),

    //仓储计划活动号
    STORAGE_FEE(310, "", "仓储费"),
    PLAN_FEE(320, "", "计划费"),

    //凯和
    CUSTOMS_APPROVAL1(111, "", "只有上面主表标星字段"),
    CUSTOMS_APPROVAL2(121, "", "只有上面主表标星字段"),
    CUSTOMS_APPROVAL3(131, "", "只有上面主表标星字段"),
    CUSTOMS_APPROVAL4(141, "", "只有上面主表标星字段"),
    CUSTOMS_APPROVAL5(151, "", "只有上面主表标星字段"),
    CUSTOMS_APPROVAL6(161, "", "只有上面主表标星字段"),

    ;

    private final Integer actId;
    private final String type;
    private final String name;


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

    public static WarehouseActIdEnum fromActId(Integer act) {
        for (WarehouseActIdEnum type : WarehouseActIdEnum.values()) {
            if (Objects.equals(type.getActId(), act)) {
                return type;
            }
        }
        throw new IllegalArgumentException("warehouse actId type not exist, {}");
    }

    /**
     * 获取仓储业务活动号集合
     *
     * @return
     */
    public static List<Integer> isWarehousingBusiness() {
        ArrayList<Integer> integers = Lists.newArrayList();
        integers.add(INSTOCK.actId);
        integers.add(OUTSTOCK.actId);
        integers.add(TRANSFER.actId);
        integers.add(CLEARANCE.actId);
        integers.add(FORWARDING.actId);
        integers.add(CALCULATE_COST.actId);
        integers.add(DIRECT_LOADING.actId);
        return integers;
    }

    /**
     * 获取仓储业务入库、出库、货转、调拨活动号集合
     *
     * @return
     */
    public static List<Integer> isWarehousingActList() {
        ArrayList<Integer> integers = Lists.newArrayList();
        integers.add(INSTOCK.actId);
        integers.add(OUTSTOCK.actId);
        integers.add(TRANSFER.actId);
        integers.add(FORWARDING.actId);
        return integers;
    }

}
