Commit c02f3a24 by zhangxingmin

oss-v1版本

parent 0223c57a
......@@ -56,15 +56,6 @@ public class ExcelImportServiceImpl implements ExcelImportService {
ExcelImportResult<Map<String, Object>> importResult =
importExcel(file, headerRowNum, dataStartRowNum);
log.info("EasyPOI导入结果:总行数={}, 成功行数={}, 失败行数={}",
importResult.getList() != null ? importResult.getList().size() : 0,
importResult.getList() != null ? "N/A" : "N/A",
importResult.isVerifyFail());
if (importResult.getList() != null) {
System.out.println("原始数据:" + JSON.toJSONString(importResult.getList()));
}
// 3. 处理导入结果
List<Map<String, Object>> data =
processImportResult(importResult, headers);
......@@ -235,37 +226,48 @@ public class ExcelImportServiceImpl implements ExcelImportService {
}
/**
* 判断一行数据是否为空行
* @param rowData 行数据
* @param headers 表头列表
* @return true-空行, false-非空行
* 判断一行数据是否为空行(更严格的条件)
*/
private static boolean isEmptyRow(Map<String, Object> rowData, List<String> headers) {
if (rowData == null || rowData.isEmpty()) {
return true;
}
// 检查所有业务字段是否都为空(排除excelRowNum等系统字段)
// 方法1:检查所有业务字段是否都为空
for (String header : headers) {
Object value = rowData.get(header);
if (value != null && !value.toString().trim().isEmpty()) {
return false; // 发现非空值,不是空行
if (value != null) {
String strValue = value.toString().trim();
// 排除常见的空值表示
if (!strValue.isEmpty() &&
!strValue.equals("-") &&
!strValue.equals("null") &&
!strValue.equals("NULL")) {
return false;
}
}
}
// 额外检查:如果只有系统字段有值,也算空行
boolean hasOnlySystemFields = true;
for (String key : rowData.keySet()) {
if (!key.equals("excelRowNum") && !key.startsWith("_")) {
Object value = rowData.get(key);
if (value != null && !value.toString().trim().isEmpty()) {
hasOnlySystemFields = false;
break;
// 方法2:检查所有键值对(包括系统字段)
int validCount = 0;
for (Map.Entry<String, Object> entry : rowData.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
// 跳过系统字段
if (key.equals("excelRowNum") || key.startsWith("_")) {
continue;
}
if (value != null) {
String strValue = value.toString().trim();
if (!strValue.isEmpty()) {
validCount++;
}
}
}
return hasOnlySystemFields;
return validCount == 0;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment