This commit is contained in:
van
2026-03-03 20:36:26 +08:00
parent a58891ef04
commit f321e40876
2 changed files with 18 additions and 12 deletions

View File

@@ -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,21 +173,24 @@ 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<>();
List<SuperAdmin> superAdminList = superAdminService.selectSuperAdminList(null);
for (SuperAdmin superAdmin : superAdminList) {
if (superAdmin.getIsCount() != null && superAdmin.getIsCount() == 0 && superAdmin.getUnionId() != null) {
try {
excludeUnionIds.add(Long.parseLong(superAdmin.getUnionId()));
} catch (NumberFormatException e) {
if (!forList) {
List<SuperAdmin> superAdminList = superAdminService.selectSuperAdminList(null);
for (SuperAdmin superAdmin : superAdminList) {
if (superAdmin.getIsCount() != null && superAdmin.getIsCount() == 0 && superAdmin.getUnionId() != null) {
try {
excludeUnionIds.add(Long.parseLong(superAdmin.getUnionId()));
} catch (NumberFormatException e) {
}
}
}
}

View File

@@ -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) {