feat:智慧食堂
This commit is contained in:
1 parent
54cc574631
commit
d3c9cfc5c4
4 files changed
+37
-11
No files matched your search
+5
@@ -19,6 +19,11 @@ public class PanelCanteenVo {
|
||||
*/
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商家ID
|
||||
*/
|
||||
private Long mchId;
|
||||
|
||||
/**
|
||||
* 商家名称
|
||||
*/
|
||||
|
||||
+4
-4
@@ -61,14 +61,14 @@ public class PanelCanteenController {
|
||||
return R.ok(panelCanteenService.mchPayPersonCount(dto));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/mch-pay-person-count-trend")
|
||||
@PostMapping(value = "/pay-person-count-trend")
|
||||
@Operation(summary = "各个食堂的用餐人数(趋势)")
|
||||
public R<List<PanelCanteenVo>> mchPayPersonCountTrend(@RequestBody PanelCanteenDto dto) {
|
||||
public R<PanelCanteenVo.HourTypeVo> payPersonCountTrend(@RequestBody PanelCanteenDto dto) {
|
||||
dto.setTotalTimeList(new LocalDateTime[]{
|
||||
LocalDateTime.now().minusDays(6).withHour(0).withMinute(0).withSecond(0),
|
||||
LocalDateTime.now().minusDays(8).withHour(0).withMinute(0).withSecond(0),
|
||||
LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)
|
||||
});
|
||||
return R.ok(panelCanteenService.mchPayPersonCount(dto));
|
||||
return R.ok(panelCanteenService.groupByTimeAndHourType(dto));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/mch-pay-count-top")
|
||||
|
||||
+27
-6
@@ -3,13 +3,17 @@ package com.bsd.pjcloud.hard.service.impl.panel;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardHourTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.panel.PanelCanteenDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.hard.PanelCanteenVo;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.PanelCanteenService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
@@ -17,10 +21,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Validated
|
||||
@@ -31,6 +32,8 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
|
||||
private final HardOrderMapper hardOrderMapper;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
|
||||
/**
|
||||
* 用餐数据统计(根据时间段和日期分类统计)
|
||||
*/
|
||||
@@ -79,7 +82,9 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
*/
|
||||
@Override
|
||||
public List<PanelCanteenVo> mchPayPersonCount(PanelCanteenDto dto) {
|
||||
return hardOrderMapper.groupByMch(dto);
|
||||
List<PanelCanteenVo> list = hardOrderMapper.groupByMch(dto);
|
||||
disposePanelCanteenVoSetMchName(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +132,9 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
*/
|
||||
@Override
|
||||
public List<PanelCanteenVo> mchPayCountTop(PanelCanteenDto dto) {
|
||||
return hardOrderMapper.groupByMch(dto);
|
||||
List<PanelCanteenVo> list = hardOrderMapper.groupByMch(dto);
|
||||
disposePanelCanteenVoSetMchName(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<PanelCanteenVo> generatePanelCanteenList(LocalDateTime[] totalTimeList) {
|
||||
@@ -148,4 +155,18 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
return dateList;
|
||||
}
|
||||
|
||||
private void disposePanelCanteenVoSetMchName(List<PanelCanteenVo> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 商户名
|
||||
List<Long> mchIds = list.stream().map(PanelCanteenVo::getMchId).distinct().filter(ObjectUtil::isNotEmpty).toList();
|
||||
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
Map<Long, MchManageVo> mchMap = CollectionUtils.convertMap(mchList, MchManageVo::getId);
|
||||
for (PanelCanteenVo i : list) {
|
||||
MchManageVo mch = mchMap.get(i.getMchId());
|
||||
if (ObjectUtil.isNotEmpty(mch)) i.setMchName(mch.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -578,7 +578,7 @@
|
||||
</select>
|
||||
|
||||
<select id="groupByMch" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelCanteenVo">
|
||||
select o.merchant_id as mchName,
|
||||
select o.merchant_id as mchId,
|
||||
sum(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
count(distinct o.id) as buyCount,
|
||||
|
||||
Reference in new issue
Block a user