pdi方法修改

This commit is contained in:
yf001217 2026-06-12 10:17:02 +08:00
parent 5a5e96f8ec
commit b8177bf2a0
1 changed files with 43 additions and 0 deletions

View File

@ -205,6 +205,7 @@ public class QmsPdiStatusItemControllerService {
*/
public void export(HttpServletResponse response, List<Long> ids, Long detectionRulesId, List<Integer> status) throws IOException {
List<QmsPdiStatusItemExportDTO> data = statusItemMapper.listForExport(ids, detectionRulesId, status);
fillExportInspectionImageUrl(data);
// 根据状态列表生成文件名
StringBuilder statusName = new StringBuilder("PDI");
@ -225,6 +226,48 @@ public class QmsPdiStatusItemControllerService {
.writeTo(response.getOutputStream());
}
private void fillExportInspectionImageUrl(List<QmsPdiStatusItemExportDTO> data) {
if (CollectionUtil.isEmpty(data)) {
return;
}
Set<Long> fileIds = data.stream()
.map(QmsPdiStatusItemExportDTO::getInspectionImage)
.filter(StrUtil::isNotBlank)
.map(String::trim)
.map(this::parseFileId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
Map<Long, String> fileUrlMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(fileIds)) {
fileUrlMap = fileUploadRecordService.listByIds(fileIds).stream()
.filter(record -> record != null && StrUtil.isNotBlank(record.getUrl()))
.collect(Collectors.toMap(FileUploadRecord::getId, FileUploadRecord::getUrl, (a, b) -> a));
}
for (QmsPdiStatusItemExportDTO dto : data) {
String inspectionImage = StrUtil.trim(dto.getInspectionImage());
Long fileId = parseFileId(inspectionImage);
if (StrUtil.isBlank(inspectionImage)) {
dto.setInspectionImage("");
} else if (fileId != null) {
dto.setInspectionImage(StrUtil.blankToDefault(fileUrlMap.get(fileId), ""));
}
}
}
private Long parseFileId(String value) {
if (StrUtil.isBlank(value)) {
return null;
}
try {
return Long.valueOf(value.trim());
} catch (NumberFormatException e) {
return null;
}
}
// ========================= 下载导入模板 =========================
/**