List去重

写在前面

需求:

将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==

 

转载于:https://www.cnblogs.com/yadongliang/p/11542815.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值