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}
|
||||
|
||||
Reference in New Issue
Block a user