From 385984d98e0891e166128eaff57b04c746ee8009 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 23 May 2022 13:37:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=AE=A1=E7=90=86-=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/IcEventListResultDTO.java | 8 ++ .../epmet/controller/IcEventController.java | 62 +++++++++ .../java/com/epmet/excel/IcEventExcel.java | 121 +++++------------- .../src/main/resources/mapper/IcEventDao.xml | 2 + 4 files changed, 105 insertions(+), 88 deletions(-) diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/IcEventListResultDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/IcEventListResultDTO.java index c4dd90f6be..19bb9b55df 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/IcEventListResultDTO.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/IcEventListResultDTO.java @@ -120,6 +120,10 @@ public class IcEventListResultDTO implements Serializable { * 0:已回复 1:已转项目 1:已转需求 */ private String operationType; + /** + * 0:已回复 1:已转项目 1:已转需求 + */ + private String operationTypeName; /** * 项目、需求ID */ @@ -179,6 +183,10 @@ public class IcEventListResultDTO implements Serializable { * 分类名称 */ private String categoryName; + /** + * 第一章图片url + */ + private String imageUrl; /** * 事件附件 diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/IcEventController.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/IcEventController.java index edca0f5cc2..62c48a83f4 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/IcEventController.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/IcEventController.java @@ -1,13 +1,22 @@ package com.epmet.controller; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.fastjson.JSON; 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.dto.form.PageFormDTO; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; @@ -17,11 +26,17 @@ import com.epmet.dto.IcEventDTO; import com.epmet.dto.IcEventReplyDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; +import com.epmet.excel.IcEventExcel; import com.epmet.service.IcEventReplyService; import com.epmet.service.IcEventService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -34,6 +49,7 @@ import java.util.List; */ @RestController @RequestMapping("icEvent") +@Slf4j public class IcEventController { @Autowired @@ -371,4 +387,50 @@ public class IcEventController { icEventService.resiReply(formDTO); return new Result(); } + + /** + * @Author sun + * @Description 数字平台-事件导出 + **/ + @PostMapping("export") + public void export(@RequestBody IcEventListFormDTO formDTO, HttpServletResponse response) throws IOException { + formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); + formDTO.setStaffId("d8dfc6c1fa2538976059f3900036d419"); + formDTO.setIsPage(false); + ExcelWriter excelWriter = null; + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + try { + String fileName = "事件管理" + DateUtils.format(new Date()) + ".xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcEventExcel.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + PageData data = null; + List list = null; + do { + data = icEventService.list(formDTO); + data.getList().forEach(d->{ + if(!org.springframework.util.CollectionUtils.isEmpty(d.getImageList())){ + d.setImageUrl(d.getImageList().get(NumConstant.ZERO)); + } + }); + list = ConvertUtils.sourceToTarget(data.getList(), IcEventExcel.class); + formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); + excelWriter.write(list, writeSheet); + } while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); + } catch (EpmetException e) { + response.reset(); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-type", "application/json; charset=UTF-8"); + PrintWriter printWriter = response.getWriter(); + Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),e.getMsg()); + printWriter.write(JSON.toJSONString(result)); + printWriter.close(); + } catch (Exception e) { + log.error("export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/IcEventExcel.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/IcEventExcel.java index fdf4ae9a0a..5bfc88d274 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/IcEventExcel.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/IcEventExcel.java @@ -1,6 +1,8 @@ package com.epmet.excel; -import cn.afterturn.easypoi.excel.annotation.Excel; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.format.DateTimeFormat; +import com.alibaba.excel.annotation.write.style.ColumnWidth; import lombok.Data; import java.util.Date; @@ -14,107 +16,50 @@ import java.util.Date; @Data public class IcEventExcel { - @Excel(name = "主键,事件id") - private String id; + @ExcelProperty(value = "所属网格") + @ColumnWidth(20) + private String gridName; - @Excel(name = "客户ID") - private String customerId; - - @Excel(name = "事件所属的网格Id") - private String gridId; - - @Excel(name = "网格的所属组织") - private String agencyId; - - @Excel(name = "网格的所有组织Id") - private String gridPids; - - @Excel(name = "报事的人【居民端/pc端居民Id】可为空") - private String reportUserId; - - @Excel(name = "报事人姓名") - private String name; - - @Excel(name = "手机号") - private String mobile; - - @Excel(name = "身份证号") - private String idCard; - - @Excel(name = "反映渠道【字典表】") - private String sourceType; - - @Excel(name = "事件内容") + @ExcelProperty(value = "事件内容") + @ColumnWidth(25) private String eventContent; - @Excel(name = "纬度") - private String latitude; + @ExcelProperty(value = "图片") + @ColumnWidth(25) + private String imageUrl; - @Excel(name = "经度") - private String longitude; + @ExcelProperty(value = "上报渠道") + @ColumnWidth(20) + private String sourceTypeName; - @Excel(name = "地址") + @ExcelProperty(value = "地址") + @ColumnWidth(25) private String address; - @Excel(name = "处理中:processing;已办结:closed_case") - private String status; - - @Excel(name = "办结时间") - private Date closeCaseTime; - - @Excel(name = "0:已回复 1:已转项目 1:已转需求") - private String operationType; - - @Excel(name = "项目、需求ID") - private String operationId; - - @Excel(name = "事件是否被阅读过;1已读;针对报事人待处理列表") - private Integer readFlag; - - @Excel(name = "报事人的红点:展示1;不展示:0;人大代表回复,工作人员回复/立项/转需求/办结更新为1; ") - private Integer redDot; - - @Excel(name = "最近一次操作时间(回复、立项、转需求、办结更新此列)") - private Date latestOperatedTime; - - @Excel(name = "是否解决:已解决 resolved,未解决 un_solved") - private String resolveStatus; - - @Excel(name = "结案说明") - private String closeRemark; + @ExcelProperty(value = "报事人") + @ColumnWidth(20) + private String name; - @Excel(name = "评论人") - private String commentUserId; + @ExcelProperty(value = "手机号") + @ColumnWidth(20) + private String mobile; - @Excel(name = "评论内容") + @ExcelProperty(value = "满意度") + @ColumnWidth(20) private String commentContent; - @Excel(name = "评论时间") - private Date commentTime; - - @Excel(name = "事件审核状态") - private String auditStatus; - - @Excel(name = "审核理由") - private String auditReason; - - @Excel(name = "删除标识:0.未删除 1.已删除") - private String delFlag; - - @Excel(name = "乐观锁") - private Integer revision; - - @Excel(name = "创建人") - private String createdBy; - - @Excel(name = "展示红点:visible;隐藏:invisible;人大回复、工作人员回复/立项更新为visible; 插入数据默认不展示") + @ExcelProperty(value = "上报时间") + @ColumnWidth(20) + @DateTimeFormat("yyyy-MM-dd HH:mm:ss") private Date createdTime; - @Excel(name = "更新人") - private String updatedBy; + @ExcelProperty(value = "结点") + @ColumnWidth(20) + private String operationTypeName; - @Excel(name = "更新时间") - private Date updatedTime; + @ExcelProperty(value = "状态") + @ColumnWidth(20) + private String statusName; } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml index d8958fd4a3..1e5f89095c 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml @@ -105,6 +105,7 @@ + @@ -156,6 +157,7 @@ ie.satisfaction, IF(ie.satisfaction = 'bad','不满意',IF (ie.satisfaction = 'good','基本满意',IF (ie.satisfaction = 'perfect','非常满意',''))) satisfactionName, ie.operation_type, + IF(ie.operation_type = '0','已回复',IF (ie.operation_type = '1','已转项目',IF (ie.operation_type = '2','已转需求',''))) operationTypeName, ie.operation_id, ie.read_flag, ie.red_dot,