package cn.estsh.i3plus.ext.mes.pcn.pojo.context;

import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * 生产过程上下文对象-零件条码(非排序产出零件条码)
 */
@Data
public class MesProductionPsOutContext extends MesProduceSn implements Serializable {

    private static final long serialVersionUID = 5562937531822977296L;

    @ApiParam(name = "数据关联键")
    private Integer foreignKey;

    @ApiParam(name = "是否计算工单完成数量")
    private Integer isCalcCompleteQty = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();

    @ApiParam(name = "是否进出一致")
    private Integer isSamePart = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();

    @ApiParam(name = "是否不累计工单完成数")
    private Integer noCalcOrderQty = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();

    public MesProductionPsOutContext() {}

    public MesProductionPsOutContext copy(MesProduceSn produceSn, Integer foreignKey) {
        if (null == produceSn) return null;
        BeanUtils.copyProperties(produceSn, this);
        this.foreignKey = foreignKey;
        return this;
    }

    public MesProductionPsOutContext foreignKey(Integer foreignKey) {
        this.foreignKey = foreignKey;
        return this;
    }

    public MesProductionPsOutContext copy(MesProduceSn produceSn) {
        BeanUtils.copyProperties(produceSn, this);
        return this;
    }

    public MesProductionPsOutContext isCalcCompleteQty(Boolean isCalcCompleteQty, Boolean isSamePart, Integer noCalcOrderQty) {
        if (isCalcCompleteQty) this.isCalcCompleteQty = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
        if (isSamePart) this.isSamePart = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
        this.noCalcOrderQty = noCalcOrderQty;
        return this;
    }

}
