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

import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * 生产过程上下文对象-加工单完成数
 */
@Data
public class MesWorkOrderCompleteQtyContext implements Serializable {

    private static final long serialVersionUID = -1602007855074296100L;

    @ApiParam("生产工单号")
    private String workOrderNo;

    @ApiParam("工单数量")
    private Double qty;

    @ApiParam("完成数量")
    private Double completeQty;

    public MesWorkOrderCompleteQtyContext(String workOrderNo, Double qty, Double completeQty) {
        this.workOrderNo = workOrderNo;
        this.qty = qty;
        this.completeQty = StringUtils.isEmpty(completeQty) ? new Double(MesPcnExtConstWords.ZERO) : completeQty;
    }

    public MesWorkOrderCompleteQtyContext overrideCompleteQty(Double completeQty) {
        this.completeQty = completeQty;
        return this;
    }

}
