Commit 539856ec authored by huyuchen's avatar huyuchen

导出优化

parent 7c05ea48
...@@ -21,6 +21,7 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -21,6 +21,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* 申报对象表 * 申报对象表
...@@ -55,4 +56,10 @@ public class TStatisticsDeclarerSearchVo extends TStatisticsDeclarer { ...@@ -55,4 +56,10 @@ public class TStatisticsDeclarerSearchVo extends TStatisticsDeclarer {
@Schema(description = "查询limit 数据条数") @Schema(description = "查询limit 数据条数")
private int limitEnd; private int limitEnd;
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID")
private List<String> idList;
} }
...@@ -54,4 +54,12 @@ public interface TStatisticsDeclarerMapper extends BaseMapper<TStatisticsDeclare ...@@ -54,4 +54,12 @@ public interface TStatisticsDeclarerMapper extends BaseMapper<TStatisticsDeclare
* @return: * @return:
**/ **/
List<TStatisticsDeclarer> doStatisticsTaxDeclarerYear(@Param("nowMonth") String nowMonth); List<TStatisticsDeclarer> doStatisticsTaxDeclarerYear(@Param("nowMonth") String nowMonth);
/**
* @Description: 导出
* @Author: huyc
* @Date: 2023/1/12 14:52
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.social.vo.TForecastLibraryVo>
**/
List<TStatisticsDeclarer> exportDeclarer(@Param("tStatisticsDeclarer") TStatisticsDeclarer tStatisticsDeclarer);
} }
...@@ -94,22 +94,19 @@ public class TStatisticsDeclarerServiceImpl extends ServiceImpl<TStatisticsDecla ...@@ -94,22 +94,19 @@ public class TStatisticsDeclarerServiceImpl extends ServiceImpl<TStatisticsDecla
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,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("预估费用").doWrite(list)
ExcelWriter excelWriter = EasyExcel.write(out, TStatisticsDeclarer.class).build(); ExcelWriter excelWriter = EasyExcel.write(out, TStatisticsDeclarer.class).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT){ if (count > CommonConstants.ZERO_INT){
WriteSheet writeSheet; WriteSheet writeSheet;
ExcelUtil<TStatisticsDeclarer> util;
for (int i = 0; i <= count; ) { for (int i = 0; i <= count; ) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo); if (Common.isNotNull(searchVo.getIds())) {
if (Common.isNotNull(list)){ searchVo.setIdList(Common.getList(searchVo.getIds()));
util = new ExcelUtil<>(TStatisticsDeclarer.class);
for (TStatisticsDeclarer vo:list){
util.convertEntity(vo,null,null,null);
}
} }
list = noPageDiy(searchVo);
if (Common.isNotNull(list)){ if (Common.isNotNull(list)){
writeSheet = EasyExcel.writerSheet("申报对象表"+index).build(); writeSheet = EasyExcel.writerSheet("申报对象表"+index).build();
excelWriter.write(list,writeSheet); excelWriter.write(list,writeSheet);
...@@ -144,16 +141,7 @@ public class TStatisticsDeclarerServiceImpl extends ServiceImpl<TStatisticsDecla ...@@ -144,16 +141,7 @@ public class TStatisticsDeclarerServiceImpl extends ServiceImpl<TStatisticsDecla
@Override @Override
public List<TStatisticsDeclarer> noPageDiy(TStatisticsDeclarerSearchVo searchVo) { public List<TStatisticsDeclarer> noPageDiy(TStatisticsDeclarerSearchVo searchVo) {
LambdaQueryWrapper<TStatisticsDeclarer> wrapper = buildQueryWrapper(searchVo); return baseMapper.exportDeclarer(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TStatisticsDeclarer::getId,idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0){
wrapper.last(" limit "+ searchVo.getLimitStart() +","+ searchVo.getLimitEnd());
}
return baseMapper.selectList(wrapper);
} }
@Override @Override
......
...@@ -87,6 +87,35 @@ ...@@ -87,6 +87,35 @@
</if> </if>
</if> </if>
</sql> </sql>
<sql id="tStatisticsDeclarer_export_where">
<if test="tStatisticsDeclarer != null">
<if test="tStatisticsDeclarer.idList != null">
AND a.ID in
<foreach item="idStr" index="index" collection="tStatisticsDeclarer.idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tStatisticsDeclarer.id != null and tStatisticsDeclarer.id.trim() != ''">
AND a.ID = #{tStatisticsDeclarer.id}
</if>
<if test="tStatisticsDeclarer.declareUnit != null and tStatisticsDeclarer.declareUnit.trim() != ''">
AND a.DECLARE_UNIT like concat(#{tStatisticsDeclarer.declareUnit},'%')
</if>
<if test="tStatisticsDeclarer.declareMonth != null and tStatisticsDeclarer.declareMonth.trim() != ''">
AND a.DECLARE_MONTH = #{tStatisticsDeclarer.declareMonth}
</if>
<if test="tStatisticsDeclarer.empName != null and tStatisticsDeclarer.empName.trim() != ''">
AND a.EMP_NAME = #{tStatisticsDeclarer.empName}
</if>
<if test="tStatisticsDeclarer.empIdcard != null and tStatisticsDeclarer.empIdcard.trim() != ''">
AND a.EMP_IDCARD = #{tStatisticsDeclarer.empIdcard}
</if>
<if test="tStatisticsDeclarer.isZeroDeclare != null and tStatisticsDeclarer.isZeroDeclare.trim() != ''">
AND a.IS_ZERO_DECLARE = #{tStatisticsDeclarer.isZeroDeclare}
</if>
</if>
</sql>
<!--tStatisticsDeclarer简单分页查询--> <!--tStatisticsDeclarer简单分页查询-->
<select id="getTStatisticsDeclarerPage" resultMap="tStatisticsDeclarerMap"> <select id="getTStatisticsDeclarerPage" resultMap="tStatisticsDeclarerMap">
SELECT SELECT
...@@ -99,6 +128,35 @@ ...@@ -99,6 +128,35 @@
order by a.DECLARE_MONTH desc order by a.DECLARE_MONTH desc
</select> </select>
<!--tStatisticsDeclarer简单分页查询-->
<select id="exportDeclarer" resultMap="tStatisticsDeclarerMap">
SELECT
a.DECLARE_UNIT,
a.DECLARE_MONTH,
a.EMP_NAME,
a.EMP_IDCARD,
a.EMP_PHONE,
CASE WHEN a.OCCUPATION_TYPE=0 THEN "雇员"
WHEN a.OCCUPATION_TYPE =1 THEN "其他"
ELSE a.OCCUPATION_TYPE END as "OCCUPATION_TYPE",
CASE WHEN a.IS_ZERO_DECLARE=0 THEN "是"
WHEN a.IS_ZERO_DECLARE =1 THEN "否"
ELSE a.IS_ZERO_DECLARE END as "IS_ZERO_DECLARE",
CASE WHEN a.IS_DECLARE=0 THEN "是"
WHEN a.IS_DECLARE =1 THEN "否"
ELSE a.IS_DECLARE END as "IS_DECLARE",
a.UNDECLARE_REASON
FROM t_statistics_declarer a
<where>
1=1
<include refid="tStatisticsDeclarer_export_where"/>
</where>
order by a.DECLARE_MONTH desc
<if test="tStatisticsDeclarer.limitStart != null">
limit #{tStatisticsDeclarer.limitStart},#{tStatisticsDeclarer.limitEnd}
</if>
</select>
<!--统计--> <!--统计-->
<select id="doStatisticsTaxDeclarer" resultMap="tStatisticsDeclarerMap"> <select id="doStatisticsTaxDeclarer" resultMap="tStatisticsDeclarerMap">
SELECT SELECT
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
package com.yifu.cloud.plus.v1.yifu.social.service.impl; package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcelFactory; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -28,6 +28,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -28,6 +28,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain; import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainListVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainListVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
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.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
...@@ -119,24 +120,26 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap ...@@ -119,24 +120,26 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
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"));
ExcelUtil<TForecastLibraryExportVo> util = new ExcelUtil<>(TForecastLibraryExportVo.class);
// 获取所有字典type
Map<String,String> nameAndDicTypeMap = util.getConverterDicType();
// 获取所有字典对应的值
Map<String,String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE);
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("预估费用").doWrite(list) //EasyExcel.write(out, TEmpBadRecord.class).sheet("预估费用").doWrite(list)
ExcelWriter excelWriter = EasyExcelFactory.write(out, TForecastLibraryExportVo.class).includeColumnFiledNames(searchVo.getExportFields()).build(); ExcelWriter excelWriter = EasyExcel.write(out, TForecastLibraryExportVo.class)
.registerConverter(new DictConverter(nameAndDicTypeMap,redisLabelMap))
.includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT) { if (count > CommonConstants.ZERO_INT) {
WriteSheet writeSheet;
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) { 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);
list = exportLibrary(searchVo); list = exportLibrary(searchVo);
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
ExcelUtil<TForecastLibraryExportVo> util = new ExcelUtil<>(TForecastLibraryExportVo.class); writeSheet = EasyExcel.writerSheet("预估费用" + index).build();
for (TForecastLibraryExportVo vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcelFactory.writerSheet("预估费用" + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
} }
...@@ -145,7 +148,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap ...@@ -145,7 +148,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
} }
} }
} else { } else {
WriteSheet writeSheet = EasyExcelFactory.writerSheet("预估费用" + index).build(); WriteSheet writeSheet = EasyExcel.writerSheet("预估费用" + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
} }
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
......
...@@ -545,12 +545,12 @@ ...@@ -545,12 +545,12 @@
a.PERSONAL_SOCIAL_SUM, a.PERSONAL_SOCIAL_SUM,
a.PERSONAL_FUND_SUM, a.PERSONAL_FUND_SUM,
a.SUM_ALL, a.SUM_ALL,
a.FUND_PROVINCE, a1.AREA_NAME as "FUND_PROVINCE",
a.FUND_CITY, a2.AREA_NAME as "FUND_CITY",
a.FUND_TOWN, a3.AREA_NAME as "FUND_TOWN",
a.SOCIAL_PROVINCE, a4.AREA_NAME as "SOCIAL_PROVINCE",
a.SOCIAL_CITY, a5.AREA_NAME as "SOCIAL_CITY",
a.SOCIAL_TOWN, a6.AREA_NAME as "SOCIAL_TOWN",
a.UNIT_PENSION_BASE, a.UNIT_PENSION_BASE,
a.UNIT_MEDICAL_BASE, a.UNIT_MEDICAL_BASE,
a.UNIT_UNEMPLOYMENT_BASE, a.UNIT_UNEMPLOYMENT_BASE,
...@@ -575,11 +575,21 @@ ...@@ -575,11 +575,21 @@
a.PERSONAL_FUND_BASE, a.PERSONAL_FUND_BASE,
a.UNIT_FUND_PROP, a.UNIT_FUND_PROP,
a.PERSONAL_FUND_PROP, a.PERSONAL_FUND_PROP,
a.DATA_PUSH, CASE WHEN a.DATA_PUSH=0 THEN "未同步"
WHEN a.DATA_PUSH =1 THEN "已同步"
ELSE a.DATA_PUSH END as "DATA_PUSH",
a.CREATE_TIME, a.CREATE_TIME,
a.DIFF_TYPE, a.DIFF_TYPE,
a.DATA_TYPE CASE WHEN a.DATA_TYPE=0 THEN "社保"
WHEN a.DATA_TYPE =1 THEN "公积金"
ELSE a.DATA_TYPE END as "DATA_TYPE"
from t_forecast_library a from t_forecast_library a
LEFT JOIN sys_area a1 on a1.id=a.FUND_PROVINCE
LEFT JOIN sys_area a2 on a2.id=a.FUND_CITY
LEFT JOIN sys_area a3 on a3.id=a.FUND_TOWN
LEFT JOIN sys_area a4 on a4.id=a.SOCIAL_PROVINCE
LEFT JOIN sys_area a5 on a5.id=a.SOCIAL_CITY
LEFT JOIN sys_area a6 on a6.id=a.SOCIAL_TOWN
<where> <where>
1=1 1=1
<include refid="tForecastLibrary_where"/> <include refid="tForecastLibrary_where"/>
......
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