diff --git a/app/api/operator.py b/app/api/operator.py index f108046..51d07b8 100644 --- a/app/api/operator.py +++ b/app/api/operator.py @@ -18,7 +18,7 @@ from ..core.auth import (COOKIE_SECURE, DUMMY_PASSWORD_HASH, MOVERS, audit, can, login_failed, may_move, may_reorder, password_matches, throttle) from ..core.models import Contraction, Move, OperatorLogin, Resolution, Review, StrictModel, UploadStart from ..printjobs import file_prefix, queue as queue_print_files -from .. import cnpj, machines, mail, payments, proof, quote_review, receipt +from .. import cnpj, hotfolder, machines, mail, payments, proof, quote_review, receipt from .. import tiny from ..runtime import (BACK, BOARD_FINISHED_LIMIT, BOARD_QUOTE_LIMIT, ENVIRONMENT, PUBLIC_ORIGIN, STATES, TRANSITIONS, payment, enqueue, freight, operator_identity, quote_view, quote_views, storage, upload_row) @@ -236,7 +236,10 @@ def with_print_files(c, orders): # Why each order was last sent to correction, for the notice to the customer. reasons = {row['order_id']: row['reason'] for row in c.execute('''SELECT DISTINCT ON (order_id) order_id,reason FROM dtf_local.movements WHERE order_id=ANY(%s) AND to_state='cor' ORDER BY order_id,id DESC''', (ids,)).fetchall()} + # Where a printing order's files are in its machine's hot folder (item 10). + hot = hotfolder.progress(c, [o['id'] for o in orders if o['state'] == 'imp']) for order in orders: + order['hot'] = hot.get(order['id']) order['correction_reason'] = reasons.get(order['id']) if order['state'] == 'cor' else None order['print_files'] = [row for row in generated if row['order_id'] == order['id']] approved = [row for row in finals if row['order_id'] == order['id']] @@ -646,6 +649,7 @@ def cancel_order(uid: UUID, body: Resolution, user=Depends(can('cancel'))): (user, body.note, uid)).fetchone() if not row: raise HTTPException(404, 'Pedido não encontrado ou já cancelado.') + hotfolder.stop(c, uid) if payments.in_tiny(row): sale = c.execute("SELECT receipt FROM dtf_local.outbox WHERE event_key=%s AND delivered_at IS NOT NULL", (f'{uid}:paid:tiny',)).fetchone() @@ -693,10 +697,14 @@ def choose_contraction(uid: UUID, body: Contraction, user=Depends(can('produce') (uid,)).fetchone() if not row: raise HTTPException(404, 'Pedido não encontrado.') - if row['cancelled_at'] or row['state'] not in ('rec', 'tra', 'cor'): - raise HTTPException(409, 'A contração muda até o pedido ir para Imprimindo.') if body.item_index >= len(row['snapshot']['items']): raise HTTPException(422, 'Item não encontrado no pedido.') + # Printing, the class still changes while the item's files wait to go + # into the hot folder: the class is its folder (item 10). + written = row['state'] == 'imp' and c.execute('''SELECT 1 FROM dtf_local.hot_parts WHERE order_id=%s + AND item_index=%s AND state NOT IN ('queued','gone') LIMIT 1''', (uid, body.item_index)).fetchone() + if row['cancelled_at'] or row['state'] not in ('rec', 'tra', 'cor', 'imp') or written: + raise HTTPException(409, 'A contração muda até o arquivo ir para a hot folder da máquina.') chosen = dict(row['contraction'] or {}) key = str(body.item_index) if body.value is None: @@ -972,6 +980,12 @@ def move(uid: UUID, body: Move, request: Request, user=Depends(operator)): (row['machine_id'],)).fetchone() or {}).get('name') c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason,back,machine) VALUES(%s,%s,%s,%s,%s,%s,%s)''', (uid,row['state'],body.state,user,body.reason,back,machine_name)) + # Pulled to Imprimindo, its files go to its machine's hot folder; out + # of it, what Flexi did not take leaves (item 10). + if row['state'] == 'imp': + hotfolder.stop(c, uid) + if body.state == 'imp': + hotfolder.start(c, uid) # A pickup reaching Finalizado has its receipt due (item 14), once. due = body.state == 'fin' and not back and receipt.is_pickup(row['snapshot']) changed = c.execute('''UPDATE dtf_local.orders SET state=%s, version=version+1, updated_at=now(), queue_key=NULL, @@ -1418,6 +1432,42 @@ class FolderSync(StrictModel): since: datetime | None = None +@router.post('/api/operator/queue/hot') +def queue_hot(user=Depends(can('print'))): + """For a computer with the automatic folders: the parts it should write + into the machines' hot folders now, claimed for it alone; those written + and not yet taken by Flexi, to see whether they still are; and those to + delete, withdrawn from cards that left Imprimindo (item 10).""" + with db.connect() as c: + due = hotfolder.claim(c, user) + keys = {str(r['upload_id']): r['object_key'] for r in c.execute( + 'SELECT id AS upload_id, object_key FROM dtf_local.uploads WHERE id=ANY(%s)', + ([r['upload_id'] for r in due],)).fetchall()} if due else {} + watched = hotfolder.watched(c) + return {'folder': hotfolder.PRINTING_FOLDER, + 'write': [{'id': r['id'], 'order': str(r['order_id']), 'folder': r['folder'], 'name': r['name'], + 'url': storage.download(keys[str(r['upload_id'])], r['name'])} for r in due], + 'watch': [{'id': r['id'], 'order': str(r['order_id']), 'folder': r['folder'], 'name': r['name']} + for r in watched if r['state'] == 'written'], + 'withdraw': [{'id': r['id'], 'order': str(r['order_id']), 'folder': r['folder'], 'name': r['name']} + for r in watched if r['state'] == 'withdraw']} + + +class HotReport(StrictModel): + state: Literal['written', 'released', 'consumed', 'gone'] + + +@router.post('/api/operator/queue/hot/{part_id}') +def report_hot(part_id: int, body: HotReport, user=Depends(can('print'))): + """What a computer saw of a part: written, not written, taken by Flexi, + or deleted after it was withdrawn.""" + with db.connect() as c: + applied = hotfolder.report(c, part_id, body.state, user) + if applied and body.state == 'written': + audit('hot_folder_written', part=part_id, operator=user) + return {'ok': applied} + + @router.post('/api/operator/queue/folder') def queue_folder(body: FolderSync, user=Depends(can('print'))): """What the Kanban's automatic folders should hold. `early` is Dropstar's diff --git a/app/hotfolder.py b/app/hotfolder.py new file mode 100644 index 0000000..70f399e --- /dev/null +++ b/app/hotfolder.py @@ -0,0 +1,136 @@ +"""Each machine's hot folders (Dropstar's third round, item 10, 2026-10-29/30). + +FlexiPRINT watches 3. Imprimindo/// and takes a file out +of it when it rips. When the operator pulls a card to Imprimindo, its files +go, as a copy, into its machine's folder for the item's contraction class; +the order's own file stays in its stage folder. A film over 15 m is several +parts (item 13): all on the same machine, in order, never more than two in +the folder at once. The third is written when Flexi takes the first. + +Only the server knows what each folder should get, and the Kanban's +computers write it: a part is claimed by one computer, so two never write +the same file and Flexi never prints it twice. A claim that did not finish +goes back to the queue. A written part that is gone from its folder was +taken by Flexi, and is never written again. A card that leaves Imprimindo +(Revisão, Correção, a step back, a cancellation) withdraws what Flexi has not +taken yet, and its computer deletes it. + +Each part's life is one row of dtf_local.hot_parts: +queued -> claimed -> written -> consumed, or withdraw -> gone. +""" +from datetime import timedelta + +# The machines' folders, inside the Kanban's main folder (Dropstar, 2026-10-30). +PRINTING_FOLDER = '3. Imprimindo' +# Two parts at most in a machine's folder (Dropstar, 2026-10-30). +IN_FOLDER = 2 +# A computer that claimed a part and never said it was written. +CLAIM_TIMEOUT = timedelta(minutes=10) +CLASSES = ('C1', 'C2', 'C3') + + +def contraction(order, index): + """The item's class for the folder: the one chosen in the Kanban, or what + the Site measured (C3 when the customer protected the solid areas).""" + chosen = (order.get('contraction') or {}).get(str(index)) or {} + if chosen.get('class') in CLASSES: + return chosen['class'] + item = order['snapshot']['items'][index] + if item.get('stroke_choice') == 'client_c3': + return 'C3' + return item.get('stroke_class') if item.get('stroke_class') in CLASSES else None + + +def start(c, order_id): + """The order entered Imprimindo: its approved finals queue for its + machine's folder, item by item, part by part.""" + files = c.execute('''SELECT f.item_index, f.upload_id, u.name FROM dtf_local.order_files f + JOIN dtf_local.uploads u ON u.id=f.upload_id + WHERE f.order_id=%s AND f.kind='final' AND f.active ORDER BY f.item_index, u.name''', (order_id,)).fetchall() + round_ = c.execute('SELECT COALESCE(max(round), 0) + 1 AS r FROM dtf_local.hot_parts WHERE order_id=%s', + (order_id,)).fetchone()['r'] + for seq, row in enumerate(files, 1): + c.execute('''INSERT INTO dtf_local.hot_parts(order_id,round,seq,item_index,upload_id,name) + VALUES(%s,%s,%s,%s,%s,%s)''', (order_id, round_, seq, row['item_index'], row['upload_id'], row['name'])) + + +def stop(c, order_id): + """The order left Imprimindo or was cancelled: what is not written stays + unwritten, and what Flexi has not taken is withdrawn from the folder.""" + c.execute('''UPDATE dtf_local.hot_parts SET state=CASE WHEN state IN ('claimed','written') THEN 'withdraw' ELSE 'gone' END, + done_at=CASE WHEN state IN ('claimed','written') THEN NULL ELSE now() END + WHERE order_id=%s AND state IN ('queued','claimed','written')''', (order_id,)) + + +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 + they entered it, until the machine has two in its folder.""" + c.execute('''UPDATE dtf_local.hot_parts SET state='queued', claimed_at=NULL, claimed_by=NULL + WHERE state='claimed' AND claimed_at < now() - %s''', (CLAIM_TIMEOUT,)) + rows = c.execute('''SELECT h.*, o.machine_id, o.contraction, o.snapshot, m.name AS machine_name, + (SELECT max(v.id) FROM dtf_local.movements v WHERE v.order_id=o.id AND v.to_state='imp') AS entered + FROM dtf_local.hot_parts h JOIN dtf_local.orders o ON o.id=h.order_id + JOIN dtf_local.machines m ON m.id=o.machine_id + WHERE h.state IN ('queued','claimed','written') AND o.state='imp' AND o.cancelled_at IS NULL + ORDER BY m.name, entered, h.order_id, h.seq FOR UPDATE OF h''').fetchall() + due, busy, blocked = [], {}, set() + for row in rows: + machine = row['machine_id'] + if row['state'] != 'queued': + busy[machine] = busy.get(machine, 0) + 1 + for row in rows: + machine, order = row['machine_id'], row['order_id'] + if row['state'] != 'queued' or order in blocked: + continue + cls = contraction(row, row['item_index']) + # A part without its class waits, and the parts after it with it. + if busy.get(machine, 0) >= IN_FOLDER or not cls: + blocked.add(order) + continue + folder = f"{row['machine_name']}/{cls}" + c.execute('''UPDATE dtf_local.hot_parts SET state='claimed', claimed_at=now(), claimed_by=%s, folder=%s + WHERE id=%s''', (user, folder, row['id'])) + busy[machine] = busy.get(machine, 0) + 1 + due.append({**row, 'folder': folder}) + return due + + +def watched(c): + """The parts written and not yet taken by Flexi, and those to delete.""" + return c.execute('''SELECT id, order_id, name, folder, state FROM dtf_local.hot_parts + WHERE state IN ('written','withdraw') AND folder IS NOT NULL ORDER BY id''').fetchall() + + +# What a computer reports about a part, and from which states it may. +REPORTS = {'written': ('claimed',), 'released': ('claimed',), 'consumed': ('written',), 'gone': ('withdraw',)} + + +def report(c, part_id, what, user): + """A computer wrote the part, could not, saw Flexi take it, or deleted a + withdrawn one. Returns whether the report applied.""" + if what == 'written': + sql = '''UPDATE dtf_local.hot_parts SET state='written', written_at=now() WHERE id=%s AND state='claimed' + AND claimed_by=%s RETURNING id''' + return bool(c.execute(sql, (part_id, user)).fetchone()) + if what == 'released': + sql = '''UPDATE dtf_local.hot_parts SET state='queued', claimed_at=NULL, claimed_by=NULL, folder=NULL + WHERE id=%s AND state='claimed' AND claimed_by=%s RETURNING id''' + return bool(c.execute(sql, (part_id, user)).fetchone()) + new = {'consumed': 'consumed', 'gone': 'gone'}[what] + return bool(c.execute(f'''UPDATE dtf_local.hot_parts SET state='{new}', done_at=now() WHERE id=%s + AND state=ANY(%s) RETURNING id''', (part_id, list(REPORTS[what]))).fetchone()) + + +def progress(c, order_ids): + """For each order in parts, where its film is (Dropstar, 2026-10-30): + "parte 3/7 imprimindo · 4/7 ripando". Flexi rips the part it took last + while the one before it prints.""" + rows = c.execute('''SELECT h.order_id, count(*) AS parts, + max(h.seq) FILTER (WHERE h.state='consumed') AS taken, + count(*) FILTER (WHERE h.state IN ('claimed','written')) AS waiting + FROM dtf_local.hot_parts h + WHERE h.order_id=ANY(%s) AND h.round=(SELECT max(round) FROM dtf_local.hot_parts x WHERE x.order_id=h.order_id) + GROUP BY h.order_id''', (order_ids,)).fetchall() + return {row['order_id']: {'parts': row['parts'], 'taken': row['taken'] or 0, 'waiting': row['waiting']} + for row in rows} diff --git a/app/schema.sql b/app/schema.sql index 0192e1b..19bc48c 100644 --- a/app/schema.sql +++ b/app/schema.sql @@ -212,6 +212,23 @@ CREATE TABLE IF NOT EXISTS dtf_local.print_parts ( FOREIGN KEY(order_id,item_index) REFERENCES dtf_local.print_files(order_id,item_index) ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS print_parts_upload ON dtf_local.print_parts(upload_id); + +-- What each machine's hot folder gets (item 10, app/hotfolder.py): one row per +-- file or part, per entry into Imprimindo (round), written by one computer. +CREATE TABLE IF NOT EXISTS dtf_local.hot_parts ( + id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + order_id uuid NOT NULL REFERENCES dtf_local.orders(id) ON DELETE CASCADE, + round integer NOT NULL, seq integer NOT NULL, item_index integer NOT NULL, + upload_id uuid NOT NULL REFERENCES dtf_local.uploads(id) ON DELETE CASCADE, + name text NOT NULL, folder text, + state text NOT NULL DEFAULT 'queued' + CHECK(state IN ('queued','claimed','written','consumed','withdraw','gone')), + claimed_at timestamptz, claimed_by text, written_at timestamptz, done_at timestamptz, + created_at timestamptz NOT NULL DEFAULT now(), + UNIQUE(order_id, round, seq) +); +CREATE INDEX IF NOT EXISTS hot_parts_open ON dtf_local.hot_parts(order_id) + WHERE state IN ('queued','claimed','written','withdraw'); INSERT INTO dtf_local.print_parts(order_id,item_index,part,upload_id) SELECT order_id,item_index,1,upload_id FROM dtf_local.print_files WHERE upload_id IS NOT NULL ON CONFLICT DO NOTHING; diff --git a/tests/print_file_test.py b/tests/print_file_test.py index b67e8ef..98c91bd 100644 --- a/tests/print_file_test.py +++ b/tests/print_file_test.py @@ -152,6 +152,37 @@ def run(): 'note': 'again'}, operator=True, expected=409) print('PASS: generated file approved as final without re-uploading; order queued for printing') + # 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. + tag = uuid4().hex[:6] + machine = client.call('/operator/machines', {'name': f'Hot {tag}', 'products': ['textil']}, operator=True)['id'] + try: + client.call('/operator/orders/' + oid + '/machine', {'machine_id': machine}, operator=True) + # No class measured or chosen: the part waits for one. + assert not [p for p in client.call('/operator/queue/hot', {}, operator=True)['write'] if p['order'] == oid] + client.call('/operator/orders/' + oid + '/contraction', {'item_index': 0, 'value': 'C2'}, operator=True) + hot = client.call('/operator/queue/hot', {}, operator=True) + due = [p for p in hot['write'] if p['order'] == oid] + assert hot['folder'] == '3. Imprimindo' and [(p['folder'], p['name']) for p in due] == \ + [(f'Hot {tag}/C2', 'DTF-%d-item-1.png' % order['number'])], hot + # Claimed by this computer only: asked again, nobody else gets it. + assert not [p for p in client.call('/operator/queue/hot', {}, operator=True)['write'] if p['order'] == oid] + part = due[0]['id'] + assert client.call(f'/operator/queue/hot/{part}', {'state': 'written'}, operator=True)['ok'] + client.call('/operator/orders/' + oid + '/contraction', {'item_index': 0, 'value': 'C1'}, operator=True, + expected=409) + watch = client.call('/operator/queue/hot', {}, operator=True)['watch'] + assert [p['id'] for p in watch if p['order'] == oid] == [part], watch + assert client.call(f'/operator/queue/hot/{part}', {'state': 'consumed'}, operator=True)['ok'] + assert not client.call(f'/operator/queue/hot/{part}', {'state': 'consumed'}, operator=True)['ok'] + board = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == oid) + assert board['hot'] == {'parts': 1, 'taken': 1, 'waiting': 0}, board['hot'] + print('PASS: the printing file goes once into its machine\'s hot folder for its class') + finally: + client.call('/operator/machines/' + machine, {'name': f'Hot {tag}', 'products': ['textil'], 'active': False}, + operator=True) + # A single-page PDF is drawn from its vectors at 300 DPI. pdf_upload = upload_bytes(client, artwork('PDF'), name='LOCAL-PRINT-TEST.pdf') pdf_order = paid_order(client, loose_item(pdf_upload)) diff --git a/tests/users_test.py b/tests/users_test.py index 8f738fe..89da3b4 100644 --- a/tests/users_test.py +++ b/tests/users_test.py @@ -431,13 +431,15 @@ def run(): onto = su.call(f'/operator/orders/{lane}/move', {'state': 'imp', 'version': 0, 'reason': '', 'machine_id': textil2}, operator=True) assert str(onto['machine_id']) == textil2 and onto['machine_chosen'], onto - # The contraction class (item 9): chosen per item until the order prints, - # and back to the browser's measure with None. + # The contraction class (item 9): chosen per item until its file goes to + # the machine's hot folder (item 10), and back to the browser's measure with None. su.call(f'/operator/orders/{third}/contraction', {'item_index': 0, 'value': 'C3'}, operator=True) chosen = next(o for o in su.call('/operator/board', operator=True)['orders'] if o['id'] == third)['contraction'] assert chosen['0']['class'] == 'C3' and chosen['0']['by'], chosen su.call(f'/operator/orders/{third}/contraction', {'item_index': 5, 'value': 'C1'}, operator=True, expected=422) - su.call(f'/operator/orders/{lane}/contraction', {'item_index': 0, 'value': 'C1'}, operator=True, expected=409) + # Printing, with nothing in the hot folder yet, it still changes. + su.call(f'/operator/orders/{lane}/contraction', {'item_index': 0, 'value': 'C1'}, operator=True) + su.call(f'/operator/orders/{lane}/contraction', {'item_index': 0, 'value': None}, operator=True) su.call(f'/operator/orders/{third}/contraction', {'item_index': 0, 'value': None}, operator=True) assert next(o for o in su.call('/operator/board', operator=True)['orders'] if o['id'] == third)['contraction'] == {} loaded = su.call('/operator/board', operator=True) diff --git a/web/kanban.js b/web/kanban.js index 9fede7f..0fac83b 100644 --- a/web/kanban.js +++ b/web/kanban.js @@ -422,6 +422,36 @@ async function fetchInto(dir,file){ await writeWhole(dir,file.name,r.body); } +// The machines' hot folders (item 10): 3. Imprimindo///. +// The server says what this computer writes now (claimed for it alone, two +// parts at most per machine); a written part gone from its folder was taken +// by FlexiPRINT, and is never written again; a withdrawn one, from a card that +// left Imprimindo, is deleted if Flexi has not taken it. Returns how many +// parts it wrote. +async function syncHot(){ + const hot=await api('/queue/hot',{}); + if(!hot.write.length&&!hot.watch.length&&!hot.withdraw.length)return 0; + const root=await stageDir(hot.folder); + const dirOf=async path=>{let dir=root;for(const part of path.split('/'))dir=await dir.getDirectoryHandle(part,{create:true});return dir;}; + const missing=e=>e.name==='NotFoundError'; + for(const p of hot.withdraw){ + await (await dirOf(p.folder)).removeEntry(p.name).catch(e=>{if(!missing(e))throw e;}); + await api('/queue/hot/'+p.id,{state:'gone'}); + } + for(const p of hot.watch){ + try{await (await dirOf(p.folder)).getFileHandle(p.name);} + catch(e){if(!missing(e))throw e;await api('/queue/hot/'+p.id,{state:'consumed'});} + } + let written=0; + for(const p of hot.write){ + FOLDER.status='Gravando na hot folder '+p.folder+': '+p.name;paintFolder(); + try{await fetchInto(await dirOf(p.folder),p);} + catch(e){await api('/queue/hot/'+p.id,{state:'released'}).catch(()=>{});throw e;} + await api('/queue/hot/'+p.id,{state:'written'});written++; + } + return written; +} + // Bring the folders in line with the board: remove the files of orders that // were cancelled, deleted, sent back for correction or given another file, // and those kept their days in Finalizado; move each file to its stage's @@ -441,7 +471,8 @@ async function syncFolder(force=false){ if(stages)await makeStageFolders(); const held=stages?[...new Set([...FOLDER.saved.values()].map(r=>r.order).filter(Boolean))].slice(-1000):[]; const {files,states,receipts=[]}=await api('/queue/folder',{early:stages,held,since:stages?FOLDER.since||await folderSince():null}); - const wanted=new Map(files.map(f=>[f.order+':'+f.item,f])); + // By file: an item over 15 m is several parts (item 13), each its own file. + const wanted=new Map(files.map(f=>[f.upload_id,f])); const where=stages?'“'+FOLDER.handle.name+'”':'a pasta de downloads'; let removed=0, moved=0, saved=0; const record=async(uid,file,folder)=>{ @@ -451,8 +482,8 @@ async function syncFolder(force=false){ if(stages)for(const [uid,rec] of [...FOLDER.saved]){ if(!rec.order||!rec.folder)continue; const state=states[rec.order], target=STAGE_FOLDERS[state]; - const now=wanted.get(rec.order+':'+rec.item); - const replaced=(state==='rec'||state==='tra')&&(!now||now.upload_id!==uid); + const now=wanted.get(uid); + const replaced=(state==='rec'||state==='tra')&&(!now||now.order!==rec.order); const kept=rec.folder===STAGE_FOLDERS.fin&&Date.now()-(rec.at||0)>KEEP_FINISHED_DAYS*86400000; if(!target||replaced||kept){await removeSaved(rec);FOLDER.saved.delete(uid);removed++;await keepSaved();continue;} if(rec.folder===target)continue; @@ -461,6 +492,7 @@ async function syncFolder(force=false){ if(now&&now.upload_id===uid){await fetchInto(await stageDir(target),now);await record(uid,now,target);moved++;} else{FOLDER.saved.delete(uid);await keepSaved();} } + const hot=stages?await syncHot():0; if(stages)for(const old of OLD_FOLDERS) if(![...FOLDER.saved.values()].some(r=>r.folder===old))await FOLDER.handle.removeEntry(old).catch(()=>{}); // New files, each into its stage's folder: the server sends those in Arte @@ -498,6 +530,7 @@ async function syncFolder(force=false){ FOLDER.lastSig=sig;FOLDER.error=''; FOLDER.status=''; if(saved)say((stages?'Salvos ':'Baixados ')+saved+' arquivo(s) em '+where+'.'); + if(hot)say('Gravados '+hot+' arquivo(s) na hot folder da máquina.'); if(printed)say(printed+' recibo(s) de retirada salvos em '+RECEIPTS_FOLDER+'.'); if(moved)say(moved+' arquivo(s) mudaram de pasta com o pedido.'); if(removed)say(removed+' arquivo(s) de pedidos cancelados, excluídos, em correção, trocados ou finalizados há mais de '+KEEP_FINISHED_DAYS+' dias saíram das pastas.'); @@ -666,6 +699,16 @@ const residueBadge=item=>badge('! Resíduo aceito','warn','O cliente aceitou imp // in is printing, the next is being ripped meanwhile. const PRINTING={imprimindo:['Imprimindo','live','Já ripou, está rodando'], ripando:['Ripando','rip','O Flexi está ripando enquanto o anterior roda']}; +// A film in parts on its machine (items 10 and 13, Dropstar 2026-10-30): +// "parte 3/7 imprimindo · 4/7 ripando". Flexi rips the part it took last from +// the hot folder while the one before it prints. +function partsStep(order){ + const hot=order.hot;if(!hot||hot.parts<2)return null; + const n=hot.parts, t=hot.taken; + if(!t)return ['Parte 1/'+n+' na hot folder','wait']; + if(t===1)return ['Parte 1/'+n+' ripando','rip']; + return ['Parte '+(t-1)+'/'+n+' imprimindo · '+t+'/'+n+' ripando','live']; +} async function proofOk(order){ await api('/orders/'+order.id+'/proof',{});say('Prova do pedido #'+order.number+' conferida.');await load(); } @@ -910,7 +953,7 @@ function nextStep(order,place){ if(order.cancelled_at)return ['Cancelado','wait']; if(order.state==='cor')return ['Esperando o cliente','wait']; if(order.state==='rev')return ['Conferir a folha','act']; - if(order.state==='imp')return order.printing?PRINTING[order.printing].slice(0,2):['Na máquina','wait']; + if(order.state==='imp')return partsStep(order)||(order.printing?PRINTING[order.printing].slice(0,2):['Na máquina','wait']); if(order.state==='tra'){ // The operator whose machine prints this product pulls the first one. const m=(board.machines||[]).find(x=>x.id===myMachine()?.id);