From b6c05dd997dbbce2f6306b02f78717d02e08a4e8 Mon Sep 17 00:00:00 2001 From: wangguangyuan Date: Thu, 4 Sep 2025 14:47:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=8D=E5=85=B4=E7=AB=99=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E5=AF=BC=E5=87=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/controller/PatrolTaskController.java | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java index 03d976f..2827b8d 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java @@ -2562,9 +2562,9 @@ public class PatrolTaskController extends BaseController { newList.sort(Comparator.comparing(PatrolData::getPointStatus)); } - if (newList.size() > maxNum) { - return ResponseEntity.ok("超过最大导出数量:" + maxNum + "条,请结合查询条件减少导出的数量!"); - } +// if (newList.size() > maxNum) { +// return ResponseEntity.ok("超过最大导出数量:" + maxNum + "条,请结合查询条件减少导出的数量!"); +// } Set uniqueImages = new HashSet<>(); for (PatrolData data : newList) { @@ -2583,28 +2583,33 @@ public class PatrolTaskController extends BaseController { long startDownImg = System.currentTimeMillis(); // // 并行下载图片 Map streamHashMap = new ConcurrentHashMap<>(); -// uniqueImages.parallelStream().forEach(imagePath -> { -// try { -// sftpClient.downLoad(imagePath, (inputStream) -> { -// byte[] shm = streamHashMap.get(imagePath); -// byte[] bytes = getStringByInputStream(inputStream); -// if (shm == null) { -// streamHashMap.put(imagePath, bytes); -// } -// -// }); -// } catch (Exception e) { -// logger.warn("图片下载失败: {}", imagePath, e); -// } -// }); - // - uniqueImages.parallelStream().forEach(imagePath -> { - byte[] shm = streamHashMap.get(imagePath); - byte[] bytes = downloadAndCompressImage(imagePath); - if (shm == null) { - streamHashMap.put(imagePath, bytes); - } - }); + if (newList.size() <= maxNum) { + // 下载原图 + uniqueImages.parallelStream().forEach(imagePath -> { + try { + sftpClient.downLoad(imagePath, (inputStream) -> { + byte[] shm = streamHashMap.get(imagePath); + byte[] bytes = getStringByInputStream(inputStream); + if (shm == null) { + streamHashMap.put(imagePath, bytes); + } + + }); + } catch (Exception e) { + logger.warn("图片下载失败: {}", imagePath, e); + } + }); + } else { + // 原图压缩 + uniqueImages.parallelStream().forEach(imagePath -> { + byte[] shm = streamHashMap.get(imagePath); + byte[] bytes = downloadAndCompressImage(imagePath); + if (shm == null) { + streamHashMap.put(imagePath, bytes); + } + }); + } + logger.info("图片下载成功"); logger.info("图片下载耗时: {} ms", (System.currentTimeMillis() - startDownImg)); // exportExcel(response, newList);