Add per-order speed and material KPIs
This commit is contained in:
1 parent
211fb45d52
commit
f6ebd78a4a
15 files changed
+773
-30
No files matched your search
@@ -123,6 +123,43 @@ def test_machine_composition(name, workplace, mode, ids):
|
||||
report.machine_name = "other"
|
||||
|
||||
|
||||
def test_order_kpis_enrich_each_production_row_without_changing_shift_totals():
|
||||
from dataclasses import replace
|
||||
|
||||
from production_analytics.service.production_order import ProductionOrderShiftKpi
|
||||
|
||||
service, stubs, _, _ = composition("K7")
|
||||
first = stubs["production"].result.items[0]
|
||||
second = replace(first, production_order="other", produced_m2=24)
|
||||
stubs["production"].result = replace(
|
||||
stubs["production"].result,
|
||||
items=(first, second), total_produced_m2=147, total_roll_count=2,
|
||||
)
|
||||
|
||||
class OrderKpis:
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
|
||||
def for_shift(self, **kwargs):
|
||||
self.calls.append(kwargs)
|
||||
return {
|
||||
"order": ProductionOrderShiftKpi((), 10.24, 3317.58),
|
||||
"other": ProductionOrderShiftKpi((), 8.5, 1863.36),
|
||||
}
|
||||
|
||||
order_kpis = OrderKpis()
|
||||
service.order_kpis = order_kpis
|
||||
report = service.build(machine_name="K7", start=START, end=END)
|
||||
assert order_kpis.calls == [{"machine_name": "K7", "start": START, "end": END,
|
||||
"orders": ("order", "other"),
|
||||
"allocated_shift_materials": None}]
|
||||
assert [(item.average_speed_m_min, item.material_consumption_kg)
|
||||
for item in report.production.items] == [(10.24, 3317.58), (8.5, 1863.36)]
|
||||
assert report.production.total_produced_m2 == 147
|
||||
assert report.materials is stubs["materials"].result
|
||||
assert report.speed is stubs["speed"].result
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", ["Gitter 1", "Gitter 2", "Gitter 3", "Gitter 4", "K5"])
|
||||
def test_boolean_speed_machines_appear_in_report_without_material(name):
|
||||
service, stubs, calls, config = composition(name)
|
||||
|
||||
Reference in new issue
Block a user