1.2.0
Issue: 002 Fix unassigned item pagination across assigned pages - Keep unassigned items off earlier assigned pages - Begin unassigned items after the last assigned slot - Continue remaining unassigned items on subsequent pages - Prevent unassigned item duplication between pages - Preserve existing assigned item slot placement
This commit is contained in:
1 parent
cb75e2bca7
commit
b6d376a2f9
2 files changed
+68
-108
No files matched your search
@@ -19,6 +19,7 @@ public class ItemsPagination {
|
||||
|
||||
int highestAssignedPage = -1;
|
||||
int unassigned = 0;
|
||||
int lastPageHighestSlot = 8;
|
||||
|
||||
for (WarehouseItem item : items) {
|
||||
|
||||
@@ -46,52 +47,52 @@ public class ItemsPagination {
|
||||
|
||||
}
|
||||
|
||||
int consumed = 0;
|
||||
if (highestAssignedPage < 0) {
|
||||
|
||||
for (int assignedPage = 0;
|
||||
assignedPage <= highestAssignedPage;
|
||||
assignedPage++) {
|
||||
int pages =
|
||||
(unassigned + 44) / 45;
|
||||
|
||||
int highestSlot = 8;
|
||||
|
||||
for (WarehouseItem item : items) {
|
||||
|
||||
if (
|
||||
item.page() != null
|
||||
&&
|
||||
item.slot() != null
|
||||
&&
|
||||
item.page() == assignedPage + 1
|
||||
) {
|
||||
|
||||
highestSlot =
|
||||
Math.max(
|
||||
highestSlot,
|
||||
item.slot()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
consumed +=
|
||||
Math.max(
|
||||
0,
|
||||
53 - highestSlot
|
||||
);
|
||||
return Math.max(
|
||||
0,
|
||||
pages - 1
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
consumed =
|
||||
Math.min(
|
||||
consumed,
|
||||
unassigned
|
||||
for (WarehouseItem item : items) {
|
||||
|
||||
if (
|
||||
item.page() != null
|
||||
&&
|
||||
item.slot() != null
|
||||
&&
|
||||
item.page() == highestAssignedPage + 1
|
||||
) {
|
||||
|
||||
lastPageHighestSlot =
|
||||
Math.max(
|
||||
lastPageHighestSlot,
|
||||
item.slot()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int availableOnLastAssignedPage =
|
||||
Math.max(
|
||||
0,
|
||||
53 - lastPageHighestSlot
|
||||
);
|
||||
|
||||
unassigned -= consumed;
|
||||
int remainingUnassigned =
|
||||
Math.max(
|
||||
0,
|
||||
unassigned - availableOnLastAssignedPage
|
||||
);
|
||||
|
||||
int overflowPages =
|
||||
(unassigned + 44) / 45;
|
||||
(remainingUnassigned + 44) / 45;
|
||||
|
||||
return Math.max(
|
||||
0,
|
||||
@@ -175,59 +176,27 @@ public class ItemsPagination {
|
||||
}
|
||||
|
||||
/*
|
||||
* Figure out how many unassigned items have
|
||||
* already been consumed by previous assigned pages.
|
||||
* Unassigned items begin only on the last assigned page.
|
||||
*/
|
||||
int consumed = 0;
|
||||
if (page == highestAssignedPage) {
|
||||
|
||||
for (int previousPage = 0;
|
||||
previousPage < page;
|
||||
previousPage++) {
|
||||
|
||||
int previousHighestSlot = 8;
|
||||
|
||||
for (WarehouseItem item : assigned) {
|
||||
|
||||
if (item.page() == (previousPage + 1)) {
|
||||
|
||||
previousHighestSlot =
|
||||
Math.max(
|
||||
previousHighestSlot,
|
||||
item.slot()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
consumed +=
|
||||
int remainingSlots =
|
||||
Math.max(
|
||||
0,
|
||||
53 - previousHighestSlot
|
||||
53 - highestSlot
|
||||
);
|
||||
|
||||
}
|
||||
for (int i = 0;
|
||||
i < remainingSlots && i < unassigned.size();
|
||||
i++) {
|
||||
|
||||
int remainingSlots =
|
||||
Math.max(
|
||||
0,
|
||||
53 - highestSlot
|
||||
results.add(
|
||||
unassigned.get(
|
||||
i
|
||||
)
|
||||
);
|
||||
|
||||
while (
|
||||
remainingSlots > 0
|
||||
&&
|
||||
consumed < unassigned.size()
|
||||
) {
|
||||
|
||||
results.add(
|
||||
unassigned.get(
|
||||
consumed
|
||||
)
|
||||
);
|
||||
|
||||
consumed++;
|
||||
remainingSlots--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -235,46 +204,37 @@ public class ItemsPagination {
|
||||
|
||||
}
|
||||
|
||||
int consumed = 0;
|
||||
/*
|
||||
* Overflow pages contain only unassigned items.
|
||||
*/
|
||||
int lastPageHighestSlot = 8;
|
||||
|
||||
for (int assignedPage = 0;
|
||||
assignedPage <= highestAssignedPage;
|
||||
assignedPage++) {
|
||||
for (WarehouseItem item : assigned) {
|
||||
|
||||
int highestSlot = 8;
|
||||
if (item.page() == highestAssignedPage + 1) {
|
||||
|
||||
for (WarehouseItem item : assigned) {
|
||||
|
||||
if (item.page() == assignedPage + 1) {
|
||||
|
||||
highestSlot =
|
||||
Math.max(
|
||||
highestSlot,
|
||||
item.slot()
|
||||
);
|
||||
|
||||
}
|
||||
lastPageHighestSlot =
|
||||
Math.max(
|
||||
lastPageHighestSlot,
|
||||
item.slot()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
consumed +=
|
||||
Math.max(
|
||||
0,
|
||||
53 - highestSlot
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
int consumed =
|
||||
Math.max(
|
||||
0,
|
||||
53 - lastPageHighestSlot
|
||||
);
|
||||
|
||||
consumed =
|
||||
Math.min(
|
||||
consumed,
|
||||
unassigned.size()
|
||||
);
|
||||
|
||||
/*
|
||||
* Overflow pages
|
||||
*/
|
||||
|
||||
int overflowPage =
|
||||
page
|
||||
- highestAssignedPage
|
||||
|
||||
Reference in new issue
Block a user