Browse Source

导出优化

develop
wangsixiang 5 months ago
parent
commit
7235ee0abd
  1. 17
      zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java
  2. 24
      zc-business/src/main/java/com/zc/business/controller/DcWarningController.java

17
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<DcPublishManage> list = dcPublishManageService.selectDcPublishManageExport(dcPublishManage);
ExcelUtil<DcPublishManage> util = new ExcelUtil<>(DcPublishManage.class);
util.exportExcel(response, list, UniversalEnum.INFORMATION_RELEASE_MANAGEMENT_RECORD_DATA.getValue());

24
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<DcWarning> list = dcWarningService.export(dcWarning);
ExcelUtil<DcWarning> util = new ExcelUtil<>(DcWarning.class);
util.exportExcel(response, list, UniversalEnum.EARLY_WARNING_INFORMATION_DATA.getValue());
}

Loading…
Cancel
Save