subList 使用修复

master
wyb 2 years ago
parent d50ec5f69a
commit 3cab981a9a

@ -90,17 +90,17 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public void makeupReportByTaskIds(List<Long> taskIds) throws Exception { public void makeupReportByTaskIds(List<Long> taskIds) throws Exception {
int taskIdLength = taskIds.size();
// 定义一批200查询分批次 // 定义一批200查询分批次
final int oneBatchCount = 200; final int oneBatchCount = 200;
int startIndex; int startIndex = 0;
int toIndex = 0; int toIndex = oneBatchCount;
boolean loop = true;
do { do {
startIndex = toIndex; // 获取截取下标
toIndex = startIndex + oneBatchCount; if (taskIds.size() <= oneBatchCount) {
// 如果大于原来集合长度,最大截取就是集合长度 toIndex = taskIds.size();
if (toIndex >= taskIdLength) { // 最后一批截取
toIndex = taskIdLength; loop = false;
} }
// 截取每一批 // 截取每一批
List<Long> makeupTaskIds = taskIds.subList(startIndex, toIndex); List<Long> makeupTaskIds = taskIds.subList(startIndex, toIndex);
@ -114,6 +114,6 @@ public class ReportServiceImpl implements ReportService {
} }
} }
// 当截取长度小于集合长度,可以进行下次循环截取 // 当截取长度小于集合长度,可以进行下次循环截取
} while (toIndex < taskIdLength); } while (loop);
} }
} }

Loading…
Cancel
Save