Method to load workorders on bootstrap

This commit is contained in:
2024-04-22 15:49:57 -04:00
parent 2a2b61bc0f
commit 7300af9073
2 changed files with 11 additions and 3 deletions
+10 -3
View File
@@ -186,20 +186,27 @@ public class dbWarehouseHandler extends dbHandlerBase {
public void LOAD_WORKORDERS() {
ArrayList<WorkOrder> deleteList = new ArrayList<>();
ArrayList<WorkOrder> submitList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;");
ResultSet rs = preparedStatement.executeQuery()) {
while (rs.next()) {
int workOrderID = rs.getInt("workOrderID");
JSONObject jsonObject = new JSONObject(rs.getString("workorder"));
WorkOrder workOrder = new WorkOrder(jsonObject);
deleteList.add(workOrder);
submitList.add(workOrder);
}
} catch (Exception e) {
Logger.error(e);
}
// Delete the old records
for (WorkOrder workOrder : submitList)
DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder);
// Pass the new workOrders to the ForgeManager
}
}
+1
View File
@@ -49,6 +49,7 @@ public class WorkOrder implements Delayed {
public WorkOrder(JSONObject jsonWorkOrder) {
this.workOrderID = jsonWorkOrder.getInt("workOrderID");
this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor"));
this.slots_used = jsonWorkOrder.getInt("slots_used");
this.total_to_produce = jsonWorkOrder.getInt("total_to_produce");