写在前面
需求:
将totalList中的某些重复记录移除.(我这里的totalList中存的是对象)
思路:
是把需要移除的记录存入removeList, 然后遍历totalList, 如果totalList中的元素在removeList中, 将该元素从totalList中移除.(土了点, 能用...)
代码
resultList = financeService.selectCaTopupRec(filterMap);//充值记录 // 去除重复ref_no的记录 start== if (resultList != null && !resultList.isEmpty()) { List<String> needRemoveRefNoList = new ArrayList<>(); for (CaTopupRec caTopupRec : resultList) { if (caTopupRec.getTopupAmt().compareTo(BigDecimal.ZERO) < 0) { needRemoveRefNoList.add(caTopupRec.getRefNo()); } } if (!needRemoveRefNoList.isEmpty()) { for (Iterator<CaTopupRec> iterator = resultList.iterator(); iterator.hasNext(); ) { CaTopupRec next = iterator.next(); if (needRemoveRefNoList.contains(next.getRefNo())) { iterator.remove(); } } } } // 去除重复ref_no的记录 end==