From d6ca0116d5bb4de2d75baa22c9ca5d8bb53d7c70 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Tue, 6 Jan 2026 17:29:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A5PN=E4=B8=BA=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CoDelExcelServiceImpl.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java index 5357380e..c4e0a6aa 100644 --- a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java @@ -458,6 +458,13 @@ public class CoDelExcelServiceImpl implements CoDelExcelService { continue; } + // 获取pn列索引 + Integer pnIdx = columnMap.get("PN"); + if (pnIdx == null) { + log.warn("Sheet [{}] 中未找到 'PN' 列,跳过该Sheet", sheetName); + continue; + } + // Cargo Ready Date 列存在,说明要处理这个 sheet,验证其他必填列 String[] requiredColumns = { "PO#", // 必填 @@ -543,11 +550,10 @@ public class CoDelExcelServiceImpl implements CoDelExcelService { continue; } - // 检查Cargo Ready Date列,如果没有值则跳过该行 - if (row.getCell(cargoReadyDateIdx) == null - || row.getCell(cargoReadyDateIdx).getCellType() == CellType.BLANK - || row.getCell(cargoReadyDateIdx).getCellType() == CellType.ERROR) { - log.debug("第{}行的Cargo Ready Date列为空,跳过该行", j+1); + // 检查PN列,如果没有值则跳过该行 + if (row.getCell(pnIdx) == null || row.getCell(pnIdx).getCellType() == CellType.BLANK + || row.getCell(pnIdx).getCellType() == CellType.ERROR) { + log.debug("第{}行的PN列为空,跳过该行", j+1); continue; } @@ -566,7 +572,7 @@ public class CoDelExcelServiceImpl implements CoDelExcelService { continue; // 跳过这一行,继续处理下一行 } - Integer pnIdx = columnMap.get("PN"); + //Integer pnIdx = columnMap.get("PN"); if (row.getCell(pnIdx) == null) { currentSheetError.addErrorDetail("第" + (j+1) + "行的 [PN] 列不能为空"); hasRowError = true; @@ -624,7 +630,7 @@ public class CoDelExcelServiceImpl implements CoDelExcelService { String formatted = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); readDate = DateUtils.getDateByParten(formatted, "yyyy-MM-dd"); } catch (Exception e) { - currentSheetError.addErrorDetail("第" + (j+1) + "行的 [Cargo Ready Date] 列格式有误: " + e.getMessage()); + currentSheetError.addErrorDetail("第" + (j+1) + "行的 [Cargo Ready Date] 列格式有误"); hasRowError = true; continue; }