Quellcode durchsuchen

优化下载zip

qitz vor 2 Jahren
Ursprung
Commit
743040d813

+ 28
- 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java Datei anzeigen

@@ -345,13 +345,39 @@ public class CaseApplicationController extends BaseController {
345 345
     /**
346 346
      * 下载案件压缩包
347 347
      */
348
-    @PostMapping("/downloadCaseZipFile")
349
-    public AjaxResult downloadCaseZipFile(@Validated @RequestBody CaseApplication caseApplication) {
348
+    @PostMapping("/downloadCaseZipFile1")
349
+    public AjaxResult downloadCaseZipFile1(@Validated @RequestBody CaseApplication caseApplication) {
350 350
 
351 351
         CaseAttach caseAttach = caseApplicationService.downloadCaseZipFile(caseApplication);
352 352
         return success(caseAttach);
353 353
     }
354 354
 
355
+    /**
356
+     * 下载案件压缩包
357
+     */
358
+    @PostMapping("/downloadCaseZipFile")
359
+    public void downloadCaseZipFile(@Validated @RequestBody CaseApplication caseApplication,HttpServletResponse response) {
360
+
361
+        CaseAttach caseAttach = caseApplicationService.downloadCaseZipFile(caseApplication);
362
+        String annexPath = caseAttach.getAnnexPath();
363
+        String annexName = caseAttach.getAnnexName();
364
+        String urlstr = "http://121.40.189.20:8000/API"  + annexPath;
365
+        try {
366
+            InputStream fileInputStream = new URL(urlstr).openStream();
367
+            response.setHeader("content-type", "application/octet-stream");
368
+            response.setContentType("application/octet-stream");
369
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(annexName,"UTF-8"));
370
+            byte[] buffer = new byte[1024];
371
+            int length;
372
+            while ((length = fileInputStream.read(buffer)) > 0) {
373
+                response.getOutputStream().write(buffer, 0, length);
374
+            }
375
+
376
+        } catch (IOException e) {
377
+            throw new RuntimeException(e);
378
+        }
379
+    }
380
+
355 381
 
356 382
     /**
357 383
      * 发送房间号短信