Map<Long, FeeInfoVo> feeInfoVoMap=sortedList.stream().collect(Collectors.groupingBy( OasReceBillDto::getFeeId,Collectors.collectingAndThen(Collectors.toList(), m->{ FeeInfoVo sr=new FeeInfoVo(); BigDecimal amountAll= m.stream().collect( Collectors.reducing(BigDecimal.ZERO, OasReceBillDto::getReceAmount, BigDecimal::add) ); Optional<OasReceBillDto> min=m.stream().min(Comparator.comparing(OasReceBillDto::getBeginDate)); Optional<OasReceBillDto> max=m.stream().max(Comparator.comparing(OasReceBillDto::getEndDate)); sr.setFeeAmount(amountAll); sr.setStartDate(min.get().getBeginDate()); sr.setEndDate(max.get().getEndDate()); return sr; })));
stream流操作分组BigDecimal求和,获取最大时间和最小时间
最新推荐文章于 2025-02-09 21:50:44 发布