package com.poyee.util; import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.List; /** * @param */ @Slf4j public class BeanUtils { public static List> batchList(List sourceList, int batchCount) { List> returnList = new ArrayList<>(); int startIndex = 0; // 从第0个下标开始 while (startIndex < sourceList.size()) { int endIndex = 0; if (sourceList.size() - batchCount < startIndex) { endIndex = sourceList.size(); } else { endIndex = startIndex + batchCount; } returnList.add(sourceList.subList(startIndex, endIndex)); startIndex = startIndex + batchCount; // 下一批 } return returnList; } }