feat: "Gerar de novo" makes a ready print file again for the part size of now (order #36)
Some checks failed
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled
Some checks failed
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled
The first film over 15 m (#36) left a 15 m part of 4,8 GB decoded, which the FlexiPRINT refuses (#30, 12,3 m and 3,9 GB, printed). PRINT_PART_CM already sets the part size; an order already generated had no way to get its new parts. - POST /orders/{id}/print-files/again (produce): in Arte recebida or Arte conferida, without a customer correction, the finals that were the generated files stop counting, the order is back in Arte recebida (a step back recorded as "Arquivo gerado de novo") and every item is generated again; one rendering now is left alone. - The order's "Próximo passo" offers "Gerar de novo" there, with a confirmation that the final must be approved again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ from ...core import db
|
||||
from ...core.auth import MOVERS, audit, can, may_move, may_reorder, operator
|
||||
from ...core.models import Contraction, Move, Resolution, StrictModel, UploadStart
|
||||
from ...payments import release_files
|
||||
from ...printjobs import queue as queue_print_files
|
||||
from ...printjobs import queue as queue_print_files, requeue as requeue_print_files
|
||||
from ...runtime import BACK, STATES, TRANSITIONS, enqueue, operator_identity, upload_row
|
||||
from ...scanning import require_clean
|
||||
from ..uploads import begin_upload
|
||||
@@ -586,3 +586,37 @@ def regenerate(uid: UUID, user=Depends(can('produce'))):
|
||||
queue_print_files(c, uid, len(row['snapshot']['items']), only_missing=True)
|
||||
audit('print_file_requeued', order=str(uid), operator=user, c=c)
|
||||
return c.execute('SELECT * FROM dtf_local.print_files WHERE order_id=%s ORDER BY item_index', (uid,)).fetchall()
|
||||
|
||||
|
||||
@router.post('/api/operator/orders/{uid}/print-files/again')
|
||||
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."""
|
||||
with db.connect() as c:
|
||||
row = c.execute('SELECT * FROM dtf_local.orders WHERE id=%s FOR UPDATE', (uid,)).fetchone()
|
||||
if not row:
|
||||
raise HTTPException(404, 'Pedido não encontrado.')
|
||||
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 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.')
|
||||
c.execute('''UPDATE dtf_local.order_files f SET active=false
|
||||
WHERE f.order_id=%s AND f.kind='final' AND f.active AND (
|
||||
EXISTS (SELECT 1 FROM dtf_local.print_parts p WHERE p.order_id=f.order_id AND p.upload_id=f.upload_id)
|
||||
OR EXISTS (SELECT 1 FROM dtf_local.print_files p WHERE p.order_id=f.order_id AND p.upload_id=f.upload_id))''',
|
||||
(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':
|
||||
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))
|
||||
requeue_print_files(c, uid, len(row['snapshot']['items']))
|
||||
audit('print_file_regenerated', order=str(uid), operator=user)
|
||||
return {'ok': True}
|
||||
|
||||
@@ -118,6 +118,16 @@ def queue(c, order_id, items, only_missing=False):
|
||||
ON CONFLICT(order_id,item_index) DO NOTHING''', (uuid4(), order_id, index))
|
||||
|
||||
|
||||
def requeue(c, order_id, items):
|
||||
"""Generate every item again, a ready one too: after the part size
|
||||
changed (PART_CM; order #36, 2026-11-17). One rendering now is left alone."""
|
||||
for index in range(items):
|
||||
c.execute('''INSERT INTO dtf_local.print_files(id,order_id,item_index) VALUES(%s,%s,%s)
|
||||
ON CONFLICT(order_id,item_index) DO UPDATE SET status='pending', attempts=0,
|
||||
claimed_at=NULL, claim_token=NULL, finished_at=NULL, upload_id=NULL, detail='{}'
|
||||
WHERE dtf_local.print_files.status<>'rendering' ''', (uuid4(), order_id, index))
|
||||
|
||||
|
||||
def claim(c):
|
||||
return c.execute('''SELECT p.*, o.snapshot, o.number, o.parent_id, o.created_at AS ordered_at FROM dtf_local.print_files p
|
||||
JOIN dtf_local.orders o ON o.id=p.order_id
|
||||
|
||||
@@ -169,6 +169,29 @@ def run():
|
||||
'note': 'again'}, operator=True, expected=409)
|
||||
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,
|
||||
# 2026-11-17): refused while printing; from Arte conferida the generated
|
||||
# final goes, the order steps back to Arte recebida and the file is made
|
||||
# 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, made = wait_print(client, paid_order(client, loose_item(again_upload))['id'], 'ready')
|
||||
v = client.call('/operator/orders/' + again['id'] + '/final-files',
|
||||
{'version': again['version'], 'files': [{'item_index': 0, 'upload_id': str(made['upload_id'])}],
|
||||
'note': 'ok'}, operator=True)['version']
|
||||
client.call('/operator/orders/' + again['id'] + '/move', {'state': 'tra', 'version': v}, operator=True)
|
||||
client.call('/operator/orders/' + again['id'] + '/print-files/again', {}, operator=True)
|
||||
with db.connect() as c:
|
||||
state = c.execute('SELECT state FROM dtf_local.orders WHERE id=%s', (again['id'],)).fetchone()['state']
|
||||
finals = c.execute('''SELECT count(*) AS n FROM dtf_local.order_files
|
||||
WHERE order_id=%s AND kind='final' AND active''', (again['id'],)).fetchone()['n']
|
||||
back = c.execute('SELECT reason,back FROM dtf_local.movements WHERE order_id=%s ORDER BY id DESC LIMIT 1',
|
||||
(again['id'],)).fetchone()
|
||||
assert (state, finals, back['reason'], back['back']) == ('rec', 0, 'Arquivo gerado de novo', True), (state, finals, back)
|
||||
again, remade = wait_print(client, again['id'], 'ready')
|
||||
assert str(remade['upload_id']) != str(made['upload_id']), (made, remade)
|
||||
print('PASS: a ready file is generated again from Arte conferida, back in Arte recebida to approve')
|
||||
|
||||
# Item 10: printing, the file goes once into its machine's hot folder for
|
||||
# its class; Flexi taking it is reported; leaving Imprimindo withdraws
|
||||
# what Flexi did not take.
|
||||
|
||||
@@ -297,6 +297,18 @@ function nextBox(order){
|
||||
note('Somente consulta: seu perfil não move pedidos.');
|
||||
return composeNext(title,body,main,more);
|
||||
}
|
||||
// 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
|
||||
// generated final goes, so the order is back in Arte recebida.
|
||||
if((st==='rec'||st==='tra')&&!order.proof_parent&&!fixed&&may('produce')&&
|
||||
(order.print_files||[]).some(r=>r.status==='ready'))
|
||||
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. '+
|
||||
'O arquivo final aprovado sai: o pedido fica em Arte recebida e o arquivo novo precisa ser aprovado.',
|
||||
'Gerar de novo',{host:$('drawer')}))return;
|
||||
await api('/orders/'+order.id+'/print-files/again',{});await load();
|
||||
say('Gerando o arquivo do #'+order.number+' de novo. Aprove quando ficar pronto.');
|
||||
},'btn quiet lg'));
|
||||
const fixBtn=()=>{if(!trans.includes('cor')||!can('cor'))return;
|
||||
const b=node('button','Pedir correção','btn ghost lg');b.type='button';b.dataset.move='cor';b.onclick=()=>correctionDialog(order);more.push(b);};
|
||||
const proofBtn=(className='btn lg')=>{if(!proofPending(order)||order.proof_card||!may('print'))return null;
|
||||
|
||||
Reference in New Issue
Block a user