feature/optimize_create_order_whbookings #117
@ -13,6 +13,7 @@ import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
 | 
			
		||||
 | 
			
		||||
import java.sql.Timestamp;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@ -101,7 +102,14 @@ public class CreateOrderAction {
 | 
			
		||||
        for (OrderItem item : orderItems) {
 | 
			
		||||
            int needed = item.quantity;
 | 
			
		||||
 | 
			
		||||
            // Sort for most empty slot first;
 | 
			
		||||
            item.availableSlots.sort(Comparator.comparingInt(a -> a.newSumSlot));
 | 
			
		||||
 | 
			
		||||
            for (WarehouseBookingPositionSlotEntry slot : item.availableSlots) {
 | 
			
		||||
                if (slot.newSumSlot == 0) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                int remove = Math.min(slot.newSumSlot, needed);
 | 
			
		||||
                needed -= remove;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user