增加数据导出功能

This commit is contained in:
liuyuan 2024-05-16 16:53:11 +08:00
parent 59ca6ccc9f
commit 00aad469b6
7 changed files with 188 additions and 5 deletions

10
pom.xml
View File

@ -146,11 +146,11 @@
<artifactId>mybatis-generator-core</artifactId> <artifactId>mybatis-generator-core</artifactId>
<version>1.3.6</version> <version>1.3.6</version>
</dependency> </dependency>
<!-- <dependency>--> <dependency>
<!-- <groupId>com.alibaba</groupId>--> <groupId>com.alibaba</groupId>
<!-- <artifactId>easyexcel</artifactId>--> <artifactId>easyexcel</artifactId>
<!-- <version>${easyexcel.version}</version>--> <version>${easyexcel.version}</version>
<!-- </dependency>--> </dependency>
<dependency> <dependency>
<groupId>commons-beanutils</groupId> <groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId> <artifactId>commons-beanutils</artifactId>

View File

@ -2,14 +2,21 @@ package com.szr.zdryztpg.controller;
import com.szr.common.model.BaseResponse; import com.szr.common.model.BaseResponse;
import com.szr.common.model.PageUtil; import com.szr.common.model.PageUtil;
import com.szr.zdryztpg.entity.ZdryJcjdztpgInfo;
import com.szr.zdryztpg.model.*; import com.szr.zdryztpg.model.*;
import com.szr.zdryztpg.service.ZdryJcjdztpgInfoService; import com.szr.zdryztpg.service.ZdryJcjdztpgInfoService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.alibaba.excel.EasyExcel;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
/** /**
* 重点人员监控检查质态评估 * 重点人员监控检查质态评估
@ -38,4 +45,24 @@ public class ZdryztpgController {
.build(); .build();
} }
@PostMapping("/dataExport")
@ApiOperation(value = "质态评估数据导出")
public void dataExport(@RequestBody ZtpgPageListDTO params, HttpServletResponse response) throws Exception {
List<ZdryJcjdztpgInfo> ztpgPageListVOS = zdryJcjdztpgInfoService.queryList(params);
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
//防止中文乱码
String fileName = generateFileName();
fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), ZdryztpgExportModel.class).autoCloseStream(Boolean.FALSE).sheet("警情巡查数据")
.doWrite(ztpgPageListVOS);
}
private String generateFileName() {
//自定义文件名
return "重点人员检查监督-质态评估" + DateFormatUtils.format(new Date(), "yyyyMMddhhmmssSSS");
}
} }

View File

@ -99,4 +99,6 @@ public interface ZdryJcjdztpgInfoMapper {
int countByParams(ZtpgPageListDTO params); int countByParams(ZtpgPageListDTO params);
List<ZdryJcjdztpgInfo> queryListByPage(ZtpgPageListDTO params); List<ZdryJcjdztpgInfo> queryListByPage(ZtpgPageListDTO params);
List<ZdryJcjdztpgInfo> queryList(ZtpgPageListDTO params);
} }

View File

@ -0,0 +1,107 @@
package com.szr.zdryztpg.model;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import java.util.Date;
/**
* @ClassName ZdryztpgExportModel
* @Description TODO
* @Author ly
* @Date 2024/05/15 16:41
* @Version 1.0
**/
public class ZdryztpgExportModel {
@ExcelIgnore
private Integer id;
@ExcelIgnore
private Date createTime;
@ExcelProperty(value = "人员类型" ,index = 0)
@ColumnWidth(12)
private String rylx;
@ExcelProperty(value = "身份号码" ,index = 1)
@ColumnWidth(12)
private String sfzhm;
@ExcelProperty(value = "姓名" ,index = 2)
private String ryxm;
@ExcelProperty(value = {"风险评估", "填写内容"} ,index = 3)
@ColumnWidth(12)
private String fxpgtxnr;
@ExcelProperty(value = {"风险评估", "检查结果"} ,index = 4)
@ColumnWidth(12)
private String fxpgjcjg;
@ExcelProperty(value = {"现实表现", "填写内容"} ,index = 5)
@ColumnWidth(12)
private String xsbxtxnr;
@ExcelProperty(value = {"现实表现", "检查结果"} ,index = 6)
@ColumnWidth(12)
private String xsbxjcjg;
@ExcelProperty(value = {"活动地", "填写内容"} ,index = 7)
@ColumnWidth(12)
private String hdztxnr;
@ExcelProperty(value = {"活动地", "检查结果"} ,index = 8)
@ColumnWidth(12)
private String hdzjcjg;
@ExcelProperty(value = {"在控情况", "填写内容"} ,index = 9)
@ColumnWidth(12)
private String zkqktxnr;
@ExcelProperty(value = {"在控情况", "检查结果"} ,index = 10)
@ColumnWidth(12)
private String zkqkjcjg;
@ExcelProperty(value = {"现实表现近三次情况", "填写内容"} ,index = 11)
@ColumnWidth(14)
private String jscqktxnr;
@ExcelProperty(value = {"现实表现近三次情况", "检查结果"} ,index = 12)
@ColumnWidth(14)
private String jscqkjcjg;
@ExcelProperty(value = {"是否见面&现实表现", "填写内容"} ,index = 13)
@ColumnWidth(12)
private String sfjmtxnr;
@ExcelProperty(value = {"是否见面&现实表现", "检查结果"} ,index = 14)
@ColumnWidth(12)
private String sfjmjcjg;
@ExcelProperty(value = {"现实表现&风险评估", "填写内容"} ,index = 15)
@ColumnWidth(12)
private String xsbxfxpgtxnr;
@ExcelProperty(value = {"现实表现&风险评估", "检查结果"} ,index = 16)
@ColumnWidth(12)
private String xsbxfxpgjcjg;
@ExcelProperty(value = "管控类型" ,index = 17)
@ColumnWidth(12)
private String gklx;
@ExcelProperty(value = {"附件", "附件名称"} ,index = 18)
@ColumnWidth(12)
private String fjmc;
@ExcelProperty(value = {"附件", "检查结果"} ,index = 19)
@ColumnWidth(12)
private String fjjcjg;
@ExcelProperty(value = "检查时间" ,index = 20)
@ColumnWidth(12)
private Date jcsj;
}

