|
|
@ -412,29 +412,8 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 验证必填列是否存在(根据代码中的验证逻辑确定) |
|
|
|
|
|
String[] requiredColumns = { |
|
|
|
|
|
"PO#", // 必填 |
|
|
|
|
|
"PN", // 必填 |
|
|
|
|
|
"Qty (pcs)", // 必填 |
|
|
|
|
|
"Cargo Ready Date", // 必填 |
|
|
|
|
|
"Destination", // 必填 |
|
|
|
|
|
"Shipping Mode", // 必填 |
|
|
|
|
|
"Currency", // 必填 |
|
|
|
|
|
"TP" // 必填 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
List<String> missingColumns = new ArrayList<>(); |
|
|
|
|
|
for (String column : requiredColumns) { |
|
|
|
|
|
if (!columnIndexMap.containsKey(column)) { |
|
|
|
|
|
missingColumns.add(column); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!missingColumns.isEmpty()) { |
|
|
|
|
|
throw new RuntimeException("Sheet [" + sheetName + "] 表头缺少必填列: " + String.join(", ", missingColumns)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 注意:这里只解析表头,不验证必填列 |
|
|
|
|
|
// 必填列的验证应该在确定要处理该 sheet 之后进行(即 Cargo Ready Date 列存在时) |
|
|
return columnIndexMap; |
|
|
return columnIndexMap; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -472,6 +451,28 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Cargo Ready Date 列存在,说明要处理这个 sheet,验证其他必填列 |
|
|
|
|
|
String[] requiredColumns = { |
|
|
|
|
|
"PO#", // 必填 |
|
|
|
|
|
"PN", // 必填 |
|
|
|
|
|
"Qty (pcs)", // 必填 |
|
|
|
|
|
"Destination", // 必填 |
|
|
|
|
|
"Shipping Mode", // 必填 |
|
|
|
|
|
"Currency", // 必填 |
|
|
|
|
|
"TP" // 必填 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
List<String> missingColumns = new ArrayList<>(); |
|
|
|
|
|
for (String column : requiredColumns) { |
|
|
|
|
|
if (!columnMap.containsKey(column)) { |
|
|
|
|
|
missingColumns.add(column); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!missingColumns.isEmpty()) { |
|
|
|
|
|
throw new RuntimeException("Sheet [" + sheetName + "] 表头缺少必填列: " + String.join(", ", missingColumns)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 遍历每一行(从第四行开始,即索引3) |
|
|
// 遍历每一行(从第四行开始,即索引3) |
|
|
for (int j = 3; j < rows; j++) { |
|
|
for (int j = 3; j < rows; j++) { |
|
|
// 获得该行 |
|
|
// 获得该行 |
|
|
|