diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index bf067c5c..9137f07c 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -192,6 +192,7 @@ public class dbWarehouseHandler extends dbHandlerBase { // via the client interface. ArrayList submitList = new ArrayList<>(); + ArrayList orphanList = new ArrayList<>(); try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;"); @@ -200,10 +201,6 @@ public class dbWarehouseHandler extends dbHandlerBase { while (rs.next()) { JSONObject jsonObject = new JSONObject(rs.getString("workorder")); WorkOrder workOrder = new WorkOrder(jsonObject); - - if (workOrder.vendor == null) - continue; - submitList.add(workOrder); } } catch (Exception e) { @@ -213,7 +210,14 @@ public class dbWarehouseHandler extends dbHandlerBase { // Submit new workOrders to the ForgeManager for (WorkOrder workOrder : submitList) { + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + + // Delete but do not reconstitute orphan workOrders + + if (workOrder.vendor == null) + continue; + workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet(); DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);