1
This commit is contained in:
@@ -462,11 +462,7 @@ public class TencentDocController extends BaseController {
|
||||
String fileId = (String) params.get("fileId");
|
||||
String sheetId = (String) params.get("sheetId");
|
||||
|
||||
// 可选参数:指定列位置
|
||||
Integer orderNoColumn = params.get("orderNoColumn") != null ?
|
||||
Integer.valueOf(params.get("orderNoColumn").toString()) : null; // 单号列索引(从0开始)
|
||||
Integer logisticsLinkColumn = params.get("logisticsLinkColumn") != null ?
|
||||
Integer.valueOf(params.get("logisticsLinkColumn").toString()) : null; // 物流链接列索引(从0开始)
|
||||
// 可选参数:表头行号
|
||||
Integer headerRow = params.get("headerRow") != null ?
|
||||
Integer.valueOf(params.get("headerRow").toString()) : 1; // 表头所在行(默认第1行,从1开始)
|
||||
|
||||
@@ -536,48 +532,68 @@ public class TencentDocController extends BaseController {
|
||||
return AjaxResult.error("无法读取表头,请检查headerRow参数。API响应: " + headerData.toJSONString());
|
||||
}
|
||||
|
||||
// 自动识别列位置(如果未指定)
|
||||
Integer arrangedColumn = null; // "是否安排"列
|
||||
Integer markColumn = null; // "标记"列
|
||||
// 自动识别列位置(从表头中识别)
|
||||
Integer orderNoColumn = null; // "单号"列
|
||||
Integer logisticsLinkColumn = null; // "物流单号"列
|
||||
Integer arrangedColumn = null; // "是否安排"列
|
||||
Integer markColumn = null; // "标记"列
|
||||
|
||||
if (orderNoColumn == null || logisticsLinkColumn == null) {
|
||||
JSONArray headerRowData = headerValues.getJSONArray(0);
|
||||
if (headerRowData == null || headerRowData.isEmpty()) {
|
||||
return AjaxResult.error("无法识别表头,请手动指定列位置");
|
||||
}
|
||||
|
||||
// 查找所有相关列
|
||||
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("单号")) {
|
||||
orderNoColumn = i;
|
||||
log.info("识别到 '单号' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
if (logisticsLinkColumn == null && (cellValueTrim.contains("物流单号") || cellValueTrim.contains("物流链接"))) {
|
||||
logisticsLinkColumn = i;
|
||||
log.info("识别到 '物流单号' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
if (arrangedColumn == null && cellValueTrim.contains("是否安排")) {
|
||||
arrangedColumn = i;
|
||||
log.info("识别到 '是否安排' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
if (markColumn == null && cellValueTrim.contains("标记")) {
|
||||
markColumn = i;
|
||||
log.info("识别到 '标记' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
JSONArray headerRowData = headerValues.getJSONArray(0);
|
||||
if (headerRowData == null || headerRowData.isEmpty()) {
|
||||
return AjaxResult.error("无法识别表头,表头数据为空");
|
||||
}
|
||||
|
||||
// 查找所有相关列
|
||||
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("单号")) {
|
||||
orderNoColumn = i;
|
||||
log.info("✓ 识别到 '单号' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
|
||||
// 识别"物流单号"或"物流链接"列
|
||||
if (logisticsLinkColumn == null && (cellValueTrim.contains("物流单号") || cellValueTrim.contains("物流链接"))) {
|
||||
logisticsLinkColumn = i;
|
||||
log.info("✓ 识别到 '物流单号' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
|
||||
// 识别"是否安排"列(可选)
|
||||
if (arrangedColumn == null && cellValueTrim.contains("是否安排")) {
|
||||
arrangedColumn = i;
|
||||
log.info("✓ 识别到 '是否安排' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
|
||||
// 识别"标记"列(可选)
|
||||
if (markColumn == null && cellValueTrim.contains("标记")) {
|
||||
markColumn = i;
|
||||
log.info("✓ 识别到 '标记' 列:第 {} 列(索引{})", i + 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (orderNoColumn == null) {
|
||||
return AjaxResult.error("无法找到单号列,请手动指定orderNoColumn参数");
|
||||
}
|
||||
if (logisticsLinkColumn == null) {
|
||||
return AjaxResult.error("无法找到物流链接列,请手动指定logisticsLinkColumn参数");
|
||||
}
|
||||
}
|
||||
|
||||
// 检查必需的列是否都已识别
|
||||
if (orderNoColumn == null) {
|
||||
return AjaxResult.error("无法找到'单号'列,请检查表头是否包含'单号'字段");
|
||||
}
|
||||
if (logisticsLinkColumn == null) {
|
||||
return AjaxResult.error("无法找到'物流单号'或'物流链接'列,请检查表头");
|
||||
}
|
||||
|
||||
// 提示可选列的识别情况
|
||||
if (arrangedColumn == null) {
|
||||
log.warn("未找到'是否安排'列,将跳过该字段的更新");
|
||||
}
|
||||
if (markColumn == null) {
|
||||
log.warn("未找到'标记'列,将跳过该字段的更新");
|
||||
}
|
||||
|
||||
log.info("列位置识别完成 - 单号: {}, 物流单号: {}, 是否安排: {}, 标记: {}",
|
||||
orderNoColumn, logisticsLinkColumn, arrangedColumn, markColumn);
|
||||
|
||||
// 读取数据行
|
||||
// 使用 A1 表示法(Excel格式)
|
||||
String range = String.format("A%d:Z%d", startRow, endRow); // 例如:A3:Z203
|
||||
|
||||
Reference in New Issue
Block a user