Commit 673f9ae0 authored by hongguangwu's avatar hongguangwu

空文件

parent 2060474e
...@@ -736,39 +736,30 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -736,39 +736,30 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo); List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo);
ServletOutputStream out = null; ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
try { list = new ArrayList<>();
ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class); }
for (EmployeeContractExportVO vo : list) { try {
util.convertEntity(vo, null, null, null); ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class);
} for (EmployeeContractExportVO vo : list) {
out = response.getOutputStream(); util.convertEntity(vo, null, null, null);
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel.write(out, EmployeeContractExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet("员工合同").doWrite(list);
out.flush();
} catch (Exception e) {
log.error("员工合同导出异常:", e);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
log.error("员工合同导出异常:", e);
}
} }
} else { out = response.getOutputStream();
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(contractInfo.getExportFields()) response.setContentType("multipart/form-data");
.sheet(EmployeeConstants.NO_DATA).doWrite(list); response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel.write(out, EmployeeContractExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet("员工合同").doWrite(list);
out.flush();
} catch (Exception e) {
log.error("员工合同导出异常:", e);
} finally {
try { try {
if (out != null) { if (out != null) {
out.close(); out.close();
} }
} catch (IOException e) { } catch (IOException e) {
log.error(EmployeeConstants.CONCART_EXPORT_EXCEPTION, e); log.error("员工合同导出异常:", e);
} }
} }
} }
...@@ -785,33 +776,24 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -785,33 +776,24 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo); List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo);
ServletOutputStream out = null; ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
try { list = new ArrayList<>();
ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class); }
for (EmployeeContractExportVO vo : list) { try {
util.convertEntity(vo, null, null, null); ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class);
} for (EmployeeContractExportVO vo : list) {
out = response.getOutputStream(); util.convertEntity(vo, null, null, null);
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel.write(out, EmployeeContractExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet("员工合同[合并]").doWrite(list);
out.flush();
} catch (Exception e) {
log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
}
} }
} else { out = response.getOutputStream();
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(contractInfo.getExportFields()) response.setContentType("multipart/form-data");
.sheet(EmployeeConstants.NO_DATA).doWrite(list); response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel.write(out, EmployeeContractExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet("员工合同[合并]").doWrite(list);
out.flush();
} catch (Exception e) {
log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
} finally {
try { try {
if (out != null) { if (out != null) {
out.close(); out.close();
...@@ -820,6 +802,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -820,6 +802,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e); log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
} }
} }
} }
} }
......
...@@ -1971,33 +1971,24 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1971,33 +1971,24 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
List<EmployeeExportVO> list = baseMapper.getTEmployeeExportList(employeeInfo); List<EmployeeExportVO> list = baseMapper.getTEmployeeExportList(employeeInfo);
ServletOutputStream out = null; ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
try { list = new ArrayList<>();
ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class); }
for (EmployeeExportVO vo : list) { try {
util.convertEntity(vo, null, null, null); ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class);
} for (EmployeeExportVO vo : list) {
out = response.getOutputStream(); util.convertEntity(vo, null, null, null);
response.setContentType("multipart/form-data"); }
response.setCharacterEncoding("utf-8"); out = response.getOutputStream();
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CommonConstants.UTF8)); response.setContentType("multipart/form-data");
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 response.setCharacterEncoding("utf-8");
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields()) response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CommonConstants.UTF8));
.sheet("人员档案").doWrite(list); // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
out.flush();
} catch (Exception e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
}
}
} else {
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields()) EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields())
.sheet(EmployeeConstants.NO_DATA).doWrite(list); .sheet("人员档案").doWrite(list);
out.flush();
} catch (Exception e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} finally {
try { try {
if (out != null) { if (out != null) {
out.close(); out.close();
...@@ -2021,33 +2012,24 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2021,33 +2012,24 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
List<EmployeeExportVO> list = baseMapper.getTEmployeeLeaveExportList(employeeInfo); List<EmployeeExportVO> list = baseMapper.getTEmployeeLeaveExportList(employeeInfo);
ServletOutputStream out = null; ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
try { list = new ArrayList<>();
ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class); }
for (EmployeeExportVO vo : list) { try {
util.convertEntity(vo, null, null, null); ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class);
} for (EmployeeExportVO vo : list) {
out = response.getOutputStream(); util.convertEntity(vo, null, null, null);
response.setContentType("multipart/form-data"); }
response.setCharacterEncoding("utf-8"); out = response.getOutputStream();
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); response.setContentType("multipart/form-data");
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 response.setCharacterEncoding("utf-8");
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields()) response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
.sheet("离职档案").doWrite(list); // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
out.flush();
} catch (Exception e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
}
}
} else {
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields()) EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields())
.sheet(EmployeeConstants.NO_DATA).doWrite(list); .sheet("离职档案").doWrite(list);
out.flush();
} catch (Exception e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} finally {
try { try {
if (out != null) { if (out != null) {
out.close(); out.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment