9.过滤集合中重复的数据

   private void printTransferCustomerRepeatDataLog(Long groupId, Long taskId, List shopCustomerVOListAll) {
        // 1.首先获取每个对象在集合中出现的个数
        Map countMap = shopCustomerVOListAll.stream()
            .filter(t -> ObjectUtils.isNotEmpty(t.getNickInfoList())
                && !t.getNickInfoList().get(0).getNick().equals(t.getNickInfoList().get(0).getPlatform()))
            .collect(Collectors.toMap(vo -> String.format(CacheKeyConstant.CUSTOMER_TRANSFER_KEY,
                vo.getNickInfoList().get(0).getNick(), vo.getNickInfoList().get(0).getPlatform()), value -> 1, (value1, value2) -> value1 + value2));

         // 2.过滤出重复的数据
        List repeatShopCustomerVO = shopCustomerVOListAll.stream().filter(t -> ObjectUtils.isNotEmpty(t.getNickInfoList())
            && countMap.get(String.format(CacheKeyConstant.CUSTOMER_TRANSFER_KEY, t.getNickInfoList().get(0).getNick(),
            t.getNickInfoList().get(0).getPlatform())) > 1).collect(Collectors.toList());
        JobLog.info("[{}][{}] bobo筛选一个会员对应多个导购,任务Id[{}]查询待转移客户数据{}",
            ServiceTypeEnum.CUSTOMER_TRANSFER_TASK_PRE_PROCESS.getName(), groupId,
            taskId, JSON.toJSONString(repeatShopCustomerVO));
    }

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章