Java8分组并统计

    List<SceneShareRelationPoJo> list =
        list(
            query ->
                query
                    .getConditions()
                    .eq(AbstractEntityPoJo::getCompanyId, companyId)
                    .eq(SceneShareRelationPoJo::getFromEmployeeId, employeeId),
            SceneShareRelationPoJo.class);
            
        Map<Integer, List<SceneShareRelationPoJo>> collect =
            list.stream().collect(Collectors.groupingBy(SceneShareRelationPoJo::getType));

    Map<Integer, Long> collect =
        list.stream()
            .collect(Collectors.groupingBy(SceneShareRelationPoJo::getType, Collectors.counting()));

你可能感兴趣的:(Java8分组并统计)