package com.zcxk.rmcp.web.excel.resolver;

import com.alibaba.fastjson.JSON;
import com.zcxk.rmcp.core.entity.ImportFile;
import com.zcxk.rmcp.web.excel.model.ExcelData;
import com.zcxk.rmcp.web.excel.resolver.HandleExcelService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.InputStream;

/**
 * excel解析模板
 */
@Slf4j
public class ResolverExcelTemplate {

    private HandleExcelService handleExcelService;


    public ResolverExcelTemplate(HandleExcelService handleExcelService) {
        this.handleExcelService = handleExcelService;
    }

    public void build(ImportFile importFile){

        ExcelData data = new ExcelData();
        data.setImportFile(importFile);

        try {
            handleExcelService.handle(data);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("read excel error = {} {}" , e.getMessage(), JSON.toJSON(e));
        }
    }

}
