List<EnterpriseReportStatistic> list = enterpriseReportStatisticMapper.getPlanFilingData();int max = list.stream().filter(x -> x.getCode().equals(enterpriseReportStatistic.getCode())).mapToInt((x)->Integer.valueOf(NumberUtil.decimalFormat("0", x.getMonitorNum()))).summaryStatistics().getMax();
实体类集合筛选->类型转换(指定字段)->统计->求和
List<EnterpriseReportStatistic> list = enterpriseReportStatisticMapper.getPlanFilingData();long sum = list.stream().filter(x -> x.getCode().equals(enterpriseReportStatistic.getCode())).mapToInt((x)->Integer.valueOf(NumberUtil.decimalFormat("0", x.getShouldReportNum()))).summaryStatistics().getSum();
实体类集合筛选->类型转换(指定字段)->统计->求均值
List<EnterpriseReportStatistic> list = enterpriseReportStatisticMapper.getPlanFilingData();double average = list.stream().filter(x -> x.getCode().equals(enterpriseReportStatistic.getCode())).mapToDouble((x)->Double.valueOf(NumberUtil.decimalFormat("0", x.getFinishRate()))).summaryStatistics().getAverage();
确保集合中的指定字段为“指定值”的要素排在最后一位
List<HashMap<String,Object>> oneList =newArrayList<>();
oneList.sort((o1, o2)->{if("指定值".equals(o1.get("指定字段"))){return1;// Always push "指定值" to the end}elseif("指定值".equals(o2.get("指定字段"))){return-1;// Always pull "指定值" to the front}return0;// Keep the order unchanged for other elements});