feat: Gestão moves a printing order to another machine with a reason; the new one resumes from the part being ripped (Rodada 5, D4)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -113,6 +113,24 @@ def stop(c, order_id):
|
||||
WHERE order_id=%s AND state IN ('queued','claimed','written')''', (order_id,))
|
||||
|
||||
|
||||
def transfer(c, order_id):
|
||||
"""The order changed machine in Imprimindo (Rodada 5, D4): the old machine
|
||||
keeps what Flexi already took, and what it had not leaves its folder; the
|
||||
new one starts from the part the old was ripping, in a new round."""
|
||||
last = c.execute('SELECT max(round) AS r FROM dtf_local.hot_parts WHERE order_id=%s',
|
||||
(order_id,)).fetchone()['r']
|
||||
if last is None:
|
||||
return 1
|
||||
taken = c.execute('''SELECT max(seq) AS s FROM dtf_local.hot_parts
|
||||
WHERE order_id=%s AND round=%s AND state='consumed' ''', (order_id, last)).fetchone()['s']
|
||||
stop(c, order_id)
|
||||
c.execute('''INSERT INTO dtf_local.hot_parts(order_id,round,seq,item_index,upload_id,name)
|
||||
SELECT order_id, %s, row_number() OVER (ORDER BY seq), item_index, upload_id, name
|
||||
FROM dtf_local.hot_parts WHERE order_id=%s AND round=%s AND seq >= %s''',
|
||||
(last + 1, order_id, last, taken or 1))
|
||||
return taken or 1
|
||||
|
||||
|
||||
def claim(c, user):
|
||||
"""The parts due in the folders now, claimed for this computer to write:
|
||||
for each machine, the next parts of its orders in Imprimindo, in the order
|
||||
|
||||
Reference in New Issue
Block a user