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
+37
-77
No files matched your search
@@ -8,7 +8,7 @@
|
|||||||
<groupId>com.rsscripting</groupId>
|
<groupId>com.rsscripting</groupId>
|
||||||
<artifactId>RS-Warehouse</artifactId>
|
<artifactId>RS-Warehouse</artifactId>
|
||||||
<name>RS-Warehouse</name>
|
<name>RS-Warehouse</name>
|
||||||
<version>1.1.0</version>
|
<version>1.2.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
int highestAssignedPage = -1;
|
int highestAssignedPage = -1;
|
||||||
int unassigned = 0;
|
int unassigned = 0;
|
||||||
|
int lastPageHighestSlot = 8;
|
||||||
|
|
||||||
for (WarehouseItem item : items) {
|
for (WarehouseItem item : items) {
|
||||||
|
|
||||||
@@ -46,13 +47,17 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int consumed = 0;
|
if (highestAssignedPage < 0) {
|
||||||
|
|
||||||
for (int assignedPage = 0;
|
int pages =
|
||||||
assignedPage <= highestAssignedPage;
|
(unassigned + 44) / 45;
|
||||||
assignedPage++) {
|
|
||||||
|
|
||||||
int highestSlot = 8;
|
return Math.max(
|
||||||
|
0,
|
||||||
|
pages - 1
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for (WarehouseItem item : items) {
|
for (WarehouseItem item : items) {
|
||||||
|
|
||||||
@@ -61,12 +66,12 @@ public class ItemsPagination {
|
|||||||
&&
|
&&
|
||||||
item.slot() != null
|
item.slot() != null
|
||||||
&&
|
&&
|
||||||
item.page() == assignedPage + 1
|
item.page() == highestAssignedPage + 1
|
||||||
) {
|
) {
|
||||||
|
|
||||||
highestSlot =
|
lastPageHighestSlot =
|
||||||
Math.max(
|
Math.max(
|
||||||
highestSlot,
|
lastPageHighestSlot,
|
||||||
item.slot()
|
item.slot()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -74,24 +79,20 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
consumed +=
|
int availableOnLastAssignedPage =
|
||||||
Math.max(
|
Math.max(
|
||||||
0,
|
0,
|
||||||
53 - highestSlot
|
53 - lastPageHighestSlot
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
int remainingUnassigned =
|
||||||
|
Math.max(
|
||||||
consumed =
|
0,
|
||||||
Math.min(
|
unassigned - availableOnLastAssignedPage
|
||||||
consumed,
|
|
||||||
unassigned
|
|
||||||
);
|
);
|
||||||
|
|
||||||
unassigned -= consumed;
|
|
||||||
|
|
||||||
int overflowPages =
|
int overflowPages =
|
||||||
(unassigned + 44) / 45;
|
(remainingUnassigned + 44) / 45;
|
||||||
|
|
||||||
return Math.max(
|
return Math.max(
|
||||||
0,
|
0,
|
||||||
@@ -175,38 +176,9 @@ public class ItemsPagination {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out how many unassigned items have
|
* Unassigned items begin only on the last assigned page.
|
||||||
* already been consumed by previous assigned pages.
|
|
||||||
*/
|
*/
|
||||||
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 +=
|
|
||||||
Math.max(
|
|
||||||
0,
|
|
||||||
53 - previousHighestSlot
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int remainingSlots =
|
int remainingSlots =
|
||||||
Math.max(
|
Math.max(
|
||||||
@@ -214,20 +186,17 @@ public class ItemsPagination {
|
|||||||
53 - highestSlot
|
53 - highestSlot
|
||||||
);
|
);
|
||||||
|
|
||||||
while (
|
for (int i = 0;
|
||||||
remainingSlots > 0
|
i < remainingSlots && i < unassigned.size();
|
||||||
&&
|
i++) {
|
||||||
consumed < unassigned.size()
|
|
||||||
) {
|
|
||||||
|
|
||||||
results.add(
|
results.add(
|
||||||
unassigned.get(
|
unassigned.get(
|
||||||
consumed
|
i
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
consumed++;
|
}
|
||||||
remainingSlots--;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,21 +204,18 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int consumed = 0;
|
/*
|
||||||
|
* Overflow pages contain only unassigned items.
|
||||||
for (int assignedPage = 0;
|
*/
|
||||||
assignedPage <= highestAssignedPage;
|
int lastPageHighestSlot = 8;
|
||||||
assignedPage++) {
|
|
||||||
|
|
||||||
int highestSlot = 8;
|
|
||||||
|
|
||||||
for (WarehouseItem item : assigned) {
|
for (WarehouseItem item : assigned) {
|
||||||
|
|
||||||
if (item.page() == assignedPage + 1) {
|
if (item.page() == highestAssignedPage + 1) {
|
||||||
|
|
||||||
highestSlot =
|
lastPageHighestSlot =
|
||||||
Math.max(
|
Math.max(
|
||||||
highestSlot,
|
lastPageHighestSlot,
|
||||||
item.slot()
|
item.slot()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -257,24 +223,18 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
consumed +=
|
int consumed =
|
||||||
Math.max(
|
Math.max(
|
||||||
0,
|
0,
|
||||||
53 - highestSlot
|
53 - lastPageHighestSlot
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
consumed =
|
consumed =
|
||||||
Math.min(
|
Math.min(
|
||||||
consumed,
|
consumed,
|
||||||
unassigned.size()
|
unassigned.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
* Overflow pages
|
|
||||||
*/
|
|
||||||
|
|
||||||
int overflowPage =
|
int overflowPage =
|
||||||
page
|
page
|
||||||
- highestAssignedPage
|
- highestAssignedPage
|
||||||
|
|||||||
Reference in new issue
Block a user