zoukankan      html  css  js  c++  java
  • 分页

    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;
        }
  • 相关阅读:
    Java自学二十六天
    Java自学三十四天
    Java自学三十二天
    Java自学三十天
    Java开学考试心得
    Java自学二十九天
    Java自学二十八天
    Java自学三十一天
    Java自学三十三天
    2020年月12日Java学习日记
  • 原文地址:https://www.cnblogs.com/lanliying/p/15386411.html
Copyright © 2011-2022 走看看