Commit 79f2214b authored by huyuchen's avatar huyuchen

Merge remote-tracking branch 'origin/MVP1.4-EXPORT' into MVP1.4-EXPORT

parents bfb175e8 bfbd74d4
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
/**
* @Author fxj
......@@ -21,4 +25,30 @@ public class EducationSearchVo extends TEmpEducation {
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
/**
* @Author fxj
* 查询数据起
**/
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
private int limitEnd;
@TableField(exist = false)
@Schema(description = "导出的表头的Set")
private Set<String> exportFields;
//派单开始时间(查询专用)
@ExcelAttribute(name = "创建开始时间")
@TableField(exist = false)
private LocalDateTime createTimeStart;
//派单截止时间(查询专用)
@ExcelAttribute(name = "创建截止时间")
@TableField(exist = false)
private LocalDateTime createTimeEnd;
private List<String> idList;
}
/*
* 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.write.style.HeadFontStyle;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
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 lombok.EqualsAndHashCode;
import javax.validation.constraints.Max;
import java.io.Serializable;
import java.util.Date;
/**
* 员工学历信息表
*
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Data
@Schema(description = "员工学历信息表")
public class TEmpEducationExportVo implements Serializable {
/**
* 主键
*/
@HeadFontStyle(fontHeightInPoints = 11)
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
@ExcelProperty("唯一标识")
private String id;
/**
* 员工姓名
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 20)
@Schema(description = "员工姓名")
@ExcelProperty("员工姓名")
private String empName;
/**
* 身份证号
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 20)
@Schema(description = "身份证号")
@ExcelProperty("身份证号")
private String empIdcard;
/**
* 学校名称
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 50)
@Schema(description = "学校名称")
@ExcelProperty("学校")
private String school;
/**
* 院系名称
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 50)
@Schema(description = "院系名称")
@ExcelProperty("院系名称")
private String collageSystem;
/**
* 专业
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 50)
@Schema(description = "专业")
@ExcelProperty("专业")
private String major;
/**
* 学历名称
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 50)
@Schema(description = "学历名称")
@ExcelAttribute(name = "学历", isNotEmpty = true,errorInfo = "学历不可为空", isDataId = true, dataType = ExcelAttributeConstants.EDUCATION)
@ExcelProperty("学历")
private String educationName;
/**
* 学历类型:全日制、自考、函授等
*/
@ExcelAttribute(name = "学历类型", isDataId = true, dataType = ExcelAttributeConstants.EDUCATION_TYPE)
@HeadFontStyle(fontHeightInPoints = 11)
@Schema(description = "学历类型:全日制、自考、函授等")
@ExcelProperty("学历类型")
private String type;
/**
* 最高学历标识0是/1否
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Schema(description = "最高学历标识0是/1否")
@ExcelProperty("最高学历")
private String highIdentification;
/**
* 学制类型
*/
@ExcelAttribute(name = "学制类型", isDataId = true, dataType = ExcelAttributeConstants.EDUCATION_SYSTEM)
@HeadFontStyle(fontHeightInPoints = 11)
@Schema(description = "学制类型")
@ExcelProperty("学制类型")
private String educationSystem;
/**
* 入学时间
*/
@HeadFontStyle(fontHeightInPoints = 11)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@Schema(description = "入学时间")
@ExcelProperty("入学时间")
private Date entryDate;
/**
* 结业日期
*/
@HeadFontStyle(fontHeightInPoints = 11)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@Schema(description = "结业日期")
@ExcelProperty("毕业日期")
private Date gradutionDate;
/**
* 证书名称
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 50)
@Schema(description = "证书名称")
@ExcelProperty("证书名称")
private String certificationName;
/**
* 备注
*/
@HeadFontStyle(fontHeightInPoints = 11)
@Max(value = 200)
@Schema(description = "备注")
@ExcelProperty("备注")
private String remark;
}
......@@ -22,9 +22,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpEducationService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EducationSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
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.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
......@@ -34,6 +39,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
......@@ -173,4 +179,15 @@ public class TEmpEducationController {
public R<List<ErrorMessage>> importListUpate(@RequestBody MultipartFile file) {
return tEmpEducationService.importEmpEducationUpdateDiy(file.getInputStream());
}
/**
* @Author fxj
* @Description 批量导出人员学历信息
* @Date 14:01 2023/1/16
**/
@Operation(summary = "批量导出人员学历信息", description = "批量导出人员学历信息")
@SysLog("批量导出人员学历信息")
@PostMapping("/exportEmpEducation")
public void exportEmpEducation(@RequestBody(required = false) EducationSearchVo searchVo, HttpServletResponse response) {
tEmpEducationService.exportEmpEducation(searchVo, response);
}
}
......@@ -19,9 +19,13 @@ package com.yifu.cloud.plus.v1.yifu.archives.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EducationSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmpEducationExportVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 员工学历信息表
*
......@@ -32,4 +36,8 @@ import org.apache.ibatis.annotations.Param;
public interface TEmpEducationMapper extends BaseMapper<TEmpEducation> {
int updateHighIdentification(@Param("empIdcard") String empIdcard);
List<TEmpEducationExportVo> noPageDiy(@Param("searchVo")EducationSearchVo searchVo,@Param("idList")List<String> idList);
int noPageCountDiy(@Param("searchVo")EducationSearchVo searchVo,@Param("idList")List<String> idList);
}
......@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
......@@ -56,4 +57,5 @@ public interface TEmpEducationService extends IService<TEmpEducation> {
R<List<ErrorMessage>> importEmpEducationUpdateDiy(InputStream inputStream);
void exportEmpEducation(EducationSearchVo searchVo, HttpServletResponse response);
}
......@@ -19,10 +19,12 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil;
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.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -34,10 +36,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpEducationMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpEducationService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EducationSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
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.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
......@@ -47,9 +47,14 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -448,4 +453,81 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
}
return wrapper;
}
/**
* 获取导出的人员学历列表
*/
@Override
public void exportEmpEducation(EducationSearchVo searchVo, HttpServletResponse response) {
String fileName = "人员学历批量导出" + DateUtil.getThisTime() + CommonConstants.XLSX;
//获取要导出的列表
List<TEmpEducationExportVo> list = new ArrayList<>();
if (Common.isNotNull(searchVo.getCreateTimes()) &&
searchVo.getCreateTimes().length == CommonConstants.TWO_INT){
searchVo.setCreateTimeEnd(searchVo.getCreateTimes()[1]);
searchVo.setCreateTimeStart(searchVo.getCreateTimes()[0]);
}
long count = noPageCountDiy(searchVo,Common.getList(searchVo.getIds()));
ServletOutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelUtil<TEmpEducationExportVo> util = new ExcelUtil<>(TEmpEducationExportVo.class);
// 获取所有字典type
Map<String,String> nameAndDicTypeMap = util.getConverterDicType();
// 获取所有字典对应的值
Map<String,String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE);
ExcelWriter excelWriter = EasyExcel.write(out, TEmpEducationExportVo.class)
.registerConverter(new DictConverter(nameAndDicTypeMap,redisLabelMap)).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
WriteSheet writeSheet;
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo,Common.getList(searchVo.getIds()));
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();
excelWriter.finish();
}catch (Exception e){
log.error("人员学历批量导出执行异常" ,e);
}finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("人员学历批量导出执行异常", e);
}
}
}
private List<TEmpEducationExportVo> noPageDiy(EducationSearchVo searchVo,List<String> idList) {
return baseMapper.noPageDiy(searchVo,idList);
}
private long noPageCountDiy(EducationSearchVo searchVo,List<String> idList) {
return baseMapper.noPageCountDiy(searchVo,idList);
}
}
......@@ -46,15 +46,100 @@
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="major" column="MAJOR"/>
<result property="remark" column="REMARK"/>
<result property="certificationName" column="CERTIFICATION_NAME"/>
</resultMap>
<resultMap id="tEmpEducationExportMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TEmpEducationExportVo">
<id property="id" column="ID"/>
<result property="empName" column="EMP_NAME"/>
<result property="empIdcard" column="EMP_IDCARD"/>
<result property="entryDate" column="ENTRY_DATE"/>
<result property="educationName" column="EDUCATION_NAME"/>
<result property="gradutionDate" column="GRADUTION_DATE"/>
<result property="school" column="SCHOOL"/>
<result property="educationSystem" column="EDUCATION_SYSTEM"/>
<result property="highIdentification" column="HIGH_IDENTIFICATION"/>
<result property="type" column="TYPE"/>
<result property="collageSystem" column="COLLAGE_SYSTEM"/>
<result property="major" column="MAJOR"/>
<result property="remark" column="REMARK"/>
<result property="certificationName" column="CERTIFICATION_NAME"/>
</resultMap>
<update id="updateHighIdentification" parameterType="java.lang.String">
update t_emp_education
set HIGH_IDENTIFICATION='1'
WHERE EMP_IDCARD=#{empIdcard}
</update>
<!--人员学历导出查询count fxj 2023-01-16-->
<select id="noPageDiy" resultMap="tEmpEducationExportMap">
select
a.id,
a.EMP_NAME,
a.EMP_IDCARD,
a.ENTRY_DATE,
a.EDUCATION_NAME,
a.GRADUTION_DATE,
a.SCHOOL,
a.EDUCATION_SYSTEM,
case when a.HIGH_IDENTIFICATION = 0 then "是"
when a.HIGH_IDENTIFICATION = 1 then "否"
else null end as "HIGH_IDENTIFICATION" ,
a.type,
a.COLLAGE_SYSTEM,
a.MAJOR,
a.REMARK,
a.CERTIFICATION_NAME
from t_emp_education a
<where>
a.DELETE_FLAG = '0'
<include refid="education_where_export"/>
</where>
order by a.CREATE_TIME desc
<if test="searchVo != null">
<if test="searchVo.limitStart != null">
limit #{searchVo.limitStart},#{searchVo.limitEnd}
</if>
</if>
</select>
<!--人员学历导出查询count fxj 2023-01-16-->
<select id="noPageCountDiy" resultType="java.lang.Integer">
select
count(1)
from t_emp_education a
<where>
a.DELETE_FLAG = '0'
<include refid="education_where_export"/>
</where>
</select>
<sql id="education_where_export">
<if test="searchVo != null">
<if test="searchVo.idList != null">
AND a.id in
<foreach item="idStr" index="index" collection="searchVo.idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="searchVo.idList == null">
<if test="searchVo.createTimeStart != null and searchVo.createTimeStart.trim() != ''">
AND a.CREATE_TIME >= #{searchVo.createTimeStart}
</if>
<if test="searchVo.createTimeEnd != null and searchVo.createTimeEnd.trim() != ''">
AND a.CREATE_TIME <![CDATA[ <= ]]> #{searchVo.createTimeEnd}
</if>
<if test="searchVo.empName != null and searchVo.empName.trim() != ''">
AND a.EMP_NAME like concat('%',#{searchVo.empName},'%')
</if>
<if test="searchVo.empIdcard != null and searchVo.empIdcard.trim() != ''">
AND a.EMP_IDCARD like concat('%',#{searchVo.empIdcard},'%')
</if>
<if test="searchVo.createName != null and searchVo.createName.trim() != ''">
AND a.CREATE_NAME = #{searchVo.createName}
</if>
</if>
</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