Add read-only ERP workplace status adapter
This commit is contained in:
@@ -217,6 +217,42 @@ start times, not source-sample timestamps. Schema application is manual.
|
||||
Bento 1 bentonite source and gate selection remain intentionally undefined pending
|
||||
process validation; the generic integration core is unchanged and reusable.
|
||||
|
||||
## ERP current workplace status
|
||||
|
||||
The read-only ERP adapter reads production-order/article context from MSSQL
|
||||
`NV_DWH.dbo.GRAFANA_WORKPLACE_STATUS`, for later live material KPIs. Credentials
|
||||
belong in ignored `secrets/erp.env`, using `ERP_DB_HOST`, `ERP_DB_PORT`,
|
||||
`ERP_DB_NAME`, `ERP_DB_USER`, and `ERP_DB_PASSWORD`. The verified endpoint is
|
||||
`192.168.111.24:49601`, database `NV_DWH`, using SQL Server authentication and
|
||||
a read-only account. All settings are required; ports must be integers 1–65535.
|
||||
|
||||
```python
|
||||
from production_analytics.erp import ErpSettings, ErpWorkplaceStatusGateway
|
||||
|
||||
settings = ErpSettings.from_secret_file() # File values override environment values.
|
||||
status = ErpWorkplaceStatusGateway(settings).get_current_workplace_status("K7")
|
||||
```
|
||||
|
||||
Alternatively, use `ErpSettings.from_environment(mapping)`. The existing simple
|
||||
dotenv loader is reused; no shell content is executed. Each call opens and closes
|
||||
one connection, with 10-second login/query timeouts, and performs a parameterized
|
||||
SELECT filtered by workplace. Zero rows returns `None`, one row returns an
|
||||
immutable `CurrentWorkplaceStatus`, and multiple rows raise `ErpReadError`.
|
||||
Driver failures and malformed rows also raise `ErpReadError` with safe messages.
|
||||
|
||||
Only trailing whitespace is removed from workplace, production order, article
|
||||
number, and description; identifiers otherwise remain unchanged. Nullable fields
|
||||
stay `None`. Decimal/integer quantities are explicitly converted to finite floats
|
||||
(with normal floating-point precision); non-finite/overflowing values are rejected.
|
||||
Quantity fields use m² and remaining time uses hours, following the supplied source
|
||||
semantics. `feedback_timestamp` is preserved exactly, including a naive timezone.
|
||||
It represents the latest ERP feedback, and the ERP export is delayed relative to
|
||||
live process data; the adapter makes no freshness inference.
|
||||
|
||||
This milestone adds no kg/m² or material-efficiency calculation, ERP-to-ENLYZE
|
||||
order mapping, persistence, polling, CLI, or Grafana integration. Automated ERP
|
||||
tests use mocks and require no live connectivity.
|
||||
|
||||
## Peak-cycle detection
|
||||
|
||||
`PeakCycleDetector` is a pure calculation-domain component for roll length,
|
||||
|
||||
Reference in New Issue
Block a user