This commit is contained in:
van
2026-04-04 15:45:45 +08:00
parent 3e37587074
commit 07c9aac9e6
3 changed files with 241 additions and 16 deletions

View File

@@ -204,6 +204,7 @@ public class TencentDocServiceImpl implements ITencentDocService {
// 2. 识别列位置(根据表头)
Integer dateColumn = null;
Integer companyColumn = null;
Integer jdPlaceOrderNoColumn = null;
Integer orderNoColumn = null;
Integer modelColumn = null;
Integer quantityColumn = null;
@@ -218,9 +219,13 @@ public class TencentDocServiceImpl implements ITencentDocService {
for (int i = 0; i < headerCells.size(); i++) {
String cellText = headerCells.getString(i);
if (cellText != null) {
if (cellText.contains("日期")) dateColumn = i;
if (TencentDocDataParser.isJdPlaceOrderNoHeader(cellText)) {
if (jdPlaceOrderNoColumn == null) {
jdPlaceOrderNoColumn = i;
}
} else if (cellText.contains("日期")) dateColumn = i;
else if (cellText.contains("公司")) companyColumn = i;
else if (cellText.contains("单号")) orderNoColumn = i;
else if (cellText.contains("单号") && !cellText.contains("物流")) orderNoColumn = i;
else if (cellText.contains("型号")) modelColumn = i;
else if (cellText.contains("数量")) quantityColumn = i;
else if (cellText.contains("姓名")) nameColumn = i;
@@ -237,7 +242,7 @@ public class TencentDocServiceImpl implements ITencentDocService {
throw new RuntimeException("未找到'单号'列,请检查表头配置");
}
log.info("表头识别完成 - 单号列: {}, 物流列: {}", orderNoColumn, logisticsColumn);
log.info("表头识别完成 - 单号列: {}, 京东下单订单号列: {}, 物流列: {}", orderNoColumn, jdPlaceOrderNoColumn, logisticsColumn);
// 3. 读取数据区域,查找第一个空行(单号列为空)
String dataRange = String.format("A%d:Z%d", startRow, startRow + 999);
@@ -293,6 +298,9 @@ public class TencentDocServiceImpl implements ITencentDocService {
if (orderNoColumn != null && order.getThirdPartyOrderNo() != null) {
requests.add(buildUpdateRequest(sheetId, rowIndex, orderNoColumn, order.getThirdPartyOrderNo(), false));
}
if (jdPlaceOrderNoColumn != null && order.getOrderId() != null && !order.getOrderId().trim().isEmpty()) {
requests.add(buildUpdateRequest(sheetId, rowIndex, jdPlaceOrderNoColumn, order.getOrderId().trim(), false));
}
if (modelColumn != null && order.getModelNumber() != null) {
requests.add(buildUpdateRequest(sheetId, rowIndex, modelColumn, order.getModelNumber(), false));
}

View File

@@ -213,5 +213,22 @@ public class TencentDocDataParser {
}
}
}
/**
* 表头是否为「京东下单订单号」列(与第三方「单号」等列区分)
*/
public static boolean isJdPlaceOrderNoHeader(String cellValueTrim) {
if (cellValueTrim == null) {
return false;
}
String t = cellValueTrim.trim();
if (t.isEmpty()) {
return false;
}
if (t.contains("京东下单订单号")) {
return true;
}
return t.contains("京东") && t.contains("下单") && t.contains("订单号");
}
}