/**
* 将集合进行分组, 每toIndex条数据作为一组
* @param list 需要分组的集合
* @param toIndex 每组的条数
* @return
*/
private List<List<String>> groupList(List<String> list,int toIndex) {
if (CollectionUtils.isEmpty(list)) {
return Collections.EMPTY_LIST;
}
int size = list.size();
// 分组次数
int time = (size % 100) == 0 ? size / 100 : size / 100 + 1;
// 用result存储新的分组数据集合
List<List<String>> result = new ArrayList<>(time);
for (int i = 0; i < list.size(); i += 100) {
if (i + 100 > size) {
toIndex = size - i;
}
result.add(list.subList(i, i + toIndex));
}
return result;
}