diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index 52ad7579..dce30752 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -316,10 +316,23 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { allGroupingRecords.put(monitor, split); //存放至包装类中 Set keys = allGroupingRecords.keySet(); + + //对key进行反向排序,保证封装的数据是反着的 + ArrayList tempKeyList = new ArrayList<>(); + for (String key : keys) { + tempKeyList.add(key); + } + // 创建一个游标在迭代器末尾的迭代器 + ListIterator stringListIterator = tempKeyList.listIterator(tempKeyList.size()); + // 然后反向遍历 + ArrayList keyList = new ArrayList<>(); + while (stringListIterator.hasPrevious()) { + keyList.add(stringListIterator.previous()); + } ArrayList itemsDTOS = new ArrayList<>(); //定义一个计数器,只要前3个月的记录 int count = 0; - for (String key : keys) { + for (String key : keyList) { count++; if (count == 4) { break;