| | |
| | | |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.R; |
| | |
| | | } |
| | | |
| | | |
| | | private static final int BATCH_COUNT = 100; |
| | | private static final int BATCH_COUNT = 5000; |
| | | private List<ComCvtServeExcelVO> list = new ArrayList<>(); |
| | | |
| | | @Override |
| | |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 在转换异常 |
| | | * @param exception |
| | | * @param context |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void onException(Exception exception, AnalysisContext context) throws ServiceException { |
| | | log.error("抛出异常:{}", exception.getMessage()); |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception; |
| | | log.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(), |
| | | excelDataConvertException.getColumnIndex(), excelDataConvertException.getCellData()); |
| | | }else{ |
| | | throw new ServiceException(exception.getMessage()); |
| | | } |
| | | } |
| | | } |