fix: a transfer asks which part the new machine resumes from and names the old machine's .prt to delete (Marcus, 2026-12-01)
The hot folder takes a PNG in about 10 s and the Hoson queues it, so the last part taken is not the one being ripped. The dialog lists the parts (already taken or still in the folder) and asks where to resume once any was taken; the new round starts there, and the parts from there on that the old machine took are named as Hoson .prt files to delete, in the toast, the card and the history. The film card no longer claims which part prints: '2/3 partes com a máquina'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -136,6 +136,9 @@ def choose_machine(uid: UUID, body: MachineChoice, request: Request, user=Depend
|
||||
class MachineTransfer(StrictModel):
|
||||
machine_id: UUID
|
||||
reason: str = Field(max_length=500)
|
||||
# The part of the last round the new machine resumes from (Marcus,
|
||||
# 2026-12-01): required once the old machine has taken any part.
|
||||
resume_from: int | None = Field(default=None, ge=1, le=10000, strict=True)
|
||||
|
||||
|
||||
@router.post('/api/operator/orders/{uid}/transfer')
|
||||
@@ -163,15 +166,21 @@ def transfer_machine(uid: UUID, body: MachineTransfer, user=Depends(can('manage'
|
||||
from_name = (c.execute('SELECT name FROM dtf_local.machines WHERE id=%s',
|
||||
(current['machine_id'],)).fetchone() if current['machine_id'] else None)
|
||||
from_name = from_name and from_name['name']
|
||||
resumed = hotfolder.transfer(c, uid)
|
||||
parts = hotfolder.last_round(c, [uid]).get(uid, [])
|
||||
if any(part['state'] == 'consumed' for part in parts) and not body.resume_from:
|
||||
raise HTTPException(422, 'Escolha de qual parte a nova máquina recomeça.')
|
||||
if body.resume_from and body.resume_from not in {part['seq'] for part in parts}:
|
||||
raise HTTPException(422, 'Essa parte não existe neste pedido.')
|
||||
resumed, delete_prt = hotfolder.transfer(c, uid, body.resume_from)
|
||||
c.execute('UPDATE dtf_local.orders SET machine_id=%s, machine_chosen=true WHERE id=%s',
|
||||
(body.machine_id, uid))
|
||||
c.execute('''INSERT INTO dtf_local.machine_transfers(order_id,from_machine,to_machine,from_name,to_name,
|
||||
reason,resumed_from,created_by) VALUES(%s,%s,%s,%s,%s,%s,%s,%s)''',
|
||||
(uid, current['machine_id'], body.machine_id, from_name, target['name'], reason, resumed, user))
|
||||
reason,resumed_from,delete_prt,created_by) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)''',
|
||||
(uid, current['machine_id'], body.machine_id, from_name, target['name'], reason, resumed,
|
||||
delete_prt, user))
|
||||
audit('order_machine_transferred', order=current['number'], from_machine=str(current['machine_id'] or ''),
|
||||
to_machine=str(body.machine_id), operator=user)
|
||||
return {'ok': True}
|
||||
return {'ok': True, 'delete_prt': delete_prt}
|
||||
|
||||
|
||||
@router.post('/api/operator/orders/{uid}/contraction')
|
||||
|
||||
Reference in New Issue
Block a user