Add Bento 1 fresh bentonite consumption
This commit is contained in:
1 parent
ed0e20a04b
commit
be8d76507a
11 files changed
+430
-14
No files matched your search
@@ -14,6 +14,8 @@ from production_analytics.enlyze.exploration import (
|
||||
load_secret_file,
|
||||
)
|
||||
from production_analytics.enlyze.gateway import EnlyzeApiGateway
|
||||
from production_analytics.erp import ErpSettings, ErpWorkplaceStatusGateway
|
||||
from production_analytics.service.material_context import ErpNominalWidthProvider
|
||||
from production_analytics.service.material_polling import (
|
||||
MaterialPollingService,
|
||||
MaterialPollingState,
|
||||
@@ -48,6 +50,7 @@ class _ReportingStateStore:
|
||||
def build_material_runner(
|
||||
calculation: MaterialCalculationConfig, *, poll_interval_seconds: float,
|
||||
state_directory: Path, secrets_file: Path,
|
||||
erp_secrets_file: Path = Path("secrets/erp.env"),
|
||||
) -> MaterialPollingRunner:
|
||||
finite_number(poll_interval_seconds, "poll interval", positive=True)
|
||||
environment = dict(os.environ)
|
||||
@@ -69,6 +72,16 @@ def build_material_runner(
|
||||
f"State directory startup check failed: {type(exc).__name__}"
|
||||
) from exc
|
||||
postgres_settings = PostgresSettings.from_environment(environment)
|
||||
source_options = {}
|
||||
if calculation.source_mode == "area_application":
|
||||
source_options = dict(
|
||||
application_variable_ids=calculation.application_signal_refs,
|
||||
nominal_width_provider=ErpNominalWidthProvider(
|
||||
ErpWorkplaceStatusGateway(ErpSettings.from_secret_file(erp_secrets_file)),
|
||||
workplace=calculation.erp_workplace,
|
||||
format_template=calculation.production_order_format,
|
||||
),
|
||||
)
|
||||
service = MaterialPollingService(
|
||||
gateway=EnlyzeApiGateway(ExplorationClient(settings)),
|
||||
state_store=_ReportingStateStore(JsonMaterialStateStore(state_directory)),
|
||||
@@ -77,6 +90,7 @@ def build_material_runner(
|
||||
gate_variable_id=calculation.gate_signal_ref,
|
||||
gate_threshold=calculation.gate_threshold,
|
||||
max_sample_gap_seconds=calculation.max_sample_gap_seconds,
|
||||
**source_options,
|
||||
)
|
||||
return MaterialPollingRunner(
|
||||
service, calculation_id=calculation.id,
|
||||
|
||||
Reference in new issue
Block a user