//List 需要导入的数据
int count = 1000;//每批次导入的数目
int Lastindex = count;
List<List<T>> shareList = new ArrayList<>();
for(int index = 0;index < List.size()){
if(Lastindex >= List.size){
Lastindex = List.size();
shareList.add(List.subList(index,Lastindex));
break;
} else {
shareList.add(List.subList(index,Lastindex));
index = Lastindex ;//设置下一次标记
Lastindex = index + (count - 1);
}
}
if(CollectionUtils.isNoEmpty(shareList)){
for(List<T> subList : shareList){
TMapper.insert(subList);
}
}
}
网友评论