Commit bbb9e435 authored by huyuchen's avatar huyuchen

项目档案批量操作速度优化

parent 29ff02f9
...@@ -62,7 +62,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -62,7 +62,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.URLEncoder; import java.net.URLEncoder;
...@@ -1139,9 +1138,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -1139,9 +1138,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
//获取要导出的列表 gettEmpProInfoExportVos //获取要导出的列表 gettEmpProInfoExportVos
List<EmployeeProjectExportVO> list = new ArrayList<>(); List<EmployeeProjectExportVO> list = new ArrayList<>();
long count = noPageCountDiy(searchVo); long count = noPageCountDiy(searchVo);
ServletOutputStream out = null; try (ServletOutputStream out = response.getOutputStream()){
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA); response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , "UTF-8")); response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , "UTF-8"));
...@@ -1152,7 +1149,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -1152,7 +1149,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
Field[] allFields = EmployeeProjectExportVO.class.getDeclaredFields(); Field[] allFields = EmployeeProjectExportVO.class.getDeclaredFields();
WriteSheet writeSheet; WriteSheet writeSheet;
ExcelUtil<EmployeeProjectExportVO> util; ExcelUtil<EmployeeProjectExportVO> util;
for (int i = 0; i <= count; ) { for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
...@@ -1168,7 +1165,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -1168,7 +1165,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
excelWriter.write(list,writeSheet); excelWriter.write(list,writeSheet);
index++; index++;
} }
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)){ if (Common.isNotNull(list)){
list.clear(); list.clear();
} }
...@@ -1180,18 +1176,9 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -1180,18 +1176,9 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
if (Common.isNotNull(list)){ if (Common.isNotNull(list)){
list.clear(); list.clear();
} }
out.flush();
excelWriter.finish(); excelWriter.finish();
}catch (Exception e){ }catch (Exception e){
log.error("执行异常" ,e); log.error("执行异常" ,e);
}finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
} }
} }
......
...@@ -383,35 +383,35 @@ ...@@ -383,35 +383,35 @@
<if test="tEmployeeProject.fileTown != null"> <if test="tEmployeeProject.fileTown != null">
AND a.SOCIAL_TOWN = #{tEmployeeProject.socialTown} AND a.SOCIAL_TOWN = #{tEmployeeProject.socialTown}
</if> </if>
<if test="tEmployeeProject.empNatureArray != null"> <if test="tEmployeeProject.empNatureArray != null and tEmployeeProject.empNatureArray.length > 0">
AND a.EMP_NATRUE in AND a.EMP_NATRUE in
<foreach item="idStr" index="index" collection="tEmployeeProject.empNatureArray" open="(" separator="," <foreach item="idStr" index="index" collection="tEmployeeProject.empNatureArray" open="(" separator=","
close=")"> close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.contractStatusArray != null"> <if test="tEmployeeProject.contractStatusArray != null and tEmployeeProject.contractStatusArray.length > 0">
AND a.CONTRACT_STATUS in AND a.CONTRACT_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.contractStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.contractStatusArray" open="("
separator="," close=")"> separator="," close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.insuranceStatusArray != null"> <if test="tEmployeeProject.insuranceStatusArray != null and tEmployeeProject.insuranceStatusArray.length > 0">
AND a.INSURANCE_STATUS in AND a.INSURANCE_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.insuranceStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.insuranceStatusArray" open="("
separator="," close=")"> separator="," close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.socialStatusArray != null"> <if test="tEmployeeProject.socialStatusArray != null and tEmployeeProject.socialStatusArray.length > 0">
AND a.SOCIAL_STATUS in AND a.SOCIAL_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.socialStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.socialStatusArray" open="("
separator="," close=")"> separator="," close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.fundStatusArray != null"> <if test="tEmployeeProject.fundStatusArray != null and tEmployeeProject.fundStatusArray.length > 0">
AND a.FUND_STATUS in AND a.FUND_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.fundStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.fundStatusArray" open="("
separator="," close=")"> separator="," close=")">
...@@ -540,35 +540,35 @@ ...@@ -540,35 +540,35 @@
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.empNatureArray != null"> <if test="tEmployeeProject.empNatureArray != null and tEmployeeProject.empNatureArray.length > 0">
AND a.EMP_NATRUE in AND a.EMP_NATRUE in
<foreach item="idStr" index="index" collection="tEmployeeProject.empNatureArray" open="(" separator="," <foreach item="idStr" index="index" collection="tEmployeeProject.empNatureArray" open="(" separator=","
close=")"> close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.contractStatusArray != null"> <if test="tEmployeeProject.contractStatusArray != null and tEmployeeProject.contractStatusArray.length > 0">
AND a.CONTRACT_STATUS in AND a.CONTRACT_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.contractStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.contractStatusArray" open="("
separator="," close=")"> separator="," close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.insuranceStatusArray != null"> <if test="tEmployeeProject.insuranceStatusArray != null and tEmployeeProject.insuranceStatusArray.length > 0">
AND a.INSURANCE_STATUS in AND a.INSURANCE_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.insuranceStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.insuranceStatusArray" open="("
separator="," close=")"> separator="," close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.socialStatusArray != null"> <if test="tEmployeeProject.socialStatusArray != null and tEmployeeProject.socialStatusArray.length > 0">
AND a.SOCIAL_STATUS in AND a.SOCIAL_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.socialStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.socialStatusArray" open="("
separator="," close=")"> separator="," close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
<if test="tEmployeeProject.fundStatusArray != null"> <if test="tEmployeeProject.fundStatusArray != null and tEmployeeProject.fundStatusArray.length > 0">
AND a.FUND_STATUS in AND a.FUND_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProject.fundStatusArray" open="(" <foreach item="idStr" index="index" collection="tEmployeeProject.fundStatusArray" open="("
separator="," close=")"> separator="," close=")">
......
...@@ -21,9 +21,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute; ...@@ -21,9 +21,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Size;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -45,7 +43,6 @@ public class TPaymentInfoBatchVo { ...@@ -45,7 +43,6 @@ public class TPaymentInfoBatchVo {
@Schema(description ="员工姓名") @Schema(description ="员工姓名")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("员工姓名") @ExcelProperty("员工姓名")
@Size(max = 20, message = "员工姓名不可超过20位")
private String empName; private String empName;
/** /**
...@@ -55,7 +52,6 @@ public class TPaymentInfoBatchVo { ...@@ -55,7 +52,6 @@ public class TPaymentInfoBatchVo {
@Schema(description ="员工编码") @Schema(description ="员工编码")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("员工编码") @ExcelProperty("员工编码")
@Size(max = 32, message = "员工编码不可超过32位")
private String empNo; private String empNo;
/** /**
...@@ -65,7 +61,6 @@ public class TPaymentInfoBatchVo { ...@@ -65,7 +61,6 @@ public class TPaymentInfoBatchVo {
@Schema(description ="身份证号") @Schema(description ="身份证号")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("身份证号") @ExcelProperty("身份证号")
@Size(max = 32, message = "身份证号不可超过32位")
private String empIdcard; private String empIdcard;
/** /**
...@@ -98,8 +93,7 @@ public class TPaymentInfoBatchVo { ...@@ -98,8 +93,7 @@ public class TPaymentInfoBatchVo {
/** /**
* 项目编码 * 项目编码
*/ */
@Length(max = 50, message = "项目编码不能超过50个字符" ) @ExcelAttribute(name = "项目编码")
@ExcelAttribute(name = "项目编码", maxLength = 50)
@Schema(description = "项目编码" ) @Schema(description = "项目编码" )
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("项目编码" ) @ExcelProperty("项目编码" )
...@@ -135,9 +129,8 @@ public class TPaymentInfoBatchVo { ...@@ -135,9 +129,8 @@ public class TPaymentInfoBatchVo {
/** /**
* 社保缴纳月份 * 社保缴纳月份
*/ */
@ExcelAttribute(name = "社保缴纳月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "社保缴纳月份")
@Schema(description ="社保缴纳月份") @Schema(description ="社保缴纳月份")
@Length(max = 6, message = "社保缴纳月份不能超过6个字符")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("社保缴纳月份") @ExcelProperty("社保缴纳月份")
private String socialPayMonth; private String socialPayMonth;
...@@ -145,8 +138,7 @@ public class TPaymentInfoBatchVo { ...@@ -145,8 +138,7 @@ public class TPaymentInfoBatchVo {
/** /**
* 社保生成月份 * 社保生成月份
*/ */
@ExcelAttribute(name = "社保生成月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "社保生成月份")
@Length(max = 6, message = "社保生成月份不能超过6个字符")
@Schema(description ="社保生成月份") @Schema(description ="社保生成月份")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("社保生成月份") @ExcelProperty("社保生成月份")
...@@ -196,35 +188,35 @@ public class TPaymentInfoBatchVo { ...@@ -196,35 +188,35 @@ public class TPaymentInfoBatchVo {
/** /**
* 单位养老基数 * 单位养老基数
*/ */
@ExcelAttribute(name = "单位养老基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "单位养老基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位养老基数") @ExcelProperty("单位养老基数")
private BigDecimal unitPensionSet; private BigDecimal unitPensionSet;
/** /**
* 单位医疗基数 * 单位医疗基数
*/ */
@ExcelAttribute(name = "单位医疗基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "单位医疗基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位医疗基数") @ExcelProperty("单位医疗基数")
private BigDecimal unitMedicalSet; private BigDecimal unitMedicalSet;
/** /**
* 单位失业基数 * 单位失业基数
*/ */
@ExcelAttribute(name = "单位失业基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "单位失业基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位失业基数") @ExcelProperty("单位失业基数")
private BigDecimal unitUnemploymentSet; private BigDecimal unitUnemploymentSet;
/** /**
* 工伤基数 * 工伤基数
*/ */
@ExcelAttribute(name = "工伤基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "工伤基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("工伤基数") @ExcelProperty("工伤基数")
private BigDecimal unitInjurySet; private BigDecimal unitInjurySet;
/** /**
* 生育基数 * 生育基数
*/ */
@ExcelAttribute(name = "生育基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "生育基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("生育基数") @ExcelProperty("生育基数")
private BigDecimal unitBirthSet; private BigDecimal unitBirthSet;
...@@ -372,8 +364,7 @@ public class TPaymentInfoBatchVo { ...@@ -372,8 +364,7 @@ public class TPaymentInfoBatchVo {
/** /**
* 公积金缴纳月份 * 公积金缴纳月份
*/ */
@ExcelAttribute(name = "公积金缴纳月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "公积金缴纳月份")
@Length(max = 6, message = "公积金缴纳月份不能超过6个字符")
@Schema(description ="公积金缴纳月份") @Schema(description ="公积金缴纳月份")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公积金缴纳月份") @ExcelProperty("公积金缴纳月份")
...@@ -382,8 +373,7 @@ public class TPaymentInfoBatchVo { ...@@ -382,8 +373,7 @@ public class TPaymentInfoBatchVo {
/** /**
* 公积金生成月份 * 公积金生成月份
*/ */
@ExcelAttribute(name = "公积金生成月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "公积金生成月份")
@Length(max = 6, message = "公积金生成月份不能超过6个字符")
@Schema(description ="公积金生成月份") @Schema(description ="公积金生成月份")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公积金生成月份") @ExcelProperty("公积金生成月份")
...@@ -410,15 +400,14 @@ public class TPaymentInfoBatchVo { ...@@ -410,15 +400,14 @@ public class TPaymentInfoBatchVo {
/** /**
* 公积金编号 * 公积金编号
*/ */
@ExcelAttribute(name = "公积金编号", maxLength = 20) @ExcelAttribute(name = "公积金编号")
@Size(max = 20, message = "公积金编号不可超过20位")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公积金编号") @ExcelProperty("公积金编号")
private String providentNo; private String providentNo;
/** /**
* 单位公积金基数 * 单位公积金基数
*/ */
@ExcelAttribute(name = "单位公积金基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "单位公积金基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位公积金基数") @ExcelProperty("单位公积金基数")
private BigDecimal unitProvidentSet; private BigDecimal unitProvidentSet;
...@@ -439,7 +428,7 @@ public class TPaymentInfoBatchVo { ...@@ -439,7 +428,7 @@ public class TPaymentInfoBatchVo {
/** /**
* 个人公积金基数 * 个人公积金基数
*/ */
@ExcelAttribute(name = "个人公积金基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "个人公积金基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("个人公积金基数") @ExcelProperty("个人公积金基数")
private BigDecimal personalProidentSet; private BigDecimal personalProidentSet;
......
...@@ -22,9 +22,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute; ...@@ -22,9 +22,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex; import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -43,7 +41,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -43,7 +41,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
@Schema(description ="员工姓名") @Schema(description ="员工姓名")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("员工姓名") @ExcelProperty("员工姓名")
@Size(max = 20, message = "员工姓名不可超过20位")
private String empName; private String empName;
/** /**
...@@ -53,7 +50,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -53,7 +50,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
@Schema(description ="员工编码") @Schema(description ="员工编码")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("员工编码") @ExcelProperty("员工编码")
@Size(max = 32, message = "员工编码不可超过32位")
private String empNo; private String empNo;
/** /**
...@@ -63,7 +59,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -63,7 +59,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
@Schema(description ="身份证号") @Schema(description ="身份证号")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("身份证号") @ExcelProperty("身份证号")
@Size(max = 32, message = "身份证号不可超过32位")
private String empIdcard; private String empIdcard;
/** /**
...@@ -87,7 +82,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -87,7 +82,6 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 项目编码 * 项目编码
*/ */
@Length(max = 50, message = "项目编码不能超过50个字符" )
@ExcelAttribute(name = "项目编码", maxLength = 50) @ExcelAttribute(name = "项目编码", maxLength = 50)
@Schema(description = "项目编码" ) @Schema(description = "项目编码" )
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
...@@ -124,9 +118,8 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -124,9 +118,8 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 社保缴纳月份 * 社保缴纳月份
*/ */
@ExcelAttribute(name = "社保缴纳月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "社保缴纳月份")
@Schema(description ="社保缴纳月份") @Schema(description ="社保缴纳月份")
@Length(max = 6, message = "社保缴纳月份不能超过6个字符")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("社保缴纳月份") @ExcelProperty("社保缴纳月份")
private String socialPayMonth; private String socialPayMonth;
...@@ -134,8 +127,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -134,8 +127,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 社保生成月份 * 社保生成月份
*/ */
@ExcelAttribute(name = "社保生成月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "社保生成月份")
@Length(max = 6, message = "社保生成月份不能超过6个字符")
@Schema(description ="社保生成月份") @Schema(description ="社保生成月份")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("社保生成月份") @ExcelProperty("社保生成月份")
...@@ -153,8 +145,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -153,8 +145,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 公积金缴纳月份 * 公积金缴纳月份
*/ */
@ExcelAttribute(name = "公积金缴纳月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "公积金缴纳月份")
@Length(max = 6, message = "公积金缴纳月份不能超过6个字符")
@Schema(description ="公积金缴纳月份") @Schema(description ="公积金缴纳月份")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公积金缴纳月份") @ExcelProperty("公积金缴纳月份")
...@@ -163,8 +154,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -163,8 +154,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 公积金生成月份 * 公积金生成月份
*/ */
@ExcelAttribute(name = "公积金生成月份", maxLength = 6,isInteger = true) @ExcelAttribute(name = "公积金生成月份")
@Length(max = 6, message = "公积金生成月份不能超过6个字符")
@Schema(description ="公积金生成月份") @Schema(description ="公积金生成月份")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公积金生成月份") @ExcelProperty("公积金生成月份")
...@@ -250,35 +240,35 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -250,35 +240,35 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 单位养老基数 * 单位养老基数
*/ */
@ExcelAttribute(name = "养老基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "养老基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("养老基数") @ExcelProperty("养老基数")
private BigDecimal unitPensionSet; private BigDecimal unitPensionSet;
/** /**
* 单位医疗基数 * 单位医疗基数
*/ */
@ExcelAttribute(name = "医疗基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "医疗基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("医疗基数") @ExcelProperty("医疗基数")
private BigDecimal unitMedicalSet; private BigDecimal unitMedicalSet;
/** /**
* 单位失业基数 * 单位失业基数
*/ */
@ExcelAttribute(name = "失业基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "失业基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("失业基数") @ExcelProperty("失业基数")
private BigDecimal unitUnemploymentSet; private BigDecimal unitUnemploymentSet;
/** /**
* 单位工伤基数 * 单位工伤基数
*/ */
@ExcelAttribute(name = "工伤基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "工伤基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("工伤基数") @ExcelProperty("工伤基数")
private BigDecimal unitInjurySet; private BigDecimal unitInjurySet;
/** /**
* 单位生育基数 * 单位生育基数
*/ */
@ExcelAttribute(name = "生育基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "生育基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("生育基数") @ExcelProperty("生育基数")
private BigDecimal unitBirthSet;; private BigDecimal unitBirthSet;;
...@@ -355,15 +345,14 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -355,15 +345,14 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 公积金编号 * 公积金编号
*/ */
@ExcelAttribute(name = "公积金编号", maxLength = 20) @ExcelAttribute(name = "公积金编号")
@Size(max = 20, message = "公积金编号不可超过20位")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公积金编号") @ExcelProperty("公积金编号")
private String providentNo; private String providentNo;
/** /**
* 单位公积金基数 * 单位公积金基数
*/ */
@ExcelAttribute(name = "单位公积金基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "单位公积金基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位公积金基数") @ExcelProperty("单位公积金基数")
private BigDecimal unitProvidentSet; private BigDecimal unitProvidentSet;
...@@ -384,7 +373,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -384,7 +373,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 个人公积金基数 * 个人公积金基数
*/ */
@ExcelAttribute(name = "个人公积金基数", isFloat = true,max = "999999999.99") @ExcelAttribute(name = "个人公积金基数")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("个人公积金基数") @ExcelProperty("个人公积金基数")
private BigDecimal personalProidentSet; private BigDecimal personalProidentSet;
...@@ -399,7 +388,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -399,7 +388,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 社保创建人姓名 * 社保创建人姓名
*/ */
@ExcelAttribute(name = "社保创建人姓名", maxLength = 32) @ExcelAttribute(name = "社保创建人姓名")
@Schema(description = "社保创建人姓名") @Schema(description = "社保创建人姓名")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("社保创建人姓名") @ExcelProperty("社保创建人姓名")
...@@ -414,7 +403,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable { ...@@ -414,7 +403,7 @@ public class TPaymentInfoExportVo extends RowIndex implements Serializable {
/** /**
* 公积金创建人姓名 * 公积金创建人姓名
*/ */
@ExcelAttribute(name = "公积金创建人姓名", maxLength = 32) @ExcelAttribute(name = "公积金创建人姓名")
@Schema(description = "公积金创建人姓名") @Schema(description = "公积金创建人姓名")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公积金创建人姓名") @ExcelProperty("公积金创建人姓名")
......
...@@ -11,4 +11,5 @@ public class PaymentConstants { ...@@ -11,4 +11,5 @@ public class PaymentConstants {
public static final String UNEMPLOYEEMENT_RISK = "失业保险"; public static final String UNEMPLOYEEMENT_RISK = "失业保险";
public static final String INJURY_RISK = "工伤保险"; public static final String INJURY_RISK = "工伤保险";
public static final String MEDICAL = "医疗"; public static final String MEDICAL = "医疗";
public static final String EXPORT = "缴费库合并导出";
} }
...@@ -69,7 +69,6 @@ import org.springframework.stereotype.Service; ...@@ -69,7 +69,6 @@ import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
...@@ -166,19 +165,17 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -166,19 +165,17 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
//获取要导出的列表 //获取要导出的列表
List<TPaymentInfoBatchVo> list = new ArrayList<>(); List<TPaymentInfoBatchVo> list = new ArrayList<>();
Integer count = baseMapper.selectCountTPaymentInfo(searchVo); Integer count = baseMapper.selectCountTPaymentInfo(searchVo);
ServletOutputStream out = null; try (ServletOutputStream out = response.getOutputStream()){
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA); response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8")); response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, TPaymentInfoBatchVo.class).includeColumnFiledNames(searchVo.getExportFields()).build(); ExcelWriter excelWriter = EasyExcel.write(out, TPaymentInfoBatchVo.class).includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT) { if (count > CommonConstants.ZERO_INT) {
WriteSheet writeSheet; WriteSheet writeSheet;
ExcelUtil<TPaymentInfoBatchVo> util; ExcelUtil<TPaymentInfoBatchVo> util;
for (int i = 0; i <= count; ) { for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
...@@ -194,7 +191,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -194,7 +191,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
} }
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
...@@ -206,18 +202,9 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -206,18 +202,9 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
out.flush();
excelWriter.finish(); excelWriter.finish();
} catch (Exception e) { } catch (Exception e) {
log.error("执行异常", e); log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
} }
} }
...@@ -229,23 +216,21 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -229,23 +216,21 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
*/ */
@Override @Override
public void listSumExport(HttpServletResponse response, TPaymentInfoSearchVo searchVo) { public void listSumExport(HttpServletResponse response, TPaymentInfoSearchVo searchVo) {
String fileName = "缴费库合并导出" + DateUtil.getThisTime() + CommonConstants.XLSX; String fileName = PaymentConstants.EXPORT + DateUtil.getThisTime() + CommonConstants.XLSX;
//获取要导出的列表 //获取要导出的列表
List<TPaymentInfoExportVo> list = new ArrayList<>(); List<TPaymentInfoExportVo> list = new ArrayList<>();
Integer count = baseMapper.selectCountSumPaymentInfo(searchVo); Integer count = baseMapper.selectCountSumPaymentInfo(searchVo);
ServletOutputStream out = null; try (ServletOutputStream out = response.getOutputStream()){
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA); response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8")); response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, TPaymentInfoExportVo.class).includeColumnFiledNames(searchVo.getExportFields()).build(); ExcelWriter excelWriter = EasyExcel.write(out, TPaymentInfoExportVo.class).includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT) { if (count > CommonConstants.ZERO_INT) {
WriteSheet writeSheet; WriteSheet writeSheet;
ExcelUtil<TPaymentInfoExportVo> util; ExcelUtil<TPaymentInfoExportVo> util;
for (int i = 0; i <= count; ) { for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
...@@ -257,34 +242,24 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -257,34 +242,24 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} }
} }
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
writeSheet = EasyExcel.writerSheet("缴费库合并导出" + index).build(); writeSheet = EasyExcel.writerSheet(PaymentConstants.EXPORT + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
} }
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
} }
} else { } else {
WriteSheet writeSheet = EasyExcel.writerSheet("缴费库合并导出" + index).build(); WriteSheet writeSheet = EasyExcel.writerSheet(PaymentConstants.EXPORT + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
} }
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
out.flush();
excelWriter.finish(); excelWriter.finish();
} catch (Exception e) { } catch (Exception e) {
log.error("执行异常", e); log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
} }
} }
......
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