|
@@ -2,6 +2,7 @@ package com.zcxk.rmcp.web.excel.resolver.strategy;
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelReader;
|
|
|
+import com.alibaba.excel.exception.ExcelAnalysisException;
|
|
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zcxk.core.common.exception.BusinessException;
|
|
@@ -55,10 +56,10 @@ public class WaterDeviceHandleExcelStrategy implements HandleExcelStrategy {
|
|
|
CommDataListener communityListener = new CommDataListener();
|
|
|
CommDataListener orgListener = new CommDataListener();
|
|
|
|
|
|
- ReadSheet readSheet1 = EasyExcel.readSheet(0).head(DeviceImportData.class).headRowNumber(4).registerReadListener(deviceImportListener).build();
|
|
|
- ReadSheet readSheet2 = EasyExcel.readSheet(1).head(CommImportData.class).registerReadListener(deviceTypeListener).build();
|
|
|
- ReadSheet readSheet3 = EasyExcel.readSheet(2).head(CommImportData.class).registerReadListener(orgListener).build();
|
|
|
- ReadSheet readSheet4 = EasyExcel.readSheet(3).head(CommImportData.class).registerReadListener(communityListener).build();
|
|
|
+ ReadSheet readSheet1 = EasyExcel.readSheet("档案管理-批量导入").head(DeviceImportData.class).headRowNumber(4).registerReadListener(deviceImportListener).build();
|
|
|
+ ReadSheet readSheet2 = EasyExcel.readSheet("设备类型").head(CommImportData.class).registerReadListener(deviceTypeListener).build();
|
|
|
+ ReadSheet readSheet3 = EasyExcel.readSheet("公司").head(CommImportData.class).registerReadListener(orgListener).build();
|
|
|
+ ReadSheet readSheet4 = EasyExcel.readSheet("小区").head(CommImportData.class).registerReadListener(communityListener).build();
|
|
|
// 这里注意 一定要把sheet1 sheet2 一起传进去,不然有个问题就是03版的excel 会读取多次,浪费性能
|
|
|
excelReader.read(readSheet1, readSheet2, readSheet3, readSheet4);
|
|
|
// 这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的
|
|
@@ -123,9 +124,9 @@ public class WaterDeviceHandleExcelStrategy implements HandleExcelStrategy {
|
|
|
|
|
|
@Override
|
|
|
public void handleException(ExcelData data, Exception e) {
|
|
|
- if(e instanceof BusinessException){
|
|
|
- sendExceptionMessage(data,((BusinessException) e).getMsg());
|
|
|
- }{
|
|
|
+ if(e instanceof ExcelAnalysisException){
|
|
|
+ sendExceptionMessage(data,((ExcelAnalysisException) e).getMessage());
|
|
|
+ }else{
|
|
|
sendExceptionMessage(data,"读取文件异常");
|
|
|
}
|
|
|
}
|