package cn.estsh.i3plus.pojo.model.mes;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Author: wangjie
 * @CreateDate: 2019/8/21 9:19 AM
 * @Description:
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Api("mes导入异常结果model")
public class ImportErrorModel implements Serializable {

    private static final long serialVersionUID = 1212013821950324792L;

    @ApiParam("sheet名称")
    private String sheetName;

    @ApiParam("错误的行号")
    private int rowNum;

    @ApiParam("错误的列号")
    private int colNum;

    @ApiParam("错误的列名")
    private String colName;

    @ApiParam("错误数量")
    private int errorNum;

    @ApiParam("错误列号")
    private String cellNum;

    @ApiParam("错误描述")
    private String errorInfo;

    public static final class Builder {
        private String sheetName;
        private int rowNum;
        private int colNum;
        private String colName;
        private String errorInfo;

        private Builder() {
        }

        public static Builder newBuilder() {
            return new Builder();
        }

        public Builder withSheetName(String sheetName) {
            this.sheetName = sheetName;
            return this;
        }

        public Builder withRowNum(int rowNum) {
            this.rowNum = rowNum;
            return this;
        }

        public Builder withColNum(int colNum) {
            this.colNum = colNum;
            return this;
        }

        public Builder withColName(String colName) {
            this.colName = colName;
            return this;
        }

        public Builder withErrorInfo(String errorInfo) {
            this.errorInfo = errorInfo;
            return this;
        }

        public ImportErrorModel build() {
            ImportErrorModel importErrorModel = new ImportErrorModel();
            importErrorModel.setSheetName(sheetName);
            importErrorModel.setRowNum(rowNum);
            importErrorModel.setColNum(colNum);
            importErrorModel.setColName(colName);
            if(errorInfo== null){
                importErrorModel.setErrorInfo("SHEET【" + sheetName + "】中第【" + rowNum + "】行，第【" + colNum + "】列 " +
                        colName + " 数据为空");
            }else {
                importErrorModel.setErrorInfo(errorInfo);
            }
            return importErrorModel;
        }
    }
}
