Commit 87b0cc46 authored by 高宇's avatar 高宇

1.导出的性能

parent 347d9eb4
......@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation;
import org.rcisoft.bus.jnsp7xtm.dao.Jnsp7xtmRepository;
import org.rcisoft.bus.jnsp7xtm.entity.*;
import org.rcisoft.bus.jnsp7xtm.service.Jnsp7xtmDtoService;
import org.rcisoft.bus.jnsp7xtm.service.impl.ExportExcelService;
import org.rcisoft.bus.jnsp7xtm.vo.QueryJnsp7xtmDto;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.exception.CyServiceException;
......@@ -47,6 +48,9 @@ public class Jnsp7xtmController extends CyPaginationController<Map> {
@Autowired
private Jnsp7xtmDtoService jnsp7xtmDtoService;
@Autowired
private ExportExcelService exportExcelService;
// 导出用户信息
@CyOpeLogAnno(title = "system-Jnsp7xtm管理-导出用户信息", businessType = CyLogTypeEnum.EXPORT)
@ApiOperation(value = "导出用户信息", notes = "导出用户信息")
......@@ -64,8 +68,7 @@ public class Jnsp7xtmController extends CyPaginationController<Map> {
excelName = "Jnsp7xtm信息.csv";
break;
}
List<RoleDto> all = jnsp7xtmDtoService.findAll(jnsp7xtm);
ExportToExcelUtil.exportExcel(all, "明细信息", "明细信息", RoleDto.class, excelName, response);
exportExcelService.outJnsp7xtmDetail(response,jnsp7xtm,excelName);
}
// 导出详细信息
......@@ -85,8 +88,7 @@ public class Jnsp7xtmController extends CyPaginationController<Map> {
excelName = "Jnsp7xtm信息.csv";
break;
}
List<RoleDto> information = jnsp7xtmServiceImpl.getInAllformation(requestInfromationDto);
ExportToExcelUtil.exportExcel(information, "明细信息", "明细信息", RoleDto.class, excelName, response);
exportExcelService.outUserJnsp7xtmDetail(response,requestInfromationDto,excelName);
}
// 导出明细信息
......@@ -106,9 +108,7 @@ public class Jnsp7xtmController extends CyPaginationController<Map> {
excelName = "Jnsp7xtm信息.csv";
break;
}
List<RoleDto> all = jnsp7xtmDtoService.findAll(jnsp7xtm);
ExportToExcelUtil.exportExcel(all, "明细信息", "明细信息", RoleDto.class, excelName, response);
// CyEpExcelUtil.exportExcel(all, "明细信息", "明细信息", RoleDto.class, excelName, response);
exportExcelService.outJnsp7xtmDetail(response,jnsp7xtm,excelName);
}
// 导出统计
......
......@@ -15,7 +15,13 @@ import java.util.List;
public interface Jnsp7xtmDtoRepository extends CyBaseMapper<Jnsp7xtmDto> {
// 分页查询用户详情信息
IPage<Jnsp7xtmDto> queryJnsp7xtmDtoByPaged(CyPageInfo cyPageInfo,@Param("entity") QueryJnsp7xtmDto queryJnsp7xtmDto);
IPage<Jnsp7xtmDto> queryJnsp7xtmDtoByPaged(CyPageInfo cyPageInfo, @Param("entity") QueryJnsp7xtmDto queryJnsp7xtmDto);
List<RoleDto> findAllList(@Param("entity") QueryJnsp7xtmDto queryJnsp7xtmDto);
// 分页查询用户信息
IPage<RoleDto> queryFindAllList(IPage<RoleDto> page, @Param("entity") QueryJnsp7xtmDto queryJnsp7xtmDto);
// 获取查询的总长度
Integer queryTotal(@Param("entity") QueryJnsp7xtmDto queryJnsp7xtmDto);
}
package org.rcisoft.bus.jnsp7xtm.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.rcisoft.bus.jnsp7xtm.entity.*;
import org.rcisoft.bus.jnsp7xtm.vo.StatisticsDto;
......@@ -94,6 +95,12 @@ public interface Jnsp7xtmRepository extends CyBaseMapper<Map> {
// 与上个方法一样 只是不分页
List<RoleDto> getAllInformation(@Param("entity") RequestInfromationDto requestInfromationDto);
// 查询详情中总数
Integer queryTotal(@Param("entity") RequestInfromationDto requestInfromationDto);
// 分页查询jnsp7xtm详情信息
IPage<RoleDto> pagingQueryAllInformation(IPage<RoleDto> page,@Param("entity") RequestInfromationDto requestInfromationDto );
// 查询用户的个数
String getClickInformationPageNum(@Param("entity") RequestInfromationDto requestInfromationDto);
......
package org.rcisoft.bus.jnsp7xtm.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.rcisoft.bus.jnsp7xtm.entity.*;
import org.rcisoft.bus.jnsp7xtm.vo.ReturntTotalDto;
......
package org.rcisoft.bus.jnsp7xtm.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.rcisoft.bus.jnsp7xtm.dao.Jnsp7xtmDtoRepository;
import org.rcisoft.bus.jnsp7xtm.dao.Jnsp7xtmRepository;
import org.rcisoft.bus.jnsp7xtm.entity.ExportTotalDto;
import org.rcisoft.bus.jnsp7xtm.entity.RequestInfromationDto;
import org.rcisoft.bus.jnsp7xtm.entity.RoleDto;
import org.rcisoft.bus.jnsp7xtm.vo.QueryJnsp7xtmDto;
import org.rcisoft.util.ExcelExportStatisticStyler;
import org.rcisoft.util.ExportToExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @Author: gy
* @Date: 2024/4/29 13:10
* @Description: 导出service 层
*/
@Service
@Slf4j
public class ExportExcelService {
@Autowired
private Jnsp7xtmDtoRepository jnsp7xtmDtoRepository;
@Autowired
private Jnsp7xtmRepository jnsp7xtmRepository;
// 获取每次写入excel的长度
@Value("${export.size}")
private Integer size;
// 导出明细
public void outJnsp7xtmDetail(HttpServletResponse response, QueryJnsp7xtmDto jnsp7xtm,String excelName) {
// 获取数组总长度
Integer total = jnsp7xtmDtoRepository.queryTotal(jnsp7xtm);
if (total > 0) {
// 获取有几页
Integer pageNumber = 1;
if (total >= size) {
pageNumber = total/size;
}
// 获取exportParams
ExportParams exportParams = new ExportParams();
exportParams.setStyle(ExcelExportStatisticStyler.class);
String[] format = excelName.split("\\.");
if (format[1].equals("xlsx")) {
exportParams.setType(ExcelType.XSSF);
}
Workbook workbook = bigExcel(pageNumber, exportParams, null, jnsp7xtm);
ExcelExportUtil.closeExportBigExcel();
ExportToExcelUtil.downLoadExcel(excelName,response,workbook);
} else {
IPage<RoleDto> page = new Page<>(1,size);
IPage<RoleDto> dtoIPage = jnsp7xtmDtoRepository.queryFindAllList(page, jnsp7xtm);
List<RoleDto> records = dtoIPage.getRecords();
ExportToExcelUtil.exportExcel(records, "明细信息", "明细信息", RoleDto.class, excelName, response);
}
}
public Workbook bigExcel(Integer pageNumber,ExportParams exportParams, Workbook workbook,QueryJnsp7xtmDto jnsp7xtm) {
for (int i = 1; i <= pageNumber; i++) {
IPage<RoleDto> page = new Page<>(i,size);
IPage<RoleDto> dtoIPage = jnsp7xtmDtoRepository.queryFindAllList(page, jnsp7xtm);
List<RoleDto> records = dtoIPage.getRecords();
workbook = ExcelExportUtil.exportBigExcel(exportParams, RoleDto.class, records);
}
return workbook;
}
public void outUserJnsp7xtmDetail(HttpServletResponse response,RequestInfromationDto requestInfromationDto,String excelName) {
//设置查询值
String key = requestInfromationDto.getClickKey();
RequestInfromationDto.cleanAndBuild(requestInfromationDto, key);
Integer total = jnsp7xtmRepository.queryTotal(requestInfromationDto);
if (total > 0) {
Integer pageNumber = 1;
if (total >= size) {
pageNumber = total/size;
}
// 获取exportParams
ExportParams exportParams = new ExportParams();
exportParams.setStyle(ExcelExportStatisticStyler.class);
String[] format = excelName.split("\\.");
if (format[1].equals("xlsx")) {
exportParams.setType(ExcelType.XSSF);
}
Workbook workbook = jnsp7xtmBigExcel(pageNumber, exportParams, null, requestInfromationDto);
ExcelExportUtil.closeExportBigExcel();
ExportToExcelUtil.downLoadExcel(excelName,response,workbook);
} else {
IPage<RoleDto> page = new Page<>(1,size);
IPage<RoleDto> dtoIPage = jnsp7xtmRepository.pagingQueryAllInformation(page, requestInfromationDto);
List<RoleDto> records = dtoIPage.getRecords();
ExportToExcelUtil.exportExcel(records, "详细信息", "详细信息", RoleDto.class, excelName, response);
}
}
public Workbook jnsp7xtmBigExcel(Integer pageNumber,ExportParams exportParams, Workbook workbook,RequestInfromationDto requestInfromationDto){
for (int i = 1; i <= pageNumber; i++) {
IPage<RoleDto> page = new Page<>(i,size);
IPage<RoleDto> dtoIPage = jnsp7xtmRepository.pagingQueryAllInformation(page, requestInfromationDto);
List<RoleDto> records = dtoIPage.getRecords();
workbook = ExcelExportUtil.exportBigExcel(exportParams, RoleDto.class, records);
}
return workbook;
}
}
......@@ -44,7 +44,6 @@ public class ExportToExcelUtil extends CyEpExcelUtil {
}
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response) {
ExportParams exportParams = new ExportParams();
exportParams.setStyle(ExcelExportStatisticStyler.class);
......@@ -65,7 +64,7 @@ public class ExportToExcelUtil extends CyEpExcelUtil {
}
// 下载excel
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
public static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
ServletOutputStream outputStream = null;
try {
......
......@@ -293,6 +293,10 @@ knife4j:
username: zhangsan
password: 123456
export:
size: 10
login:
loginName: "00"
password: "admin321"
......
......@@ -251,4 +251,182 @@
</foreach>
</if>
</select>
<select id="queryFindAllList" resultMap="roleResultMap">
SELECT
zd,
nqy,
ddh,
khdm,
khm,
khqf,
mksqf,
jlpm,
xslj,
pn,
fzdm,
jypn,
bz,
xsjg,
fnq,
szzt,
zzc,
zzcg,
rmb,
chzsa,
chzsb,
ddjsr,
ddzdnq,
yydd,
L24
FROM
jnsp7xtm
where
1=1
<if test="entity.khdm != null and entity.khdm != ''">
and khdm = #{entity.khdm}
</if>
<if test="entity.myKhdm != null and entity.myKhdm != ''">
and khdm in
<foreach collection="entity.myKhdm.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.fnq != null and entity.fnq != ''">
and fnq in
<foreach collection="entity.fnq.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.szzt != null and entity.szzt != ''">
and szzt in
<foreach collection="entity.szzt.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.zd != null and entity.zd != ''">
and zd in
<foreach collection="entity.zd.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.jlpm != null and entity.jlpm != ''">
and jlpm in
<foreach collection="entity.jlpm.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.nqy != null and entity.nqy != ''">
and nqy in
<foreach collection="entity.nqy.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.khqf != null and entity.khqf != ''">
and khqf in
<foreach collection="entity.khqf.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.mksqf != null and entity.mksqf != ''">
and mksqf in
<foreach collection="entity.mksqf.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.ddh != null and entity.ddh != ''">
and ddh in
<foreach collection="entity.ddh.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.khm != null and entity.khm != ''">
and khm in
<foreach collection="entity.khm.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.pn != null and entity.pn != ''">
and pn in
<foreach collection="entity.pn.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
</select>
<select id="queryTotal" resultType="java.lang.Integer">
SELECT
count(*)
FROM
jnsp7xtm
where
1=1
<if test="entity.khdm != null and entity.khdm != ''">
and khdm = #{entity.khdm}
</if>
<if test="entity.myKhdm != null and entity.myKhdm != ''">
and khdm in
<foreach collection="entity.myKhdm.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.fnq != null and entity.fnq != ''">
and fnq in
<foreach collection="entity.fnq.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.szzt != null and entity.szzt != ''">
and szzt in
<foreach collection="entity.szzt.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.zd != null and entity.zd != ''">
and zd in
<foreach collection="entity.zd.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.jlpm != null and entity.jlpm != ''">
and jlpm in
<foreach collection="entity.jlpm.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.nqy != null and entity.nqy != ''">
and nqy in
<foreach collection="entity.nqy.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.khqf != null and entity.khqf != ''">
and khqf in
<foreach collection="entity.khqf.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.mksqf != null and entity.mksqf != ''">
and mksqf in
<foreach collection="entity.mksqf.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.ddh != null and entity.ddh != ''">
and ddh in
<foreach collection="entity.ddh.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.khm != null and entity.khm != ''">
and khm in
<foreach collection="entity.khm.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
<if test="entity.pn != null and entity.pn != ''">
and pn in
<foreach collection="entity.pn.split(',')" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
......@@ -2401,4 +2401,147 @@
AS PivotTable
ORDER BY khdm,khm
</select>
<select id="pagingQueryAllInformation" resultMap="roleResultMap">
SELECT *
FROM jnsp7xtm d
WHERE khdm = #{entity.clickKhdm}
<if test="entity.nqy != null and entity.nqy.size() != 0">
and nqy in
<foreach item="item" index="index" collection="entity.nqy" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.khdm != null and entity.khdm.size() != 0">
and khdm in
<foreach item="item" index="index" collection="entity.khdm" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.mksqf != null and entity.mksqf.size() != 0">
and mksqf in
<foreach item="item" index="index" collection="entity.mksqf" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.khqf != null and entity.khqf.size() != 0">
and khqf in
<foreach item="item" index="index" collection="entity.khqf" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.ddh != null and entity.ddh.size() != 0">
and ddh in
<foreach item="item" index="index" collection="entity.ddh" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.khm != null and entity.khm.size() != 0">
and khm in
<foreach item="item" index="index" collection="entity.khm" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.pn != null and entity.pn.size() != 0">
and pn in
<foreach item="item" index="index" collection="entity.pn" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.jlpm != null and entity.jlpm.size() != 0">
and jlpm in
<foreach item="item" index="index" collection="entity.jlpm" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.zd != null and entity.zd.size() != 0 ">
and zd in
<foreach item="item" index="index" collection="entity.zd" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.fnq != null and entity.fnq.size() != 0 ">
and fnq in
<foreach item="item" index="index" collection="entity.fnq" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.mySzzt != null and entity.mySzzt.size() != 0 ">
and szzt in
<foreach item="item" index="index" collection="entity.mySzzt" open="(" separator="," close=")">
#{item}
</foreach>
</if>
ORDER BY nqy
</select>
<select id="queryTotal" resultType="java.lang.Integer">
SELECT count(*)
FROM jnsp7xtm d
WHERE khdm = #{entity.clickKhdm}
<if test="entity.nqy != null and entity.nqy.size() != 0">
and nqy in
<foreach item="item" index="index" collection="entity.nqy" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.khdm != null and entity.khdm.size() != 0">
and khdm in
<foreach item="item" index="index" collection="entity.khdm" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.mksqf != null and entity.mksqf.size() != 0">
and mksqf in
<foreach item="item" index="index" collection="entity.mksqf" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.khqf != null and entity.khqf.size() != 0">
and khqf in
<foreach item="item" index="index" collection="entity.khqf" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.ddh != null and entity.ddh.size() != 0">
and ddh in
<foreach item="item" index="index" collection="entity.ddh" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.khm != null and entity.khm.size() != 0">
and khm in
<foreach item="item" index="index" collection="entity.khm" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.pn != null and entity.pn.size() != 0">
and pn in
<foreach item="item" index="index" collection="entity.pn" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.jlpm != null and entity.jlpm.size() != 0">
and jlpm in
<foreach item="item" index="index" collection="entity.jlpm" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.zd != null and entity.zd.size() != 0 ">
and zd in
<foreach item="item" index="index" collection="entity.zd" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.fnq != null and entity.fnq.size() != 0 ">
and fnq in
<foreach item="item" index="index" collection="entity.fnq" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entity.mySzzt != null and entity.mySzzt.size() != 0 ">
and szzt in
<foreach item="item" index="index" collection="entity.mySzzt" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</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