diff --git a/prototype/src/main/java/org/hso/ecommerce/action/shop/CreateOrderAction.java b/prototype/src/main/java/org/hso/ecommerce/action/shop/CreateOrderAction.java index 854be3a..0102ced 100644 --- a/prototype/src/main/java/org/hso/ecommerce/action/shop/CreateOrderAction.java +++ b/prototype/src/main/java/org/hso/ecommerce/action/shop/CreateOrderAction.java @@ -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; diff --git a/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java b/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java index ba54b0f..79b6f01 100644 --- a/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java +++ b/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java @@ -11,10 +11,10 @@ import java.util.Optional; @Repository public interface WarehouseBookingPositionSlotEntryRepository extends JpaRepository { - @Query(value = "Select e.id, e.article_id, e.new_sum_slot, e.slot_id from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND e.article_id = :article GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true) + @Query(value = "Select e.* from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND e.article_id = :article GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true) List getByArticle(long article); - @Query(value = "Select e.id, e.article_id, e.new_sum_slot, e.slot_id from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND s.slot_num = :slotnum GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true) + @Query(value = "Select e.* from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND s.slot_num = :slotnum GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true) Optional getBySlotNum(long slotnum); } diff --git a/prototype/src/main/resources/templates/intern/warehouse/slots/index.html b/prototype/src/main/resources/templates/intern/warehouse/slots/index.html index 3d52f6b..b7e47f9 100644 --- a/prototype/src/main/resources/templates/intern/warehouse/slots/index.html +++ b/prototype/src/main/resources/templates/intern/warehouse/slots/index.html @@ -24,6 +24,10 @@
+

+ Es wird der Lagerstand angezeigt, der entsteht nachdem alle austehenden Lagerbuchungen auf der Packliste + angearbeitet wurden. +

Plätze in Verwendung