Commit 539856ec authored by huyuchen's avatar huyuchen

导出优化

parent 7c05ea48
......@@ -21,6 +21,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* 申报对象表
......@@ -55,4 +56,10 @@ public class TStatisticsDeclarerSearchVo extends TStatisticsDeclarer {
@Schema(description = "查询limit 数据条数")
private int limitEnd;
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID")
private List<String> idList;
}
......@@ -54,4 +54,12 @@ public interface TStatisticsDeclarerMapper extends BaseMapper<TStatisticsDeclare
* @return:
**/
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);
}
......@@ -93,23 +93,20 @@ public class TStatisticsDeclarerServiceImpl extends ServiceImpl<TStatisticsDecla
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,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, TStatisticsDeclarer.class).build();
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("预估费用").doWrite(list)
ExcelWriter excelWriter = EasyExcel.write(out, TStatisticsDeclarer.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
WriteSheet writeSheet;
ExcelUtil<TStatisticsDeclarer> util;
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
if (Common.isNotNull(searchVo.getIds())) {
searchVo.setIdList(Common.getList(searchVo.getIds()));
}
list = noPageDiy(searchVo);
if (Common.isNotNull(list)){
util = new ExcelUtil<>(TStatisticsDeclarer.class);
for (TStatisticsDeclarer vo:list){
util.convertEntity(vo,null,null,null);
}
}
if (Common.isNotNull(list)){
writeSheet = EasyExcel.writerSheet("申报对象表"+index).build();
excelWriter.write(list,writeSheet);
......@@ -142,19 +139,10 @@ public class TStatisticsDeclarerServiceImpl extends ServiceImpl<TStatisticsDecla
}
}
@Override
public List<TStatisticsDeclarer> noPageDiy(TStatisticsDeclarerSearchVo searchVo) {
LambdaQueryWrapper<TStatisticsDeclarer> wrapper = buildQueryWrapper(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
public List<TStatisticsDeclarer> noPageDiy(TStatisticsDeclarerSearchVo searchVo) {
return baseMapper.exportDeclarer(searchVo);
}
@Override
public R updateFlagById(String id, String isDeclare, String undeclareReason) {
......
......@@ -87,6 +87,35 @@
</if>
</if>
</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简单分页查询-->
<select id="getTStatisticsDeclarerPage" resultMap="tStatisticsDeclarerMap">
SELECT
......@@ -99,6 +128,35 @@
order by a.DECLARE_MONTH desc
</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
......
......@@ -17,7 +17,7 @@
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
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.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -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.vo.TSettleDomainListVo;
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.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
......@@ -119,24 +120,26 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("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,然后文件流会自动关闭
//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;
if (count > CommonConstants.ZERO_INT) {
WriteSheet writeSheet;
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = exportLibrary(searchVo);
if (Common.isNotNull(list)) {
ExcelUtil<TForecastLibraryExportVo> util = new ExcelUtil<>(TForecastLibraryExportVo.class);
for (TForecastLibraryExportVo vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcelFactory.writerSheet("预估费用" + index).build();
writeSheet = EasyExcel.writerSheet("预估费用" + index).build();
excelWriter.write(list, writeSheet);
index++;
}
......@@ -145,7 +148,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
}
} else {
WriteSheet writeSheet = EasyExcelFactory.writerSheet("预估费用" + index).build();
WriteSheet writeSheet = EasyExcel.writerSheet("预估费用" + index).build();
excelWriter.write(list, writeSheet);
}
if (Common.isNotNull(list)) {
......
......@@ -545,12 +545,12 @@
a.PERSONAL_SOCIAL_SUM,
a.PERSONAL_FUND_SUM,
a.SUM_ALL,
a.FUND_PROVINCE,
a.FUND_CITY,
a.FUND_TOWN,
a.SOCIAL_PROVINCE,
a.SOCIAL_CITY,
a.SOCIAL_TOWN,
a1.AREA_NAME as "FUND_PROVINCE",
a2.AREA_NAME as "FUND_CITY",
a3.AREA_NAME as "FUND_TOWN",
a4.AREA_NAME as "SOCIAL_PROVINCE",
a5.AREA_NAME as "SOCIAL_CITY",
a6.AREA_NAME as "SOCIAL_TOWN",
a.UNIT_PENSION_BASE,
a.UNIT_MEDICAL_BASE,
a.UNIT_UNEMPLOYMENT_BASE,
......@@ -575,11 +575,21 @@
a.PERSONAL_FUND_BASE,
a.UNIT_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.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
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>
1=1
<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