Compare commits
2 Commits
26f6f6e058
...
f321e40876
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f321e40876 | ||
|
|
a58891ef04 |
@@ -66,7 +66,8 @@ public class OrderRowsController extends BaseController
|
||||
TableDataInfo dataTable = getDataTable(list);
|
||||
Date beginTime = getDateFromParams(orderRows.getParams(), "beginTime");
|
||||
Date endTime = getDateFromParams(orderRows.getParams(), "endTime");
|
||||
dataTable.setStatistics(buildStatistics(orderRows, beginTime, endTime));
|
||||
// 与列表同数据源,不排除 isCount=0,保证总订单数与分页 total 一致
|
||||
dataTable.setStatistics(buildStatistics(orderRows, beginTime, endTime, true));
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
@@ -172,15 +173,17 @@ public class OrderRowsController extends BaseController
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public AjaxResult getStatistics(OrderRows orderRows, Date beginTime, Date endTime) {
|
||||
return AjaxResult.success(buildStatistics(orderRows, beginTime, endTime));
|
||||
return AjaxResult.success(buildStatistics(orderRows, beginTime, endTime, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按列表相同条件构建统计数据(与 selectOrderRowsList 同条件:日期、unionId 等,排除 isCount=0)
|
||||
* 构建统计数据。
|
||||
* @param forList true=与列表同数据源(不排除 isCount=0),保证总订单数与分页一致;false=独立统计(排除 isCount=0)
|
||||
*/
|
||||
private Map<String, Object> buildStatistics(OrderRows orderRows, Date beginTime, Date endTime) {
|
||||
private Map<String, Object> buildStatistics(OrderRows orderRows, Date beginTime, Date endTime, boolean forList) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<Long> excludeUnionIds = new ArrayList<>();
|
||||
if (!forList) {
|
||||
List<SuperAdmin> superAdminList = superAdminService.selectSuperAdminList(null);
|
||||
for (SuperAdmin superAdmin : superAdminList) {
|
||||
if (superAdmin.getIsCount() != null && superAdmin.getIsCount() == 0 && superAdmin.getUnionId() != null) {
|
||||
@@ -190,6 +193,7 @@ public class OrderRowsController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<OrderRows> filteredList = orderRowsService.selectOrderRowsListWithFilter(orderRows, beginTime, endTime, excludeUnionIds);
|
||||
|
||||
Map<String, List<String>> groups = new HashMap<>();
|
||||
|
||||
@@ -105,7 +105,7 @@ public class TencentDocConfigController extends BaseController {
|
||||
if (rowCount > 0) {
|
||||
config.put("currentProgress", rowCount);
|
||||
int effectiveStart = startRow != null ? startRow : 3;
|
||||
int nextStartRow = Math.max(effectiveStart, rowCount - 200);
|
||||
int nextStartRow = Math.max(effectiveStart, rowCount - 199); // 与填充逻辑一致,含最后一行共200行
|
||||
config.put("nextStartRow", nextStartRow);
|
||||
config.put("progressHint", String.format("表格当前有 %d 行数据(从接口获取),下次将从第 %d 行开始", rowCount, nextStartRow));
|
||||
} else {
|
||||
|
||||
@@ -998,9 +998,9 @@ public class TencentDocController extends BaseController {
|
||||
startRow = forceStartRow;
|
||||
endRow = Math.min(rowTotal, startRow + READ_ROWS_WHEN_USE_ROW_TOTAL - 1);
|
||||
} else {
|
||||
// startRow = rowTotal - 200,且必须大于 2(>= MIN_START_ROW_WHEN_USE_ROW_TOTAL)
|
||||
// startRow = rowCount - 199,使 endRow 能取到 rowCount,不漏最后一行(共 200 行含最后一行)
|
||||
startRow = Math.max(MIN_START_ROW_WHEN_USE_ROW_TOTAL,
|
||||
Math.max(effectiveStartRow, rowTotal - READ_ROWS_WHEN_USE_ROW_TOTAL));
|
||||
Math.max(effectiveStartRow, rowTotal - (READ_ROWS_WHEN_USE_ROW_TOTAL - 1)));
|
||||
endRow = Math.min(rowTotal, startRow + READ_ROWS_WHEN_USE_ROW_TOTAL - 1);
|
||||
}
|
||||
log.info("使用接口 rowCount={},本次范围: 第 {} ~ {} 行(共 {} 行,单次最多 {} 行)",
|
||||
@@ -1030,10 +1030,10 @@ public class TencentDocController extends BaseController {
|
||||
}
|
||||
if (rowTotal > 0) {
|
||||
if (startRow > rowTotal) {
|
||||
// 配置/缓存的起始行超出表尾时,必须忽略 effectiveStartRow,按 rowTotal 回溯
|
||||
startRow = Math.max(MIN_START_ROW_WHEN_USE_ROW_TOTAL, rowTotal - READ_ROWS_WHEN_USE_ROW_TOTAL);
|
||||
// 按 rowCount 回溯,且保证 endRow=rowCount 不漏最后一行(rowCount - 199 起共 200 行)
|
||||
startRow = Math.max(MIN_START_ROW_WHEN_USE_ROW_TOTAL, rowTotal - (READ_ROWS_WHEN_USE_ROW_TOTAL - 1));
|
||||
endRow = Math.min(rowTotal, startRow + READ_ROWS_WHEN_USE_ROW_TOTAL - 1);
|
||||
log.info("按 rowCount={} 修正范围(忽略超出表尾的配置起始行): 第 {} ~ {} 行", rowTotal, startRow, endRow);
|
||||
log.info("按 rowCount={} 修正范围(含最后一行): 第 {} ~ {} 行", rowTotal, startRow, endRow);
|
||||
} else if (endRow > rowTotal) {
|
||||
endRow = rowTotal;
|
||||
log.info("按 rowTotal={} 截断结束行: endRow={}", rowTotal, endRow);
|
||||
@@ -1164,6 +1164,7 @@ public class TencentDocController extends BaseController {
|
||||
orderNoColumn, logisticsLinkColumn, remarkColumn, arrangedColumn, markColumn, phoneColumn);
|
||||
|
||||
// 读取数据行:接口实际只能读 200 行,严格限制单次行数,失败时逐步缩小范围重试
|
||||
// 腾讯文档 get_range 的 range 为「结束行不包含」:要读到 endRow 含最后一行,须传 endRow+1
|
||||
int effectiveEndRow = Math.min(endRow, startRow + READ_ROWS_WHEN_USE_ROW_TOTAL - 1);
|
||||
JSONObject sheetData = null;
|
||||
int[] retryDecrements = new int[] { 0, 20, 50, 100 };
|
||||
@@ -1177,7 +1178,8 @@ public class TencentDocController extends BaseController {
|
||||
if (tryEndRow < startRow) {
|
||||
continue;
|
||||
}
|
||||
String range = String.format("A%d:%s%d", startRow, DATA_RANGE_COL_END, tryEndRow);
|
||||
int rangeEndInclusive = tryEndRow + 1; // API 结束行不包含,+1 才能读到 tryEndRow 行
|
||||
String range = String.format("A%d:%s%d", startRow, DATA_RANGE_COL_END, rangeEndInclusive);
|
||||
log.info("开始读取数据行 - 行号: {} ~ {} (共 {} 行), range: {} (尝试 decrement={})", startRow, tryEndRow, tryRowCount, range, decrement);
|
||||
try {
|
||||
sheetData = tencentDocService.readSheetData(accessToken, fileId, sheetId, range);
|
||||
@@ -1207,7 +1209,7 @@ public class TencentDocController extends BaseController {
|
||||
for (int decrement : new int[] { 1, 10 }) {
|
||||
int tryEndRow = Math.max(startRow, effectiveEndRow - decrement);
|
||||
if (tryEndRow >= startRow) {
|
||||
String retryRange = String.format("A%d:%s%d", startRow, DATA_RANGE_COL_END, tryEndRow);
|
||||
String retryRange = String.format("A%d:%s%d", startRow, DATA_RANGE_COL_END, tryEndRow + 1); // API 结束行不包含
|
||||
try {
|
||||
sheetData = tencentDocService.readSheetData(accessToken, fileId, sheetId, retryRange);
|
||||
if (sheetData != null) {
|
||||
|
||||
@@ -295,7 +295,7 @@ public class TencentDocDelayedPushServiceImpl implements ITencentDocDelayedPushS
|
||||
int rowTotal = tencentDocService.getSheetRowTotal(accessToken, fileId, sheetId);
|
||||
if (rowTotal > 0) {
|
||||
if (startRow > rowTotal) {
|
||||
batchStartRow = Math.max(MIN_START_ROW_WHEN_USE_ROW_TOTAL, rowTotal - READ_ROWS_WHEN_USE_ROW_TOTAL);
|
||||
batchStartRow = Math.max(MIN_START_ROW_WHEN_USE_ROW_TOTAL, rowTotal - (READ_ROWS_WHEN_USE_ROW_TOTAL - 1));
|
||||
batchEndRow = Math.min(rowTotal, batchStartRow + READ_ROWS_WHEN_USE_ROW_TOTAL - 1);
|
||||
log.info("配置起始行 {} 超出表尾 rowTotal={},修正为第 {} ~ {} 行", startRow, rowTotal, batchStartRow, batchEndRow);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user