This commit is contained in:
YAS\29473
2025-09-26 14:55:18 +08:00
parent 297405471e
commit 60ced96cb5
3 changed files with 43 additions and 15 deletions

View File

@@ -923,7 +923,7 @@ public class TempController extends BaseController {
RestApiResponse<?> response = null;
try {
//stationId ,merchantIdList,stationIdList,merchantId,startTime,endTime
List<OrderCountByTimeVO> result = tempService.queryOrderCountByTime(dto);
OrderCountByTimeVO result = tempService.queryOrderCountByTime(dto);
response = new RestApiResponse<>(result);
} catch (Exception e) {
logger.error("时间区间查询订单统计 error", e);

View File

@@ -1280,7 +1280,7 @@ public class TempService {
* @param dto
* @return
*/
public List<OrderCountByTimeVO> queryOrderCountByTime(QueryOrderDTO dto) {
public OrderCountByTimeVO queryOrderCountByTime(QueryOrderDTO dto) {
// 处理时间默认值
if (dto == null) {
dto = new QueryOrderDTO();
@@ -1301,7 +1301,7 @@ public class TempService {
List<OrderListVO> orderListVOS = orderBasicInfoMapper.selectOrderBasicInfoList(dto);
//统计订单
List<OrderCountByTimeVO> result = new ArrayList<>();
List<OrderCountByTimeVO.OrderCountByTimeListVO> result = new ArrayList<>();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS);
try {
// 将开始时间和结束时间转换为LocalDateTime类型
@@ -1332,22 +1332,32 @@ public class TempService {
LocalDateTime nextHour = currentHour.plusHours(1);
int count = ordersByHour.getOrDefault(currentHour, Collections.emptyList()).size();
OrderCountByTimeVO vo = new OrderCountByTimeVO();
OrderCountByTimeVO.OrderCountByTimeListVO vo = new OrderCountByTimeVO.OrderCountByTimeListVO();
vo.setStartTime(currentHour.format(dateTimeFormatter));
vo.setEndTime(nextHour.format(dateTimeFormatter));
vo.setCount(count);
vo.setOrderCount(count);
result.add(vo);
currentHour = nextHour;
}
// 按开始时间排序
result.sort(Comparator.comparing(OrderCountByTimeVO::getStartTime));
result.sort(Comparator.comparing(OrderCountByTimeVO.OrderCountByTimeListVO::getStartTime));
} catch (Exception e) {
logger.error("统计订单数量失败", e);
}
logger.info("查询订单数量结果:{}", JSONObject.toJSONString(result));
return result;
OrderCountByTimeVO orderCountByTimeVO = new OrderCountByTimeVO();
orderCountByTimeVO.setOrderCountByTimeList(result);
//订单总数
Integer totalCount = 0;
for (OrderCountByTimeVO.OrderCountByTimeListVO vo : result) {
totalCount += vo.getCount();
}
orderCountByTimeVO.setTotalCount(totalCount);
return orderCountByTimeVO;
}
public void updateWalletCode() {