11
This commit is contained in:
1 parent
0798720bd6
commit
b68f0bbad9
4 files changed
+103
-2
No files matched your search
+20
-1
@@ -1,15 +1,20 @@
|
||||
package com.bsd.pjcloud.hard.controller.panel;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.DateRangeTool;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.panel.PanelCanteenDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.hard.PanelCanteenVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.PanelCanteenService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -25,6 +30,7 @@ import java.util.List;
|
||||
public class PanelCanteenController {
|
||||
|
||||
private final PanelCanteenService panelCanteenService;
|
||||
private final HardOrderService hardwareOrderService;
|
||||
|
||||
@PostMapping(value = "/group/by-time-and-hour-type")
|
||||
@Operation(summary = "用餐数据统计(根据时间段和日期分类统计)")
|
||||
@@ -35,6 +41,15 @@ public class PanelCanteenController {
|
||||
return R.ok(panelCanteenService.groupByTimeAndHourType(dto));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/group/classify/by-time-and-hour-type")
|
||||
@Operation(summary = "菜品分类统计(根据时间段和日期分类统计)")
|
||||
public R<PanelCanteenVo.HourTypeVo> classifyGroupByTimeAndHourType(PanelCanteenDto dto) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isNotEmpty(dto.getTotalTimeList())) {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
return R.ok(panelCanteenService.classifyGroupByTimeAndHourType(dto));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/group/by-time-and-custom-hour")
|
||||
@Operation(summary = "用餐数据统计(根据自定义时间段和日期分类统计)")
|
||||
public R<List<PanelCanteenVo>> groupByTimeAndCustomHour(PanelCanteenDto dto) {
|
||||
@@ -54,5 +69,9 @@ public class PanelCanteenController {
|
||||
return R.ok(panelCanteenService.top(dto));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/new-page")
|
||||
@Operation(summary = "最新的吃饭数据")
|
||||
public R<Page<HardOrderVo>> newPage(@ParameterObject Page page, HardOrderDto dto) {
|
||||
return R.ok(hardwareOrderService.scopePageList(page, dto, null));
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.bsd.pjcloud.hard.redis;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 监听Redis的Key过期事件
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener {
|
||||
|
||||
@Resource
|
||||
private HardOrderMapper hardOrderMapper;
|
||||
|
||||
public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
|
||||
super(listenerContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
String expiredKey = message.toString();
|
||||
String expiredPattern = new String(pattern, StandardCharsets.UTF_8);
|
||||
|
||||
// 过期订单(扫一扫支付)
|
||||
if (expiredKey.startsWith(CacheConstants.HARDER_ORDER_NON_PAY)) {
|
||||
log.info("hard模块RedisKey过期,pattern|{}|key|{}|", expiredPattern, expiredKey);
|
||||
disposeExpiredQrCodeScanOrder(expiredKey);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除过期的扫一扫订单
|
||||
public void disposeExpiredQrCodeScanOrder(String expiredValue) {
|
||||
if (ObjectUtil.isEmpty(expiredValue)) return;
|
||||
|
||||
String orderId = expiredValue.substring(CacheConstants.HARDER_ORDER_NON_PAY.length() + 1);
|
||||
|
||||
HardOrderEntity order = hardOrderMapper.selectOne(new LambdaQueryWrapper<HardOrderEntity>()
|
||||
.eq(HardOrderEntity::getId, orderId)
|
||||
.eq(HardOrderEntity::getPayType, HardPayTypeEnum.WALLET_QR_CODE_SCAN.getType())
|
||||
.eq(HardOrderEntity::getOrderStatus, HardOrderStatusEnum.CREATE.getType())
|
||||
);
|
||||
if (ObjectUtil.isEmpty(order)) {
|
||||
log.info("删除过期的扫一扫订单,订单不存在orderId|{}|", orderId);
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(order.getWalletId()) && ObjectUtil.equals(order.getUserId(), -1L)) {
|
||||
// 删除订单
|
||||
hardOrderMapper.deleteById(order.getId());
|
||||
log.info("删除过期的扫一扫订单,orderId|{}|", expiredValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -12,6 +12,11 @@ public interface PanelCanteenService {
|
||||
*/
|
||||
PanelCanteenVo.HourTypeVo groupByTimeAndHourType(PanelCanteenDto dto);
|
||||
|
||||
/**
|
||||
* 菜品分类统计(根据时间段和日期分类统计)
|
||||
*/
|
||||
PanelCanteenVo.HourTypeVo classifyGroupByTimeAndHourType(PanelCanteenDto dto);
|
||||
|
||||
/**
|
||||
* 用餐数据统计(根据自定义时间段和日期分类统计)
|
||||
*/
|
||||
|
||||
+10
-1
@@ -72,6 +72,15 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜品分类统计(根据时间段和日期分类统计)
|
||||
*/
|
||||
@Override
|
||||
public PanelCanteenVo.HourTypeVo classifyGroupByTimeAndHourType(PanelCanteenDto dto) {
|
||||
List<PanelCanteenVo> sqlList = hardOrderMapper.groupByTimeAndHourType(dto);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用餐数据统计(根据时间段和日期分类统计)
|
||||
*/
|
||||
@@ -85,7 +94,7 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
*/
|
||||
@Override
|
||||
public List<PanelCanteenVo> top(PanelCanteenDto dto) {
|
||||
return hardOrderMapper.top(dto);
|
||||
return hardOrderMapper.top(dto);
|
||||
}
|
||||
|
||||
private List<PanelCanteenVo> generatePanelCanteenList(LocalDateTime[] totalTimeList) {
|
||||
|
||||
Reference in new issue
Block a user