Browse Source

Sanity check for deleted vendors

postwipe-mines
MagicBot 5 months ago
parent
commit
24215e21c9
  1. 12
      src/engine/db/handlers/dbWarehouseHandler.java

12
src/engine/db/handlers/dbWarehouseHandler.java

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

Loading…
Cancel
Save