From d55278560d29562b341aafa1652209a8aae0af33 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期四, 30 四月 2026 17:08:16 +0800
Subject: [PATCH] 计量器具台账附件修改
---
src/main/java/com/ruoyi/basic/utils/FileUtil.java | 45 +++++++++++++++++++--------------------------
1 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/utils/FileUtil.java b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
index 0e3d10d..c57468a 100644
--- a/src/main/java/com/ruoyi/basic/utils/FileUtil.java
+++ b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
@@ -286,41 +286,20 @@
/**
* 閫氳繃璁板綍绫诲瀷鑾峰彇鏂囦欢淇℃伅 attachment锛堝垎椤碉級
*
- * @param page 鍒嗛〉鍙傛暟
* @param storageAttachmentDTO 鍏宠仈璁板綍淇℃伅
*/
- public IPage<StorageAttachmentVO> getStorageAttachmentVosPageListByApplicationAndRecordTypeAndRecordId(Page page, StorageAttachmentDTO storageAttachmentDTO) {
- // 鍒嗛〉鏌ヨ绗﹀悎鏉′欢鐨� StorageAttachment 璁板綍
+ public List<StorageBlobVO> getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(StorageAttachmentDTO storageAttachmentDTO) {
LambdaQueryWrapper<StorageAttachment> queryWrapper = new LambdaQueryWrapper<StorageAttachment>()
.eq(StorageAttachment::getRecordType, storageAttachmentDTO.getRecordType())
.eq(StorageAttachment::getRecordId, storageAttachmentDTO.getRecordId());
if (storageAttachmentDTO.getApplication() != null) {
queryWrapper.eq(StorageAttachment::getApplication, storageAttachmentDTO.getApplication());
}
- IPage<StorageAttachmentVO> storageAttachmentIPage = storageAttachmentMapper.selectPage(page, queryWrapper);
-
- // 杞崲涓� StorageAttachmentVO 骞惰幏鍙栧搴旂殑 StorageBlobVO
- List<StorageAttachmentVO> storageAttachmentVOS = new ArrayList<>();
- if (CollectionUtils.isNotEmpty(storageAttachmentIPage.getRecords())) {
- for (StorageAttachment storageAttachment : storageAttachmentIPage.getRecords()) {
- StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
- BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
- List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
- if (CollectionUtils.isEmpty(storageBlobVOS)) {
- storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
- } else {
- storageAttachmentVO.setStorageBlobVOS(storageBlobVOS);
- }
- storageAttachmentVOS.add(storageAttachmentVO);
- }
+ List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(queryWrapper);
+ if (CollectionUtils.isEmpty(storageAttachments)) {
+ return null;
}
-
- // 鏋勫缓鍒嗛〉缁撴灉
- IPage<StorageAttachmentVO> resultPage = new Page<>();
- BeanUtils.copyProperties(storageAttachmentIPage, resultPage);
- resultPage.setRecords(storageAttachmentVOS);
-
- return resultPage;
+ return getStorageBlobVOsByStorageAttachmentIds(storageAttachments.stream().map(StorageAttachment::getId).collect(Collectors.toList()));
}
/**
@@ -355,6 +334,9 @@
if (CollectionUtils.isEmpty(storageAttachments)) {
return null;
}
+ Map<Long, Long> blobIdToAttachmentIdMap = storageAttachments.stream()
+ .collect(Collectors.toMap(StorageAttachment::getStorageBlobId, StorageAttachment::getId));
+
List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
@@ -363,6 +345,7 @@
BeanUtils.copyProperties(storageBlob, storageBlobVO);
storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
+ storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
storageBlobDTOS.add(storageBlobVO);
}
return storageBlobDTOS;
@@ -398,6 +381,10 @@
if (CollectionUtils.isEmpty(storageAttachments)) {
return null;
}
+ // 鏋勫缓 storageBlobId -> storageAttachmentId 鐨勬槧灏�
+ Map<Long, Long> blobIdToAttachmentIdMap = storageAttachments.stream()
+ .collect(Collectors.toMap(StorageAttachment::getStorageBlobId, StorageAttachment::getId));
+
List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
@@ -406,6 +393,7 @@
BeanUtils.copyProperties(storageBlob, storageBlobVO);
storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
+ storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
storageBlobDTOS.add(storageBlobVO);
}
return storageBlobDTOS;
@@ -448,6 +436,10 @@
if (CollectionUtils.isEmpty(storageAttachments)) {
return null;
}
+ // 鏋勫缓 storageBlobId -> storageAttachmentId 鐨勬槧灏�
+ Map<Long, Long> blobIdToAttachmentIdMap = storageAttachments.stream()
+ .collect(Collectors.toMap(StorageAttachment::getStorageBlobId, StorageAttachment::getId));
+
List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
@@ -456,6 +448,7 @@
BeanUtils.copyProperties(storageBlob, storageBlobVO);
storageBlobVO.setPreviewURL(buildSignedUrl(storageBlobVO, "/preview/", expired));
storageBlobVO.setDownloadURL(buildSignedUrl(storageBlobVO, "/download/", expired));
+ storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
storageBlobDTOS.add(storageBlobVO);
}
return storageBlobDTOS;
--
Gitblit v1.9.3