统计接口,最下面加 总计 一行时
public List<GateBaseBResultStatis> gateBaseBResultStatisTotal(List<GateBaseBResultStatis> list){ GateBaseBResultStatis model = new GateBaseBResultStatis(); model.setAddvcd("总计"); model.setTotalCount(list.stream().map(GateBaseBResultStatis :: getTotalCount).reduce(BigDecimal.ZERO, BigDecimal :: add).setScale(2, BigDecimal.ROUND_HALF_UP)); model.setGateNumberCount(list.stream().map(GateBaseBResultStatis :: getGateNumberCount).reduce(BigDecimal.ZERO, BigDecimal :: add).setScale(2, BigDecimal.ROUND_HALF_UP)); model.setGateNumberRate(model.getGateNumberCount().divide(model.getTotalCount(), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")) + "%"); list.add(model); return list; }
需要注意,属性也要用BigDecimal 修饰,否则 BigDecimal :: add 不能用
//总计 private BigDecimal totalCount;