|
|
|
@ -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<String> uniqueImages = new HashSet<>(); |
|
|
|
for (PatrolData data : newList) { |
|
|
|
@ -2583,28 +2583,33 @@ public class PatrolTaskController extends BaseController { |
|
|
|
long startDownImg = System.currentTimeMillis(); |
|
|
|
// // 并行下载图片 |
|
|
|
Map<String, byte[]> 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); |
|
|
|
|