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


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

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: wangjie
 * @CreateDate: 2019/8/21 9:19 AM
 * @Description:
 **/
@Data
@AllArgsConstructor
@Api("mes导入结果model")
public class ExcelImportModel<T> implements Serializable {

    private static final long serialVersionUID = 3075276018074690913L;

    @ApiParam("结果")
    private boolean result;

    @ApiParam("成功行数量")
    private int successRowNum;

    @ApiParam("失败行数量")
    private int failRowNum;

    @ApiParam("错误信息集合")
    private List<ImportErrorModel> importErrorModels;

    @ApiParam("错误的行号")
    private String errorRows;

    @ApiParam("导入数据集合")
    private List<T> excelList;

    @ApiParam("导入进度")
    private String importSpeed;

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


    public ExcelImportModel() {
        result = true;
    }

    public ExcelImportModel(List<T> excelList) {
        result = true;
        this.excelList = excelList;
    }

    public void addErrorMsg(ImportErrorModel errorModel) {
        if (importErrorModels == null) {
            importErrorModels = new ArrayList<>();
        }
        importErrorModels.add(errorModel);
        result = false;
    }

}
