| | |
| | | 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.dto.StorageBlobVO; |
| | | import com.ruoyi.basic.mapper.StorageAttachmentMapper; |
| | | import com.ruoyi.basic.mapper.StorageBlobMapper; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.pojo.StorageBlob; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.common.constant.StorageAttachmentConstants.StorageAttachmentFile; |
| | | import static com.ruoyi.common.enums.StorageAttachmentRecordType.InspectionTasks; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper, InspectionTask> implements InspectionTaskService { |
| | | |
| | | |
| | | @Autowired |
| | | private InspectionTaskMapper inspectionTaskMapper; |
| | | private final InspectionTaskMapper inspectionTaskMapper; |
| | | |
| | | @Autowired |
| | | private StorageAttachmentService storageAttachmentService; |
| | | private final StorageAttachmentService storageAttachmentService; |
| | | |
| | | @Autowired |
| | | private StorageBlobMapper storageBlobMapper; |
| | | private final StorageBlobMapper storageBlobMapper; |
| | | |
| | | @Autowired |
| | | private StorageAttachmentMapper storageAttachmentMapper; |
| | | private final StorageAttachmentMapper storageAttachmentMapper; |
| | | |
| | | @Autowired |
| | | private MinioUtils minioUtils; |
| | | private final MinioUtils minioUtils; |
| | | |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | private final SysUserMapper sysUserMapper; |
| | | |
| | | @Autowired |
| | | private CommonFileMapper commonFileMapper; |
| | | private final CommonFileMapper commonFileMapper; |
| | | |
| | | @Autowired |
| | | private CommonFileServiceImpl commonFileService; |
| | | private final CommonFileServiceImpl commonFileService; |
| | | |
| | | @Override |
| | | public IPage<InspectionTaskDto> selectInspectionTaskList(Page<InspectionTask> page, InspectionTaskDto inspectionTaskDto) { |
| | |
| | | if(commonFiles == null){ |
| | | commonFiles = new ArrayList<>(); |
| | | } |
| | | List<CommonFile> finalCommonFiles = commonFiles; |
| | | AtomicReference<List<CommonFile>> finalCommonFiles = new AtomicReference<>(commonFiles); |
| | | |
| | | List<InspectionTaskDto> dtoList = entityPage.getRecords().stream().map(inspectionTask -> { |
| | | InspectionTaskDto dto = new InspectionTaskDto(); |
| | |
| | | } |
| | | |
| | | dto.setDateStr(inspectionTask.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | |
| | | finalCommonFiles.set(finalCommonFiles.get().stream().filter(commonFile -> commonFile.getCommonId().equals(inspectionTask.getId())).collect(Collectors.toList())); |
| | | // 初始化三个附件列表 |
| | | dto.setCommonFileList(finalCommonFiles.stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION.getValue())).collect(Collectors.toList())); |
| | | dto.setCommonFileListAfter(finalCommonFiles.stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_AFTER.getValue())).collect(Collectors.toList())); |
| | | dto.setCommonFileListBefore(finalCommonFiles.stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue())).collect(Collectors.toList())); |
| | | dto.setCommonFileList(finalCommonFiles.get().stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION.getValue())).collect(Collectors.toList())); |
| | | dto.setCommonFileListAfter(finalCommonFiles.get().stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_AFTER.getValue())).collect(Collectors.toList())); |
| | | dto.setCommonFileListBefore(finalCommonFiles.get().stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue())).collect(Collectors.toList())); |
| | | |
| | | |
| | | return dto; |
| | |
| | | } |
| | | |
| | | // 提取创建BlobDTO的公共方法 |
| | | private StorageBlobDTO createBlobDto(StorageBlob blob) { |
| | | StorageBlobDTO dto = new StorageBlobDTO(); |
| | | private StorageBlobVO createBlobDto(StorageBlob blob) { |
| | | StorageBlobVO dto = new StorageBlobVO(); |
| | | BeanUtils.copyProperties(blob, dto); |
| | | |
| | | // 设置URL |
| | | dto.setUrl(minioUtils.getPreviewUrls( |
| | | blob.getBucketFilename(), |
| | | blob.getBucketName(), |
| | | true |
| | | )); |
| | | |
| | | // 设置下载URL |
| | | dto.setDownloadUrl(minioUtils.getDownloadUrls( |
| | | blob.getBucketFilename(), |
| | | blob.getBucketName(), |
| | | blob.getOriginalFilename(), |
| | | true |
| | | )); |
| | | // todo fileChange |
| | | // // 设置URL |
| | | // dto.setUrl(minioUtils.getPreviewUrls( |
| | | // blob.getBucketFilename(), |
| | | // blob.getBucketName(), |
| | | // true |
| | | // )); |
| | | // |
| | | // // 设置下载URL |
| | | // dto.setDownloadUrl(minioUtils.getDownloadUrls( |
| | | // blob.getBucketFilename(), |
| | | // blob.getBucketName(), |
| | | // blob.getOriginalFilename(), |
| | | // true |
| | | // )); |
| | | return dto; |
| | | } |
| | | |