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()); + }