| Line 37... |
Line 37... |
| 37 |
|
37 |
|
| 38 |
import javax.servlet.http.HttpServletRequest;
|
38 |
import javax.servlet.http.HttpServletRequest;
|
| 39 |
import java.time.LocalDate;
|
39 |
import java.time.LocalDate;
|
| 40 |
import java.time.LocalDateTime;
|
40 |
import java.time.LocalDateTime;
|
| 41 |
import java.util.ArrayList;
|
41 |
import java.util.ArrayList;
|
| - |
|
42 |
import java.util.HashMap;
|
| 42 |
import java.util.List;
|
43 |
import java.util.List;
|
| 43 |
import java.util.Map;
|
44 |
import java.util.Map;
|
| 44 |
import java.util.Set;
|
45 |
import java.util.Set;
|
| 45 |
import java.util.HashSet;
|
46 |
import java.util.HashSet;
|
| 46 |
import java.util.function.Function;
|
47 |
import java.util.function.Function;
|
| Line 251... |
Line 252... |
| 251 |
Map<Integer, CustomerAddress> addressMap = customerAddressRepository.selectAllByIds(addressIds).stream()
|
252 |
Map<Integer, CustomerAddress> addressMap = customerAddressRepository.selectAllByIds(addressIds).stream()
|
| 252 |
.collect(Collectors.toMap(CustomerAddress::getId, Function.identity()));
|
253 |
.collect(Collectors.toMap(CustomerAddress::getId, Function.identity()));
|
| 253 |
|
254 |
|
| 254 |
// Batch fetch all items
|
255 |
// Batch fetch all items
|
| 255 |
Set<Integer> itemIds = allOrderItems.stream().map(FofoOrderItem::getItemId).collect(Collectors.toSet());
|
256 |
Set<Integer> itemIds = allOrderItems.stream().map(FofoOrderItem::getItemId).collect(Collectors.toSet());
|
| - |
|
257 |
// A customer whose only order is an insurance-only sale has no fofo_order_item rows, so
|
| - |
|
258 |
// itemIds is empty and selectByIds would throw "List should not be empty" on the empty IN.
|
| - |
|
259 |
Map<Integer, Item> itemMap = itemIds.isEmpty()
|
| - |
|
260 |
? new HashMap<>()
|
| 256 |
Map<Integer, Item> itemMap = itemRepository.selectByIds(new ArrayList<>(itemIds)).stream()
|
261 |
: itemRepository.selectByIds(new ArrayList<>(itemIds)).stream()
|
| 257 |
.collect(Collectors.toMap(Item::getId, Function.identity()));
|
262 |
.collect(Collectors.toMap(Item::getId, Function.identity()));
|
| 258 |
|
263 |
|
| 259 |
// Batch fetch all line items
|
264 |
// Batch fetch all line items
|
| 260 |
Set<Integer> orderItemIds = allOrderItems.stream().map(FofoOrderItem::getId).collect(Collectors.toSet());
|
265 |
Set<Integer> orderItemIds = allOrderItems.stream().map(FofoOrderItem::getId).collect(Collectors.toSet());
|
| 261 |
List<FofoLineItem> allLineItems = fofoLineItemRepository.selectByFofoOrderItemIds(orderItemIds);
|
266 |
List<FofoLineItem> allLineItems = fofoLineItemRepository.selectByFofoOrderItemIds(orderItemIds);
|
| 262 |
Map<Integer, List<FofoLineItem>> lineItemsByOrderItemId = allLineItems.stream()
|
267 |
Map<Integer, List<FofoLineItem>> lineItemsByOrderItemId = allLineItems.stream()
|