写在前面

需求:

需要将totalList中的某些重复记录移除.思路是把需要移除的记录存入removeList,  然后遍历移除.

代码

            // 去除重复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();
                        }
                    }
                }
02-12 13:32