List<WmsOutboundPushInfo> models = this.findByStatus(whCode, statusList,pushNum,2); if (models.isEmpty()) { return; } int pageSize = 500;// 条数 int listCount = models.size(); int totalPage = listCount % pageSize > 0 ? listCount / pageSize + 1 : listCount / pageSize; for (int i = 0; i < totalPage; i++) { List<WmsOutboundPushInfo> modelList = pageBySubList(models, pageSize, i + 1); this.updateOutboundPushInfo(modelList); }
/** * 利用subList方法进行分页 * * @param list 分页数据 * @param pageSize 页面大小 * @param currentPage 当前页面 */ public List<WmsOutboundPushInfo> pageBySubList(List<WmsOutboundPushInfo> list, int pageSize, int currentPage) { int totalCount = list.size(); int pageCount = 0; List<WmsOutboundPushInfo> subList; int m = totalCount % pageSize; if (m > 0) { pageCount = totalCount / pageSize + 1; } else { pageCount = totalCount / pageSize; } if (m == 0) { subList = list.subList((currentPage - 1) * pageSize, pageSize * (currentPage)); } else { if (currentPage == pageCount) { subList = list.subList((currentPage - 1) * pageSize, totalCount); } else { subList = list.subList((currentPage - 1) * pageSize, pageSize * (currentPage)); } } return subList; }