View File

@ -1,9 +1,12 @@
package com.szr.zdryztpg.service; package com.szr.zdryztpg.service;
import com.szr.common.model.PageUtil; import com.szr.common.model.PageUtil;
import com.szr.zdryztpg.entity.ZdryJcjdztpgInfo;
import com.szr.zdryztpg.model.ZtpgPageListDTO; import com.szr.zdryztpg.model.ZtpgPageListDTO;
import com.szr.zdryztpg.model.ZtpgPageListVO; import com.szr.zdryztpg.model.ZtpgPageListVO;
import java.util.List;
/** /**
* 重点人员质态评估 service * 重点人员质态评估 service
* *
@ -13,4 +16,6 @@ import com.szr.zdryztpg.model.ZtpgPageListVO;
public interface ZdryJcjdztpgInfoService { public interface ZdryJcjdztpgInfoService {
PageUtil<ZtpgPageListVO> queryPageList(ZtpgPageListDTO params); PageUtil<ZtpgPageListVO> queryPageList(ZtpgPageListDTO params);
List<ZdryJcjdztpgInfo> queryList(ZtpgPageListDTO params);
} }

View File

@ -41,4 +41,11 @@ public class ZdryJcjdztpgServiceImpl implements ZdryJcjdztpgInfoService {
return new PageUtil<>(counts, params.getPage(), params.getPageSize(), checkInfoPageListVOS); return new PageUtil<>(counts, params.getPage(), params.getPageSize(), checkInfoPageListVOS);
} }
@Override
@DataScope(mainAlias = "zji")
public List<ZdryJcjdztpgInfo> queryList(ZtpgPageListDTO params) {
List<ZdryJcjdztpgInfo> zdryJcjdztpgInfos = zdryJcjdztpgInfoMapper.queryList(params);
return zdryJcjdztpgInfos;
}
} }

View File

@ -639,4 +639,39 @@
</if> </if>
</where> </where>
</select> </select>
<select id="queryList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from zdry_jcjdztpg_info zji
<where>
<if test="keyWord!=null and keyWord!=''">
and (zji.ryxm like '%'||#{keyWord,jdbcType=VARCHAR}||'%' or
zji.sfzhm like '%'||#{keyWord,jdbcType=VARCHAR}||'%' or
zji.rylx like '%'||#{keyWord,jdbcType=VARCHAR}||'%' or
zji.gklx like '%'||#{keyWord,jdbcType=VARCHAR}||'%' or)
</if>
<if test="rylx!=null and rylx!=''">
and zji.rylx = #{rylx,jdbcType=VARCHAR}
</if>
<if test="sfzhm!=null and sfzhm!=''">
and zji.sfzhm = #{sfzhm,jdbcType=VARCHAR}
</if>
<if test="ryxm!=null and ryxm!=''">
and zji.ryxm = #{ryxm,jdbcType=VARCHAR}
</if>
<if test="gklx!=null and gklx!=''">
and zji.gklx = #{gklx,jdbcType=VARCHAR}
</if>
<if test="jckssj!=null and jckssj!=''">
and to_char(zji.jcsj,'yyyy-MM-dd HH:mm:ss') <![CDATA[>]]> #{jckssj,jdbcType=VARCHAR}
</if>
<if test="jcjssj!=null and jcjssj!=''">
and to_char(zji.jcsj,'yyyy-MM-dd HH:mm:ss') <![CDATA[<=]]> #{jcjssj,jdbcType=VARCHAR}
</if>
<if test="params!=null and params!=''">
${params.dataScope}
</if>
</where>
order by zji.jcsj desc
</select>
</mapper> </mapper>