From e2e7fba2e1f108c26e135d614d96135b2621f25a Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Thu, 12 Feb 2026 11:36:13 +0800 Subject: [PATCH] =?UTF-8?q?2026-02-12=20=E7=89=B9=E6=AE=8A=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=E9=85=8D=E7=BD=AE=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/Impl/QcBaseInfoServiceImpl.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java b/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java index e34b64c..e3b4996 100644 --- a/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java +++ b/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java @@ -15,6 +15,7 @@ import com.gaotao.modules.pms.service.QcBaseInfoService; import com.gaotao.modules.sys.entity.SysUserEntity; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -1540,16 +1541,25 @@ public class QcBaseInfoServiceImpl implements QcBaseInfoService { // 读取是否默认 String defaultFlag = "N"; if (row.getCell(4) != null) { - String defaultStr = row.getCell(4).getStringCellValue().trim(); - if ("是".equals(defaultStr) || "Y".equalsIgnoreCase(defaultStr)) { - defaultFlag = "Y"; - if (hasDefault) { - errInfo.append("第").append(j + 1).append("行设置为默认,但已存在默认配置(").append(defaultOperationDesc).append(");"); - errorCount++; - continue; + try { + // 先检查单元格类型,避免空白单元格调用getStringCellValue报错 + CellType cellType = row.getCell(4).getCellType(); + if (cellType != CellType.BLANK) { + String defaultStr = row.getCell(4).getStringCellValue().trim(); + if ("是".equals(defaultStr) || "Y".equalsIgnoreCase(defaultStr)) { + defaultFlag = "Y"; + if (hasDefault) { + errInfo.append("第").append(j + 1).append("行设置为默认,但已存在默认配置(").append(defaultOperationDesc).append(");"); + errorCount++; + continue; + } + hasDefault = true; + defaultOperationDesc = operationDesc; + } } - hasDefault = true; - defaultOperationDesc = operationDesc; + } catch (Exception e) { + // 是否默认列读取失败不影响导入,使用默认值N + log.warn("第{}行是否默认列读取失败,使用默认值N: {}", j + 1, e.getMessage()); } }