Commit 0aefb5a8 authored by hongguangwu's avatar hongguangwu

合同-批量导出

parent c9693958
...@@ -35,6 +35,7 @@ import java.math.BigDecimal; ...@@ -35,6 +35,7 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 员工合同 * 员工合同
...@@ -437,4 +438,12 @@ public class TEmployeeContractInfo extends BaseEntity { ...@@ -437,4 +438,12 @@ public class TEmployeeContractInfo extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private List<String> attaList; private List<String> attaList;
@TableField(exist = false)
@Schema(description = "选中的idList")
private List<String> idList;
@TableField(exist = false)
@Schema(description = "导出的表头的Set")
private Set<String> exportFields;
} }
...@@ -20,6 +20,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller; ...@@ -20,6 +20,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeContractInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeContractInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorMessageVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorMessageVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO;
...@@ -40,6 +41,7 @@ import org.springframework.security.access.prepost.PreAuthorize; ...@@ -40,6 +41,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
...@@ -251,4 +253,30 @@ public class TEmployeeContractInfoController { ...@@ -251,4 +253,30 @@ public class TEmployeeContractInfoController {
return tEmployeeContractInfoService.batchUpdate(file.getInputStream()); return tEmployeeContractInfoService.batchUpdate(file.getInputStream());
} }
/**
* 批量导出人员档案信息
*
* @Author hgw
* @Date 2022-6-24 09:36:06
**/
@Operation(summary = "批量导出合同employee_export_contract", description = "批量导出合同 hasPermission('employee_export_contract')")
@SysLog("批量导出合同")
@PostMapping("/exportContractInfo")
public void exportContractInfo(@RequestBody(required = false) TEmployeeContractInfo contractInfo, HttpServletResponse response) {
tEmployeeContractInfoService.exportContractInfo(contractInfo, response);
}
/**
* 批量导出人员档案信息
*
* @Author hgw
* @Date 2022-6-24 09:36:06
**/
@Operation(summary = "批量导出合同[历史]employee_export_contract_history", description = "批量导出合同[历史]hasPermission('employee_export_contract_history')")
@SysLog("批量导出合同[历史]")
@PostMapping("/exportContractInfoHistory")
public void exportContractInfoHistory(@RequestBody(required = false) TEmployeeContractInfo contractInfo, HttpServletResponse response) {
tEmployeeContractInfoService.exportContractInfoHistory(contractInfo, response);
}
} }
...@@ -29,6 +29,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; ...@@ -29,6 +29,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
...@@ -122,6 +123,22 @@ public interface TEmployeeContractInfoService extends IService<TEmployeeContract ...@@ -122,6 +123,22 @@ public interface TEmployeeContractInfoService extends IService<TEmployeeContract
**/ **/
R<List<ErrorMessage>> batchUpdate(InputStream inputStream); R<List<ErrorMessage>> batchUpdate(InputStream inputStream);
/**
* @param contractInfo
* @Description: 批量导出员工合同
* @Author: hgw
* @Date: 2022-7-4 17:17:46
**/
void exportContractInfo(TEmployeeContractInfo contractInfo, HttpServletResponse response);
/**
* @param contractInfo
* @param response
* @Description: 批量导出员工合同[合并]
* @Author: hgw
* @Date: 2022/7/4 17:24
* @return: void
**/
void exportContractInfoHistory(TEmployeeContractInfo contractInfo, HttpServletResponse response);
} }
...@@ -164,7 +164,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> { ...@@ -164,7 +164,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @param employeeVo * @param employeeVo
* @Description: 批量导出人员档案 * @Description: 批量导出人员档案
* @Author: hgw * @Author: hgw
* @Date: 2022/6/23 10:302022-6-24 09:35:54 * @Date: 2022/6/23 10:30
**/ **/
void exportEmployee(TEmployeeInfo employeeVo, HttpServletResponse response); void exportEmployee(TEmployeeInfo employeeVo, HttpServletResponse response);
...@@ -172,7 +172,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> { ...@@ -172,7 +172,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @param employeeVo * @param employeeVo
* @Description: 批量导出离职档案 * @Description: 批量导出离职档案
* @Author: hgw * @Author: hgw
* @Date: 2022/6/23 10:302022-6-24 09:35:54 * @Date: 2022-6-24 09:35:54
**/ **/
void exportLeaveEmployee(TEmployeeInfo employeeVo, HttpServletResponse response); void exportLeaveEmployee(TEmployeeInfo employeeVo, HttpServletResponse response);
......
...@@ -32,6 +32,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeContractInfoMapper; ...@@ -32,6 +32,7 @@ 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.EmployeeContractUpdateVO; 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.EmployeeContractVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeExportVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO; 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;
...@@ -49,7 +50,11 @@ import org.springframework.stereotype.Service; ...@@ -49,7 +50,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -682,4 +687,82 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -682,4 +687,82 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
} }
} }
/**
* 获取导出的人员档案列表
*/
@Override
public void exportContractInfo(TEmployeeContractInfo contractInfo, HttpServletResponse response) {
if (contractInfo != null && contractInfo.getExportFields() != null && !contractInfo.getExportFields().isEmpty()) {
String fileName = "员工合同批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TEmployeeContractInfo> list = baseMapper.getTEmployeeContractList(contractInfo);
if (list != null && !list.isEmpty()) {
ServletOutputStream out = null;
try {
ExcelUtil<TEmployeeContractInfo> util = new ExcelUtil<>(TEmployeeContractInfo.class);
for (TEmployeeContractInfo vo : list) {
util.convertEntity(vo,null,null,null);
}
out = response.getOutputStream();
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, EmployeeExportVO.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);
}
}
}
}
}
/**
* 获取导出的人员档案列表
*/
@Override
public void exportContractInfoHistory(TEmployeeContractInfo contractInfo, HttpServletResponse response) {
if (contractInfo != null && contractInfo.getExportFields() != null && !contractInfo.getExportFields().isEmpty()) {
String fileName = "员工合同批量导出[合并]" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TEmployeeContractInfo> list = baseMapper.getTEmployeeContractList(contractInfo);
if (list != null && !list.isEmpty()) {
ServletOutputStream out = null;
try {
ExcelUtil<TEmployeeContractInfo> util = new ExcelUtil<>(TEmployeeContractInfo.class);
for (TEmployeeContractInfo vo : list) {
util.convertEntity(vo,null,null,null);
}
out = response.getOutputStream();
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, EmployeeExportVO.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);
}
}
}
}
}
} }
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