feat: "Gerar de novo" also from Imprimindo, taking the file out of the hot folder (order #36)
All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 7m9s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m30s

#36 is already in Imprimindo. From there the order goes back to Arte
recebida like a card leaving Imprimindo: what Flexi has not taken is
withdrawn from the machine's hot folder (hotfolder.stop), and the step
back is recorded as "Arquivo gerado de novo".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-17 17:38:02 -03:00
parent 27b26cd1ae
commit d76288c335
3 changed files with 16 additions and 13 deletions

View File

@@ -593,8 +593,9 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))):
"""Generate the print files again although they are ready, for the part
size of now (PRINT_PART_CM): a 15 m part is more than the FlexiPRINT
opens (order #36, 2026-11-17). The finals that were the generated files
stop counting, and an order in Arte conferida steps back to Arte
recebida, where the new files are approved again."""
stop counting, and an order in Arte conferida or Imprimindo goes back to
Arte recebida, where the new files are approved again; from Imprimindo
what Flexi has not taken leaves the hot folder (app/hotfolder.py)."""
with db.connect() as c:
row = c.execute('SELECT * FROM dtf_local.orders WHERE id=%s FOR UPDATE', (uid,)).fetchone()
if not row:
@@ -602,8 +603,8 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))):
if row['cancelled_at']:
raise HTTPException(409, 'Pedido cancelado.')
proof.require_unlocked(c, row)
if row['state'] not in ('rec', 'tra'):
raise HTTPException(409, 'Volte o pedido para Arte conferida antes de gerar o arquivo de novo.')
if row['state'] not in ('rec', 'tra', 'imp'):
raise HTTPException(409, 'O arquivo é gerado de novo até Imprimindo.')
if c.execute("SELECT 1 FROM dtf_local.order_files WHERE order_id=%s AND kind='correction' LIMIT 1",
(uid,)).fetchone():
raise HTTPException(409, 'O cliente mandou uma correção: o arquivo final é preparado à mão.')
@@ -614,9 +615,11 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))):
(uid,))
# The new version tells the board and the folders the files changed.
c.execute("UPDATE dtf_local.orders SET state='rec', version=version+1, updated_at=now() WHERE id=%s", (uid,))
if row['state'] == 'tra':
if row['state'] == 'imp':
hotfolder.stop(c, uid)
if row['state'] != 'rec':
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason,back)
VALUES(%s,'tra','rec',%s,'Arquivo gerado de novo',true)''', (uid, user))
VALUES(%s,%s,'rec',%s,'Arquivo gerado de novo',true)''', (uid, row['state'], user))
requeue_print_files(c, uid, len(row['snapshot']['items']))
audit('print_file_regenerated', order=str(uid), operator=user)
return {'ok': True}