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