liding
2026-04-22 c1babcfa8a9cd01dbeb8527a6a95cbcc431957c7
src/main/java/com/ruoyi/inspectiontask/service/impl/QrCodeScanRecordServiceImpl.java
@@ -5,7 +5,6 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.StorageBlobDTO;
import com.ruoyi.basic.mapper.StorageAttachmentMapper;
import com.ruoyi.basic.mapper.StorageBlobMapper;
import com.ruoyi.basic.pojo.StorageAttachment;
@@ -127,23 +126,24 @@
                    });
            // 6.2 设置附件信息
            dto.setStorageBlobDTO(
                    Optional.ofNullable(attachmentsMap.get(record.getId()))
                            .orElse(Collections.emptyList())
                            .stream()
                            .map(att -> {
                                StorageBlobDTO blobDTO = new StorageBlobDTO();
                                Optional.ofNullable(blobMap.get(att.getStorageBlobId()))
                                        .ifPresent(blob -> {
                                            BeanUtils.copyProperties(blob, blobDTO);
                                            blobDTO.setUrl(minioUtils.getPreviewUrls(blob.getBucketFilename(), blob.getBucketName(), true));
                                            blobDTO.setDownloadUrl(minioUtils.getDownloadUrls(blob.getBucketFilename(),blob.getBucketName(),blob.getOriginalFilename(),true));
                                        });
                                return blobDTO;
                            })
                            .filter(blobDTO -> blobDTO.getId() != null) // 过滤无效附件
                            .collect(Collectors.toList())
            );
            // todo fileChange
//            dto.setStorageBlobDTO(
//                    Optional.ofNullable(attachmentsMap.get(record.getId()))
//                            .orElse(Collections.emptyList())
//                            .stream()
//                            .map(att -> {
//                                StorageBlobDTO blobDTO = new StorageBlobDTO();
//                                Optional.ofNullable(blobMap.get(att.getStorageBlobId()))
//                                        .ifPresent(blob -> {
//                                            BeanUtils.copyProperties(blob, blobDTO);
//                                            blobDTO.setUrl(minioUtils.getPreviewUrls(blob.getBucketFilename(), blob.getBucketName(), true));
//                                            blobDTO.setDownloadUrl(minioUtils.getDownloadUrls(blob.getBucketFilename(),blob.getBucketName(),blob.getOriginalFilename(),true));
//                                        });
//                                return blobDTO;
//                            })
//                            .filter(blobDTO -> blobDTO.getId() != null) // 过滤无效附件
//                            .collect(Collectors.toList())
//            );
            return dto;
        }).collect(Collectors.toList());
@@ -166,18 +166,19 @@
            i = qrCodeScanRecordMapper.updateById(qrCodeScanRecord);
        }
        if (qrCodeScanRecordDto.getStorageBlobDTO() != null && !qrCodeScanRecordDto.getStorageBlobDTO().isEmpty()) {
        if (qrCodeScanRecordDto.getStorageBlobVO() != null && !qrCodeScanRecordDto.getStorageBlobVO().isEmpty()) {
            List<StorageAttachment> attachments = new ArrayList<>();
            for (StorageBlobDTO storageBlobDTO : qrCodeScanRecordDto.getStorageBlobDTO()) {
                StorageAttachment storageAttachment = new StorageAttachment(
                        StorageAttachmentFile,
                        (long) QrCodeScanRecords.ordinal(),
                        qrCodeScanRecord.getId()
                );
                storageAttachment.setStorageBlobDTO(storageBlobDTO);
                attachments.add(storageAttachment);
            }
            // todo fileChange
//            for (StorageBlobDTO storageBlobDTO : qrCodeScanRecordDto.getStorageBlobDTO()) {
//                StorageAttachment storageAttachment = new StorageAttachment(
//                        StorageAttachmentFile,
//                        (long) QrCodeScanRecords.ordinal(),
//                        qrCodeScanRecord.getId()
//                );
//                storageAttachment.setStorageBlobDTO(storageBlobDTO);
//                attachments.add(storageAttachment);
//            }
            storageAttachmentService.saveStorageAttachment(attachments, qrCodeScanRecord.getId(), QrCodeScanRecords, StorageAttachmentFile);
        }
        return i;