|
@@ -13,6 +13,7 @@ import cn.tr.module.excel.core.handler.write.CustomCellWriteHandler;
|
|
|
import cn.tr.module.excel.core.handler.write.CustomHorizontalCellStyleStrategy;
|
|
import cn.tr.module.excel.core.handler.write.CustomHorizontalCellStyleStrategy;
|
|
|
import cn.tr.module.excel.core.handler.write.CustomRowWriteHandler;
|
|
import cn.tr.module.excel.core.handler.write.CustomRowWriteHandler;
|
|
|
import cn.tr.module.excel.core.handler.write.CustomSheetWriteHandler;
|
|
import cn.tr.module.excel.core.handler.write.CustomSheetWriteHandler;
|
|
|
|
|
+import cn.tr.module.export.handler.AbstractCascadeSelectConverter;
|
|
|
import cn.tr.module.register.ExportSampleRegister;
|
|
import cn.tr.module.register.ExportSampleRegister;
|
|
|
import cn.tr.module.excel.core.utils.ExcelTemplateDescUtil;
|
|
import cn.tr.module.excel.core.utils.ExcelTemplateDescUtil;
|
|
|
import cn.tr.module.excel.core.utils.StyleUtils;
|
|
import cn.tr.module.excel.core.utils.StyleUtils;
|
|
@@ -67,6 +68,7 @@ public class ExcelService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public <T> byte[] exportExcel(Class<T> aClass, Collection<T> data){
|
|
public <T> byte[] exportExcel(Class<T> aClass, Collection<T> data){
|
|
|
|
|
+ AbstractCascadeSelectConverter.threadLocal.remove();
|
|
|
ByteArrayOutputStream outputStream =new ByteArrayOutputStream();
|
|
ByteArrayOutputStream outputStream =new ByteArrayOutputStream();
|
|
|
ExcelWriter excelWriter = EasyExcel.write(outputStream).build();
|
|
ExcelWriter excelWriter = EasyExcel.write(outputStream).build();
|
|
|
String sheetName="导入(导出)数据";
|
|
String sheetName="导入(导出)数据";
|
|
@@ -79,6 +81,7 @@ public class ExcelService {
|
|
|
createSheet(excelWriter,1,"模板注释",ExcelTemplateDescDTO.class,exportTemplate);
|
|
createSheet(excelWriter,1,"模板注释",ExcelTemplateDescDTO.class,exportTemplate);
|
|
|
IoUtil.flush(outputStream);
|
|
IoUtil.flush(outputStream);
|
|
|
IoUtil.close(excelWriter);
|
|
IoUtil.close(excelWriter);
|
|
|
|
|
+ AbstractCascadeSelectConverter.threadLocal.remove();
|
|
|
return outputStream.toByteArray();
|
|
return outputStream.toByteArray();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -94,6 +97,7 @@ public class ExcelService {
|
|
|
* @return 返回SheetId
|
|
* @return 返回SheetId
|
|
|
*/
|
|
*/
|
|
|
public <T> String importExcel(String filename, InputStream inputStream, Class<T> aClass, Map<String,Object> customObj) throws Exception {
|
|
public <T> String importExcel(String filename, InputStream inputStream, Class<T> aClass, Map<String,Object> customObj) throws Exception {
|
|
|
|
|
+ AbstractCascadeSelectConverter.threadLocal.remove();
|
|
|
byte[] content = IoUtil.readBytes(inputStream);
|
|
byte[] content = IoUtil.readBytes(inputStream);
|
|
|
String fileId = storageApi.upload(content,filename);
|
|
String fileId = storageApi.upload(content,filename);
|
|
|
//新增sheet导入记录
|
|
//新增sheet导入记录
|
|
@@ -117,6 +121,8 @@ public class ExcelService {
|
|
|
storageApi.removeById(fileId);
|
|
storageApi.removeById(fileId);
|
|
|
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
|
|
+ }finally {
|
|
|
|
|
+ AbstractCascadeSelectConverter.threadLocal.remove();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return sheetId;
|
|
return sheetId;
|