Merge pull request 'feature/optimize_create_order_whbookings' (#117) from feature/optimize_create_order_whbookings into master
Reviewed-on: #117 Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
This commit is contained in:
commit
e87d0d8cdd
|
@ -13,6 +13,7 @@ import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -101,7 +102,14 @@ public class CreateOrderAction {
|
||||||
for (OrderItem item : orderItems) {
|
for (OrderItem item : orderItems) {
|
||||||
int needed = item.quantity;
|
int needed = item.quantity;
|
||||||
|
|
||||||
|
// Sort for most empty slot first;
|
||||||
|
item.availableSlots.sort(Comparator.comparingInt(a -> a.newSumSlot));
|
||||||
|
|
||||||
for (WarehouseBookingPositionSlotEntry slot : item.availableSlots) {
|
for (WarehouseBookingPositionSlotEntry slot : item.availableSlots) {
|
||||||
|
if (slot.newSumSlot == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int remove = Math.min(slot.newSumSlot, needed);
|
int remove = Math.min(slot.newSumSlot, needed);
|
||||||
needed -= remove;
|
needed -= remove;
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ import java.util.Optional;
|
||||||
@Repository
|
@Repository
|
||||||
public interface WarehouseBookingPositionSlotEntryRepository extends JpaRepository<WarehouseBookingPositionSlotEntry, Long> {
|
public interface WarehouseBookingPositionSlotEntryRepository extends JpaRepository<WarehouseBookingPositionSlotEntry, Long> {
|
||||||
|
|
||||||
@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<WarehouseBookingPositionSlotEntry> getByArticle(long article);
|
List<WarehouseBookingPositionSlotEntry> 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<WarehouseBookingPositionSlotEntry> getBySlotNum(long slotnum);
|
Optional<WarehouseBookingPositionSlotEntry> getBySlotNum(long slotnum);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
<main class="sidebar-layout content-width">
|
<main class="sidebar-layout content-width">
|
||||||
<nav th:replace="fragments/intern :: sidebar"></nav>
|
<nav th:replace="fragments/intern :: sidebar"></nav>
|
||||||
<div class="content-width">
|
<div class="content-width">
|
||||||
|
<p>
|
||||||
|
Es wird der Lagerstand angezeigt, der entsteht nachdem alle austehenden Lagerbuchungen auf der Packliste
|
||||||
|
angearbeitet wurden.
|
||||||
|
</p>
|
||||||
<!-- Dirty -->
|
<!-- Dirty -->
|
||||||
<div style="min-width: 10rem; display: inline-block; margin: var(--u0);">
|
<div style="min-width: 10rem; display: inline-block; margin: var(--u0);">
|
||||||
<h3>Plätze in Verwendung</h3>
|
<h3>Plätze in Verwendung</h3>
|
||||||
|
|
Reference in New Issue