| | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | |
| | | 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.*; |
| | | |
| | |
| | | |
| | | @ApiOperation( value = "商品分类销售排行") |
| | | @PostMapping(value = "/salesRanking") |
| | | public AjaxResult<List<SalesRankingVO>> salesRanking(@RequestBody TDataStatisticsQuery query) { |
| | | public AjaxResult<PageInfo<SalesRankingVO>> salesRanking(@RequestBody TDataStatisticsQuery query) { |
| | | Integer roleType = tokenService.getLoginUser().getRoleType(); |
| | | Long objectId = tokenService.getLoginUser().getObjectId(); |
| | | query.setShopId(objectId); |
| | |
| | | } |
| | | query.setStartTime(DateUtils.localDateTimeToDate(startTime)); |
| | | query.setEndTime(DateUtils.localDateTimeToDate(endTime)); |
| | | List<SalesRankingVO> salesRankingVOS; |
| | | PageInfo<SalesRankingVO> salesRankingVOS; |
| | | if(roleType == 2){ |
| | | salesRankingVOS = orderMealService.salesRanking(query); |
| | | }else{ |
| | |
| | | |
| | | @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())){ |
| | |
| | | } |
| | | 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().filter(e->e.getPersonCount() != null).mapToInt(PersonnelStatisticsVO::getPersonCount).sum()); |
| | | // 计算列表中平均金额乘以人数的总和 |
| | | personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToDouble(personnelStatisticsVO -> personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()).sum()); |
| | | } |
| | | return AjaxResult.success(personnelStatisticsAndSumVO); |
| | | } |
| | | |
| | | |