package com.sw.mes.itemclean.clean.dto.boxNoOperate;

import com.sw.mes.core.enums.ItemCleanEnums;
import lombok.Getter;
import org.hibernate.engine.jdbc.batch.spi.Batch;

/**
 * @author liuzemin
 * @date 2022/11/22 8:49
 * @description
 */
@Getter
public class BoxNoOperate {

    /**
     * {@link com.sw.mes.core.enums.ItemCleanEnums.BoxNoType}
     */
    private ItemCleanEnums.BoxNoType boxNoType;

    /**
     * 物料编码 or 批次号
     */
    private String value;

    /**
     * -----------------------------------------------------------------------------------------------------------------
     */

    /**
     * 物料编码模型
     */
    private MaterialNo materialNo;

    /**
     * 批次号模型
     */
    private BatchNo batchNo;

    private BoxNoOperate(ItemCleanEnums.BoxNoType boxNoType, String value) {
        this.boxNoType = boxNoType;
        this.value = value;
    }

    public BoxNoOperate(ItemCleanEnums.BoxNoType boxNoType, MaterialNo materialNo) {
        if (boxNoType.getType().getKey() != ItemCleanEnums.BoxNoParam.物料编码.getKey()){
            throw new RuntimeException(boxNoType + "箱号生成需要" + boxNoType.getType());
        }
        this.boxNoType = boxNoType;
        this.value = materialNo.getMaterialCode();
    }

    public BoxNoOperate(ItemCleanEnums.BoxNoType boxNoType, BatchNo batchNo) {
        if (boxNoType.getType().getKey() != ItemCleanEnums.BoxNoParam.批次号.getKey()){
            throw new RuntimeException(boxNoType + "箱号生成需要" + boxNoType.getType());
        }
        this.boxNoType = boxNoType;
        this.value = batchNo.getBatchNo();
    }

    public BoxNoOperate(ItemCleanEnums.BoxNoType boxNoType) {
        if (boxNoType.getType().getKey() != ItemCleanEnums.BoxNoParam.不传.getKey()){
            throw new RuntimeException(boxNoType + "箱号生成需要" + boxNoType.getType());
        }
        this.boxNoType = boxNoType;
    }
}
