Add running_productions_quantity to ProductionPlan: Introduced a new field to track the quantity of ongoing productions. Updated the DirectorWorker to parse this new field from the database and adjusted the free capacity calculation accordingly. Enhanced logging to provide detailed information when production cannot be started due to capacity constraints.

This commit is contained in:
Torsten Schulz (local)
2025-12-01 10:04:09 +01:00
parent 8a08a74b80
commit fbca231de5

View File

@@ -26,6 +26,7 @@ struct ProductionPlan {
stock_size: i32,
used_in_stock: i32,
running_productions: i32,
running_productions_quantity: i32,
}
#[derive(Debug, Clone)]
@@ -378,6 +379,10 @@ impl DirectorWorker {
stock_size: row.get("stock_size")?.parse().ok()?,
used_in_stock: row.get("used_in_stock")?.parse().ok()?,
running_productions: row.get("running_productions")?.parse().ok()?,
running_productions_quantity: row
.get("running_productions_quantity")?
.parse()
.ok()?,
})
}
@@ -391,7 +396,10 @@ impl DirectorWorker {
return Ok(());
}
let free_capacity = plan.stock_size - plan.used_in_stock - plan.running_productions;
// Freie Lagerkapazität: Gesamtbestand minus bereits belegter Bestand
// (Inventar) minus bereits eingeplante Produktionsmengen.
let free_capacity =
plan.stock_size - plan.used_in_stock - plan.running_productions_quantity;
// Stückkosten monetär berechnen. Da money ein f64 ist, arbeiten wir hier ebenfalls
// mit Gleitkomma und runden erst am Ende auf eine ganze Stückzahl ab.
@@ -406,6 +414,13 @@ impl DirectorWorker {
let to_produce = free_capacity.min(max_money_production).min(300).max(0);
if to_produce < 1 {
eprintln!(
"[DirectorWorker] Keine Produktion gestartet: free_capacity={}, max_money_production={}, running_productions={}, running_qty={}",
free_capacity,
max_money_production,
plan.running_productions,
plan.running_productions_quantity
);
return Ok(());
}