feat: each machine's sheet, counters and alerts (front 1a)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 6m20s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m11s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 6m20s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m11s
The machine's name in Imprimindo (and "Ficha" in Usuários › Máquinas) opens its sheet: metres since the last cleaning and since the last film change, each supply's estimate, pending alerts and the entries. The room enters supplies (film, ink by colour, powder; a supply without cost takes the last one), parts (cap, damper, head, wiper, other) and events (cleaning, head alignment, a stop with reason and minutes). Gestão types the price, installation date and supply minimums. Alerts appear when someone pulls the next card onto the machine, never mid-print: 10 m since the last cleaning, 20 m after a film change without aligning the head, and a supply at its minimum. Marked done it records the event; postponed once it lets one more card through. The server refuses the pull otherwise. Counters start when the sheet went live (machines.log_since), not from everything printed before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -546,3 +546,38 @@ CREATE TABLE IF NOT EXISTS dtf_local.order_reviews (
|
||||
UNIQUE(order_id, seq)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS order_reviews_order ON dtf_local.order_reviews(order_id);
|
||||
|
||||
-- Each machine's sheet (Fase 2, front 1, app/machine_log.py): what it cost and
|
||||
-- when it started, typed once by Gestão; what goes into it, entered by the
|
||||
-- room; and the minimum of each supply that raises the alert.
|
||||
ALTER TABLE dtf_local.machines ADD COLUMN IF NOT EXISTS price_cents bigint CHECK (price_cents >= 0);
|
||||
ALTER TABLE dtf_local.machines ADD COLUMN IF NOT EXISTS installed_on date;
|
||||
-- When the counters start: a machine with no cleaning on record counts from
|
||||
-- here, not from everything it printed before the sheet existed.
|
||||
ALTER TABLE dtf_local.machines ADD COLUMN IF NOT EXISTS log_since timestamptz NOT NULL DEFAULT now();
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.machine_entries (
|
||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
machine_id uuid NOT NULL REFERENCES dtf_local.machines(id) ON DELETE CASCADE,
|
||||
kind text NOT NULL CHECK(kind IN ('supply','part','event')),
|
||||
item text NOT NULL,
|
||||
quantity numeric(12,3) CHECK (quantity > 0),
|
||||
cost_cents bigint CHECK (cost_cents >= 0),
|
||||
serial text, note text,
|
||||
stop_minutes integer CHECK (stop_minutes > 0),
|
||||
from_alert boolean NOT NULL DEFAULT false,
|
||||
created_by text NOT NULL, created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS machine_entries_machine ON dtf_local.machine_entries(machine_id, created_at);
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.machine_minimums (
|
||||
machine_id uuid NOT NULL REFERENCES dtf_local.machines(id) ON DELETE CASCADE,
|
||||
item text NOT NULL, minimum numeric(12,3) NOT NULL CHECK (minimum >= 0),
|
||||
PRIMARY KEY(machine_id, item)
|
||||
);
|
||||
-- "Adiar uma vez": an alert postponed lets one more card be pulled, once per
|
||||
-- cycle (the cycle starts at the event that resets its counter).
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.machine_snoozes (
|
||||
machine_id uuid NOT NULL REFERENCES dtf_local.machines(id) ON DELETE CASCADE,
|
||||
alert text NOT NULL, cycle_from timestamptz NOT NULL,
|
||||
snoozed_by text NOT NULL, snoozed_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY(machine_id, alert, cycle_from)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user