1
This commit is contained in:
@@ -66,7 +66,8 @@ public class OrderRowsController extends BaseController
|
|||||||
TableDataInfo dataTable = getDataTable(list);
|
TableDataInfo dataTable = getDataTable(list);
|
||||||
Date beginTime = getDateFromParams(orderRows.getParams(), "beginTime");
|
Date beginTime = getDateFromParams(orderRows.getParams(), "beginTime");
|
||||||
Date endTime = getDateFromParams(orderRows.getParams(), "endTime");
|
Date endTime = getDateFromParams(orderRows.getParams(), "endTime");
|
||||||
dataTable.setStatistics(buildStatistics(orderRows, beginTime, endTime));
|
// 与列表同数据源,不排除 isCount=0,保证总订单数与分页 total 一致
|
||||||
|
dataTable.setStatistics(buildStatistics(orderRows, beginTime, endTime, true));
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,15 +173,17 @@ public class OrderRowsController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/statistics")
|
@GetMapping("/statistics")
|
||||||
public AjaxResult getStatistics(OrderRows orderRows, Date beginTime, Date endTime) {
|
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<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
List<Long> excludeUnionIds = new ArrayList<>();
|
List<Long> excludeUnionIds = new ArrayList<>();
|
||||||
|
if (!forList) {
|
||||||
List<SuperAdmin> superAdminList = superAdminService.selectSuperAdminList(null);
|
List<SuperAdmin> superAdminList = superAdminService.selectSuperAdminList(null);
|
||||||
for (SuperAdmin superAdmin : superAdminList) {
|
for (SuperAdmin superAdmin : superAdminList) {
|
||||||
if (superAdmin.getIsCount() != null && superAdmin.getIsCount() == 0 && superAdmin.getUnionId() != null) {
|
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);
|
List<OrderRows> filteredList = orderRowsService.selectOrderRowsListWithFilter(orderRows, beginTime, endTime, excludeUnionIds);
|
||||||
|
|
||||||
Map<String, List<String>> groups = new HashMap<>();
|
Map<String, List<String>> groups = new HashMap<>();
|
||||||
|
|||||||
@@ -1164,6 +1164,7 @@ public class TencentDocController extends BaseController {
|
|||||||
orderNoColumn, logisticsLinkColumn, remarkColumn, arrangedColumn, markColumn, phoneColumn);
|
orderNoColumn, logisticsLinkColumn, remarkColumn, arrangedColumn, markColumn, phoneColumn);
|
||||||
|
|
||||||
// 读取数据行:接口实际只能读 200 行,严格限制单次行数,失败时逐步缩小范围重试
|
// 读取数据行:接口实际只能读 200 行,严格限制单次行数,失败时逐步缩小范围重试
|
||||||
|
// 腾讯文档 get_range 的 range 为「结束行不包含」:要读到 endRow 含最后一行,须传 endRow+1
|
||||||
int effectiveEndRow = Math.min(endRow, startRow + READ_ROWS_WHEN_USE_ROW_TOTAL - 1);
|
int effectiveEndRow = Math.min(endRow, startRow + READ_ROWS_WHEN_USE_ROW_TOTAL - 1);
|
||||||
JSONObject sheetData = null;
|
JSONObject sheetData = null;
|
||||||
int[] retryDecrements = new int[] { 0, 20, 50, 100 };
|
int[] retryDecrements = new int[] { 0, 20, 50, 100 };
|
||||||
@@ -1177,7 +1178,8 @@ public class TencentDocController extends BaseController {
|
|||||||
if (tryEndRow < startRow) {
|
if (tryEndRow < startRow) {
|
||||||
continue;
|
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);
|
log.info("开始读取数据行 - 行号: {} ~ {} (共 {} 行), range: {} (尝试 decrement={})", startRow, tryEndRow, tryRowCount, range, decrement);
|
||||||
try {
|
try {
|
||||||
sheetData = tencentDocService.readSheetData(accessToken, fileId, sheetId, range);
|
sheetData = tencentDocService.readSheetData(accessToken, fileId, sheetId, range);
|
||||||
@@ -1207,7 +1209,7 @@ public class TencentDocController extends BaseController {
|
|||||||
for (int decrement : new int[] { 1, 10 }) {
|
for (int decrement : new int[] { 1, 10 }) {
|
||||||
int tryEndRow = Math.max(startRow, effectiveEndRow - decrement);
|
int tryEndRow = Math.max(startRow, effectiveEndRow - decrement);
|
||||||
if (tryEndRow >= startRow) {
|
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 {
|
try {
|
||||||
sheetData = tencentDocService.readSheetData(accessToken, fileId, sheetId, retryRange);
|
sheetData = tencentDocService.readSheetData(accessToken, fileId, sheetId, retryRange);
|
||||||
if (sheetData != null) {
|
if (sheetData != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user