From df8bbae8096c4d0f65de373260410bfb9150d146 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 18 九月 2024 16:45:50 +0800
Subject: [PATCH] 修改接口

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java
index b10c644..a0fba52 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java
@@ -20,6 +20,7 @@
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -284,7 +285,7 @@
 
     @ApiOperation( value = "接待人数统计")
     @PostMapping(value = "/personnelStatistics")
-    public AjaxResult<List<PersonnelStatisticsVO>> personnelStatistics(@RequestBody TDataStatisticsQuery query) {
+    public AjaxResult<PersonnelStatisticsAndSumVO> personnelStatistics(@RequestBody TDataStatisticsQuery query) {
         Long objectId = tokenService.getLoginUser().getObjectId();
         query.setShopId(objectId);
         if(Objects.isNull(query.getTimeType())){
@@ -316,7 +317,16 @@
         }
         query.setStartTime(DateUtils.localDateTimeToDate(startTime));
         query.setEndTime(DateUtils.localDateTimeToDate(endTime));
-        return AjaxResult.success(orderMealService.personnelStatistics(query));
+
+        PersonnelStatisticsAndSumVO personnelStatisticsAndSumVO = new PersonnelStatisticsAndSumVO();
+        List<PersonnelStatisticsVO> personnelStatisticsVOS = orderMealService.personnelStatistics(query);
+        personnelStatisticsAndSumVO.setPersonnelStatisticsVOS(personnelStatisticsVOS);
+        if(!CollectionUtils.isEmpty(personnelStatisticsVOS)){
+            personnelStatisticsAndSumVO.setPersonCountSum(personnelStatisticsVOS.stream().mapToInt(PersonnelStatisticsVO::getPersonCount).sum());
+            // 计算列表中平均金额乘以人数的总和
+            personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().mapToDouble(personnelStatisticsVO -> personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()).sum());
+        }
+        return AjaxResult.success(personnelStatisticsAndSumVO);
     }
 
 

--
Gitblit v1.7.1