package com.xisc.pm.api.dto;

import com.xisc.pm.domain.vo.MmPlateVO;
import com.xisc.pm.infra.enums.PdMatType;
import io.choerodon.core.exception.CommonException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 *
 * @author 曾俊 jun.zeng@hand-china.com
 * 2024-08-01 15:50:20
 *
 */
@Data
@ApiModel("生产合同抽取DTO")
public class PmProContFilterRequestDTO implements Serializable {

    private static final long serialVersionUID = -2481269779637833518L;

    @ApiModelProperty("租户ID")
    private Long tenantId;

    @ApiModelProperty("内部钢种")
    private String stNo;

    @ApiModelProperty("牌号")
    private String sgSign;

    @ApiModelProperty("结晶器厚")
    private BigDecimal moldThick;

    @ApiModelProperty("结晶器宽")
    private BigDecimal moldWidth;

    @ApiModelProperty("订货厚度起")
    private BigDecimal orderThickFrom;

    @ApiModelProperty("订货厚度止")
    private BigDecimal orderThickTo;

    @ApiModelProperty("订货宽度起")
    private BigDecimal orderWidthFrom;

    @ApiModelProperty("订货宽度止")
    private BigDecimal orderWidthTo;

    @ApiModelProperty("订货长度起")
    private BigDecimal orderLenFrom;

    @ApiModelProperty("订货长度止")
    private BigDecimal orderLenTo;

    @ApiModelProperty("交货日期起")
    private Date delivyDateFrom;

    @ApiModelProperty("交货日期止")
    private Date delivyDateTo;

    @ApiModelProperty("产线号")
    private String mscLineNo;

    @ApiModelProperty("外委标记")
    private String xzFlag;

    @ApiModelProperty("热处理模式匹配标志")
    private Long ruleNoSTFlag;

    @ApiModelProperty("超声探伤要求匹配标志")
    private Long ruleNoSXFlag;

    @ApiModelProperty("以优充次")
    private Long stReplFlag;

    @ApiModelProperty("轧制方向")
    private String rollDirectCode ;

    @ApiModelProperty("组板方式")
    private String formPlateMode ;

    @ApiModelProperty("指定长")
    private BigDecimal fixSlabLen;

    @ApiModelProperty("奉送样长度")
    private BigDecimal sampleLenGice ;
    
    @ApiModelProperty("坯锭型")
    private String ingotType ;

    @ApiModelProperty("指定长类型方式,值集范围：0-不指定长，1-指定长，2-奉送样")
    private Long fixSlabLenFlag ;

    @ApiModelProperty("楔形板形")
    private String shpCode;

    @ApiModelProperty("加热炉类型，前端默认‘C")
    private String furType ;

    @ApiModelProperty("连铸机类型，前端默认‘‘")
    private String ccType ;

    @ApiModelProperty("材料设计类型")
    private String matDesignKind;

    @ApiModelProperty("选中的合同集合")
    private List<String> orderNoList ;

    @ApiModelProperty("是否转置1，0")
    private String transFlag;

    @ApiModelProperty("剩余板坯长度，余坯组板使用")
    private BigDecimal remainSlabLen;

    @ApiModelProperty("余材组板材料号主键，余材组板使用")
    private Long plateId ;
    
    @ApiModelProperty("是否一次轧制")
    private Long oneRollFlag ;
    
    @ApiModelProperty("余材组板-钢板信息，余材组板使用")
    private MmPlateVO mmPlate;
    
    @ApiModelProperty("制造命令号")
    private String pono ;
    
    private Long joinCtMainFlag = 0L ;

    @ApiModelProperty("限制收得率")
    private BigDecimal limitYield;

    private String queryQfh = "0";

    private List<String> lovHavingComList;

    private List<String> lovNotHavingComList;
    
    public void check() {
        if(StringUtils.isBlank(this.getMscLineNo())) {
            throw new CommonException("pm.pm_pro_cont_009", "产线号");
        }
        if(StringUtils.isBlank(this.getFurType())) {
            throw new CommonException("pm.pm_pro_cont_009", "加热炉类型");
        }
        if(StringUtils.isBlank(this.getCcType())) {
            throw new CommonException("pm.pm_pro_cont_009", "连铸机类型");
        }
        if(StringUtils.isBlank(this.getMatDesignKind())) {
            throw new CommonException("pm.pm_pro_cont_009", "材料设计类型");
        }
        if(this.moldThick == null) {
            throw new CommonException("pm.pm_pro_cont_009", "结晶器厚");
        }
        if(this.moldWidth == null) {
            throw new CommonException("pm.pm_pro_cont_009", "结晶器宽");
        }
        if(StringUtils.isBlank(this.stNo)) {
            throw new CommonException("pm.pm_pro_cont_009", "内部钢种");
        }
        if(PdMatType.P.getCode().equals(this.getMatDesignKind()) && plateId == null) {
            throw new CommonException("pm.pm_pro_cont_009", "余材组板，钢板材料号");
        }
    }
}
