Commit 43d3c32e authored by chenyuxi's avatar chenyuxi

feat: 入离职登记导出调整

parent cdef9efb
package com.yifu.cloud.plus.v1.csp.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 入离职登记导出
*
* @author chenyuxi
* @date 2025-03-21
* @since 1.9.8
*/
@Data
@ColumnWidth(17)
public class EmployeeRegistrationHrAutoExportVo implements Serializable {
@ExcelAttribute(name = "项目名称")
@Schema(description = "项目名称")
@ExcelProperty("项目名称")
private String deptName;
@ExcelAttribute(name = "项目编码")
@Schema(description = "项目编码")
@ExcelProperty("项目编码")
private String deptNo;
@ExcelAttribute(name = "员工姓名")
@Schema(description = "员工姓名")
@ExcelProperty("员工姓名")
private String employeeName;
@ExcelAttribute(name = "身份证号")
@Schema(description = "身份证号")
@ExcelProperty("身份证号")
private String empIdcard;
@ExcelAttribute(name = "手机号码")
@Schema(description = "手机号码")
@ExcelProperty("手机号码")
private String empPhone;
@ExcelAttribute(name = "就职岗位")
@Schema(description = "就职岗位")
@ExcelProperty("就职岗位")
private String position;
@ExcelAttribute(name = "登记类型")
@Schema(description = "登记类型 1入职 2离职")
@ExcelProperty("登记类型")
private String feedbackType;
@ExcelAttribute(name = "入/离职日期", isDate = true)
@Schema(description = "入/离职日期")
@ExcelProperty("入/离职日期")
@DateTimeFormat("yyyy-MM-dd")
private Date joinLeaveDate;
@ExcelAttribute(name = "登记人")
@Schema(description = "登记人")
@ExcelProperty("登记人")
private String registorUsername;
@ExcelAttribute(name = "登记时间", isDate = true)
@Schema(description = "登记时间")
@ExcelProperty("登记时间")
private Date createTime;
@ExcelAttribute(name = "前端客服")
@Schema(description = "前端客服")
@ExcelProperty("前端客服")
private String customerUsername;
@ExcelAttribute(name = "数据来源")
@Schema(description = "数据来源")
@ExcelProperty("数据来源")
private String dataSource;
@ExcelAttribute(name = "处理状态")
@Schema(description = "处理状态,0已接收,1未处理,2已处理")
@ExcelProperty("处理状态")
private String processStatus;
}
......@@ -83,7 +83,10 @@ public class EmployeeRegistrationController {
*
* @param page 分页对象
* @param employeeRegistration 入离职登记表
* @return
* @return R<IPage<EmployeeRegistration>>
* @author chenyuxi
* @date 2025-03-21
* @since 1.9.8
*/
@Operation(description = "作业自动化-入离职登记列表简单分页查询")
@GetMapping("/hrRegistrationPage")
......@@ -203,8 +206,9 @@ public class EmployeeRegistrationController {
/**
* 作业自动化-入离职登记导出
*
* @author huych
* @date 2025-02-25 14:48:11
* @author chenyuxi
* @date 2025-03-21
* @since 1.9.8
**/
@Operation(description = "作业自动化-入离职登记导出")
@PostMapping("/hrRegistrationExport")
......
......@@ -4,10 +4,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.csp.entity.EmployeeRegistration;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationExportVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationHrExportVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationHrPreExportVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationSearchVo;
import com.yifu.cloud.plus.v1.csp.vo.*;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProjectBelongDept;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmployeeProjectBelongDeptSearchCspVo;
import org.apache.ibatis.annotations.Mapper;
......@@ -46,4 +43,7 @@ public interface EmployeeRegistrationMapper extends BaseMapper<EmployeeRegistrat
// 将数据处理为已处理
int updateTwoRegistrationByIdCard(@Param("searchCspVo") TEmployeeProjectBelongDeptSearchCspVo searchCspVo);
List<EmployeeRegistrationHrAutoExportVo> selectHrAutoExportList(@Param("employeeRegistration") EmployeeRegistrationSearchVo employeeRegistration);
}
......@@ -211,7 +211,43 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
String fileName = "入离职待办任务表批量导出" + DateUtil.getThisTime() + ".xlsx";
this.hrExportCommon(response,searchVo,fileName);
//获取要导出的列表
List<EmployeeRegistrationHrExportVo> list = new ArrayList<>();
long count = baseMapper.selectExportCount(searchVo);
try (ServletOutputStream out = response.getOutputStream()) {
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeRegistrationHrExportVo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = baseMapper.selectHrExportList(searchVo);
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("入离职待办任务表" + index).build();
excelWriter.write(list, writeSheet);
index++;
}
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();
excelWriter.finish();
} catch (Exception e) {
log.error("执行异常", e);
}
}
/**
......@@ -230,35 +266,24 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
initSearchVo(searchVo);
String fileName = "入离职登记批量导出" + DateUtil.getThisTime() + ".xlsx";
this.hrExportCommon(response,searchVo,fileName);
}
/**
* 入离职导出公共
*
* @param searchVo 入离职登记表
*/
private void hrExportCommon(HttpServletResponse response, EmployeeRegistrationSearchVo searchVo, String fileName){
//获取要导出的列表
List<EmployeeRegistrationHrExportVo> list = new ArrayList<>();
List<EmployeeRegistrationHrAutoExportVo> list = new ArrayList<>();
long count = baseMapper.selectExportCount(searchVo);
try (ServletOutputStream out = response.getOutputStream()) {
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeRegistrationHrExportVo.class).build();
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeRegistrationHrAutoExportVo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = baseMapper.selectHrExportList(searchVo);
list = baseMapper.selectHrAutoExportList(searchVo);
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("入离职待办任务表" + index).build();
WriteSheet writeSheet = EasyExcel.writerSheet("入离职登记" + index).build();
excelWriter.write(list, writeSheet);
index++;
}
......@@ -267,7 +292,7 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
}
}
} else {
WriteSheet writeSheet = EasyExcel.writerSheet("入离职待办任务表" + index).build();
WriteSheet writeSheet = EasyExcel.writerSheet("入离职登记" + index).build();
excelWriter.write(list, writeSheet);
}
if (Common.isNotNull(list)) {
......@@ -278,8 +303,8 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
} catch (Exception e) {
log.error("执行异常", e);
}
}
}
/**
* 入职待确认批量导出
......
......@@ -76,6 +76,22 @@
<result property="dataSource" column="data_source"/>
<result property="customerUsernameNew" column="customer_username_new"/>
</resultMap>
<resultMap id="employeeRegistrationHrAutoExportMap" type="com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationHrAutoExportVo">
<result property="employeeName" column="employee_name"/>
<result property="empIdcard" column="emp_idcard"/>
<result property="empPhone" column="emp_phone"/>
<result property="position" column="position"/>
<result property="feedbackType" column="feedback_type"/>
<result property="joinLeaveDate" column="join_leave_date"/>
<result property="processStatus" column="process_status"/>
<result property="registorUsername" column="registor_username"/>
<result property="customerUsername" column="customer_username"/>
<result property="createTime" column="create_time"/>
<result property="deptName" column="dept_name"/>
<result property="deptNo" column="dept_no"/>
<result property="dataSource" column="data_source"/>
</resultMap>
<sql id="Base_Column_List">
a.id,
a.employee_name,
......@@ -337,6 +353,32 @@
order by a.create_time desc
</select>
<select id="selectHrAutoExportList" resultMap="employeeRegistrationHrAutoExportMap">
SELECT
a.dept_name,
a.dept_no,
a.employee_name,
a.emp_idcard,
a.emp_phone,
a.position,
if(a.feedback_type = '1','入职','离职') feedback_type,
a.join_leave_date,
if(a.process_status= '0','已接收',if(a.process_status= '1','待处理','已处理')) process_status,
a.registor_username,
a.create_time,
a.customer_username,
if(a.data_source = '1','客户端','客服端') data_source
FROM employee_registration a
<where>
1=1
<include refid="employeeRegistration_where"/>
</where>
order by a.create_time desc
<if test="employeeRegistration.limitStart != null">
limit #{employeeRegistration.limitStart},#{employeeRegistration.limitEnd}
</if>
</select>
<!-- 将数据处理为已处理 -->
<update id="updateTwoRegistrationByIdCard">
update employee_registration a
......
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