diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml
index 7f1fb8e728..e516c5fba7 100644
--- a/epmet-commons/epmet-commons-tools/pom.xml
+++ b/epmet-commons/epmet-commons-tools/pom.xml
@@ -24,6 +24,7 @@
2.8.6
1.11.3
1.18.4
+ 3.0.3
@@ -177,6 +178,25 @@
javase
3.4.1
+
+ com.alibaba
+ easyexcel
+ ${easyexcel.version}
+
+
+ poi
+ org.apache.poi
+
+
+ poi-ooxml
+ org.apache.poi
+
+
+ poi-ooxml-schemas
+ org.apache.poi
+
+
+
diff --git a/epmet-module/data-report/data-report-server/pom.xml b/epmet-module/data-report/data-report-server/pom.xml
index 472525e5e7..cf8312e897 100644
--- a/epmet-module/data-report/data-report-server/pom.xml
+++ b/epmet-module/data-report/data-report-server/pom.xml
@@ -100,12 +100,6 @@
2.0.0
compile
-
- com.alibaba
- easyexcel
- 3.0.3
- compile
-
diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java
index b19a1d9caf..e9620dc5d2 100644
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java
+++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java
@@ -1,17 +1,17 @@
package com.epmet.dto.form;
+import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
-import java.io.Serializable;
/**
* @Description 核酸检测-我的上报记录
* @Author sun
*/
@Data
-public class MyNatListFormDTO implements Serializable {
+public class MyNatListFormDTO extends PageFormDTO {
private static final long serialVersionUID = 9156247659994638103L;
public interface MyNat extends CustomerClientShowGroup {
@@ -49,11 +49,6 @@ public class MyNatListFormDTO implements Serializable {
* 检测结束时间yyyy-MM-dd HH:mm间yy-mm-dd
*/
private String endTime;
- /**
- * 分页参数
- */
- private Integer pageNo = 1;
- private Integer pageSize = 10;
/**
* 核酸记录Id
@@ -61,7 +56,9 @@ public class MyNatListFormDTO implements Serializable {
@NotBlank(message = "核酸记录Id不能为空", groups = { Detail.class, Del.class, Synchro.class})
private String icNatId;
- //token信息
+ /**
+ * token里设置
+ */
private String customerId;
private String userId;
diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java
index d3cbead954..7a62c359a8 100644
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java
+++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java
@@ -1,12 +1,13 @@
package com.epmet.dto.result;
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
/**
* @Description 核酸检测-我的上报记录
@@ -16,61 +17,69 @@ import java.util.List;
public class NatListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
- //总条数
- private Integer total;
- List list = new ArrayList<>();
+ /**
+ * 核酸记录Id
+ */
+ @ExcelIgnore
+ private String icNatId;
+ /**
+ * 组织Id
+ */
+ @ExcelIgnore
+ private String agencyId;
+ /**
+ * 居民端小程序的用户id、数字社区的icResiUserId、其他情况无值
+ */
+ @ExcelIgnore
+ private String userId;
+ /**
+ * 居民端小程序的人:resi;数字社区的居民:icresi;未关联上的:other
+ */
+ @ExcelIgnore
+ private String userType;
- @Data
- public static class NatListDTO {
+ /**
+ * 姓名
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("姓名")
+ private String name;
- /**
- * 核酸记录Id
- */
- private String icNatId;
- /**
- * 组织Id
- */
- private String agencyId;
- /**
- * 居民端小程序的用户id、数字社区的icResiUserId、其他情况无值
- */
- private String userId;
- /**
- * 居民端小程序的人:resi;数字社区的居民:icresi;未关联上的:other
- */
- private String userType;
+ /**
+ * 手机号
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("手机号")
+ private String mobile;
- /**
- * 姓名
- */
- private String name;
+ /**
+ * 身份证号
+ */
+ @ColumnWidth(25)
+ @ExcelProperty("身份证号")
+ private String idCard;
- /**
- * 手机号
- */
- private String mobile;
+ /**
+ * 检测时间,yyyy-MM-dd HH:mm
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+ @ColumnWidth(25)
+ @ExcelProperty("检测时间")
+ private Date natTime;
- /**
- * 身份证号
- */
- private String idCard;
+ /**
+ * 检测结果
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("检测结果")
+ private String natResult;
- /**
- * 检测时间,yyyy-MM-dd HH:mm
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
- private Date natTime;
+ /**
+ * 检测地点
+ */
+ @ColumnWidth(30)
+ @ExcelProperty("检测地点")
+ private String natAddress;
- /**
- * 检测结果
- */
- private String natResult;
-
- /**
- * 检测地点
- */
- private String natAddress;
-
- }
}
diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml
index 0189ee8ce0..fb8ea8e9b4 100644
--- a/epmet-user/epmet-user-server/pom.xml
+++ b/epmet-user/epmet-user-server/pom.xml
@@ -18,25 +18,6 @@
epmet-admin-client
2.0.0
-
- com.alibaba
- easyexcel
- 3.0.3
-
-
- poi
- org.apache.poi
-
-
- poi-ooxml
- org.apache.poi
-
-
- poi-ooxml-schemas
- org.apache.poi
-
-
-
com.epmet
epmet-user-client
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java
index 35d3511196..a52e4e2a59 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java
@@ -1,8 +1,14 @@
package com.epmet.controller;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
+import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
+import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.IcNatDTO;
@@ -11,6 +17,8 @@ import com.epmet.dto.form.MyNatListFormDTO;
import com.epmet.dto.result.MyNatListResultDTO;
import com.epmet.dto.result.NatListResultDTO;
import com.epmet.service.IcNatService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
@@ -30,6 +38,7 @@ import java.util.List;
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-03-25
*/
+@Slf4j
@RestController
@RequestMapping("icNat")
public class IcNatController {
@@ -69,10 +78,10 @@ public class IcNatController {
**/
@NoRepeatSubmit
@PostMapping("natlist")
- public Result natList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) {
+ public Result> natList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) {
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setUserId(tokenDto.getUserId());
- return new Result().ok(icNucleinService.natList(formDTO));
+ return new Result>().ok(icNucleinService.natList(formDTO));
}
/**
@@ -148,5 +157,45 @@ public class IcNatController {
}
+ /**
+ * @Author sun
+ * @Description 【核酸】核酸检测信息列表
+ **/
+ @NoRepeatSubmit
+ @PostMapping("export")
+ public void export(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO, HttpServletResponse response) {
+ formDTO.setCustomerId(tokenDto.getCustomerId());
+ formDTO.setUserId(tokenDto.getUserId());
+
+ //formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc");
+ //formDTO.setUserId("73ae6280e46a6653a5605d51d5462725");
+
+ formDTO.setPage(false);
+
+ ExcelWriter excelWriter = null;
+ formDTO.setPageSize(NumConstant.TEN_THOUSAND);
+ int pageNo = formDTO.getPageNo();
+ try {
+ // 这里 需要指定写用哪个class去写
+ String fileName = "核酸检测信息.xlsx";
+ excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response),NatListResultDTO.class).build();
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
+ PageData data = null;
+ do {
+ data = icNucleinService.natList(formDTO);
+ formDTO.setPageNo(++pageNo);
+ excelWriter.write(data.getList(), writeSheet);
+ } while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size()==formDTO.getPageSize());
+
+ }catch (Exception e){
+ log.error("export exception", e);
+ }finally {
+ // 千万别忘记finish 会帮忙关闭流
+ if (excelWriter != null) {
+ excelWriter.finish();
+ }
+ }
+ }
+
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java
index 5ab06f865d..4ac7359f2e 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java
@@ -29,11 +29,11 @@ public interface IcNatDao extends BaseDao {
* @Author sun
* @Description 【核酸】核酸检测信息列表
**/
- List getNatList(MyNatListFormDTO formDTO);
+ List getNatList(MyNatListFormDTO formDTO);
/**
* @Author sun
* @Description 删除/取消同步操作--物理删除业务数据
**/
int delById(@Param("icNatId") String icNatId);
-}
\ No newline at end of file
+}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java
index 50bf30b6f8..736cb505df 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java
@@ -1,6 +1,7 @@
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
+import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcNatDTO;
import com.epmet.dto.form.AddIcNatFormDTO;
import com.epmet.dto.form.MyNatListFormDTO;
@@ -33,8 +34,9 @@ public interface IcNatService extends BaseService {
/**
* @Author sun
* @Description 【核酸】核酸检测信息列表
- **/
- NatListResultDTO natList(MyNatListFormDTO formDTO);
+ *
+ * @return*/
+ PageData natList(MyNatListFormDTO formDTO);
/**
* @Author sun
@@ -59,4 +61,4 @@ public interface IcNatService extends BaseService {
* @Description 【核酸】核酸检测信息同步
**/
void synchro(MyNatListFormDTO formDTO);
-}
\ No newline at end of file
+}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java
index f367748156..f022f10d9b 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java
@@ -6,6 +6,7 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
@@ -90,10 +91,10 @@ public class IcNatServiceImpl extends BaseServiceImpl imp
/**
* @Author sun
* @Description 【核酸】核酸检测信息列表
- **/
+ *
+ * @return*/
@Override
- public NatListResultDTO natList(MyNatListFormDTO formDTO) {
- NatListResultDTO resultDTO = new NatListResultDTO();
+ public PageData natList(MyNatListFormDTO formDTO) {
//1.根据orgType值判断是查询当前组织下还是整个客户下数据
if ("current".equals(formDTO.getOrgType())) {
//获取工作人员缓存信息
@@ -105,12 +106,9 @@ public class IcNatServiceImpl extends BaseServiceImpl imp
}
//2.按条件查询业务数据
- PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize())
+ PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.isPage())
.doSelectPageInfo(() -> baseDao.getNatList(formDTO));
- resultDTO.setTotal((int) data.getTotal());
- resultDTO.setList(data.getList());
-
- return resultDTO;
+ return new PageData(data.getList(),data.getTotal());
}
/**
@@ -215,4 +213,4 @@ public class IcNatServiceImpl extends BaseServiceImpl imp
insert(entity);
}
-}
\ No newline at end of file
+}
diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml
index f8b162ee5c..a16f593941 100644
--- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml
+++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml
@@ -25,7 +25,7 @@
ORDER BY nat_time DESC
-