Commit 1ad2009a authored by hongguangwu's avatar hongguangwu

空导出

parent b25f5057
...@@ -37,6 +37,10 @@ public class EmployeeConstants { ...@@ -37,6 +37,10 @@ public class EmployeeConstants {
* 无数据可更新 * 无数据可更新
**/ **/
public static final String NO_DATA_UPDATE = "无数据可更新"; public static final String NO_DATA_UPDATE = "无数据可更新";
public static final String NO_DATA = "无数据";
public static final String FILE_EXPORT_EXCEPTION = "档案导出异常";
public static final String CONCART_EXPORT_EXCEPTION = "合同导出异常";
public static final String CONCART_ALL_EXPORT_EXCEPTION = "合同[合并]导出异常";
/** /**
* 数据更新是失败 * 数据更新是失败
......
...@@ -26,14 +26,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -26,14 +26,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.constants.EmployeeConstants;
import com.yifu.cloud.plus.v1.yifu.archives.constants.EmployeeContractConstants; import com.yifu.cloud.plus.v1.yifu.archives.constants.EmployeeContractConstants;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*; import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeContractInfoMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeContractInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.*; import com.yifu.cloud.plus.v1.yifu.archives.service.*;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeContractExportVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeContractUpdateVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeContractVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants;
...@@ -736,8 +734,8 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -736,8 +734,8 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
String fileName = "员工合同批量导出" + DateUtil.getThisTime() + ".xlsx"; String fileName = "员工合同批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表 //获取要导出的列表
List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo); List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo);
ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
ServletOutputStream out = null;
try { try {
ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class); ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class);
for (EmployeeContractExportVO vo : list) { for (EmployeeContractExportVO vo : list) {
...@@ -762,6 +760,16 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -762,6 +760,16 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
log.error("员工合同导出异常:", e); log.error("员工合同导出异常:", e);
} }
} }
} else {
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet(EmployeeConstants.NO_DATA).doWrite(list);
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
log.error(EmployeeConstants.CONCART_EXPORT_EXCEPTION, e);
}
} }
} }
} }
...@@ -775,8 +783,8 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -775,8 +783,8 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
String fileName = "员工合同批量导出[合并]" + DateUtil.getThisTime() + ".xlsx"; String fileName = "员工合同批量导出[合并]" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表 //获取要导出的列表
List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo); List<EmployeeContractExportVO> list = baseMapper.getTEmployeeContractExportHistory(contractInfo);
ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
ServletOutputStream out = null;
try { try {
ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class); ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class);
for (EmployeeContractExportVO vo : list) { for (EmployeeContractExportVO vo : list) {
...@@ -791,15 +799,25 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -791,15 +799,25 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
.sheet("员工合同[合并]").doWrite(list); .sheet("员工合同[合并]").doWrite(list);
out.flush(); out.flush();
} catch (Exception e) { } catch (Exception e) {
log.error("员工合同[合并]导出异常:", e); log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
} finally { } finally {
try { try {
if (out != null) { if (out != null) {
out.close(); out.close();
} }
} catch (IOException e) { } catch (IOException e) {
log.error("员工合同[合并]导出异常:", e); log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
}
}
} else {
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet(EmployeeConstants.NO_DATA).doWrite(list);
try {
if (out != null) {
out.close();
} }
} catch (IOException e) {
log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
} }
} }
} }
......
...@@ -50,6 +50,7 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil; ...@@ -50,6 +50,7 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
...@@ -1968,8 +1969,8 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1968,8 +1969,8 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
//获取要导出的列表 //获取要导出的列表
employeeInfo.setFileStatus(CommonConstants.ZERO_INT); employeeInfo.setFileStatus(CommonConstants.ZERO_INT);
List<EmployeeExportVO> list = baseMapper.getTEmployeeExportList(employeeInfo); List<EmployeeExportVO> list = baseMapper.getTEmployeeExportList(employeeInfo);
ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
ServletOutputStream out = null;
try { try {
ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class); ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class);
for (EmployeeExportVO vo : list) { for (EmployeeExportVO vo : list) {
...@@ -1984,16 +1985,26 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1984,16 +1985,26 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
.sheet("人员档案").doWrite(list); .sheet("人员档案").doWrite(list);
out.flush(); out.flush();
} catch (Exception e) { } catch (Exception e) {
log.error("人员档案导出异常:", e); log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} finally { } finally {
try { try {
if (out != null) { if (out != null) {
out.close(); out.close();
} }
} catch (IOException e) { } catch (IOException e) {
log.error("档案导出异常:", e); log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} }
} }
} else {
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields())
.sheet(EmployeeConstants.NO_DATA).doWrite(list);
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
}
} }
} }
} }
...@@ -2008,8 +2019,8 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2008,8 +2019,8 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
//获取要导出的列表 //获取要导出的列表
employeeInfo.setFileStatus(CommonConstants.ONE_INT); employeeInfo.setFileStatus(CommonConstants.ONE_INT);
List<EmployeeExportVO> list = baseMapper.getTEmployeeLeaveExportList(employeeInfo); List<EmployeeExportVO> list = baseMapper.getTEmployeeLeaveExportList(employeeInfo);
ServletOutputStream out = null;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
ServletOutputStream out = null;
try { try {
ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class); ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class);
for (EmployeeExportVO vo : list) { for (EmployeeExportVO vo : list) {
...@@ -2024,15 +2035,25 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -2024,15 +2035,25 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
.sheet("离职档案").doWrite(list); .sheet("离职档案").doWrite(list);
out.flush(); out.flush();
} catch (Exception e) { } catch (Exception e) {
log.error("离职档案导出异常:", e); log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} finally { } finally {
try { try {
if (out != null) { if (out != null) {
out.close(); out.close();
} }
} catch (IOException e) { } catch (IOException e) {
log.error("档案导出异常:", e); log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
}
}
} else {
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields())
.sheet(EmployeeConstants.NO_DATA).doWrite(list);
try {
if (out != null) {
out.close();
} }
} catch (IOException e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} }
} }
} }
......
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