fix(租柜单元格): 修复查询租用单元格最新订单时的空列表问题

当租用单元格列表为空时,避免执行不必要的查询操作
This commit is contained in:
dzq 2025-07-01 15:28:09 +08:00
parent 2bf2494383
commit a068d54493
1 changed files with 11 additions and 9 deletions

View File

@ -41,16 +41,18 @@ public class CabinetCellApplicationService {
.filter(cell -> cell.getIsRented().equals(1))
.collect(Collectors.toList());
List<CabinetCellLatestOrderDTO> cellLatestOrderDTOS = cabinetCellService.selectLatestOrderInfoByCell(rentingCells.stream()
.map(CabinetCellWithOrderCountDTO::getCellId).collect(Collectors.toList()));
if (!rentingCells.isEmpty()) {
List<CabinetCellLatestOrderDTO> cellLatestOrderDTOS = cabinetCellService.selectLatestOrderInfoByCell(rentingCells.stream()
.map(CabinetCellWithOrderCountDTO::getCellId).collect(Collectors.toList()));
for (CabinetCellWithOrderCountDTO cell : rentingCells) {
cellLatestOrderDTOS.stream()
.filter(order -> order.getCellId().equals(cell.getCellId()))
.findFirst()
.ifPresent(order -> {
BeanUtils.copyProperties(order, cell);
});
for (CabinetCellWithOrderCountDTO cell : rentingCells) {
cellLatestOrderDTOS.stream()
.filter(order -> order.getCellId().equals(cell.getCellId()))
.findFirst()
.ifPresent(order -> {
BeanUtils.copyProperties(order, cell);
});
}
}
return new PageDTO<>(list, page.getTotal());