Commit 219276ec by 王军业

211245412

1 parent 34d5144c
package com.vion.financial.handler;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import com.vion.financial.excel.ImportModel;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
public class ImportExcel {
private static final Logger log=LoggerFactory.getLogger(ImportExcel.class);
public List<ImportModel> Import(MultipartFile file) throws IOException, Exception {
ImportParams importParams = new ImportParams();
IExcelDataHandler<ImportModel> handle=new ImportHandle();
handle.setNeedHandlerFields(new String[] {"合同编号"});
importParams.setDataHanlder(handle);
importParams.setNeedVerfiy(true);
ExcelImportResult<ImportModel> result=ExcelImportUtil.importExcelMore(file.getInputStream(), ImportModel.class, importParams);
List<ImportModel> successList=result.getList();
List<ImportModel> failList=result.getFailList();
log.info("是否存在验证未通过的数据:"+result.isVerfiyFail());
log.info("验证通过的数量:"+successList.size());
log.info("验证未通过的数量"+failList.size());
for(ImportModel importModel:successList) {
log.info("导入成功数据,编号="+importModel.getContract_unid()+";签订时间="+importModel.getSign_date());
}
for(ImportModel importModel:failList) {
log.info("导入失败数据,编号"+importModel.getContract_unid());
}
return successList;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!