Commit 8d240faf authored by fangxinjiang's avatar fangxinjiang

权限配置页面

parent 81a3daba
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @Author fxj
* @Date 2022/11/2
* @Description
* @Version 1.0
*/
@Data
public class EmployeeInfoSearchVo extends TEmployeeInfo {
/**
* 导出IDS
*/
@Schema(description = "导出IDS")
private String ids;
/**
* 创建时间区间 [开始时间,结束时间]
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
/**
* @Author fxj
* 查询数据起
**/
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
private int limitEnd;
}
......@@ -302,15 +302,15 @@ public class TEmployeeInfoController {
@SysLog("批量导出人员档案信息")
// @ResponseExcel
@PostMapping("/exportEmployee")
public void exportEmployee(@RequestBody(required = false) TEmployeeInfo employeeInfo, HttpServletResponse response) {
public void exportEmployee(@RequestBody(required = false) EmployeeInfoSearchVo searchVo, HttpServletResponse response) {
YifuUser user = SecurityUtils.getUser();
if (user != null && Common.isNotNull(user.getId())) {
menuUtil.setAuthSql(user, employeeInfo);
if (Common.isNotNull(employeeInfo.getAuthSql()) && employeeInfo.getAuthSql().contains(CommonConstants.A_DEPT_ID)) {
employeeInfo.setAuthSql(employeeInfo.getAuthSql().replace(CommonConstants.A_DEPT_ID, "b.DEPT_ID"));
menuUtil.setAuthSql(user, searchVo);
if (Common.isNotNull(searchVo.getAuthSql()) && searchVo.getAuthSql().contains(CommonConstants.A_DEPT_ID)) {
searchVo.setAuthSql(searchVo.getAuthSql().replace(CommonConstants.A_DEPT_ID, "b.DEPT_ID"));
}
}
tEmployeeInfoService.exportEmployee(employeeInfo, response);
tEmployeeInfoService.exportEmployee(searchVo, response);
}
/**
......
......@@ -21,10 +21,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.DispatchCheckVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.DispatchEmpVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeExportVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -80,4 +77,8 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
String getMaxEmpCode();
List<DispatchEmpVo> getDispatchEmpVo(@Param("checkVo")DispatchCheckVo checkVo);
// 同 getTEmployeeExportList 方法
int noPageCountDiy(@Param("tEmployeeInfo")EmployeeInfoSearchVo searchVo);
// 同 getTEmployeeExportList 方法
List<EmployeeExportVO> noPageDiy(@Param("tEmployeeInfo")EmployeeInfoSearchVo searchVo);
}
......@@ -169,7 +169,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @Author: hgw
* @Date: 2022/6/23 10:30
**/
void exportEmployee(TEmployeeInfo employeeVo, HttpServletResponse response);
void exportEmployee(EmployeeInfoSearchVo employeeVo, HttpServletResponse response);
/**
* @param employeeVo
......
......@@ -19,10 +19,12 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -1988,41 +1990,75 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
* 获取导出的人员档案列表
*/
@Override
public void exportEmployee(TEmployeeInfo employeeInfo, HttpServletResponse response) {
if (employeeInfo != null && employeeInfo.getExportFields() != null && !employeeInfo.getExportFields().isEmpty()) {
public void exportEmployee(EmployeeInfoSearchVo searchVo, HttpServletResponse response) {
if (searchVo != null && searchVo.getExportFields() != null && !searchVo.getExportFields().isEmpty()) {
String fileName = "人员档案批量导出" + DateUtil.getThisTime() + CommonConstants.XLSX;
//获取要导出的列表
employeeInfo.setFileStatus(CommonConstants.ZERO_INT);
List<EmployeeExportVO> list = baseMapper.getTEmployeeExportList(employeeInfo);
List<EmployeeExportVO> list = new ArrayList<>();
//获取要导出的列表
searchVo.setFileStatus(CommonConstants.ZERO_INT);
long count = noPageCountDiy(searchVo);
ServletOutputStream out = null;
if (list == null || list.isEmpty()) {
list = new ArrayList<>();
}
try {
ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class);
for (EmployeeExportVO vo : list) {
util.convertEntity(vo, null, null, null);
}
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding(CommonConstants.UTF8);
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel.write(out, EmployeeExportVO.class).includeColumnFiledNames(employeeInfo.getExportFields())
.sheet("人员档案").doWrite(list);
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeExportVO.class).includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)){
ExcelUtil<EmployeeExportVO> util = new ExcelUtil<>(EmployeeExportVO.class);
for (EmployeeExportVO vo:list){
util.convertEntity(vo,(String[])searchVo.getExportFields().toArray(),null,null);
}
}
if (Common.isNotNull(list)){
WriteSheet writeSheet = EasyExcel.writerSheet("不良记录"+index).build();
excelWriter.write(list,writeSheet);
index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)){
list.clear();
}
}
}else {
WriteSheet writeSheet = EasyExcel.writerSheet("不良记录"+index).build();
excelWriter.write(list,writeSheet);
}
if (Common.isNotNull(list)){
list.clear();
}
out.flush();
} catch (Exception e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
} finally {
excelWriter.finish();
}catch (Exception e){
log.error("执行异常" ,e);
}finally {
try {
if (out != null) {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error(EmployeeConstants.FILE_EXPORT_EXCEPTION, e);
log.error("执行异常", e);
}
}
}
}
private List<EmployeeExportVO> noPageDiy(EmployeeInfoSearchVo searchVo) {
return baseMapper.noPageDiy(searchVo);
}
private long noPageCountDiy(EmployeeInfoSearchVo searchVo) {
return baseMapper.noPageCountDiy(searchVo);
}
/**
......
......@@ -927,4 +927,51 @@
</select>
<!--tEmployeeInfo人员档案导出查询改造 fxj 2022-11-02-->
<select id="noPageDiy" resultMap="tEmployeeExportMap">
select
<include refid="Base_Export_List"/>,
p.IS_PROJECTS ,
p.DEPT_NAME,
p.DEPT_NO,
P.PROJECT_NUM
from t_employee_info a
LEFT JOIN view_project p on a.EMP_IDCARD=p.EMP_IDCARD
<where>
a.DELETE_FLAG = '0'
<include refid="employeeInfo_where_export"/>
</where>
order by a.CREATE_TIME desc
<if test="tEmployeeInfo != null">
<if test="tEmployeeInfo.limitStart != null">
limit #{tEmployeeInfo.limitStart},#{tEmployeeInfo.limitEnd}
</if>
</if>
</select>
<!--tEmployeeInfo人员档案导出查询count fxj 2022-11-02-->
<select id="noPageCountDiy" resultType="java.lang.Integer">
select
count(1)
from t_employee_info a
LEFT JOIN view_project p on a.EMP_IDCARD=p.EMP_IDCARD
<where>
a.DELETE_FLAG = '0'
<include refid="employeeInfo_where_export"/>
</where>
</select>
<sql id="employeeInfo_where_export">
<include refid="employeeInfo_where"/>
<if test="tEmployeeInfo.authSql != null and tEmployeeInfo.authSql.trim() != ''">
and
a.id in (
select b.emp_id from t_employee_project b
where
b.DELETE_FLAG = '0'
${tEmployeeInfo.authSql}
)
</if>
</sql>
</mapper>
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