From 7235ee0abd396fe0cf9182191b025751eacd743a Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Wed, 3 Jul 2024 15:16:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcPublishManageController.java | 17 +++++++++++-- .../controller/DcWarningController.java | 24 +++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java b/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java index b6c3b556..ac81413f 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java @@ -14,6 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -154,8 +157,18 @@ public class DcPublishManageController extends BaseController //@PreAuthorize("@ss.hasPermi('business:manage:export')") @Log(title = "信息发布管理记录", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response,@RequestBody DcPublishManage dcPublishManage) - { + public void export(HttpServletResponse response,@RequestBody DcPublishManage dcPublishManage) throws UnsupportedEncodingException { + String percentEncodedFileName= URLEncoder.encode("公众服务统计.xlsx", StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20"); + StringBuilder contentDispositionValue = new StringBuilder(); + contentDispositionValue.append("attachment; filename=") + .append(percentEncodedFileName) + .append(";") + .append("filename*=") + .append("utf-8''") + .append(percentEncodedFileName); + response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); + response.setHeader("Content-disposition", contentDispositionValue.toString()); + response.setHeader("download-filename", percentEncodedFileName); List list = dcPublishManageService.selectDcPublishManageExport(dcPublishManage); ExcelUtil util = new ExcelUtil<>(DcPublishManage.class); util.exportExcel(response, list, UniversalEnum.INFORMATION_RELEASE_MANAGEMENT_RECORD_DATA.getValue()); diff --git a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java index 250e1ed3..d5086948 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java @@ -22,6 +22,9 @@ import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; @@ -74,11 +77,28 @@ public class DcWarningController extends BaseController //@PreAuthorize("@ss.hasPermi('business:warning:export')") @Log(title = "预警信息", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response,@RequestBody DcWarning dcWarning) - { + public void export(HttpServletResponse response,@RequestBody DcWarning dcWarning) throws UnsupportedEncodingException { + String percentEncodedFileName=URLEncoder.encode("感知事件列表.xlsx", StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20"); + if (dcWarning!=null&&dcWarning.getWarningSource()!=null&&dcWarning.getWarningSource()==6){ + percentEncodedFileName = URLEncoder.encode("非机预警事件列表.xlsx", StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20"); + } + if (dcWarning!=null&&dcWarning.getWarningState()!=null&&dcWarning.getWarningState()==1){ + percentEncodedFileName = URLEncoder.encode("告警事件列表.xlsx", StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20"); + } + StringBuilder contentDispositionValue = new StringBuilder(); + contentDispositionValue.append("attachment; filename=") + .append(percentEncodedFileName) + .append(";") + .append("filename*=") + .append("utf-8''") + .append(percentEncodedFileName); + response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); + response.setHeader("Content-disposition", contentDispositionValue.toString()); + response.setHeader("download-filename", percentEncodedFileName); List list = dcWarningService.export(dcWarning); ExcelUtil util = new ExcelUtil<>(DcWarning.class); util.exportExcel(response, list, UniversalEnum.EARLY_WARNING_INFORMATION_DATA.getValue()); + }