package com.xisc.pm.api.dto;

import com.xisc.pm.domain.entity.PmPdSlab;
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.util.List;

/**
 * 
 * @author 曾俊 jun.zeng@hand-china.com 2024-07-29 15:50:20
 *
 */
@Data
@ApiModel("生产合同组板收得率计算接口参数DTO")
public class PmProContYieldRequestDTO implements Serializable {
    
    private static final long serialVersionUID = 915089742581422663L;

    @ApiModelProperty("租户ID")
    private Long tenantId ;
    
    @ApiModelProperty("虚拟板坯号")
    private String virtualSlabNo;
    
    @ApiModelProperty("合同抽取条件")
    private PmProContFilterRequestDTO pmContFilterRequest ;
    
    @ApiModelProperty("轴合同编码")
    private String axisOrderNo ;
    
    @ApiModelProperty("选择的合同列表")
    private List<PmProContYieldDTO> pmProContYieldList ;
    
    @ApiModelProperty("组板信息")
    private PmCompositeBoardDTO compositeBoard ;
    
    @ApiModelProperty("组板板坯信息，余坯组板使用")
    private PmPdSlab pmPdSlab ;

    @ApiModelProperty("产品代码")
    private String prodCd;
    
    @ApiModelProperty("是否发送合同跟踪时间，默认是")
    private boolean sendCtEvent = true;
    
    @ApiModelProperty("二次设计执行标记")
    private boolean secondaryDesignFlag = false ;
    
    @ApiModelProperty("余坯自动生成分割信息标记")
    private boolean slabAutoAddSplitFlag = false ;
    
    public void check() {
        if(StringUtils.isBlank(this.axisOrderNo)) {
            throw new CommonException("pm.pm_pro_cont_009", "轴合同号");
        }
        if(pmContFilterRequest == null) {
            throw new CommonException("pm.pm_pro_cont_009", "合同抽取");
        }
        if(pmProContYieldList == null || pmProContYieldList.isEmpty()) {
            throw new CommonException("pm.pm_pro_cont_009", "合同");
        }
        if(compositeBoard == null) {
            throw new CommonException("pm.pm_pro_cont_009", "组合版信息");
        }
        compositeBoard.check();
    }
    
}
