package com.aps.macroplanner.data;

/**
 * 操作输入物料 (OperationInput) — 对应 Quintiq 中的 OperationInput
 *
 * 定义某个操作 (Operation) 生产时需要消耗的原材料/半成品，
 * 即 BOM (Bill of Materials) 中的输入物料关系。
 *
 * 例如: 生产 1 个 ProductA 需要消耗 0.5 个 ProductB
 */
public class OperationInput {
    private final Operation operation;       // 所属操作
    private final Product inputProduct;      // 输入物料产品
    private final StockingPoint inputSp;     // 输入物料来源库存点
    private final double factor;             // 消耗因子 (每单位 PTQty 消耗的输入物料量)

    public OperationInput(Operation operation, Product inputProduct,
                          StockingPoint inputSp, double factor) {
        this.operation = operation;
        this.inputProduct = inputProduct;
        this.inputSp = inputSp;
        this.factor = factor;
    }

    public Operation getOperation() { return operation; }
    public Product getInputProduct() { return inputProduct; }
    public StockingPoint getInputSp() { return inputSp; }
    public double getFactor() { return factor; }

    public String getKey() {
        return operation.getId() + "_" + inputProduct.getId() + "_" + inputSp.getId();
    }

    @Override
    public String toString() {
        return "OpInput[" + operation.getName() + " <- " + inputProduct.getName()
                + "@" + inputSp.getName() + " x" + factor + "]";
    }
}