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 """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 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 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 stop counting, and an order in Arte conferida or Imprimindo goes back to
recebida, where the new files are approved again.""" 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: with db.connect() as c:
row = c.execute('SELECT * FROM dtf_local.orders WHERE id=%s FOR UPDATE', (uid,)).fetchone() row = c.execute('SELECT * FROM dtf_local.orders WHERE id=%s FOR UPDATE', (uid,)).fetchone()
if not row: if not row:
@@ -602,8 +603,8 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))):
if row['cancelled_at']: if row['cancelled_at']:
raise HTTPException(409, 'Pedido cancelado.') raise HTTPException(409, 'Pedido cancelado.')
proof.require_unlocked(c, row) proof.require_unlocked(c, row)
if row['state'] not in ('rec', 'tra'): if row['state'] not in ('rec', 'tra', 'imp'):
raise HTTPException(409, 'Volte o pedido para Arte conferida antes de gerar o arquivo de novo.') 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", if c.execute("SELECT 1 FROM dtf_local.order_files WHERE order_id=%s AND kind='correction' LIMIT 1",
(uid,)).fetchone(): (uid,)).fetchone():
raise HTTPException(409, 'O cliente mandou uma correção: o arquivo final é preparado à mão.') 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,)) (uid,))
# The new version tells the board and the folders the files changed. # 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,)) 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) 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'])) requeue_print_files(c, uid, len(row['snapshot']['items']))
audit('print_file_regenerated', order=str(uid), operator=user) audit('print_file_regenerated', order=str(uid), operator=user)
return {'ok': True} return {'ok': True}

View File

@@ -170,10 +170,8 @@ def run():
print('PASS: generated file approved as final without re-uploading; order queued for printing') print('PASS: generated file approved as final without re-uploading; order queued for printing')
# A ready file generated again for the part size of now (order #36, # A ready file generated again for the part size of now (order #36,
# 2026-11-17): refused while printing; from Arte conferida the generated # 2026-11-17): from Arte conferida or Imprimindo the generated final goes,
# final goes, the order steps back to Arte recebida and the file is made # the order is back in Arte recebida and the file is made once more.
# once more.
client.call('/operator/orders/' + oid + '/print-files/again', {}, operator=True, expected=409)
again_upload = upload_bytes(client, artwork(), name='LOCAL-AGAIN.png') again_upload = upload_bytes(client, artwork(), name='LOCAL-AGAIN.png')
again, made = wait_print(client, paid_order(client, loose_item(again_upload))['id'], 'ready') again, made = wait_print(client, paid_order(client, loose_item(again_upload))['id'], 'ready')
v = client.call('/operator/orders/' + again['id'] + '/final-files', v = client.call('/operator/orders/' + again['id'] + '/final-files',

View File

@@ -299,12 +299,14 @@ function nextBox(order){
} }
// A ready file generated again, for the part size of now: a 15 m part is // A ready file generated again, for the part size of now: a 15 m part is
// more than the FlexiPRINT opens (order #36, 2026-11-17). The approved // more than the FlexiPRINT opens (order #36, 2026-11-17). The approved
// generated final goes, so the order is back in Arte recebida. // generated final goes, so the order is back in Arte recebida; from
if((st==='rec'||st==='tra')&&!order.proof_parent&&!fixed&&may('produce')&& // Imprimindo its file also leaves the machine's hot folder.
if((st==='rec'||st==='tra'||st==='imp')&&!order.proof_parent&&!fixed&&may('produce')&&
(order.print_files||[]).some(r=>r.status==='ready')) (order.print_files||[]).some(r=>r.status==='ready'))
more.push(button('Gerar de novo',async()=>{ more.push(button('Gerar de novo',async()=>{
if(!await ask('Gerar o arquivo de novo?','O sistema gera o arquivo do pedido de novo, com o tamanho de parte de agora. '+ if(!await ask('Gerar o arquivo de novo?','O sistema gera o arquivo do pedido de novo, com o tamanho de parte de agora. '+
'O arquivo final aprovado sai: o pedido fica em Arte recebida e o arquivo novo precisa ser aprovado.', 'O arquivo final aprovado sai: o pedido volta para Arte recebida'+(st==='imp'?', sai da hot folder da máquina,':'')+
' e o arquivo novo precisa ser aprovado.',
'Gerar de novo',{host:$('drawer')}))return; 'Gerar de novo',{host:$('drawer')}))return;
await api('/orders/'+order.id+'/print-files/again',{});await load(); await api('/orders/'+order.id+'/print-files/again',{});await load();
say('Gerando o arquivo do #'+order.number+' de novo. Aprove quando ficar pronto.'); say('Gerando o arquivo do #'+order.number+' de novo. Aprove quando ficar pronto.');