The signal drops just after a slitting operator submits the result. On the floor are Coil B at 6.000 t, Coil C at 3.700 t, and 0.300 t of trim from the original 10.000 t coil. The operator can see the steel. The planner at the next desk needs to know whether Coil B is in stock. A missing reply leaves that question open.

The operator and the planner work from the same record. Slitting and inventory share a Django backend, so one PostgreSQL transaction saves the cut, the stock movements, and the link from each output to its source. The operator’s screen has two ways to recover when the connection returns. Which one it offers depends on whether the server confirmed the submission.

From the operator’s screen to the slitting job

The operator signs in through Keycloak. When they submit a result, the Next.js server checks the browser session and forwards the request to the Django REST API. The API verifies the operator’s identity and checks their authority to record work at this site. The submission also identifies the job version and the physical source coil the operator saw when they opened the form. If another job has used that steel and the reservation has moved to a remaining piece, the operator needs to see which coil a new submission would consume.

The Next.js workspace sends the result to Django. An as-planned cut posts stock and lineage together. A change to trim or scrap sends the result to Review before stock can post. In a separate billing workflow, a saved document request goes to a PDF worker after commit.

Suppose the first cut had also produced unexpected scrap. The operator would submit the actual trim and scrap, and the supervisor would see the result in Review. Coil B would become available to the planner only after approval and posting.

One visible result needs one commit

Imagine saving the result of the as-planned cut and losing the database connection just before creating Coil B in inventory. The operator would see a completed job, but the planner searching for the new coil would come up empty. Reversing the order creates another problem. A planner could claim a coil whose production record has yet to be saved.

For a cut that is ready to post, the service locks the relevant stock rows and checks the available quantity again. PostgreSQL then commits the consumption of Coil A, the new stock identities, their weights, the links back to the cut, and the audit record together. If a check fails during posting, those writes roll back together. Once the transaction commits, the planner can look up Coil B even if the reply never reaches the operator.

Ask what happened to this attempt

When the connection returns, the screen distinguishes two cases.

  • Retry same result. If confirmation never arrived, the operator uses this action with the form still open. The screen resends the original values, job version, source reference, and attempt identifier, called an idempotency key. If the first request committed, the server checks the operator’s current authority and returns the saved result. If it never committed, the server can process the request if the job and stock still permit it. Reusing the key with different inputs raises a conflict.
  • Reload production data. If submission was confirmed but the screen failed to load the updated job or stock, the operator uses this action to fetch fresh data. The application already has the acknowledgement. Only the reads need to run again.

I tested the awkward case by making the server fail while preparing its reply, after the stock transaction had committed. The first call returned an error even though the ledger contained one posting. Retrying the original request returned the saved result. The ledger still contained exactly one posting.

What each module owns

Slitting knows the planned strip layout and why unexpected scrap calls for review. Inventory knows how much material is available and how to post balanced movements. The two modules communicate through an explicit interface. That lets the slitting form change as the floor’s requirements change, while dispatch can still rely on the same stock rules.

The two recovery buttons rely on a distinction between commands that can change stock and queries that read it. Retry same result goes through the command checks because it may still have work to do. Reload production data reads the current state. An OpenAPI specification describes those requests and responses and supplies the TypeScript types for the frontend. Weights and money cross the API as decimal strings. The build regenerates the specification and types and flags any difference from the committed versions.

When a background worker is useful

Later, when billing requests an invoice PDF, the figures have already been reconciled. The application saves a snapshot of those figures and a request to render the document in the same database transaction. That durable list of pending requests is the transactional outbox. After commit, a Celery worker receives the job through Redis and renders the PDF. If delivery to the worker fails, a periodic dispatcher can pick up the saved request again.

Back at the slitting line, the operator can recover the outcome of the cut and the planner can trace Coil B to Coil A. The ledger tells the planner how much steel is on hand. If the customer later asks which coil that steel came from, the link to the slitting result gives the planner a place to start.

Previous — Turning Shop-Floor Work Into Software Requirements · Series index · Next — Stock You Can Reconcile and Material You Can Trace

Discussion

Comments 0

New comments are moderated before they appear publicly.

Be the first to leave a thoughtful comment.