gongchunyi
7 小时以前 263b034b4058bb7a36c709278abdc88ca1ba26c1
src/main/java/com/ruoyi/production/service/impl/ProductionCostServiceImpl.java
@@ -179,12 +179,24 @@
    private <T> IPage<T> getMemoryPage(Page<T> page, List<T> list) {
        int total = list.size();
        int size = (int) page.getSize();
        int current = (int) page.getCurrent();
        int fromIndex = (current - 1) * size;
        int toIndex = Math.min(fromIndex + size, total);
        long size = page.getSize();
        long current = page.getCurrent();
        List<T> subList = (fromIndex < total && fromIndex >= 0) ? list.subList(fromIndex, toIndex) : new ArrayList<>();
        if (size == -1 || current == -1) {
            page.setTotal(total);
            page.setRecords(list);
            return page;
        }
        int fromIndex = (int) ((current - 1) * size);
        int toIndex = Math.min(fromIndex + (int) size, total);
        List<T> subList;
        if (fromIndex >= 0 && fromIndex < total) {
            subList = list.subList(fromIndex, toIndex);
        } else {
            subList = new ArrayList<>();
        }
        page.setTotal(total);
        page.setRecords(subList);