| | |
| | | |
| | | @GetMapping("/download/overFloodInfo") |
| | | public ResponseEntity overFloodInfo(String isShow) throws Exception{ |
| | | String time = new SimpleDateFormat("yyyy-MM-dd HH").format(new Date()); |
| | | String fileName = time+ "时报汛文件.docx"; |
| | | String time = new SimpleDateFormat("yyyy日MM月dd日HH时").format(new Date()); |
| | | String fileName = time+ "报汛文件.docx"; |
| | | String fileNameURL = URLEncoder.encode(fileName, "UTF-8"); |
| | | //获取总览、大中库、明细数据 |
| | | List<TotalInfo> totalList = sjztmdService.getTotalInfo(isShow); |
| | |
| | | // 将临时文件添加到响应中,以便用户下载 |
| | | return ResponseEntity.ok() |
| | | .contentType(MediaType.valueOf("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) // 设置响应的内容类型为二进制流(octet stream) |
| | | .header("Content-Disposition", "attachment; filename=\"" + fileNameURL) // 设置响应的Content-Disposition头,以便浏览器提示用户下载文件 |
| | | .header("Content-Disposition", "attachment; filename=" + fileNameURL) // 设置响应的Content-Disposition头,以便浏览器提示用户下载文件 |
| | | .body(resource); // 将InputStreamResource对象作为响应体 |
| | | } |
| | | |