From d893821e26a55b55b462a7251b7de25820811cba Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Thu, 8 Jan 2026 12:55:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E8=AF=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CoDelExcelServiceImpl.java | 24 ++++++++++++------- .../ecss/service/impl/CoDelServiceImpl.java | 10 ++++---- .../resources/mapper/ecss/CoDelMapper.xml | 2 +- 3 files changed, 22 insertions(+), 14 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 1c55e442..d56ff889 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,13 +550,12 @@ 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); - continue; - } + // 检查PN列,如果没有值则跳过该行 + if (row.getCell(pnIdx) == null || row.getCell(pnIdx).getCellType() == CellType.BLANK + || row.getCell(pnIdx).getCellType() == CellType.ERROR) { + log.debug("第{}行的PN列为空,跳过该行", j+1); + continue; + } // 跳过内销数据(如果"内外销方式"列存在) Integer saleTypeIdx = columnMap.get("内外销方式"); @@ -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; } diff --git a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java index 149b8e55..89a5c968 100644 --- a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java @@ -300,10 +300,10 @@ public class CoDelServiceImpl implements CoDelService { if (checkHeader.isEmpty()) { throw new RuntimeException("不存在该发货通知单,请刷新界面"); } - + // 调用Mapper方法执行批量更新 int updatedRows = coDelMapper.fixTtlAmount(data); - + if (updatedRows == 0) { throw new RuntimeException("没有需要修正的明细数据"); } @@ -4206,7 +4206,9 @@ public class CoDelServiceImpl implements CoDelService { } Object detailRollsObj = detail.get("detailRolls"); - if (detailRollsObj instanceof BigDecimal) { + if (detailRollsObj == null || "".equals(detailRollsObj)) { + palletDetailData.setRolls(BigDecimal.valueOf(0)); + } else if (detailRollsObj instanceof BigDecimal) { palletDetailData.setRolls((BigDecimal) detailRollsObj); } else if (detailRollsObj instanceof Integer) { palletDetailData.setRolls(BigDecimal.valueOf((Integer) detailRollsObj)); @@ -4214,7 +4216,7 @@ public class CoDelServiceImpl implements CoDelService { palletDetailData.setRolls(BigDecimal.valueOf((Double) detailRollsObj)); } else if (detailRollsObj instanceof String) { palletDetailData.setRolls(new BigDecimal((String) detailRollsObj)); - } else if (detailRollsObj != null) { + } else { palletDetailData.setRolls(BigDecimal.valueOf(((Number) detailRollsObj).doubleValue())); } diff --git a/src/main/resources/mapper/ecss/CoDelMapper.xml b/src/main/resources/mapper/ecss/CoDelMapper.xml index 8748f06b..13a5a16b 100644 --- a/src/main/resources/mapper/ecss/CoDelMapper.xml +++ b/src/main/resources/mapper/ecss/CoDelMapper.xml @@ -881,7 +881,7 @@ left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=no