From 370185978832d8d71a0f9f33be15a6a49b92eb37 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 13 五月 2026 16:08:17 +0800
Subject: [PATCH] fix:1. 报工报废入库不合格 2.同一报工批号一致,质检(合格或者不不合格)也一样
---
src/main/java/com/ruoyi/basic/utils/FileUtil.java | 56 +++++++++++++++++++++++++++++---------------------------
1 files changed, 29 insertions(+), 27 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..6ad5d77 100644
--- a/src/main/java/com/ruoyi/basic/utils/FileUtil.java
+++ b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
@@ -98,8 +98,11 @@
}
// 鍒犻櫎鏃ч檮浠朵俊鎭�
- if (application == null) {
+ if (application == null || application.trim().isEmpty()) {
for (StorageBlobDTO storageBlobDTO : storageBlobDTOS) {
+ if (storageBlobDTO.getApplication() == null || storageBlobDTO.getApplication().trim().isEmpty()) {
+ throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
+ }
deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum.getByType(storageBlobDTO.getApplication()), recordType, recordId);
}
} else {
@@ -286,41 +289,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 +337,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<>();
@@ -362,7 +347,10 @@
StorageBlobVO storageBlobVO = new StorageBlobVO();
BeanUtils.copyProperties(storageBlob, storageBlobVO);
storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setUrl(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setName(storageBlob.getOriginalFilename());
storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
+ storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
storageBlobDTOS.add(storageBlobVO);
}
return storageBlobDTOS;
@@ -398,6 +386,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<>();
@@ -405,7 +397,10 @@
StorageBlobVO storageBlobVO = new StorageBlobVO();
BeanUtils.copyProperties(storageBlob, storageBlobVO);
storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setUrl(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setName(storageBlob.getOriginalFilename());
storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
+ storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
storageBlobDTOS.add(storageBlobVO);
}
return storageBlobDTOS;
@@ -429,6 +424,8 @@
StorageBlobVO storageBlobVO = new StorageBlobVO();
BeanUtils.copyProperties(storageBlob, storageBlobVO);
storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setUrl(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setName(storageBlob.getOriginalFilename());
storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
storageBlobDTOS.add(storageBlobVO);
}
@@ -448,6 +445,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 +457,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