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:
@@ -26,6 +26,7 @@ struct ProductionPlan {
|
|||||||
stock_size: i32,
|
stock_size: i32,
|
||||||
used_in_stock: i32,
|
used_in_stock: i32,
|
||||||
running_productions: i32,
|
running_productions: i32,
|
||||||
|
running_productions_quantity: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -378,6 +379,10 @@ impl DirectorWorker {
|
|||||||
stock_size: row.get("stock_size")?.parse().ok()?,
|
stock_size: row.get("stock_size")?.parse().ok()?,
|
||||||
used_in_stock: row.get("used_in_stock")?.parse().ok()?,
|
used_in_stock: row.get("used_in_stock")?.parse().ok()?,
|
||||||
running_productions: row.get("running_productions")?.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(());
|
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
|
// 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.
|
// 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);
|
let to_produce = free_capacity.min(max_money_production).min(300).max(0);
|
||||||
|
|
||||||
if to_produce < 1 {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user