package com.xisc.pm.api.dto;

import java.io.Serializable;
import java.math.BigDecimal;

import org.apache.commons.lang3.StringUtils;

import io.choerodon.core.exception.CommonException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 组合板信息DTO
 * @author jun.zeng
 *
 */
@Data
public class PmSmallPlateDTO implements Serializable{
    
    private static final long serialVersionUID = 2298891622687835182L;

    @ApiModelProperty("子板顺序号,前端输入")
    private Long blockNo;

    @ApiModelProperty("合同号,前端输入")
    private String orderNo;

    @ApiModelProperty("合同顺序号,前端输入")
    private Long orderSeqNo;

    @ApiModelProperty("合同组总子板数,前端输入")
    private Long orderBlockNum;

    @ApiModelProperty("订货厚，合同带入")
    private BigDecimal orderThick;

    @ApiModelProperty("订货宽，合同带入")
    private BigDecimal orderWidth;

    @ApiModelProperty("订货长，合同带入")
    private BigDecimal orderLen;

    @ApiModelProperty("订货长上限，合同带入")
    private BigDecimal orderLenMax;

    @ApiModelProperty("订货长下限，合同带入")
    private BigDecimal orderLenMin;

    @ApiModelProperty("小板厚,前端输入")
    private BigDecimal smallPlateThick;

    @ApiModelProperty("小板宽,前端输入")
    private BigDecimal smallPlateWidth;

    @ApiModelProperty("小板长,前端输入")
    private BigDecimal smallPlateLen;
    
    @ApiModelProperty("长度方向坐标,前端输入")
    private Integer pickModeLenDirPos;
    
    @ApiModelProperty("宽度方向坐标,前端输入")
    private Integer pickModeWidDirPos;
    
    public void check() {
        if(this.orderThick == null) {
            throw new CommonException("pm.pm_pro_cont_009", "订货厚");
        }
        if(this.orderWidth == null) {
            throw new CommonException("pm.pm_pro_cont_009", "订货宽");
        }
        if(this.orderLen == null) {
            throw new CommonException("pm.pm_pro_cont_009", "订货长");
        }
        if(this.orderLenMax == null) {
            throw new CommonException("pm.pm_pro_cont_009", "订货长上限");
        }
        if(this.orderLenMin == null) {
            throw new CommonException("pm.pm_pro_cont_009", "订货长下限");
        }
        if(this.smallPlateThick == null) {
            throw new CommonException("pm.pm_pro_cont_009", "小板厚");
        }
        if(this.smallPlateWidth == null) {
            throw new CommonException("pm.pm_pro_cont_009", "小板宽");
        }
        if(this.smallPlateLen == null) {
            throw new CommonException("pm.pm_pro_cont_009", "小板长");
        }
        if(this.blockNo == null) {
            throw new CommonException("pm.pm_pro_cont_009", "板块号");
        }
        if(StringUtils.isBlank(orderNo)) {
            throw new CommonException("pm.pm_pro_cont_009", "合同号");
        }
        if(this.orderSeqNo == null) {
            throw new CommonException("pm.pm_pro_cont_009", "合同顺序号");
        }
        if(this.orderBlockNum == null || orderBlockNum == 0) {
            throw new CommonException("pm.pm_pro_cont_009", "合同组总子板数");
        }
        if(this.pickModeLenDirPos == null || pickModeLenDirPos == 0) {
            throw new CommonException("pm.pm_pro_cont_009", "长度方向坐标");
        }
        if(this.pickModeWidDirPos == null || pickModeWidDirPos == 0) {
            throw new CommonException("pm.pm_pro_cont_009", "宽度方向坐标");
        }
    }
}
