subList 使用修复

master
wyb 2 years ago
parent d50ec5f69a
commit 3cab981a9a

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

Loading…
Cancel
Save