This commit is contained in:
van
2026-04-04 16:39:46 +08:00
parent bce83f680c
commit 6fbfecf690
4 changed files with 184 additions and 118 deletions

View File

@@ -1056,66 +1056,61 @@ public class TencentDocController extends BaseController {
return AjaxResult.error("无法识别表头,表头数据为空");
}
// 查找所有相关列
log.info("开始识别表头列,共 {} 列", headerRowData.size());
// 列名须与表格完全一致(仅忽略首尾空白、不间断空格等):备注、是否安排、物流单号、下单电话、标记、京东下单订单号;另需「单号」或「第三方单号」
log.info("开始识别表头列(完全匹配列名),共 {} 列", headerRowData.size());
for (int i = 0; i < headerRowData.size(); i++) {
String cellValue = headerRowData.getString(i);
if (cellValue != null) {
String cellValueTrim = cellValue.trim();
log.debug("列 {} 内容: [{}]", i, cellValueTrim);
if (cellValue == null) {
continue;
}
String norm = TencentDocDataParser.normalizeTencentDocHeader(cellValue);
log.debug("列 {} 原始: [{}] 规范化: [{}]", i, cellValue.trim(), norm);
if (jdPlaceOrderNoColumn == null && TencentDocDataParser.isJdPlaceOrderNoHeader(cellValueTrim)) {
jdPlaceOrderNoColumn = i;
log.info("识别到 '京东下单订单号' 列:第 {} 列(索引{}", i + 1, i);
}
// 识别"单号"列
if (orderNoColumn == null && cellValueTrim.contains("单号")
&& !TencentDocDataParser.isJdPlaceOrderNoHeader(cellValueTrim)
&& !cellValueTrim.contains("物流")) {
orderNoColumn = i;
log.info("识别到 '单号' 列:第 {} 列(索引{}", i + 1, i);
}
// 识别"物流单号"或"物流链接"列
if (logisticsLinkColumn == null && (cellValueTrim.contains("物流单号") || cellValueTrim.contains("物流链接"))) {
logisticsLinkColumn = i;
log.info("✓ 识别到 '物流单号' 列:第 {} 列(索引{}", i + 1, i);
}
// 识别"备注"列(可选)
if (remarkColumn == null && cellValueTrim.contains("备注")) {
remarkColumn = i;
log.info("识别到 '备注' 列:第 {} 列(索引{}", i + 1, i);
}
// 识别"是否安排"列(可选)
if (arrangedColumn == null && (cellValueTrim.contains("是否安排") || cellValueTrim.contains("安排"))) {
arrangedColumn = i;
log.info("✓ 识别到 '是否安排' 列:第 {} 列(索引{}", i + 1, i);
}
// 识别"标记"列(可选)
if (markColumn == null && cellValueTrim.contains("标记")) {
markColumn = i;
log.info("识别到 '标记' 列:第 {} 列(索引{}", i + 1, i);
}
// 识别"下单电话"列(可选)
if (phoneColumn == null && (cellValueTrim.contains("下单电话"))) {
phoneColumn = i;
log.info("✓ 识别到 '下单电话' 列:第 {} 列(索引{}),列名: [{}]", i + 1, i, cellValueTrim);
}
if (jdPlaceOrderNoColumn == null && TencentDocDataParser.headerEquals(cellValue, "京东下单订单号")) {
jdPlaceOrderNoColumn = i;
log.info("列名完全匹配「京东下单订单号:第 {} 列(索引{}", i + 1, i);
}
if (orderNoColumn == null && TencentDocDataParser.headerEquals(cellValue, "单号")) {
orderNoColumn = i;
log.info("✓ 列名完全匹配「单号」:第 {} 列(索引{}", i + 1, i);
}
if (orderNoColumn == null && TencentDocDataParser.headerEquals(cellValue, "第三方单号")) {
orderNoColumn = i;
log.info("列名完全匹配「第三方单号」:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && TencentDocDataParser.headerEquals(cellValue, "物流单号")) {
logisticsLinkColumn = i;
log.info("✓ 列名完全匹配「物流单号」:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && TencentDocDataParser.headerEquals(cellValue, "物流链接")) {
logisticsLinkColumn = i;
log.warn("✓ 列名匹配「物流链接」(建议改为「物流单号」):第 {} 列(索引{}", i + 1, i);
}
if (remarkColumn == null && TencentDocDataParser.headerEquals(cellValue, "备注")) {
remarkColumn = i;
log.info("列名完全匹配「备注」:第 {} 列(索引{}", i + 1, i);
}
if (arrangedColumn == null && TencentDocDataParser.headerEquals(cellValue, "是否安排")) {
arrangedColumn = i;
log.info("✓ 列名完全匹配「是否安排」:第 {} 列(索引{}", i + 1, i);
}
if (markColumn == null && TencentDocDataParser.headerEquals(cellValue, "标记")) {
markColumn = i;
log.info("✓ 列名完全匹配「标记」:第 {} 列(索引{}", i + 1, i);
}
if (phoneColumn == null && TencentDocDataParser.headerEquals(cellValue, "下单电话")) {
phoneColumn = i;
log.info("列名完全匹配「下单电话」:第 {} 列(索引{}", i + 1, i);
}
}
log.info("表头列识别完成");
// 检查必需的列是否都已识别
if (orderNoColumn == null) {
return AjaxResult.error("无法找到'单号'列,请检查表头是否包含'单号'字段");
return AjaxResult.error("无法找到列名完全为「单号」或「第三方单号」的列(请与表格列名一致,勿加空格或后缀)");
}
if (logisticsLinkColumn == null) {
return AjaxResult.error("无法找到'物流单号'或'物流链接'列,请检查表头");
return AjaxResult.error("无法找到列名完全为「物流单号」的列(兼容「物流链接」);请与表格列名一致");
}
// 提示可选列的识别情况
@@ -2237,24 +2232,29 @@ public class TencentDocController extends BaseController {
for (int i = 0; i < headerRowData.size(); i++) {
String cellValue = headerRowData.getString(i);
if (cellValue != null) {
String cellValueTrim = cellValue.trim();
if (orderNoColumn == null && cellValueTrim.contains("单号") && !cellValueTrim.contains("物流")
&& !TencentDocDataParser.isJdPlaceOrderNoHeader(cellValueTrim)) {
orderNoColumn = i;
log.info("✓ 识别到 '单号' 列:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && (cellValueTrim.contains("物流单号") || cellValueTrim.contains("物流链接"))) {
logisticsLinkColumn = i;
log.info("✓ 识别到 '物流单号' 列:第 {} 列(索引{}", i + 1, i);
}
if (cellValue == null) {
continue;
}
if (orderNoColumn == null && TencentDocDataParser.headerEquals(cellValue, "单号")) {
orderNoColumn = i;
log.info("✓ 列名完全匹配「单号」:第 {} 列(索引{}", i + 1, i);
}
if (orderNoColumn == null && TencentDocDataParser.headerEquals(cellValue, "第三方单号")) {
orderNoColumn = i;
log.info("✓ 列名完全匹配「第三方单号」:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && TencentDocDataParser.headerEquals(cellValue, "物流单号")) {
logisticsLinkColumn = i;
log.info("✓ 列名完全匹配「物流单号」:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && TencentDocDataParser.headerEquals(cellValue, "物流链接")) {
logisticsLinkColumn = i;
log.info("✓ 列名匹配「物流链接」:第 {} 列(索引{}", i + 1, i);
}
}
if (orderNoColumn == null || logisticsLinkColumn == null) {
return AjaxResult.error("无法识别表头列,请确保表头包含'单号'和'物流单号'列");
return AjaxResult.error("无法识别表头列,请确保存在列名完全为「单号」或「第三方单号」,以及「物流单号」(或「物流链接」)");
}
// 统计结果
@@ -2536,24 +2536,29 @@ public class TencentDocController extends BaseController {
for (int i = 0; i < headerRowData.size(); i++) {
String cellValue = headerRowData.getString(i);
if (cellValue != null) {
String cellValueTrim = cellValue.trim();
if (orderNoColumn == null && cellValueTrim.contains("单号") && !cellValueTrim.contains("物流")
&& !TencentDocDataParser.isJdPlaceOrderNoHeader(cellValueTrim)) {
orderNoColumn = i;
log.info("✓ 识别到 '单号' 列:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && (cellValueTrim.contains("物流单号") || cellValueTrim.contains("物流链接"))) {
logisticsLinkColumn = i;
log.info("✓ 识别到 '物流单号' 列:第 {} 列(索引{}", i + 1, i);
}
if (cellValue == null) {
continue;
}
if (orderNoColumn == null && TencentDocDataParser.headerEquals(cellValue, "单号")) {
orderNoColumn = i;
log.info("✓ 列名完全匹配「单号」:第 {} 列(索引{}", i + 1, i);
}
if (orderNoColumn == null && TencentDocDataParser.headerEquals(cellValue, "第三方单号")) {
orderNoColumn = i;
log.info("✓ 列名完全匹配「第三方单号」:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && TencentDocDataParser.headerEquals(cellValue, "物流单号")) {
logisticsLinkColumn = i;
log.info("✓ 列名完全匹配「物流单号」:第 {} 列(索引{}", i + 1, i);
}
if (logisticsLinkColumn == null && TencentDocDataParser.headerEquals(cellValue, "物流链接")) {
logisticsLinkColumn = i;
log.info("✓ 列名匹配「物流链接」:第 {} 列(索引{}", i + 1, i);
}
}
if (orderNoColumn == null || logisticsLinkColumn == null) {
return AjaxResult.error("无法识别表头列,请确保表头包含'单号'和'物流单号'列");
return AjaxResult.error("无法识别表头列,请确保存在列名完全为「单号」或「第三方单号」,以及「物流单号」(或「物流链接」)");
}
// 统计结果