diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewAddQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewAddQO.java index 4ba71bcf..83ff728d 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewAddQO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewAddQO.java @@ -1,6 +1,7 @@ package com.nflg.wms.common.pojo.qo; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; import lombok.Data; import java.util.List; @@ -29,10 +30,10 @@ public class QmsCoaReviewAddQO { private String batchNo; /** - * COA报告/文件地址(必传) + * COA报告文件ID列表(必传) */ - @NotBlank(message = "COA报告不能为空") - private String coaFile; + @NotEmpty(message = "COA报告不能为空") + private List coaFileIds; /** * 图片列表(可选) diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewUpdateQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewUpdateQO.java index c36f9ab9..7a992c9b 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewUpdateQO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsCoaReviewUpdateQO.java @@ -1,6 +1,7 @@ package com.nflg.wms.common.pojo.qo; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -37,10 +38,10 @@ public class QmsCoaReviewUpdateQO { private String batchNo; /** - * COA报告 + * COA报告文件ID列表 */ - @NotBlank(message = "COA报告不能为空") - private String coaFile; + @NotEmpty(message = "COA报告不能为空") + private List coaFileIds; /** * 图片列表(可选) diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewDetailVO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewDetailVO.java index 9e990742..2b2a79de 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewDetailVO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewDetailVO.java @@ -14,7 +14,7 @@ public class QmsCoaReviewDetailVO { private Long id; /** - * 供应商编号 + * 供应商编码 */ private String supplierCode; @@ -74,9 +74,9 @@ public class QmsCoaReviewDetailVO { private String rejectionReason; /** - * COA文件地址 + * COA文件列表 */ - private String coaFile; + private List coaFiles; /** * 报告模板 diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewVO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewVO.java index 53a2478a..d4f5c078 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewVO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsCoaReviewVO.java @@ -14,7 +14,7 @@ public class QmsCoaReviewVO { private Long id; /** - * 供应商编号 + * 供应商编码 */ private String supplierCode; @@ -84,9 +84,9 @@ public class QmsCoaReviewVO { private String createBy; /** - * COA文件地址 + * COA文件列表 */ - private String coaFile; + private List coaFiles; /** * 图片列表 diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsCoaReviewServiceImpl.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsCoaReviewServiceImpl.java index 7c6653dc..468ecc14 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsCoaReviewServiceImpl.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsCoaReviewServiceImpl.java @@ -14,15 +14,18 @@ import com.nflg.wms.common.pojo.qo.QmsCoaReviewAddQO; import com.nflg.wms.common.pojo.qo.QmsCoaReviewAuditQO; import com.nflg.wms.common.pojo.qo.QmsCoaReviewSearchQO; import com.nflg.wms.common.pojo.qo.QmsCoaReviewUpdateQO; +import com.nflg.wms.common.pojo.vo.FileUploadVO; import com.nflg.wms.common.pojo.vo.QmsCoaReviewDetailVO; import com.nflg.wms.common.pojo.vo.QmsCoaReviewVO; import com.nflg.wms.common.util.UserUtil; +import com.nflg.wms.repository.entity.FileUploadRecord; import com.nflg.wms.repository.entity.QmsCoaTask; import com.nflg.wms.repository.entity.QmsCoaReview; import com.nflg.wms.repository.entity.QmsQcMaterial; import com.nflg.wms.repository.entity.User; import com.nflg.wms.repository.entity.UserSupplier; import com.nflg.wms.repository.mapper.QmsCoaReviewMapper; +import com.nflg.wms.repository.service.IFileUploadRecordService; import com.nflg.wms.repository.service.IQmsCoaTaskService; import com.nflg.wms.repository.service.IQmsCoaReviewService; import com.nflg.wms.repository.service.IQmsQcMaterialService; @@ -33,6 +36,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; +import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Objects; @@ -46,6 +51,8 @@ import java.util.stream.Collectors; public class QmsCoaReviewServiceImpl extends ServiceImpl implements IQmsCoaReviewService { + private static final String COA_FILE_ID_SEPARATOR = ";"; + @Resource private IQmsQcMaterialService qcMaterialService; @@ -58,6 +65,9 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl userMap = userIds.isEmpty() ? Map.of() : userService.lambdaQuery().in(User::getId, userIds).list() .stream().collect(Collectors.toMap(User::getId, u -> u)); + Map coaFileMap = getCoaFileMap(records); List vos = records.stream() - .map(r -> toVO(r, supplierMap, materialMap, userMap)) + .map(r -> toVO(r, supplierMap, materialMap, userMap, coaFileMap)) .collect(Collectors.toList()); return buildPageData(page, vos); } @@ -537,7 +546,7 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl coaFileIds) { + if (CollUtil.isEmpty(coaFileIds)) { + throw new NflgException(STATE.BusinessError, "COA报告不能为空"); + } + Set fileIds = coaFileIds.stream() + .filter(Objects::nonNull) + .collect(Collectors.toCollection(LinkedHashSet::new)); + if (fileIds.isEmpty()) { + throw new NflgException(STATE.BusinessError, "COA报告不能为空"); + } + List files = fileUploadRecordService.lambdaQuery() + .in(FileUploadRecord::getId, fileIds) + .list(); + Set existingFileIds = files.stream() + .map(FileUploadRecord::getId) + .collect(Collectors.toSet()); + if (existingFileIds.size() != fileIds.size()) { + throw new NflgException(STATE.BusinessError, "COA报告文件不存在"); + } + return fileIds.stream() + .map(String::valueOf) + .collect(Collectors.joining(COA_FILE_ID_SEPARATOR)); + } + + private List parseCoaFileIds(String coaFile) { + if (StrUtil.isBlank(coaFile)) { + return List.of(); + } + return StrUtil.split(coaFile, COA_FILE_ID_SEPARATOR).stream() + .map(StrUtil::trim) + .filter(StrUtil::isNotBlank) + .map(Long::valueOf) + .toList(); + } + + private Map getCoaFileMap(List records) { + Set fileIds = records.stream() + .map(QmsCoaReview::getCoaFile) + .filter(StrUtil::isNotBlank) + .flatMap(coaFile -> parseCoaFileIds(coaFile).stream()) + .collect(Collectors.toCollection(LinkedHashSet::new)); + if (fileIds.isEmpty()) { + return Collections.emptyMap(); + } + return fileUploadRecordService.lambdaQuery() + .in(FileUploadRecord::getId, fileIds) + .list() + .stream() + .collect(Collectors.toMap(FileUploadRecord::getId, file -> file, (a, b) -> a)); + } + + private List buildCoaFiles(String coaFile, Map fileMap) { + return parseCoaFileIds(coaFile).stream() + .map(fileMap::get) + .filter(Objects::nonNull) + .map(file -> new FileUploadVO() + .setId(file.getId()) + .setFileName(file.getFileName()) + .setUrl(file.getUrl()) + .setSize(0L)) + .toList(); + } + private QmsCoaReviewVO toVO(QmsCoaReview r, Map supplierMap, - Map materialMap, Map userMap) { + Map materialMap, Map userMap, + Map coaFileMap) { QmsCoaReviewVO vo = new QmsCoaReviewVO(); vo.setId(r.getId()); vo.setPurchaseNo(r.getPurchaseNo()); @@ -644,7 +717,7 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl