Compare commits
2 Commits
c291f00e96
...
25e4ac541a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25e4ac541a | ||
|
|
dc87d46801 |
@@ -6,7 +6,7 @@ import secrets
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import date, datetime, timedelta, timezone
|
from datetime import date, datetime, timedelta, timezone
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
from uuid import UUID
|
from uuid import UUID, uuid4
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request, Response
|
from fastapi import APIRouter, Depends, HTTPException, Query, Request, Response
|
||||||
from fastapi.responses import RedirectResponse
|
from fastapi.responses import RedirectResponse
|
||||||
@@ -808,7 +808,23 @@ def proof_answer(uid: UUID, body: ProofAnswer, user=Depends(can('proof'))):
|
|||||||
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason)
|
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason)
|
||||||
VALUES(%s,'rev','fin',%s,%s)''', (uid, user, label))
|
VALUES(%s,'rev','fin',%s,%s)''', (uid, user, label))
|
||||||
if body.result == 'ok':
|
if body.result == 'ok':
|
||||||
# The order enters the queue: Arte conferida, if its finals are approved.
|
# A prova aprovada é a conferência do pai: os arquivos completos
|
||||||
|
# que o Prumo gerou entram como finais, e o pai segue para a fila.
|
||||||
|
# Itens que ainda dependem de preparo manual continuam em Arte
|
||||||
|
# recebida, com o botão de final disponível.
|
||||||
|
if parent['state'] == 'rec':
|
||||||
|
generated = c.execute('''SELECT p.item_index,p.upload_id FROM dtf_local.print_files p
|
||||||
|
WHERE p.order_id=%s AND p.status='ready' AND p.upload_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f
|
||||||
|
WHERE f.order_id=p.order_id AND f.item_index=p.item_index
|
||||||
|
AND f.kind='final' AND f.active)
|
||||||
|
ORDER BY p.item_index''', (parent['id'],)).fetchall()
|
||||||
|
for row in generated:
|
||||||
|
c.execute('''INSERT INTO dtf_local.order_files
|
||||||
|
(id,order_id,upload_id,item_index,kind,note,created_by)
|
||||||
|
VALUES(%s,%s,%s,%s,'final',%s,'Prumo')''',
|
||||||
|
(uuid4(), parent['id'], row['upload_id'], row['item_index'],
|
||||||
|
f'Aprovado pela prova do #{card["number"]}'))
|
||||||
ready = parent['state'] == 'rec' and all(c.execute('''SELECT 1 FROM dtf_local.order_files
|
ready = parent['state'] == 'rec' and all(c.execute('''SELECT 1 FROM dtf_local.order_files
|
||||||
WHERE order_id=%s AND kind='final' AND active AND item_index=%s LIMIT 1''', (parent['id'], i)).fetchone()
|
WHERE order_id=%s AND kind='final' AND active AND item_index=%s LIMIT 1''', (parent['id'], i)).fetchone()
|
||||||
for i in range(len(parent['snapshot']['items'])))
|
for i in range(len(parent['snapshot']['items'])))
|
||||||
|
|||||||
@@ -275,6 +275,34 @@ def run():
|
|||||||
assert mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok' and mine['state'] == 'tra', mine
|
assert mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok' and mine['state'] == 'tra', mine
|
||||||
print('PASS: an order with a proof waits for its proof card, which is answered OK or rejected in Revisão')
|
print('PASS: an order with a proof waits for its proof card, which is answered OK or rejected in Revisão')
|
||||||
|
|
||||||
|
# Prova OK is the parent's check: the full print file Prumo already made
|
||||||
|
# becomes the parent final and the parent enters Arte conferida (0.1).
|
||||||
|
readable = upload_bytes(client, artwork(), name='LOCAL-PROOF-REAL.png')
|
||||||
|
long = loose_item(readable, copies=1)
|
||||||
|
parent = paid_order(client, long)
|
||||||
|
# A proof card for a small order, as the panel can open one; the parent
|
||||||
|
# file is only 10 cm tall, so this test does not draw a 10 m film.
|
||||||
|
with db.connect() as c:
|
||||||
|
c.execute("UPDATE dtf_local.orders SET snapshot=jsonb_set(snapshot,'{proof}','true') WHERE id=%s",
|
||||||
|
(parent['id'],))
|
||||||
|
client.call('/operator/orders/' + parent['id'] + '/proof-card', {}, operator=True)
|
||||||
|
board = client.call('/operator/board', operator=True)['orders']
|
||||||
|
mine = next(o for o in board if o['id'] == parent['id'])
|
||||||
|
card = next(o for o in board if o['id'] == mine['proof_card']['id'])
|
||||||
|
wait_print(client, parent['id'], 'ready')
|
||||||
|
wait_print(client, card['id'], 'ready')
|
||||||
|
with db.connect() as c:
|
||||||
|
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (card['id'],))
|
||||||
|
client.call('/operator/orders/' + card['id'] + '/proof-answer', {'result': 'ok'}, operator=True)
|
||||||
|
mine = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == parent['id'])
|
||||||
|
assert mine['state'] == 'tra' and mine['final_items'] == [0], mine
|
||||||
|
assert mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok', mine
|
||||||
|
with db.connect() as c:
|
||||||
|
final = c.execute('''SELECT note,created_by FROM dtf_local.order_files
|
||||||
|
WHERE order_id=%s AND kind='final' AND active''', (parent['id'],)).fetchone()
|
||||||
|
assert final['created_by'] == 'Prumo' and 'prova' in final['note'].lower(), final
|
||||||
|
print('PASS: Prova OK turns Prumo\'s full file into the parent final and queues it')
|
||||||
|
|
||||||
# A customer cannot see or reuse another order's generated file.
|
# A customer cannot see or reuse another order's generated file.
|
||||||
other = Client()
|
other = Client()
|
||||||
other.call('/session')
|
other.call('/session')
|
||||||
|
|||||||
@@ -506,7 +506,8 @@
|
|||||||
const titulo=node('h4','Pagamento confirmado');
|
const titulo=node('h4','Pagamento confirmado');
|
||||||
titulo.insertAdjacentHTML('afterbegin', icone('okCirculo'));
|
titulo.insertAdjacentHTML('afterbegin', icone('okCirculo'));
|
||||||
box.append(titulo,
|
box.append(titulo,
|
||||||
node('p','Recebemos seu pedido e ele já está na produção. Você acompanha cada etapa em Meus pedidos.'));
|
node('p','Recebemos seu pedido e ele já está na produção. Você acompanha cada etapa em Meus pedidos.'),
|
||||||
|
node('p','O Prumo está preparando o arquivo de impressão. Em geral leva até 1 min por 10 m; o card aparece em Meus pedidos quando fica pronto.'));
|
||||||
button('Ver meus pedidos',()=>location.assign('/conta/pedidos?order='+quote.order.id),box);
|
button('Ver meus pedidos',()=>location.assign('/conta/pedidos?order='+quote.order.id),box);
|
||||||
actions.append(box);
|
actions.append(box);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
scope and run top to bottom, exactly as the original did. */
|
scope and run top to bottom, exactly as the original did. */
|
||||||
|
|
||||||
const $=id=>document.getElementById(id);
|
const $=id=>document.getElementById(id);
|
||||||
|
// Segundos desde um marco, para as etapas nunca ficarem mudas (item 0.12).
|
||||||
|
const segundosDesde=inicio=>inicio?Math.max(0,Math.round((Date.now()-inicio)/1000)):0;
|
||||||
// What the browser measured while the customer built the cart (item 0.12):
|
// What the browser measured while the customer built the cart (item 0.12):
|
||||||
// page load, upload, Prumo's check and the loose-art montage. It only feeds
|
// page load, upload, Prumo's check and the loose-art montage. It only feeds
|
||||||
// Números; no price or acceptance depends on it.
|
// Números; no price or acceptance depends on it.
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ function previaAoVivo(){
|
|||||||
if(!x.previewSrc){
|
if(!x.previewSrc){
|
||||||
const esqueleto=document.createElement('div'); esqueleto.className='skel folhaSkel';
|
const esqueleto=document.createElement('div'); esqueleto.className='skel folhaSkel';
|
||||||
esqueleto.style.aspectRatio=x.med ? x.med.larg+' / '+Math.min(x.med.alt,x.med.larg*4) : '1 / 2';
|
esqueleto.style.aspectRatio=x.med ? x.med.larg+' / '+Math.min(x.med.alt,x.med.larg*4) : '1 / 2';
|
||||||
esqueleto.append(Object.assign(document.createElement('span'),{textContent:'Gerando a prévia da folha…'}));
|
esqueleto.append(Object.assign(document.createElement('span'),{textContent:'Gerando a prévia da folha… · '+segundosDesde(x.analiseInicio)+' s'}));
|
||||||
figura.append(esqueleto,legenda); painel.append(figura); return;
|
figura.append(esqueleto,legenda); painel.append(figura); return;
|
||||||
}
|
}
|
||||||
const pilha=document.createElement('div'); pilha.className='folhaPilha';
|
const pilha=document.createElement('div'); pilha.className='folhaPilha';
|
||||||
|
|||||||
@@ -406,8 +406,9 @@ function medirFolha(file){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function textoProgresso(x){
|
function textoProgresso(x){
|
||||||
if(x.med && x.med.grande) return 'gerando a prévia e conferindo a arte · '+faltaLeitura(x.leitura);
|
const tempo=x.analiseInicio?' · '+segundosDesde(x.analiseInicio)+' s':'';
|
||||||
return x.pct<50?'lendo o arquivo…':x.pct<70?'medindo a folha…':'conferindo a arte…';
|
if(x.med && x.med.grande) return 'gerando a prévia e conferindo a arte · '+faltaLeitura(x.leitura)+tempo;
|
||||||
|
return (x.pct<50?'lendo o arquivo…':x.pct<70?'medindo a folha…':'conferindo a arte…')+tempo;
|
||||||
}
|
}
|
||||||
// The file card's thumbnail (52 x 96 px, drawn at twice that for sharp screens).
|
// The file card's thumbnail (52 x 96 px, drawn at twice that for sharp screens).
|
||||||
// At 480 x 720 it is the picture the Kanban shows of the order (checkout.js).
|
// At 480 x 720 it is the picture the Kanban shows of the order (checkout.js).
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ function avaliar(){
|
|||||||
// Resíduo e fundo chapado barram antes do pagamento, com um ponto só
|
// Resíduo e fundo chapado barram antes do pagamento, com um ponto só
|
||||||
// (Dropstar, 21/10/2026): então o pedido espera a conferência terminar.
|
// (Dropstar, 21/10/2026): então o pedido espera a conferência terminar.
|
||||||
const lendo=folhas.find(x=>x.pct!=null);
|
const lendo=folhas.find(x=>x.pct!=null);
|
||||||
if(lendo) return {pronto:false, falta:'Conferindo '+lendo.f.name+'…'};
|
if(lendo) return {pronto:false, falta:'Conferindo '+lendo.f.name+'… · '+segundosDesde(lendo.analiseInicio)+' s'};
|
||||||
const barrada=folhas.find(folhaBarrada);
|
const barrada=folhas.find(folhaBarrada);
|
||||||
if(barrada) return {pronto:false, falta:barrada.an.fundoChapado
|
if(barrada) return {pronto:false, falta:barrada.an.fundoChapado
|
||||||
? barrada.f.name+' está sem fundo transparente. Exporte a folha com fundo transparente, em PNG ou PDF, e envie de novo.'
|
? barrada.f.name+' está sem fundo transparente. Exporte a folha com fundo transparente, em PNG ou PDF, e envie de novo.'
|
||||||
@@ -145,7 +145,8 @@ function avaliar(){
|
|||||||
return {pronto:true};
|
return {pronto:true};
|
||||||
}
|
}
|
||||||
if(!artes.length) return {pronto:false, falta:'Arraste suas artes para começar.'};
|
if(!artes.length) return {pronto:false, falta:'Arraste suas artes para começar.'};
|
||||||
if(artes.some(a=>a.lendo!=null)) return {pronto:false, falta:'Gerando a prévia das artes grandes…'};
|
const grande=artes.find(a=>a.lendo!=null);
|
||||||
|
if(grande) return {pronto:false, falta:'Gerando a prévia das artes grandes… · '+segundosDesde(grande.analiseInicio)+' s'};
|
||||||
if(artes.some(a=>a.decodeError || !(a.src||a.semPrevia) || !(a.px>0) || !(a.py>0)))
|
if(artes.some(a=>a.decodeError || !(a.src||a.semPrevia) || !(a.px>0) || !(a.py>0)))
|
||||||
return {pronto:false, falta:'Não conseguimos ler uma das imagens. Exporte-a novamente em PNG antes de continuar.'};
|
return {pronto:false, falta:'Não conseguimos ler uma das imagens. Exporte-a novamente em PNG antes de continuar.'};
|
||||||
if(artes.some(a=>!Number.isFinite(a.cm) || a.cm>larguraFilme()))
|
if(artes.some(a=>!Number.isFinite(a.cm) || a.cm>larguraFilme()))
|
||||||
@@ -156,7 +157,8 @@ function avaliar(){
|
|||||||
' para ver a nota e o preço.'};
|
' para ver a nota e o preço.'};
|
||||||
// Item 4: a dot under 2 mm in a loose artwork holds the order like on a
|
// Item 4: a dot under 2 mm in a loose artwork holds the order like on a
|
||||||
// sheet, until the customer erases it or accepts printing that artwork so.
|
// sheet, until the customer erases it or accepts printing that artwork so.
|
||||||
if(artes.some(a=>a.lendoArte)) return {pronto:false, falta:'Conferindo as artes…'};
|
const lendoArte=artes.find(a=>a.lendoArte);
|
||||||
|
if(lendoArte) return {pronto:false, falta:'Conferindo as artes… · '+segundosDesde(lendoArte.analiseInicio)+' s'};
|
||||||
const comPontos=artes.find(a=>{const an=analiseDaArte(a);return an&&an.residuos&&!a.residuoAceito;});
|
const comPontos=artes.find(a=>{const an=analiseDaArte(a);return an&&an.residuos&&!a.residuoAceito;});
|
||||||
if(comPontos){const n=analiseDaArte(comPontos).residuos;
|
if(comPontos){const n=analiseDaArte(comPontos).residuos;
|
||||||
return {pronto:false, falta:comPontos.f.name+' tem '+n+' ponto'+(n>1?'s':'')+
|
return {pronto:false, falta:comPontos.f.name+' tem '+n+' ponto'+(n>1?'s':'')+
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ async function sel(fs){
|
|||||||
// On their way at once; a JPG is refused at the order anyway.
|
// On their way at once; a JPG is refused at the order anyway.
|
||||||
fs.filter(f=>!/\.jpe?g$/i.test(f.name)).forEach(f=>window.dtfEnvio?.enviar(f));
|
fs.filter(f=>!/\.jpe?g$/i.test(f.name)).forEach(f=>window.dtfEnvio?.enviar(f));
|
||||||
if(ehFolha()){
|
if(ehFolha()){
|
||||||
const novas=fs.map(f=>({f, med:null, rep:1, m:0, semAnalise:null}));
|
const novas=fs.map(f=>({f, med:null, rep:1, m:0, semAnalise:null, analiseInicio:Date.now()}));
|
||||||
folhas=folhas.concat(novas); // soma, não substitui
|
folhas=folhas.concat(novas); // soma, não substitui
|
||||||
pintaFolha();
|
pintaFolha();
|
||||||
novas.forEach(x=>{
|
novas.forEach(x=>{
|
||||||
@@ -219,7 +219,7 @@ async function sel(fs){
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const novos=fs.map(f=>({f,px:0,py:0,cm:0,q:1,prop:1,giro:0,esp:false}));
|
const novos=fs.map(f=>({f,px:0,py:0,cm:0,q:1,prop:1,giro:0,esp:false,analiseInicio:Date.now()}));
|
||||||
artes=novos.concat(artes); // a mais recente fica no topo da fila
|
artes=novos.concat(artes); // a mais recente fica no topo da fila
|
||||||
recemChegada=novos[0];
|
recemChegada=novos[0];
|
||||||
pintaArtes();
|
pintaArtes();
|
||||||
|
|||||||
Reference in New Issue
Block a user