Commit cf7f206d authored by fangxinjiang's avatar fangxinjiang

离职库导出

parent f55cfbe9
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
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 lombok.Data;
import java.time.LocalDateTime;
/**
* 人员档案表excel导出对应的实体
*
* @author hgw
* @date 2022-6-24 15:15:24
*/
@Data
@ColumnWidth(10)
public class EmployeeLeaveExportVO {
private static final long serialVersionUID = 1L;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "员工主码")
private String empCode;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "员工姓名")
private String empName;
@ColumnWidth(20)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "身份证号")
private String empIdcard;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "手机号码")
private String empPhone;
@ExcelAttribute(name = "档案所在省", isArea = true)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "档案所在省")
private String fileProvince;
@ExcelAttribute(name = "档案所在市", isArea = true, parentField = "fileProvince")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "档案所在市")
private String fileCity;
@ExcelAttribute(name = "档案所在县", isArea = true, parentField = "fileCity")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "档案所在县")
private String fileTown;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "单位名称")
private String unitName;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "项目名称")
private String deptName;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "项目编码")
private String deptNo;
@ExcelAttribute(name = "员工类型", isDataId = true,dataType = ExcelAttributeConstants.EMP_NATRUE)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "员工类型")
private String empNatrue;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "减档人")
private String leaveUserName;
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "减档时间")
private LocalDateTime leaveTime;
}
......@@ -323,7 +323,7 @@ public class TEmployeeInfoController {
@SysLog("批量导出离职档案信息")
// @ResponseExcel
@PostMapping("/exportLeaveEmployee")
public void exportLeaveEmployee(@RequestBody(required = false) TEmployeeInfo employeeInfo, HttpServletResponse response) {
public void exportLeaveEmployee(@RequestBody(required = false) EmployeeInfoSearchVo employeeInfo, HttpServletResponse response) {
YifuUser user = SecurityUtils.getUser();
if (user != null && Common.isNotNull(user.getId())) {
menuUtil.setAuthSql(user, employeeInfo);
......
......@@ -81,4 +81,8 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
int noPageCountDiy(@Param("tEmployeeInfo")EmployeeInfoSearchVo searchVo);
// 同 getTEmployeeExportList 方法
List<EmployeeExportVO> noPageDiy(@Param("tEmployeeInfo")EmployeeInfoSearchVo searchVo);
List<EmployeeLeaveExportVO> noPageLeaveDiy(@Param("tEmployeeInfo")EmployeeInfoSearchVo searchV);
int noPageCountLeaveDiy(@Param("tEmployeeInfo")EmployeeInfoSearchVo searchV);
}
......@@ -177,7 +177,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @Author: hgw
* @Date: 2022-6-24 09:35:54
**/
void exportLeaveEmployee(TEmployeeInfo employeeVo, HttpServletResponse response);
void exportLeaveEmployee(EmployeeInfoSearchVo employeeVo, HttpServletResponse response);
Map<String,DispatchEmpVo> getDispatchEmpVo(DispatchCheckVo checkVo);
......
......@@ -2069,41 +2069,78 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
* 获取导出的离职档案列表
*/
@Override
public void exportLeaveEmployee(TEmployeeInfo employeeInfo, HttpServletResponse response) {
if (employeeInfo != null && employeeInfo.getExportFields() != null && !employeeInfo.getExportFields().isEmpty()) {
public void exportLeaveEmployee(EmployeeInfoSearchVo searchVo, HttpServletResponse response) {
if (searchVo != null && searchVo.getExportFields() != null && !searchVo.getExportFields().isEmpty()) {
String fileName = "离职档案批量导出" + DateUtil.getThisTime() + CommonConstants.XLSX;
//获取要导出的列表
employeeInfo.setFileStatus(CommonConstants.ONE_INT);
List<EmployeeExportVO> list = baseMapper.getTEmployeeLeaveExportList(employeeInfo);
List<EmployeeLeaveExportVO> list = new ArrayList<>();
//获取要导出的列表
searchVo.setFileStatus(CommonConstants.ONE_INT);
long count = noPageCountLeaveDiy(searchVo);
// baseMapper.getTEmployeeLeaveExportList(employeeInfo);
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);
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeLeaveExportVO.class).includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
Field[] allFields = EmployeeLeaveExportVO.class.getDeclaredFields();
WriteSheet writeSheet;
ExcelUtil<EmployeeLeaveExportVO> util;
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageLeaveDiy(searchVo);
/*if (Common.isNotNull(list)){
util = new ExcelUtil<>(EmployeeLeaveExportVO.class);
for (EmployeeLeaveExportVO vo:list){
util.convertEntityAsso(vo,null,null,null,allFields);
}
}*/
if (Common.isNotNull(list)){
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<EmployeeLeaveExportVO> noPageLeaveDiy(EmployeeInfoSearchVo searchVo) {
return baseMapper.noPageLeaveDiy(searchVo);
}
private long noPageCountLeaveDiy(EmployeeInfoSearchVo searchVo) {
return baseMapper.noPageCountLeaveDiy(searchVo);
}
@Override
......
......@@ -125,6 +125,22 @@
<result property="leaveRemark" column="LEAVE_REMARK"/>
<result property="status" column="STATUS"/>
</resultMap>
<resultMap id="tEmployeeLeaveExportMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeLeaveExportVO">
<result property="empCode" column="EMP_CODE"/>
<result property="empNatrue" column="EMP_NATRUE"/>
<result property="empName" column="EMP_NAME"/>
<result property="empIdcard" column="EMP_IDCARD"/>
<result property="empPhone" column="EMP_PHONE"/>
<result property="fileProvince" column="FILE_PROVINCE"/>
<result property="fileCity" column="FILE_CITY"/>
<result property="fileTown" column="FILE_TOWN"/>
<result property="deptName" column="DEPT_NAME"/>
<result property="deptNo" column="DEPT_NO"/>
<result property="unitName" column="UNIT_NAME"/>
<result property="leaveUserName" column="LEAVE_USER_NAME"/>
<result property="leaveTime" column="LEAVE_TIME"/>
</resultMap>
<resultMap id="dispatchEmpVoMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.DispatchEmpVo">
<id property="id" column="ID"/>
<result property="empCode" column="EMP_CODE"/>
......@@ -798,8 +814,12 @@
,a.LEAVE_TIME
,a.LEAVE_USER
,a.LEAVE_USER_NAME
,a.LEAVE_REASON
,a.LEAVE_REASON,
p.IS_PROJECTS ,
p.DEPT_NAME,
p.DEPT_NO,p.UNIT_NAME
from t_employee_info a
LEFT JOIN view_project_leave p on a.EMP_IDCARD=p.EMP_IDCARD
<!--left join (
select
b.EMP_ID,
......@@ -974,4 +994,92 @@
)
</if>
</sql>
<!--tEmployeeInfo离职档案导出查询-->
<select id="noPageLeaveDiy" resultMap="tEmployeeLeaveExportMap">
SELECT
a.EMP_CODE,
CASE WHEN a.EMP_NATRUE='0' THEN "外包"
WHEN a.EMP_NATRUE='1' THEN "派遣"
WHEN a.EMP_NATRUE='2' THEN "代理"
WHEN a.EMP_NATRUE='3' THEN "内部员工"
ELSE "" END as "EMP_NATRUE",
a.EMP_NAME,
a.EMP_IDCARD,
a.EMP_PHONE,
a.EMP_EMAIL,
a1.area_name as "FILE_PROVINCE",
a2.area_name as "FILE_CITY",
a3.area_name as "FILE_TOWN",
a.LEAVE_TIME,
a.LEAVE_USER_NAME,
p.DEPT_NAME,
p.DEPT_NO,
p.UNIT_NAME
from t_employee_info a
LEFT JOIN view_project_leave p on a.EMP_IDCARD=p.EMP_IDCARD
LEFT JOIN sys_area a1 on a1.id=a.FILE_PROVINCE
LEFT JOIN sys_area a2 on a2.id=a.FILE_CITY
LEFT JOIN sys_area a3 on a3.id=a.FILE_TOWN
<where>
a.DELETE_FLAG = '0'
<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>
<if test="tEmployeeInfo.unitName != null and tEmployeeInfo.unitName.trim() != ''">
AND p.UNIT_NAME like concat('%',#{tEmployeeInfo.unitName},'%')
</if>
<if test="tEmployeeInfo.deptName != null and tEmployeeInfo.deptName.trim() != ''">
AND p.DEPT_NAME like concat('%',#{tEmployeeInfo.deptName},'%')
</if>
<if test="tEmployeeInfo.deptNo != null and tEmployeeInfo.deptNo.trim() != ''">
AND p.DEPT_NO like concat('%',#{tEmployeeInfo.deptNo},'%')
</if>
</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离职档案导出查询-->
<select id="noPageCountLeaveDiy" resultType="java.lang.Integer">
select count(1)
from t_employee_info a
LEFT JOIN view_project_leave p on a.EMP_IDCARD=p.EMP_IDCARD
<where>
a.DELETE_FLAG = '0'
<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>
<if test="tEmployeeInfo.unitName != null and tEmployeeInfo.unitName.trim() != ''">
AND p.UNIT_NAME like concat('%',#{tEmployeeInfo.unitName},'%')
</if>
<if test="tEmployeeInfo.deptName != null and tEmployeeInfo.deptName.trim() != ''">
AND p.DEPT_NAME like concat('%',#{tEmployeeInfo.deptName},'%')
</if>
<if test="tEmployeeInfo.deptNo != null and tEmployeeInfo.deptNo.trim() != ''">
AND p.DEPT_NO like concat('%',#{tEmployeeInfo.deptNo},'%')
</if>
</where>
order by a.CREATE_TIME desc
</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