|
|
@ -32,6 +32,7 @@ import org.apache.poi.ss.usermodel.Cell; |
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
import org.apache.poi.ss.usermodel.DataFormatter; |
|
|
import org.apache.poi.ss.usermodel.DataFormatter; |
|
|
import org.apache.poi.ss.usermodel.DateUtil; |
|
|
import org.apache.poi.ss.usermodel.DateUtil; |
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
@ -473,6 +474,43 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
throw new RuntimeException("Sheet [" + sheetName + "] 表头缺少必填列: " + String.join(", ", missingColumns)); |
|
|
throw new RuntimeException("Sheet [" + sheetName + "] 表头缺少必填列: " + String.join(", ", missingColumns)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 扫描整个 sheet,如果发现"内销"则跳过该 sheet |
|
|
|
|
|
boolean hasInternalSale = false; |
|
|
|
|
|
for (int scanRow = 0; scanRow < rows; scanRow++) { |
|
|
|
|
|
XSSFRow checkRow = sheet.getRow(scanRow); |
|
|
|
|
|
if (checkRow == null) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 遍历该行所有单元格 |
|
|
|
|
|
int lastCellNum = checkRow.getLastCellNum(); |
|
|
|
|
|
for (int scanCol = 0; scanCol < lastCellNum; scanCol++) { |
|
|
|
|
|
XSSFCell cell = checkRow.getCell(scanCol); |
|
|
|
|
|
if (cell != null && cell.getCellType() != CellType.BLANK) { |
|
|
|
|
|
try { |
|
|
|
|
|
String cellValue = getStringCellValue(checkRow, scanCol); |
|
|
|
|
|
if (cellValue != null && cellValue.contains("内销")) { |
|
|
|
|
|
hasInternalSale = true; |
|
|
|
|
|
log.info("Sheet [{}] 在第{}行第{}列发现\"内销\",跳过该Sheet", sheetName, scanRow + 1, scanCol + 1); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
// 忽略单元格读取异常,继续扫描其他单元格 |
|
|
|
|
|
log.debug("Sheet [{}] 第{}行第{}列读取失败: {}", sheetName, scanRow + 1, scanCol + 1, e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hasInternalSale) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果发现内销,跳过该 sheet |
|
|
|
|
|
if (hasInternalSale) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 遍历每一行(从第四行开始,即索引3) |
|
|
// 遍历每一行(从第四行开始,即索引3) |
|
|
for (int j = 3; j < rows; j++) { |
|
|
for (int j = 3; j < rows; j++) { |
|
|
// 获得该行 |
|
|
// 获得该行 |
|
|
|