xuhy
2024-09-19 45403c689e2e0d6e69d32e1833faabc116f859e2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java
@@ -322,9 +322,9 @@
        List<PersonnelStatisticsVO> personnelStatisticsVOS = orderMealService.personnelStatistics(query);
        personnelStatisticsAndSumVO.setPersonnelStatisticsVOS(personnelStatisticsVOS);
        if(!CollectionUtils.isEmpty(personnelStatisticsVOS)){
            personnelStatisticsAndSumVO.setPersonCountSum(personnelStatisticsVOS.stream().mapToInt(PersonnelStatisticsVO::getPersonCount).sum());
            personnelStatisticsAndSumVO.setPersonCountSum(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToInt(PersonnelStatisticsVO::getPersonCount).sum());
            // 计算列表中平均金额乘以人数的总和
            personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().mapToDouble(personnelStatisticsVO -> personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()).sum());
            personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToDouble(personnelStatisticsVO -> personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()).sum());
        }
        return AjaxResult.success(personnelStatisticsAndSumVO);
    }