Commit 42c8c96e authored by fangxinjiang's avatar fangxinjiang

权限配置页面

parent fa77967d
......@@ -23,6 +23,7 @@ import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttributeConstants;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.Past;
......@@ -484,4 +485,21 @@ public class EmployeeProjectExportParamVO extends BaseEntity {
private String[] empNatureArray;
private List<String> idList;
/**
* @Author fxj
* 查询数据起
**/
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
private int limitEnd;
/**
* 导出IDS
*/
@Schema(description = "导出IDS")
private String ids;
}
......@@ -59,4 +59,8 @@ public interface TEmployeeProjectMapper extends BaseMapper<TEmployeeProject> {
* @return
*/
List<EmployeeProjectExportVO> getTEmployeeProjectExportPage(@Param("tEmployeeProject") EmployeeProjectExportParamVO tEmployeeProject);
// getTEmployeeProjectExportPage 改造
List<EmployeeProjectExportVO> noPageDiy(@Param("tEmployeeProject")EmployeeProjectExportParamVO searchVo);
int noPageCountDiy(@Param("tEmployeeProject")EmployeeProjectExportParamVO searchVo);
}
......@@ -2033,7 +2033,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
}else {
WriteSheet writeSheet = EasyExcel.writerSheet("不良记录"+index).build();
WriteSheet writeSheet = EasyExcel.writerSheet("人员档案批量导出"+index).build();
excelWriter.write(list,writeSheet);
}
if (Common.isNotNull(list)){
......
......@@ -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.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -62,6 +64,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.*;
......@@ -1173,38 +1176,58 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
* @Date 10:55 2022/6/23
**/
@Override
public void listExportProject(HttpServletResponse response, EmployeeProjectExportParamVO projectDTO, String idstr, List<String> exportFields) {
public void listExportProject(HttpServletResponse response, EmployeeProjectExportParamVO searchVo, String idstr, List<String> exportFields) {
searchVo.setIdList(Common.getList(idstr));
String fileName = "项目档案批量导出" + DateUtil.getThisTime() + CommonConstants.XLSX;
// 根据用户传入确定要导出的字段
Set<String> includeColumnFiledNames = new HashSet<>(exportFields);
//获取要导出的列表
List<EmployeeProjectExportVO> list;
//获取记录
list = gettEmpProInfoExportVos(idstr, projectDTO);
//获取要导出的列表 gettEmpProInfoExportVos
List<EmployeeProjectExportVO> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
ServletOutputStream out = null;
if (list == null || list.isEmpty()) {
list = new ArrayList<>();
}
try {
out = response.getOutputStream();
ExcelUtil<EmployeeProjectExportVO> util = new ExcelUtil<>(EmployeeProjectExportVO.class);
for (EmployeeProjectExportVO vo : list) {
util.convertEntity(vo, null, null, null);
}
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, EmployeeProjectExportVO.class).includeColumnFiledNames(includeColumnFiledNames).sheet("项目档案")
.doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeProjectExportVO.class).includeColumnFieldNames(includeColumnFiledNames).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
Field[] allFields = EmployeeProjectExportVO.class.getDeclaredFields();
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)){
ExcelUtil<EmployeeProjectExportVO> util = new ExcelUtil<>(EmployeeProjectExportVO.class);
for (EmployeeProjectExportVO vo:list){
util.convertEntityAsso(vo,null,null,null,allFields);
}
}
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("执行异常", e);
} finally {
excelWriter.finish();
}catch (Exception e){
log.error("执行异常" ,e);
}finally {
try {
if (null != out) {
out.close();
......@@ -1215,6 +1238,14 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
}
private List<EmployeeProjectExportVO> noPageDiy(EmployeeProjectExportParamVO searchVo) {
return baseMapper.noPageDiy(searchVo);
}
private int noPageCountDiy(EmployeeProjectExportParamVO searchVo) {
return baseMapper.noPageCountDiy(searchVo);
}
/**
* @param employeeInfo
* @Description: 新增项目档案
......
......@@ -802,4 +802,39 @@
</where>
order by a.CREATE_TIME desc
</select>
<!--tEmployeeInfo导出查询改造 fxj 2022-11-03-->
<select id="noPageDiy" resultMap="tEmployeeProjectExportMap">
SELECT
<include refid="Base_Export_List"/>
FROM t_employee_project a
left join t_employee_info b on a.EMP_ID = b.id
<where>
a.DELETE_FLAG = '0'
<include refid="exportTEmployeeProject_where"/>
<if test="tEmployeeProject.authSql != null and tEmployeeProject.authSql.trim() != ''">
${tEmployeeProject.authSql}
</if>
</where>
order by a.CREATE_TIME desc
<if test="tEmployeeProject != null">
<if test="tEmployeeProject.limitStart != null">
limit #{tEmployeeProject.limitStart},#{tEmployeeProject.limitEnd}
</if>
</if>
</select>
<!--tEmployeeInfo导出查询count改造 fxj 2022-11-03-->
<select id="noPageCountDiy" resultType="java.lang.Integer">
SELECT
count(1)
FROM t_employee_project a
left join t_employee_info b on a.EMP_ID = b.id
<where>
a.DELETE_FLAG = '0'
<include refid="exportTEmployeeProject_where"/>
<if test="tEmployeeProject.authSql != null and tEmployeeProject.authSql.trim() != ''">
${tEmployeeProject.authSql}
</if>
</where>
</select>
</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