Compare commits
41 Commits
produzione
...
xwms
| Author | SHA1 | Date | |
|---|---|---|---|
| f96da60231 | |||
| a874d09e40 | |||
| 9d87b07648 | |||
| fc43cbb7ec | |||
| 106ea49f64 | |||
| e4b227e82c | |||
| 85b11834b6 | |||
| 588bf6ce73 | |||
| d3941e88cc | |||
| 04406e840d | |||
| a60610c03e | |||
| 3a2893dc3d | |||
| 5dc26b21b1 | |||
| 0ae052e55b | |||
| 7dc068b1b0 | |||
| 1ea37eb49d | |||
| 7f3ce9d3af | |||
| 8e9294f80b | |||
| fa9d0be09a | |||
| 44cd82352b | |||
| eb12af3b9a | |||
| 77da8d9bad | |||
| 5dd7139b19 | |||
| d4cfe0be54 | |||
| f4e73bd5b9 | |||
| e575c748cc | |||
| 7ecc906d59 | |||
| 29687c8094 | |||
| bd844ce056 | |||
| 466778ae5f | |||
| cc9680c49a | |||
| be7ce700d1 | |||
| 29900b8b09 | |||
| 8f9957a2db | |||
| 742f6a9fe9 | |||
| 4dabba8ce7 | |||
| d2a1f6a068 | |||
| a5e704c214 | |||
| 8489cd7459 | |||
| 6ab42a2303 | |||
| f556b476ff |
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Local credentials, database reports and runtime artifacts are not source code.
|
||||
db_connection.json
|
||||
local_setup/
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.log
|
||||
.codegraph/
|
||||
.venv/
|
||||
*.bak
|
||||
281
DIAGRAMMA_STATI_UDC_2026-10-28.md
Normal file
281
DIAGRAMMA_STATI_UDC_2026-10-28.md
Normal file
@@ -0,0 +1,281 @@
|
||||
# UDC: diagramma degli automatismi e dei movimenti manuali
|
||||
|
||||
Aggiornamento: 29 ottobre 2026. Allegato alla **revisione 12** del
|
||||
[riepilogo degli stati UDC](RIEPILOGO_STATI_UDC_2026-10-28.md).
|
||||
|
||||
**Specifiche da verificare, nessuna implementazione eseguita.**
|
||||
Gli oggetti del diagramma saranno sviluppati soltanto nei database di test
|
||||
Xwmsdb/SAMA1_Xwmstest: vedere [ambiente locale](XWMS_AMBIENTE_LOCALE.md).
|
||||
Vedere anche la [revisione di coerenza e delle alternative tecniche](REVISIONE_SPECIFICHE_E_SERVIZIO_UDC_2026-10-28.md).
|
||||
Questa revisione sostituisce il precedente diagramma esclusivamente manuale.
|
||||
|
||||
L'area precedentemente chiamata NON SCAFFALATE si chiama ora **Pavimento**.
|
||||
Lo stato della UDC resta **non scaffalata**. La scorciatoia principale
|
||||
**UDC non scaffalate** apre questa area in Gestione layout.
|
||||
|
||||
## 1. Due ingressi, un unico insieme di regole
|
||||
|
||||
```text
|
||||
SAM: nascita / cambio effettivo N-S ----> evento automatico ---+
|
||||
|
|
||||
v
|
||||
Regole di transizione
|
||||
|
|
||||
Menu desktop / comando barcode -------> comando manuale -----+
|
||||
|
|
||||
controlli, origine, destinazione
|
||||
|
|
||||
movimento atomico + storico + UI
|
||||
```
|
||||
|
||||
La posizione non si deduce continuamente dal solo flag. Esempio fondamentale:
|
||||
una UDC N caricata in Validazione deve restarvi, non tornare in Confezionamento
|
||||
a ogni refresh. E' il nuovo evento di riapertura, non il mero valore N, che
|
||||
attiva il ritorno. Analogamente una UDC S in cella non torna in Accettazione
|
||||
finche' non avviene una transizione pertinente.
|
||||
|
||||
Il programma esterno controlla CHIUSA; i comandi WMS non aprono o chiudono
|
||||
implicitamente la UDC. Un aggiornamento N -> N o S -> S non e' un cambio stato.
|
||||
|
||||
## 2. Diagramma degli automatismi confermati
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
NEW["Nuova UDC aperta"]
|
||||
C["CONFEZIONAMENTO"]
|
||||
A["ACCETTAZIONE"]
|
||||
V["VALIDAZIONE"]
|
||||
NS["Pavimento"]
|
||||
W["CELLA WMS"]
|
||||
SP["SPEDITA: stato finale, nessun rientro"]
|
||||
|
||||
NEW -->|"A1: nascita con N"| C
|
||||
C -->|"A2: chiusura N -> S"| A
|
||||
V -->|"A3: chiusura N -> S, anche per errore"| A
|
||||
A -->|"A4: riapertura S -> N"| C
|
||||
NS -->|"A5: riapertura S -> N"| C
|
||||
W -->|"A6: riapertura S -> N; libera associazione"| C
|
||||
```
|
||||
|
||||
Il carico di una UDC N in Validazione e' manuale, quindi compare nel diagramma
|
||||
successivo. In Validazione la UDC deve essere aperta; se viene chiusa passa
|
||||
in Accettazione. Se poi viene riaperta, da Accettazione va in Confezionamento.
|
||||
|
||||
**SPEDITA e' uno stato finale:** nessuna riapertura o recupero e' consentito
|
||||
dalle procedure ordinarie. Il nodo e' mostrato senza frecce di ritorno; gli
|
||||
ingressi in Spedizione appartengono ai flussi di spedizione gia' previsti,
|
||||
non agli automatismi di apertura/chiusura rappresentati qui.
|
||||
|
||||
Se SAM producesse comunque una riapertura di una UDC spedita, l'evento non
|
||||
attiva alcun rientro: il WMS mantiene Spedita e segnala l'incoerenza nel log
|
||||
e nella diagnostica da progettare. Una spedizione errata viene corretta
|
||||
esclusivamente con intervento SQL manuale, fuori dai comandi ordinari.
|
||||
Restano le protezioni esistenti sui documenti chiusi con posizione residua.
|
||||
Una chiusura N -> S in altri contesti inattesi richiede ancora una regola specifica.
|
||||
|
||||
### Lettura senza Mermaid
|
||||
|
||||
```text
|
||||
Nascita aperta ------------------------------> CONFEZIONAMENTO
|
||||
CONFEZIONAMENTO -- chiusura in SAM -----------> ACCETTAZIONE
|
||||
VALIDAZIONE ---- chiusura in SAM -------------> ACCETTAZIONE
|
||||
ACCETTAZIONE --- riapertura in SAM -----------> CONFEZIONAMENTO
|
||||
Pavimento ------ riapertura in SAM -----------> CONFEZIONAMENTO
|
||||
CELLA WMS ------ riapertura in SAM -----------> CONFEZIONAMENTO
|
||||
(cessa la vecchia associazione)
|
||||
SPEDITA -------- nessun ritorno consentito; anomalia se SAM tenta la riapertura
|
||||
```
|
||||
|
||||
La movimentazione logica non prova lo spostamento fisico del pallet. Dopo
|
||||
la successiva chiusura e il ritorno in Accettazione, l'eventuale nuova
|
||||
allocazione fisica deve essere registrata manualmente.
|
||||
La coerenza fisica resta responsabilita' del magazziniere: non si aggiungono
|
||||
conferme di rimozione o blocchi della vecchia cella. Decisione confermata.
|
||||
|
||||
## 3. Diagramma dei comandi manuali
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
NS["Pavimento"]
|
||||
A["ACCETTAZIONE"]
|
||||
C["CONFEZIONAMENTO"]
|
||||
V["VALIDAZIONE"]
|
||||
W["CELLA WMS"]
|
||||
|
||||
NS -->|"M1: Scarico qui; S"| A
|
||||
A -->|"M2: Scarico qui; N"| C
|
||||
C -->|"M3: Carico in Accettazione; S"| A
|
||||
C -->|"M4: Carico in Validazione; solo N"| V
|
||||
V -->|"M5: Scarico qui; N"| C
|
||||
A -->|"M6: allocazione; controlli WMS"| W
|
||||
A -->|"M7: dichiarazione non scaffalata"| NS
|
||||
W -->|"M8: disassociazione; controlli WMS"| NS
|
||||
NS -->|"M9: allocazione; controlli WMS"| W
|
||||
```
|
||||
|
||||
**Scarico da Confezionamento e' disabilitato.**
|
||||
Carico si esegue nella destinazione e identifica una UDC da aggiungere.
|
||||
Scarico si esegue nell'origine sulla UDC selezionata e ha destinazione definita.
|
||||
Togliere dall'area non significa cancellare anagrafica/storico o spedire.
|
||||
|
||||
M2 e M3 possono sovrapporsi agli automatismi A4 e A2. Rimangono percorsi
|
||||
manuali ammessi, ma non si devono eseguire due volte gli stessi effetti.
|
||||
Il comportamento operativo in presenza di eventi pendenti va coordinato
|
||||
dalla procedura comune: non basta lasciare due procedure indipendenti.
|
||||
|
||||
M4 e M5 sono esclusivamente desktop. A3 e' invece un automatismo generato
|
||||
da SAM, non un comando barcode. M4 ammette esclusivamente l'origine
|
||||
Confezionamento: nessun ingresso diretto da cella, Pavimento o Accettazione.
|
||||
|
||||
## 4. Tabella dei controlli manuali
|
||||
|
||||
| ID | Percorso | Condizione specifica |
|
||||
|---|---|---|
|
||||
| M1 | Pavimento -> Accettazione, Scarico | Origine corretta, CHIUSA=S, UDC disponibile |
|
||||
| M2 | Accettazione -> Confezionamento, Scarico | CHIUSA=N, coordinamento con automatismo di riapertura |
|
||||
| M3 | Confezionamento -> Accettazione, Carico nella destinazione | CHIUSA=S, coordinamento con automatismo di chiusura |
|
||||
| M4 | Confezionamento -> Validazione, Carico nella destinazione | Origine esclusivamente Confezionamento e CHIUSA=N; altra origine o S respinti senza movimento |
|
||||
| M5 | Validazione -> Confezionamento, Scarico | CHIUSA=N; origine ancora valida |
|
||||
| M6 | Accettazione -> cella fisica | CHIUSA=S, eventi pertinenti sincronizzati, cella valida/libera e controlli WMS |
|
||||
| M7 | Accettazione -> Pavimento | CHIUSA=S, eventi pertinenti sincronizzati, dichiarazione esplicita e controlli WMS |
|
||||
| M8 | Cella -> Pavimento | CHIUSA=S, eventi pertinenti sincronizzati, corrispondenza sorgente UDC/cella e controlli WMS |
|
||||
| M9 | Pavimento -> cella | CHIUSA=S, eventi pertinenti sincronizzati, destinazione valida/libera e controlli WMS |
|
||||
|
||||
Dopo riapertura e' obbligatorio completare il percorso Confezionamento
|
||||
(eventualmente Validazione) -> chiusura -> Accettazione prima della riallocazione.
|
||||
Nessun arco diretto da Confezionamento/Validazione a cella o Pavimento e' ammesso.
|
||||
CHIUSA=S non basta se l'evento di chiusura e' ancora pendente. Il controllo e'
|
||||
transazionale nel backend, sia per desktop sia per barcode.
|
||||
Pavimento -> cella e gli spostamenti ordinari fra celle di UDC chiuse restano
|
||||
ammessi: non si impone un passaggio in Accettazione a ogni movimento.
|
||||
|
||||
Un controllo fallito lascia la posizione invariata. Un evento automatico
|
||||
gia' completato richiede invece di aggiornare la GUI e non ripetere il movimento.
|
||||
Una posizione inattesa non autorizza a scegliere un'altra origine in silenzio.
|
||||
|
||||
I flussi di picking verso Spedizione restano distinti: questi menu non sono
|
||||
nuovi comandi di spedizione libera. Le UDC in Accettazione vanno proposte
|
||||
con tale stato. Aperte/in Validazione non sono spedibili. Per una UDC riaperta
|
||||
mentre era proposta dal barcode vale il percorso speciale di recupero seguente;
|
||||
non si applica indiscriminatamente alle altre UDC in Accettazione/Pavimento.
|
||||
|
||||
### UDC riaperta mentre e' proposta dal barcode
|
||||
|
||||
```text
|
||||
UDC proposta -> riapertura accidentale in SAM -> Confezionamento
|
||||
|
|
||||
+-> tentativo di prelievo BLOCCATO e segnalato
|
||||
|
||||
Confezionamento (eventualmente Validazione)
|
||||
-> chiusura SAM -> Accettazione -> riallocazione manuale in cella WMS
|
||||
-> nuovo controllo -> prelievo picking consentito
|
||||
```
|
||||
|
||||
Controllare nel backend transazionale anche il prelievo automatico da scansione.
|
||||
Messaggio dopo sincronizzazione: "UDC riaperta: si trova in Confezionamento.
|
||||
Chiudere la UDC e riallocarla in una cella prima della spedizione."
|
||||
Se la sincronizzazione e' pendente, mostrare l'attesa; se poi e' in Validazione,
|
||||
mostrare la posizione effettiva. Non dichiarare un trasferimento non completato.
|
||||
Il blocco non spedisce, completa o salta automaticamente la UDC. Pausa/salto
|
||||
rimangono comandi espliciti. Chiudere e arrivare in Accettazione non basta per
|
||||
questa UDC: serve la riallocazione. Alla ripresa rileggere la posizione corrente.
|
||||
La prova del ciclo e la gestione delle corse con SAM restano da progettare.
|
||||
|
||||
## 5. Esempio: chiusura accidentale in Validazione
|
||||
|
||||
1. La UDC aperta e' in Confezionamento.
|
||||
2. L'operatore apre Validazione e usa Carico: il controllo N permette M4.
|
||||
3. Il programma esterno chiude la UDC, anche per errore.
|
||||
4. L'evento N -> S attiva A3: la UDC passa automaticamente in Accettazione.
|
||||
5. L'operatore la riapre nel programma esterno.
|
||||
6. L'evento S -> N attiva A4: la UDC torna automaticamente in Confezionamento.
|
||||
7. Se occorre rivalidarla ancora, si esegue nuovamente Carico in Validazione con N.
|
||||
8. Se invece viene chiusa in Confezionamento, A2 la riporta in Accettazione.
|
||||
9. Il magazziniere puo' registrare manualmente l'allocazione in una cella
|
||||
oppure la dichiarazione NON SCAFFALATA con le procedure ammesse.
|
||||
|
||||
Il sistema non distingue una chiusura volontaria da una accidentale:
|
||||
il responsabile ha confermato che producono lo stesso passaggio.
|
||||
|
||||
Durante riapertura/rivalidazione possono cambiare bag e quantita' del contenuto.
|
||||
Per l'inventario a una data passata serve quindi anche la storia del contenuto,
|
||||
non solo questo diagramma delle posizioni e degli stati. Le fonti SAM e le
|
||||
eventuali lacune storiche sono ancora da verificare; non usare il contenuto
|
||||
attuale come se fosse rimasto immutato.
|
||||
|
||||
## 6. Rilevamento e concorrenza: architettura scelta, da implementare
|
||||
|
||||
```text
|
||||
EXTUC modificata da SAM
|
||||
|
|
||||
v
|
||||
EXTUCLOG scritto dal trigger esistente
|
||||
|
|
||||
v
|
||||
Nuovo trigger leggero: evento persistente
|
||||
|
|
||||
v
|
||||
Elaboratore Python esterno: regole secondo contesto e cronologia
|
||||
|
|
||||
v
|
||||
Transazione movimento + storico + conferma evento
|
||||
|
|
||||
v
|
||||
Aggiornamento delle schermate
|
||||
```
|
||||
|
||||
L'accodamento su tabella eventi e l'elaboratore esterno sono la scelta progettuale,
|
||||
non sono installati. Le regole saranno testabili senza SQL; l'esecutore SQL
|
||||
garantira' atomicita' e controlli concorrenti da provare anche sul DB di test.
|
||||
Lo stesso elaboratore funzionera' da console per debug e come servizio Windows.
|
||||
Leggera' eventi pendenti con intervallo configurabile, senza scansione completa
|
||||
del log. Non si attivano Broker o Agent come esecutori nella prima versione.
|
||||
La nascita necessita del trigger AFTER INSERT concordato
|
||||
su EXTUC; i quattro NULL identificano nascita, non cambio S/N. Lo stato al
|
||||
momento della nascita va acquisito senza perderlo se segue subito una chiusura.
|
||||
|
||||
Requisiti proposti:
|
||||
- Ordinamento per UDC e nessuna perdita di eventi intermedi S -> N -> S.
|
||||
- Persistenza e ripresa dopo arresto, senza doppi movimenti.
|
||||
- Coordinamento con i menu: prima risolvere gli eventi pendenti pertinenti,
|
||||
poi controllare origine e stato del comando sotto protezione transazionale.
|
||||
- Nessun evento vecchio deve cancellare una movimentazione manuale successiva.
|
||||
- Controllo, trasferimento e storico atomici; log degli errori e casi non applicabili.
|
||||
- Fonte automatica/manuale distinguibile nello storico, con data evento ed esecuzione.
|
||||
- GUI in attesa/errore riconoscibile, senza simulare aggiornamenti DB riusciti.
|
||||
|
||||
Una lettura periodica del solo flag corrente non basta: potrebbe perdere
|
||||
riaperture seguite da chiusure fra due letture. Una vista non esegue movimenti.
|
||||
Il trigger di accodamento deve essere breve ma resta parte della transazione
|
||||
ERP; verificare errori, permessi, trigger annidati e inserimenti multipli.
|
||||
Il confronto del trigger legacy non copre le transizioni NULL: decidere
|
||||
come gestirle senza considerarle automaticamente eventi N/S validi.
|
||||
|
||||
## 7. UI e punti ancora aperti
|
||||
|
||||
Quattro scaffali virtuali, cinque righe e colonne necessarie. Carico anche
|
||||
sullo sfondo vuoto, Scarico sulla UDC selezionata, Scarico da Confezionamento
|
||||
disabilitato. Validazione e' una cella logica multi-UDC con ingresso manuale N
|
||||
esclusivamente da Confezionamento.
|
||||
|
||||
Le regole precedenti di permanenza verde dopo riapertura sono superate:
|
||||
la nuova regola trasferisce in Confezionamento. Errori e sincronizzazioni
|
||||
pendenti richiedono una visualizzazione distinta da progettare.
|
||||
|
||||
Restano aperti:
|
||||
- Eventuale blocco preventivo della riapertura nel programma esterno: rilevare
|
||||
l'evento dopo la scrittura non impedisce da solo l'UPDATE in SAM. Il WMS
|
||||
deve comunque vietare il recupero, indipendentemente da questo controllo.
|
||||
- Nascita gia' S, valori NULL e chiusure in posizioni inattese.
|
||||
- Inizializzazione dei dati pregressi, senza inventare eventi/data di nascita.
|
||||
- Prova del ciclo riapertura/riallocazione e coerenza con il contenuto della picking list.
|
||||
- Identificazione/ordinamento eventi, latenza del servizio e gestione delle gare con i menu.
|
||||
- Fonti storiche del contenuto per l'inventario, permessi, colori, ordine e scorrimento.
|
||||
|
||||
Non sono piu' aperti: uscita automatica da Validazione alla chiusura, requisito
|
||||
N per entrarvi, ingresso automatico delle nuove aperte, ritorno automatico
|
||||
delle riaperte disponibili e disabilitazione di Scarico da Confezionamento.
|
||||
E' definitivo anche il carattere finale di Spedita: nessun ritorno automatico
|
||||
o manuale tramite applicazione, solo correzione SQL eccezionale fuori flusso.
|
||||
Sono definiti anche l'origine esclusiva Confezionamento per Validazione e il
|
||||
blocco del prelievo di UDC riaperte fino a chiusura, Accettazione e riallocazione.
|
||||
70
FREEZE_2.0_WAREHOUSE_MONOLISTA.md
Normal file
70
FREEZE_2.0_WAREHOUSE_MONOLISTA.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Warehouse monolista - freeze 2.0
|
||||
|
||||
Data: 02/10/2026.
|
||||
Titolo release: warehouse monolista.
|
||||
Tag Git: `warehouse-monolista-2.0`.
|
||||
|
||||
## Scopo e contenuto
|
||||
|
||||
Punto di ripristino prima dello sviluppo del prelievo guidato di due liste.
|
||||
La versione conserva la prenotazione singola e i cicli F1/F2 separati.
|
||||
Include i sorgenti e gli script SQL gia' versionati, oltre alla correzione
|
||||
del documento fisso F1/F2, ai suoi test e alla relativa documentazione.
|
||||
|
||||
La denominazione 2.0 identifica questo freeze, non una rinumerazione di tutti
|
||||
i moduli. Il barcode conserva la versione visibile 1.0.27; repository 1.0.14,
|
||||
servizio 1.0.25. Il registro delle versioni resta `version_info.py`.
|
||||
|
||||
La specifica `specifica_prelievo_due_pickinglist.md` descrive lo sviluppo
|
||||
successivo, NON una funzionalita' gia' implementata in questa release.
|
||||
Comprende il vincolo di due liste nella stessa area operativa (5 oppure 6).
|
||||
|
||||
## Verifiche del freeze
|
||||
|
||||
Gli 11 test di `tests/test_barcode_document_binding.py` sono passati con:
|
||||
|
||||
```bat
|
||||
python -B -m unittest discover -s tests -v
|
||||
```
|
||||
|
||||
Si tratta di test automatici con repository simulato, non di un collaudo
|
||||
completo della GUI o del terminalino fisico. Non eseguono movimenti sul DB.
|
||||
|
||||
## Database e file locali
|
||||
|
||||
La correzione F1/F2 non richiede nuovi oggetti SQL. Le patch gia' necessarie
|
||||
alla versione precedente restano nel repository, inclusa
|
||||
`apply_online_python_wms_full_patch.sql`. Questo freeze non esegue patch SQL
|
||||
e non costituisce un backup dei database Mediseawall e SAM.
|
||||
|
||||
Gli script in `sql_tests/` servono soltanto alla preparazione locale dei test:
|
||||
NON lanciarli in produzione. Il ripristino delle sole testate non annulla
|
||||
eventuali movimenti successivi; leggere `sql_tests/README.md`.
|
||||
|
||||
Configurazione locale `db_connection.json`, log, cache, impostazioni IDE,
|
||||
registrazioni e vecchi ZIP locali non vengono aggiunti a questo commit.
|
||||
Conservare separatamente configurazione e backup coerenti dei database
|
||||
prima di modificare schema o dati per il futuro prelievo abbinato.
|
||||
|
||||
## Recuperare esattamente il freeze
|
||||
|
||||
Chiudere l'applicazione. Nella cartella del repository, con working tree pulito:
|
||||
|
||||
```bat
|
||||
git fetch origin --tags
|
||||
git switch --detach warehouse-monolista-2.0
|
||||
git describe --tags --exact-match
|
||||
python -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Se Git segnala modifiche locali, fermarsi e salvarle prima: non forzare la
|
||||
sovrascrittura della configurazione o dei sorgenti. Per una prima installazione:
|
||||
|
||||
```bat
|
||||
git clone --branch warehouse-monolista-2.0 --single-branch https://gitea.alessandrobonvicini.it/administrator/ware_house.git C:\flywms-monolista-2.0
|
||||
```
|
||||
|
||||
Il checkout di un tag e' intenzionalmente in detached HEAD: identifica una
|
||||
versione fissa. `git pull origin main` non e' il comando per restare su questo
|
||||
freeze. Il ritorno al codice precedente non ripristina il database: eventuali
|
||||
future patch richiederanno il rispettivo rollback compatibile o un backup.
|
||||
235
GUIDA_INVENTARIO.md
Normal file
235
GUIDA_INVENTARIO.md
Normal file
@@ -0,0 +1,235 @@
|
||||
# Inventario WMS / SAM: guida alla schermata
|
||||
|
||||
Versione della schermata: **1.1.1**, monolista. Aggiornamento: 21/10/2026.
|
||||
|
||||
## 1. A cosa serve
|
||||
|
||||
La schermata confronta i pezzi ricostruiti dalle registrazioni del WMS e dei
|
||||
contenitori con i pezzi risultanti nel **Magazzino Principale di SAM**, alla
|
||||
fine del giorno scelto. Non movimenta materiale e non corregge automaticamente
|
||||
le differenze: serve a individuarle e a capire dove cercare.
|
||||
|
||||
**Attenzione al perimetro:** per ora e' il WMS a guidare la ricerca.
|
||||
Si parte dalle coppie prodotto/lotto presenti nelle UDC del WMS, nelle aree
|
||||
5 e 6 oppure non scaffalate, alla data scelta. Per quelle coppie si cercano
|
||||
anche i contenitori in SAM. Un lotto presente soltanto in confezionamento,
|
||||
senza alcuna UDC nel WMS, non entra nel report. Quindi non e' ancora un
|
||||
inventario completo di tutto SAM.
|
||||
|
||||
Una UDC puo' contenere piu' bag e piu' lotti. Una bag o una vasca e' un
|
||||
contenitore identificato in LOTSER: **contenitore, UDC e pezzi sono tre
|
||||
misure diverse**.
|
||||
|
||||
## 2. Come iniziare
|
||||
|
||||
1. Apri **Inventario** dal menu principale.
|
||||
2. Inserisci una data nel formato **gg/mm/aaaa**.
|
||||
3. Premi **Calcola inventario** e attendi la fine dell'overlay.
|
||||
4. Guarda **Esito / anomalie** e **Residuo SAM-(A+B+C)** nella griglia alta.
|
||||
5. Seleziona un prodotto: sotto compaiono le schede **Lotti** e **Contenitori**.
|
||||
6. Esamina prima il lotto che presenta la differenza, poi i relativi contenitori.
|
||||
7. Usa **Esporta XLSX** per conservare il risultato o proseguire la verifica.
|
||||
|
||||
Le colonne sono numerose: usa la barra orizzontale in fondo alla griglia.
|
||||
Cliccando un'intestazione della griglia prodotti puoi ordinare i risultati;
|
||||
un secondo clic inverte l'ordine. L'ordinamento puo' azzerare la selezione:
|
||||
riseleziona il prodotto per visualizzarne il dettaglio.
|
||||
|
||||
## 3. Legenda A, B, C e X
|
||||
|
||||
**A: materiale registrato nel WMS.**
|
||||
Sono i pezzi nelle UDC scaffalate nelle aree 5/6 oppure registrate come
|
||||
non scaffalate. Nella griglia, A corrisponde alla colonna **Pezzi WMS**.
|
||||
La quantita' nominale e' ricavata dai carichi produzione dei contenitori:
|
||||
va validata rispetto alle etichette, non e' una lettura fisica dei pezzi.
|
||||
|
||||
**B: materiale assegnato a UDC ma fuori dal WMS.**
|
||||
Sono contenitori con un numero UDC assegnato, giacenza SAM positiva alla data
|
||||
e nessuna posizione WMS che li collochi gia' in A o presenti anomalie.
|
||||
La collocazione in confezionamento e' **dedotta**, non rilevata fisicamente.
|
||||
Le UDC possono essere piene oppure ancora in riempimento: il report non
|
||||
determina quale dei due casi si verifichi.
|
||||
|
||||
**C: materiale non ancora assegnato a UDC.**
|
||||
Sono bag o vasche con seriale del tipo **000000/123456** e giacenza SAM
|
||||
positiva alla data. Possono essere parzialmente piene: si usano i pezzi
|
||||
registrati, non una capacita' teorica moltiplicata per il numero di bag.
|
||||
|
||||
**X: materiale con una classificazione anomala.**
|
||||
E' esposto nel dettaglio ma non viene aggiunto artificialmente ad A, B o C.
|
||||
Il suo saldo SAM contribuisce al confronto. Esempio: una UDC risulta spedita
|
||||
nel WMS ma ha ancora giacenza SAM. Il residuo deve far emergere il problema,
|
||||
non nasconderlo assegnandolo a B.
|
||||
|
||||
Una UDC non scaffalata gia' compresa in A **non viene contata anche in B**.
|
||||
Le UDC effettivamente spedite alla data non appartengono al normale stock A.
|
||||
La sola chiusura di un documento non sostituisce un movimento WMS mancante.
|
||||
|
||||
## 4. Comandi e messaggi in alto
|
||||
|
||||
| Campo o comando | Significato |
|
||||
| --- | --- |
|
||||
| Data (gg/mm/aaaa) | Giorno di riferimento, dalla fine del quale si ricostruisce l'inventario. Sono accettate date dal 01/01/2010 a oggi; cio' non garantisce che lo storico sia completo per ogni data. |
|
||||
| Calcola inventario | Avvia una nuova interrogazione. Aprire la finestra non avvia automaticamente il calcolo. Anche Invio nel campo data lo avvia. |
|
||||
| Esporta XLSX | Esporta l'ultimo risultato calcolato: prodotti, lotti e contenitori. Non esegue un nuovo calcolo. E' disabilitato prima del risultato, durante le operazioni o in assenza di righe. |
|
||||
| Legenda A/B/C/X | Definizioni fisse, separate dal messaggio di avanzamento: restano visibili dopo il calcolo. |
|
||||
| Inventario al ... (fine giornata) | Data effettiva del risultato, da controllare soprattutto se hai modificato il campo data senza premere Calcola. |
|
||||
| Prodotti | Numero di righe prodotto presenti nel report, non numero di UDC. |
|
||||
| Da verificare | Numero di prodotti con anomalie di ricostruzione. **Non e' il conteggio di tutte le differenze numeriche**: una differenza senza anomalie si legge nel residuo e nell'esito. |
|
||||
| Ultimo movimento WMS / SAM | Date massime dei movimenti rilevate nelle fonti. Non certificano quando e' stato effettuato il backup e non sono la data di ogni riga. |
|
||||
| Giornata corrente non ancora conclusa | Per oggi sono disponibili solo le operazioni gia' registrate: non e' possibile conoscere in anticipo lo stock di questa sera. |
|
||||
|
||||
Il limite temporale e' la mezzanotte successiva, esclusa. Ad esempio,
|
||||
per il 20/10 si considerano le operazioni precedenti alle 00:00 del 21/10.
|
||||
Non e' una funzionalita' riservata al 31 dicembre.
|
||||
|
||||
Se cambi solo la data nel campo, le righe gia' visualizzate e l'eventuale
|
||||
export rimangono riferiti all'ultimo calcolo. Premi Calcola per aggiornarli.
|
||||
In caso di errore del nuovo calcolo il risultato precedente viene svuotato,
|
||||
per evitare di scambiarlo per quello della nuova data.
|
||||
|
||||
## 5. Griglia principale: una riga per prodotto
|
||||
|
||||
I conteggi con **N.** contano identificativi distinti; gli altri valori
|
||||
quantitativi sono **pezzi**, non pallet.
|
||||
|
||||
| Colonna | Come leggerla |
|
||||
| --- | --- |
|
||||
| Prodotto | Codice articolo SAM. E' la chiave per raggruppare i lotti del prodotto inclusi nel perimetro. |
|
||||
| Descrizione | Descrizione dell'articolo. |
|
||||
| UM | Unita' di misura. Il calcolo accetta NR, PZ o PCS come pezzi; altre unita' richiedono verifica. |
|
||||
| N. UDC WMS | Numero di UDC distinte del prodotto comprese in A, scaffalate o non scaffalate. Una UDC con due lotti dello stesso prodotto conta una volta. |
|
||||
| Pezzi scaffalati | Pezzi di A nelle celle fisiche delle aree 5/6 alla data. |
|
||||
| Pezzi non scaffalati | Pezzi di A nella locazione virtuale non scaffalata, IDCella 1000. Non sono tutte le UDC presenti in SAM fuori WMS. |
|
||||
| Pezzi WMS | **A = Pezzi scaffalati + Pezzi non scaffalati**. E' il contenuto nominale delle UDC WMS ricostruito dai carichi produzione. |
|
||||
| N. UDC fuori WMS | Numero di UDC distinte nella componente B. Non e' il numero delle bag al loro interno. |
|
||||
| Pezzi B - UDC fuori WMS | Pezzi dei contenitori assegnati alle UDC B, usando la loro giacenza SAM alla data. |
|
||||
| N. contenitori senza UDC | Numero di identificativi LOTSER distinti in C: bag o vasche senza UDC. |
|
||||
| Pezzi C - Senza UDC | Pezzi presenti in quei contenitori C secondo il saldo SAM alla data. |
|
||||
| Totale A+B+C | Quantita' complessiva spiegata dalle tre componenti. Non include X. |
|
||||
| Pezzi SAM | Giacenza del Magazzino Principale per i soli prodotti/lotti compresi nel perimetro. Puo' includere saldi di contenitori classificati X. |
|
||||
| Differenza SAM-A | Differenza iniziale: **Pezzi SAM meno Pezzi WMS**. Serve a capire quanta parte potrebbe trovarsi fuori dal WMS. |
|
||||
| Residuo SAM-(A+B+C) | Differenza che rimane dopo aver aggiunto anche B e C. E' il principale valore da indagare. |
|
||||
| Esito / anomalie | Esito del confronto o motivi per cui il dato non e' determinabile/affidabile. Un saldo zero con anomalie non va considerato automaticamente corretto. |
|
||||
|
||||
**Non sommare indiscriminatamente N. UDC WMS tra prodotti:** una UDC
|
||||
multicomponente puo' essere contata una volta in ciascun prodotto.
|
||||
Analogamente non si sommano i conteggi UDC dei lotti per ottenere il
|
||||
conteggio distinto del prodotto.
|
||||
|
||||
## 6. Scheda Lotti
|
||||
|
||||
Mostra solo i lotti del prodotto selezionato nella griglia alta.
|
||||
|
||||
La colonna **Lotto** identifica NUMLOT. **Prodotto**, **UM**, i conteggi,
|
||||
le componenti A/B/C, le differenze e l'esito hanno lo stesso significato
|
||||
della griglia principale, ma sono limitati alla coppia prodotto/lotto.
|
||||
Non e' ripetuta la descrizione del prodotto.
|
||||
|
||||
Controllare sempre questa scheda: un lotto con +100 pezzi e un altro con
|
||||
-100 producono zero sul prodotto, ma non sono due lotti corretti.
|
||||
Il programma segnala questa compensazione nell'esito del prodotto.
|
||||
|
||||
## 7. Scheda Contenitori
|
||||
|
||||
Mostra tutti i contenitori del prodotto selezionato, anche su piu' lotti.
|
||||
La selezione di una riga nella scheda Lotti non filtra ulteriormente questa
|
||||
scheda. Per isolare un lotto puoi usare i filtri del foglio XLSX.
|
||||
|
||||
| Colonna | Significato |
|
||||
| --- | --- |
|
||||
| Componente | A - WMS, B - UDC fuori WMS, C - Senza UDC oppure X - Anomalia / fuori perimetro. |
|
||||
| Prodotto | Codice del prodotto contenuto nella bag/vasca. |
|
||||
| Lotto | Lotto del contenitore, NUMLOT. |
|
||||
| UDC | Numero dell'UDC cui il contenitore risulta assegnato alla data. Vuoto per il prefisso 000000. |
|
||||
| ID LOTSER | Identificativo tecnico del record contenitore in SAM. Utile per una verifica puntuale; non e' il numero UDC. |
|
||||
| Seriale contenitore | NUMSER ricostruito alla data: ad esempio 554321/123245 oppure 000000/123456. |
|
||||
| Cella alla data | Ubicazione WMS ricostruita. Per B/C senza cella compare Confezionamento (dedotto): non e' una cella fisica verificata. |
|
||||
| Pezzi della componente | Per A: pezzi nominali da carichi produzione. Per B/C: saldo SAM alla data. Per X: quantita' diagnostica, non inclusa in A+B+C. Un dato non determinabile compare come ?. |
|
||||
| Giacenza SAM contenitore | Saldo di quel singolo record LOTSER nel Magazzino Principale alla data. Puo' differire dal nominale di A. |
|
||||
| Esito / anomalie | Problemi specifici del contenitore. Una cella vuota in questa colonna significa nessuna anomalia specifica rilevata, non una certificazione fisica del contenuto. |
|
||||
|
||||
Il dettaglio serve alla diagnosi, non a una somma manuale indiscriminata:
|
||||
in caso di posizioni WMS anomale puo' comparire lo stesso contenitore piu'
|
||||
volte. Nel riepilogo il saldo SAM viene deduplicato e l'anomalia segnalata.
|
||||
|
||||
## 8. Esempio completo
|
||||
|
||||
Per un prodotto e i suoi lotti inclusi nel perimetro:
|
||||
|
||||
| Voce | Pezzi |
|
||||
| --- | ---: |
|
||||
| Scaffalati in WMS | 9.000 |
|
||||
| Non scaffalati in WMS | 1.000 |
|
||||
| A: Pezzi WMS | 10.000 |
|
||||
| B: in UDC fuori WMS | 400 |
|
||||
| C: bag/vasche senza UDC | 200 |
|
||||
| Totale A+B+C | 10.600 |
|
||||
| Pezzi SAM | 10.600 |
|
||||
| Differenza SAM-A | 600 |
|
||||
| Residuo SAM-(A+B+C) | 0 |
|
||||
|
||||
I 600 pezzi di differenza iniziale sono spiegati da B e C.
|
||||
Se SAM fosse 10.700 con le altre componenti invariate, rimarrebbero **+100**
|
||||
pezzi da spiegare. Se SAM fosse 10.500, il residuo sarebbe **-100**:
|
||||
la ricostruzione supererebbe SAM di 100 pezzi.
|
||||
|
||||
B e C derivano da SAM stesso: il pareggio indica coerenza documentale,
|
||||
non dimostra da solo che il materiale sia fisicamente in confezionamento.
|
||||
|
||||
## 9. Zero, punto interrogativo, colori ed esiti
|
||||
|
||||
- **0**: valore numerico noto pari a zero.
|
||||
- **?**: quantita' non determinabile. Non va sostituita con zero.
|
||||
- **Saldo coerente (nominale)**: residuo zero e nessuna anomalia rilevata dal calcolo.
|
||||
- **Differenza da verificare**: residuo diverso da zero senza ulteriori anomalie diagnostiche.
|
||||
- **Testo arancione/marrone**, nel tema attuale: riga con differenza numerica.
|
||||
- **Testo rosso**, nel tema attuale: riga con anomalie; controllare l'esito anche se alcuni valori sono numerici.
|
||||
|
||||
| Anomalia | Cosa controllare |
|
||||
| --- | --- |
|
||||
| Contenuto UDC non determinabile | Carichi produzione mancanti, non positivi o altre entrate che rendono ambiguo il contenuto nominale. |
|
||||
| UDC in piu' locazioni | Associazioni WMS multiple alla data scelta. |
|
||||
| Saldo movimenti UDC anomalo | Coerenza dei prelievi e versamenti WMS, presenza unitaria ed eventuali saldi negativi. |
|
||||
| Unita' di misura da verificare | UM diversa dai pezzi supportati, oppure incoerente nello stesso aggregato. |
|
||||
| Movimenti WMS privi di data | Movimenti senza una data utilizzabile: ricostruzione temporale non affidabile. |
|
||||
| Assegnazione storica non determinabile | Storico NUMSER assente, troppo recente rispetto alla data richiesta o ambiguo. |
|
||||
| Movimenti o saldo SAM non determinabili | Saldo o dati dei movimenti SAM insufficienti per la ricostruzione. |
|
||||
| Giacenza SAM negativa | Saldo negativo del contenitore. |
|
||||
| Seriale contenitore mancante o non valido | NUMSER non interpretabile nel formato atteso. |
|
||||
| Spedita WMS ma presenza residua da verificare | Incongruenza tra spedizione WMS e presenza/saldo residuo. |
|
||||
| Presenza fuori perimetro / classificazione anomala | Posizione non appartenente alle categorie ammesse o materiale non classificabile. |
|
||||
| Contenitore duplicato con dati incompatibili | Stesso contenitore restituito con attributi o quantita' contrastanti. |
|
||||
| Differenze tra lotti si compensano | Totale prodotto apparentemente corretto, ma differenze nei singoli lotti. |
|
||||
|
||||
Un'anomalia puo' rendere ignota solo una parte del risultato: le parti note
|
||||
restano consultabili. I totali dipendenti da un dato ignoto diventano ?.
|
||||
|
||||
## 10. Export e precauzioni
|
||||
|
||||
L'XLSX contiene tre fogli: **Inventario**, **Lotti** e **Contenitori**.
|
||||
Riporta data del calcolo, perimetro e avvertenze. Il foglio prodotti segue
|
||||
l'ordinamento scelto a video. I dettagli esportati comprendono tutti i
|
||||
prodotti del report, non solo quello selezionato. Le quantita' ignote sono
|
||||
celle vuote, mentre gli zeri reali restano numeri zero.
|
||||
|
||||
Eseguire la quadratura a movimentazioni ferme e con fonti WMS/SAM coerenti.
|
||||
Una copia WMS di ieri e una copia SAM di oggi possono generare differenze
|
||||
che non sono errori fisici. Il report non crea una fotografia atomica dei
|
||||
due database mentre altri operatori li stanno modificando.
|
||||
|
||||
Per una data storica il calcolo usa i movimenti e lo storico delle variazioni
|
||||
NUMSER disponibile. Uno storico incompleto o modifiche non tracciate
|
||||
possono impedire una ricostruzione attendibile. Prima dell'uso ufficiale
|
||||
confrontare alcuni lotti con etichette e inventario SAM alla medesima data.
|
||||
|
||||
## 11. Perche' alcune versioni non mostravano A/B/C
|
||||
|
||||
Il prototipo Inventario **1.0.0** presente nella cartella di sviluppo bilista
|
||||
non coincideva con la monolista **1.1.0** pubblicata. Il prototipo non aveva
|
||||
la stessa legenda e lo stesso dettaglio A/B/C della versione aggiornata.
|
||||
Non era un cambiamento provocato dai dati o dall'esecuzione del calcolo.
|
||||
|
||||
La revisione **1.1.1** presenta A/B/C/X su righe distinte, lettere in grassetto,
|
||||
contrasto dedicato e testo adattato alla larghezza della finestra. Elimina
|
||||
la ripetizione iniziale del perimetro. I calcoli e la query non cambiano.
|
||||
61
INSTALLAZIONE.md
Normal file
61
INSTALLAZIONE.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Installazione Warehouse Python
|
||||
|
||||
## Requisiti
|
||||
|
||||
1. Windows 11 o Windows Server 2019.
|
||||
2. Python 3.13 o versione compatibile installata e presente nel `PATH`.
|
||||
3. Microsoft ODBC Driver per SQL Server installato sul PC.
|
||||
- Driver consigliato: `ODBC Driver 17 for SQL Server`.
|
||||
4. Accesso di rete al server SQL.
|
||||
|
||||
## Installazione dipendenze
|
||||
|
||||
Aprire PowerShell nella cartella del programma ed eseguire:
|
||||
|
||||
```powershell
|
||||
python -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Avvio backoffice
|
||||
|
||||
```powershell
|
||||
python main.py
|
||||
```
|
||||
|
||||
Al primo avvio, se manca `db_connection.json`, il programma mostra la finestra di configurazione database.
|
||||
|
||||
Per avviare senza finestra console:
|
||||
|
||||
```powershell
|
||||
pythonw warehouse.pyw
|
||||
```
|
||||
|
||||
## Avvio client barcode
|
||||
|
||||
```powershell
|
||||
python barcode_client.py
|
||||
```
|
||||
|
||||
Per avviare senza finestra console:
|
||||
|
||||
```powershell
|
||||
pythonw barcode.pyw
|
||||
```
|
||||
|
||||
## Patch DB Picking List
|
||||
|
||||
Per usare in parallelo C# legacy e Python, eseguire in SSMS:
|
||||
|
||||
```text
|
||||
apply_python_parallel_pickinglist_patch.sql
|
||||
```
|
||||
|
||||
Questa patch crea solo oggetti dedicati al Python con prefisso `py_` e non modifica gli oggetti legacy usati dal C#.
|
||||
|
||||
Per rimuovere gli oggetti Python dopo i test, eseguire:
|
||||
|
||||
```text
|
||||
rollback_python_parallel_pickinglist_patch.sql
|
||||
```
|
||||
|
||||
La vecchia patch `apply_plist_reservation_patch.sql` modifica invece gli oggetti legacy: usarla solo se si vuole sostituire temporaneamente il comportamento del C#.
|
||||
104
INSTALLAZIONE_MONOLISTA_INVENTARIO.md
Normal file
104
INSTALLAZIONE_MONOLISTA_INVENTARIO.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Aggiornamento reparto: monolista con Inventario
|
||||
|
||||
Release: `warehouse-monolista-2.0.1-inventario`, ramo di distribuzione `main`.
|
||||
La bilista rimane separata su `codex/doppia-pickinglist` e non e' inclusa.
|
||||
Modulo Inventario 1.1.0, launcher 1.0.3. Barcode e logica picking monolista
|
||||
invariati rispetto al freeze `warehouse-monolista-2.0`.
|
||||
|
||||
## Prima dell'aggiornamento
|
||||
|
||||
Chiudere backoffice e terminalini Python che usano il database.
|
||||
Conservare una copia della cartella installata, in particolare dei file locali
|
||||
di configurazione e dei log utili. Non pubblicare db_connection.json su Git.
|
||||
Se si aggiorna il DB, eseguire prima un backup e conservarne il ripristino.
|
||||
|
||||
## Aggiornare il programma con Git
|
||||
|
||||
Dal prompt nella cartella di installazione (esempio C:\flywms):
|
||||
|
||||
```bat
|
||||
cd /d C:\flywms
|
||||
git status --short
|
||||
git rev-parse HEAD
|
||||
git fetch origin --tags
|
||||
git switch main
|
||||
git pull --ff-only origin main
|
||||
python -m pip install -r requirements.txt
|
||||
git log -1 --oneline
|
||||
git describe --tags --exact-match HEAD
|
||||
```
|
||||
|
||||
Annotare il vecchio commit prima dell'aggiornamento. Se Git segnala modifiche
|
||||
locali o una divergenza, fermarsi: NON usare reset --hard, clean o push --force.
|
||||
I file locali non tracciati, come la configurazione DB, non devono essere eliminati.
|
||||
Verificare che la connessione rimanga quella del reparto, non del PC di sviluppo.
|
||||
|
||||
Il tag identifica questa pubblicazione; se in futuro main avanza, il comando
|
||||
describe potra' mostrare un'altra release. Per scegliere esattamente questa:
|
||||
|
||||
```bat
|
||||
git switch --detach warehouse-monolista-2.0.1-inventario
|
||||
```
|
||||
|
||||
Per riprendere in seguito gli aggiornamenti normali: git switch main, poi
|
||||
git pull --ff-only origin main.
|
||||
|
||||
## Script SQL da usare
|
||||
|
||||
Il cumulativo MONOLISTA e' `apply_online_python_wms_full_patch.sql`, ottenuto
|
||||
dal ramo main/tag di questa release. Aprirlo in SSMS, selezionare esplicitamente
|
||||
il database Mediseawall e lanciarlo dopo backup, con client Python chiusi.
|
||||
Controllare tutti i messaggi di errore: lo script usa piu' batch GO e non e'
|
||||
una singola transazione atomica; il solo PRINT finale non certifica il successo.
|
||||
|
||||
Sono gia' inclusi:
|
||||
- oggetti Python di prenotazione e viste picking residue;
|
||||
- oggetti per storico picking e salti UDC;
|
||||
- filtro operativo massimo 30 giorni, selezionabile nella UI a 10/15/20/30;
|
||||
- LEFT JOIN per le destinazioni senza nazione;
|
||||
- tabella py_PickingListPrelievoSequenza e vista py_ViewPackingListPrelievo;
|
||||
- ordine di default con non scaffalate prima degli scaffali e sequenza
|
||||
personalizzata per documento, che nella monolista prevale sul default.
|
||||
|
||||
Se si applica il cumulativo non occorre ripetere separatamente le patch
|
||||
days_filter, optional_destination_country e sequence. I singoli script e i
|
||||
rollback gia' presenti rimangono nel repository per interventi mirati:
|
||||
non eseguirli tutti indiscriminatamente e non usarli come rollback cumulativo.
|
||||
|
||||
ATTENZIONE: nel ramo BILISTA il file cumulativo ha lo stesso nome ma comprende
|
||||
anche oggetti py_PickingPair. Non prelevarlo da quella cartella/ramo per questa
|
||||
installazione. Questa pubblicazione non esegue alcuno script sul DB online.
|
||||
|
||||
## Inventario: nessuna nuova patch DB
|
||||
|
||||
Se il DB ha gia' tutte le patch monolista sopra elencate, per aggiungere
|
||||
l'inventario non serve rilanciare il cumulativo: gli script SQL sono invariati
|
||||
rispetto al freeze monolista 2.0.
|
||||
|
||||
`inventory_report.sql` DEVE rimanere accanto a inventory_service.py, ma NON va
|
||||
incollato in SSMS: e' la query parametrizzata eseguita dal programma.
|
||||
L'utente DB deve poter leggere le sorgenti WMS e SAMA1, incluso EXTTACLOTSER.
|
||||
Non vengono create tabelle persistenti per l'inventario.
|
||||
|
||||
Avviare il programma come di consueto, aprire Inventario, scegliere la data,
|
||||
eseguire il calcolo e provare l'export. Una seconda pressione di Inventario
|
||||
deve riportare la stessa finestra in primo piano. Nessuna query parte
|
||||
automaticamente all'apertura della finestra.
|
||||
|
||||
Prima dell'inventario ufficiale validare etichette e stampa SAM su un campione,
|
||||
con movimentazioni ferme e dati ERP/WMS coerenti. Il perimetro provvisorio e'
|
||||
guidato dai prodotti/lotti WMS; le limitazioni sono in specifica_inventario.md.
|
||||
|
||||
## Ritorno alla precedente monolista
|
||||
|
||||
Con programmi chiusi e senza modifiche locali ai sorgenti:
|
||||
|
||||
```bat
|
||||
git switch --detach warehouse-monolista-2.0
|
||||
```
|
||||
|
||||
Oppure usare il commit precedente annotato, se il PC partiva da un'altra
|
||||
versione. Il nuovo inventario non modifica lo schema o i dati persistenti,
|
||||
quindi il suo solo aggiornamento non richiede rollback SQL. Se sono state
|
||||
applicate anche patch mancanti di versioni precedenti, valutarne separatamente
|
||||
il ripristino usando il backup: tornare al vecchio codice non annulla il DB.
|
||||
61
INSTALL_PRODUZIONE_20260610.md
Normal file
61
INSTALL_PRODUZIONE_20260610.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Installazione produzione - Warehouse/FlyWMS bridge
|
||||
|
||||
## Ordine consigliato
|
||||
|
||||
1. Fare backup del database `Mediseawall`.
|
||||
2. Copiare il contenuto dello zip in una cartella locale, ad esempio `C:\flywms`.
|
||||
3. Installare le dipendenze Python:
|
||||
|
||||
```bat
|
||||
python -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. In SSMS, sul database `Mediseawall`, lanciare:
|
||||
|
||||
```text
|
||||
apply_python_parallel_pickinglist_patch.sql
|
||||
apply_online_history_forms_patch.sql
|
||||
```
|
||||
|
||||
## Cosa fanno gli script
|
||||
|
||||
- `apply_python_parallel_pickinglist_patch.sql` crea il ramo SQL Python per gestione picking list, senza modificare le stored procedure C# legacy.
|
||||
- `apply_online_history_forms_patch.sql` crea le viste Python-only per "Storico Picking List".
|
||||
- "Storico movimenti UDC" non richiede script dedicati: legge in sola lettura `MagazziniPallet`, `Celle` e `XMag_GiacenzaPalletPlistChiuse`.
|
||||
|
||||
## Rollback SQL
|
||||
|
||||
Se serve tornare indietro sugli oggetti Python, usare:
|
||||
|
||||
```text
|
||||
rollback_online_history_forms_patch.sql
|
||||
rollback_python_parallel_pickinglist_patch.sql
|
||||
```
|
||||
|
||||
La tabella `dbo.PyPickingListReservation`, se creata, puo' rimanere anche in caso di rollback perche' il C# legacy non la usa.
|
||||
|
||||
## Avvio
|
||||
|
||||
Backoffice con console:
|
||||
|
||||
```bat
|
||||
python main.py
|
||||
```
|
||||
|
||||
Backoffice senza console:
|
||||
|
||||
```bat
|
||||
pythonw warehouse.pyw
|
||||
```
|
||||
|
||||
Barcode senza console:
|
||||
|
||||
```bat
|
||||
pythonw barcode.pyw
|
||||
```
|
||||
|
||||
Se si usa un collegamento Windows, impostare anche la cartella "Da" alla cartella dell'applicazione, ad esempio `C:\flywms`.
|
||||
|
||||
## File esclusi dal pacchetto
|
||||
|
||||
Il pacchetto non include `db_connection.json`, log, cache Python e vecchi zip locali. Alla prima apertura il programma chiedera' la configurazione DB se `db_connection.json` non esiste.
|
||||
369
REVISIONE_SPECIFICHE_E_SERVIZIO_UDC_2026-10-28.md
Normal file
369
REVISIONE_SPECIFICHE_E_SERVIZIO_UDC_2026-10-28.md
Normal file
@@ -0,0 +1,369 @@
|
||||
# Revisione specifiche UDC e alternative per la sincronizzazione
|
||||
|
||||
Aggiornamento: 29 ottobre 2026. Specifica e diagramma alla revisione 12.
|
||||
**Nessun nuovo automatismo UDC installato.** La preparazione separata dei cloni
|
||||
e' descritta in [ambiente locale XWMS](XWMS_AMBIENTE_LOCALE.md); le osservazioni
|
||||
di istanza sotto restano quelle raccolte il 28 ottobre.
|
||||
|
||||
Documenti di riferimento:
|
||||
- [Specifica degli stati UDC](RIEPILOGO_STATI_UDC_2026-10-28.md).
|
||||
- [Diagramma automatico/manuale](DIAGRAMMA_STATI_UDC_2026-10-28.md).
|
||||
|
||||
## 1. Esito della revisione
|
||||
|
||||
Il nucleo delle regole e' coerente: evento SAM e comando manuale sono due
|
||||
ingressi distinti alle stesse regole; Validazione ammette solo N, chiuderla
|
||||
porta in Accettazione, riaprire una UDC disponibile porta in Confezionamento,
|
||||
Spedita e' finale. Pavimento e' un solo gruppo e non cambia lo stato
|
||||
"non scaffalata". Non occorrono nuovi pulsanti principali.
|
||||
|
||||
Non e' pero' una specifica ancora completamente eseguibile: restano decisioni
|
||||
operative e contratti tecnici necessari. La revisione non le trasforma in
|
||||
regole approvate senza il responsabile.
|
||||
|
||||
### R1. Riapertura e cella fisica: decisione chiusa, rischio operativo accettato
|
||||
|
||||
La regola approvata libera l'associazione WMS e porta in Confezionamento.
|
||||
Se il pallet non viene realmente rimosso, un altro operatore potrebbe vedere
|
||||
la cella libera e tentare una nuova allocazione. Non e' una contraddizione
|
||||
del testo, ma una conseguenza accettata e da gestire operativamente.
|
||||
|
||||
**Decisione del responsabile:** normalmente la riapertura segue la rimozione
|
||||
dalla cella, ma non e' garantito. In assenza di un varco/sensore, e' compito del
|
||||
magazziniere sincronizzare posizione fisica e logica. Non si introduce una
|
||||
conferma obbligatoria di rimozione ne' un blocco aggiuntivo della vecchia cella.
|
||||
Il rischio residuo non viene dichiarato eliminato dal software.
|
||||
|
||||
### R2. UDC riaperta durante il picking: regola operativa definita
|
||||
|
||||
Il responsabile esclude la riapertura come pratica normale durante il picking,
|
||||
ma richiede la gestione dell'errore. Il prelievo deve ricontrollare stato,
|
||||
posizione ed eventi pertinenti nella transazione, anche se parte da scansione
|
||||
automatica. UDC aperte/in Validazione non possono essere spedite.
|
||||
|
||||
**Decisione:** segnalare la riapertura e il passaggio in Confezionamento.
|
||||
Per questa UDC occorrono chiusura -> Accettazione -> riallocazione in cella WMS
|
||||
prima di riprendere il prelievo; la sola chiusura non basta. Mostrare attesa
|
||||
se il trasferimento e' pendente, oppure Validazione se e' la posizione successiva
|
||||
effettiva. Non marcare spedita, saltata o completata per il solo errore.
|
||||
Pausa/salto restano espliciti; alla ripresa rileggere posizione e dati correnti.
|
||||
Il vincolo di recupero non cambia il trattamento delle altre UDC ordinariamente
|
||||
proposte da Accettazione/Pavimento. Prova del ciclo e concorrenza restano da progettare.
|
||||
|
||||
### R3. Origine Validazione e riallocazione: regole definite
|
||||
|
||||
**Decisione:** il Carico in Validazione e' ammesso solo dal desktop, con origine
|
||||
Confezionamento e CHIUSA=N. Le altre origini sono vietate, non ancora da autorizzare.
|
||||
Verificare origine e stato nella transazione, non soltanto nella schermata.
|
||||
|
||||
**Precisazione concordata:** dopo riapertura, nessuna allocazione da Confezionamento
|
||||
o Validazione verso cella/Pavimento prima della chiusura e del passaggio effettivo
|
||||
in Accettazione. CHIUSA=S da solo non basta con eventi ancora pendenti. Le normali
|
||||
allocazioni da Pavimento e gli spostamenti fra celle restano consentiti per UDC
|
||||
chiuse disponibili; non devono ripassare ogni volta da Accettazione. Controlli
|
||||
comuni nel backend transazionale per desktop/barcode, non soltanto nella UI.
|
||||
|
||||
Abilitare solo i percorsi elencati; non creare collegamenti fra
|
||||
tutte le aree perche' esiste un menu generico Carico. Scarico da Confezionamento
|
||||
e' gia' definitivamente disabilitato.
|
||||
|
||||
M2 e M3 duplicano intenzionalmente la destinazione di un automatismo. Non sono
|
||||
errori di specifica, ma dopo la sincronizzazione potrebbero non esserci UDC
|
||||
nelle condizioni necessarie. Il comando non deve simulare un nuovo movimento
|
||||
quando quello automatico e' gia' avvenuto.
|
||||
|
||||
### R4. Stato finale Spedita e documenti chiusi con residui
|
||||
|
||||
Il divieto di recupero e' definitivo. Va precisato il dato autorevole usato
|
||||
dal controllo: spedizione effettiva, evento storico di spedizione, protezione
|
||||
per documento chiuso con residui. Queste condizioni non sono la stessa cosa.
|
||||
|
||||
Un documento chiuso con residui deve continuare a bloccare i recuperi impropri,
|
||||
ma non autorizza a inventare un movimento a 9999. La correzione SQL manuale
|
||||
eccezionale dovra' verificare anche eventi pendenti e indizi di spedizione,
|
||||
non soltanto cambiare una cella e lasciare il sincronizzatore in contraddizione.
|
||||
|
||||
Rimane distinta la scelta di impedire preventivamente la riapertura in SAM:
|
||||
un servizio asincrono puo' rilevarla e impedire il rientro WMS, non annullare
|
||||
retroattivamente un UPDATE ERP gia' confermato.
|
||||
|
||||
### R5. Inizializzazione e casi senza evento normale
|
||||
|
||||
Servono decisioni per: nascita gia' S, CHIUSA NULL/vuoto, chiusura in contesto
|
||||
inatteso, cancellazione/reinserimento dello stesso codice, codice non numerico,
|
||||
UDC chiuse senza giacenza attendibile e materiale pregresso fuori perimetro.
|
||||
|
||||
La prima migrazione richiede un punto di avvio concordato e una ricognizione
|
||||
verificabile, separata dagli eventi nuovi. Non riprodurre tutto EXTUCLOG come
|
||||
se fossero movimentazioni odierne. I filtri annuali non devono far scomparire
|
||||
assegnazioni attive o UDC rientrate legittimamente.
|
||||
|
||||
### R6. Contenuto variabile confermato; ricostruzione storica da progettare
|
||||
|
||||
Accettazione, Confezionamento e Validazione non devono essere accidentalmente
|
||||
contati due volte fra A/B/C. Il responsabile conferma che durante la riapertura,
|
||||
in particolare per rivalidazione, possono essere aggiunte o tolte bag/materiale.
|
||||
La vecchia assunzione di UDC con contenuto immutabile non vale per questi casi.
|
||||
Non dedurre quantita' storiche dalle etichette correnti.
|
||||
|
||||
**Da progettare:** verificare in SAM la storia delle associazioni bag/UDC e
|
||||
delle quantita' per lotto/prodotto. I soli eventi CHIUSA non descrivono il contenuto.
|
||||
Se la storia e' insufficiente, definire la tracciatura futura e segnalare i limiti
|
||||
del pregresso; non inventare quantita'. Esempio: 100 pezzi alla data D, 80 dopo
|
||||
una rivalidazione successiva; l'inventario a D deve mantenere 100 se documentati.
|
||||
Verificare anche la coerenza con lotti/quantita' della picking list dopo variazioni,
|
||||
senza modificare automaticamente il documento SAM. Nessuna implementazione ora.
|
||||
|
||||
### R7. Concorrenza, cronologia e identificazione degli eventi
|
||||
|
||||
EXTUCLOG locale non ha una colonna identificativa univoca: sono presenti solo
|
||||
CODICE, DIMENSIONE, PRE_CHIUSA, POST_CHIUSA, STAMPARE, RILASCIATA, HOSTNAME,
|
||||
AGGIORNAMENTO, tutte nullable. Timestamp e codice non garantiscono unicita'
|
||||
o ordine totale. Non usare "data maggiore dell'ultima letta" come unico criterio.
|
||||
|
||||
La proposta e' catturare gli inserimenti futuri in un registro eventi dedicato,
|
||||
senza aggiungere campi a EXTUC/EXTUCLOG, con identita', stati prima/dopo,
|
||||
tipo evento, date, tentativi, esito e relazione al movimento applicato.
|
||||
Anche un ID crescente non e' da solo un ordine di commit: non saltare eventi
|
||||
solo perche' una transazione con ID maggiore termina prima.
|
||||
|
||||
Esempio da testare: SAM produce S -> N -> S mentre il consumatore e' fermo.
|
||||
I due eventi vanno applicati nella giusta sequenza al contesto logistico,
|
||||
anche se il valore corrente e' gia' S. Il controllo corrente N del comando
|
||||
manuale non si puo' riutilizzare ciecamente per riprodurre l'evento storico
|
||||
di riapertura, altrimenti il primo passaggio verrebbe rifiutato.
|
||||
|
||||
Prima di un comando manuale occorre coordinare eventi precedenti, posizione
|
||||
e stato corrente, con serializzazione per UDC e controllo della concorrenza
|
||||
con SAM. Proposta iniziale: se la sincronizzazione non e' verificabile o ha
|
||||
un errore su quella UDC, bloccare quel movimento con messaggio, non tutto il WMS.
|
||||
|
||||
**Punti da scegliere:** latenza accettabile, blocco/attesa in caso di servizio
|
||||
fermo, politica di retry, isolamento dei casi errati e modalita' di ripresa.
|
||||
|
||||
### R8. Rappresentazione e audit
|
||||
|
||||
Rimangono da dettagliare ordine delle UDC nella matrice, scorrimento, codici
|
||||
virtuali, messaggi di attesa, permessi dei menu e autore dei movimenti automatici.
|
||||
HOSTNAME non equivale all'utente applicativo SAM: conservare cio' che e' noto
|
||||
e usare un'identita' tecnica riconoscibile per l'esecutore, senza inventare utenti.
|
||||
|
||||
## 2. Verifica dell'ambiente locale
|
||||
|
||||
Letture di metadati del 28 ottobre 2026 sull'istanza configurata localmente:
|
||||
|
||||
| Elemento | Risultato |
|
||||
|---|---|
|
||||
| Motore | SQL Server 2017, build 14.0.2140.2 |
|
||||
| Edizione | Developer Edition (64-bit) |
|
||||
| SQL Server Agent | Running, avvio Automatic |
|
||||
| Service Broker in Mediseawall | is_broker_enabled = 0 |
|
||||
| Service Broker in SAMA1 | is_broker_enabled = 0 |
|
||||
| CDC in entrambi i DB | is_cdc_enabled = 0 |
|
||||
| nested triggers | value_in_use = 1 |
|
||||
|
||||
Non e' una verifica del server online: una copia del DB non dimostra edizione,
|
||||
servizi e impostazioni dell'istanza di produzione. Non e' stata cambiata alcuna
|
||||
opzione. Developer e' per sviluppo/test, non produzione; disponibilita' dei
|
||||
componenti va verificata sulla versione/edizione online, senza dedurla dal
|
||||
nome Windows Server 2019. [Edizioni SQL Server 2017](https://learn.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2017).
|
||||
|
||||
Successiva precisazione del responsabile: il server online e' identico a quello
|
||||
locale. Questo e' il presupposto di progetto, non una nuova ispezione remota;
|
||||
prima del rilascio verificare comunque opzioni, permessi ed edizione/licenza.
|
||||
|
||||
## 3. Separare cattura, esecuzione e visualizzazione
|
||||
|
||||
```text
|
||||
CATTURA: SAM cambia EXTUC -> log/evento persistente
|
||||
ESECUZIONE: un consumatore applica la transizione WMS
|
||||
VISUALIZZAZIONE: le GUI rileggono risultato ed eventuali errori
|
||||
```
|
||||
|
||||
La cattura deve coprire sia nascita sia cambi N/S. Il trigger AFTER INSERT
|
||||
concordato registra la nascita con quattro NULL; l'evento dedicato deve
|
||||
distinguere tale nascita e acquisire lo stato originale, prima di eventuali
|
||||
ulteriori cambiamenti. Il log legacy non intercetta le transizioni NULL.
|
||||
|
||||
Una vista e' utile per leggere lo stato, ma non sostituisce cattura ed esecuzione.
|
||||
La notifica alle schermate non deve essere confusa con il movimento nel DB.
|
||||
|
||||
## 4. Alternativa nativa: Service Broker con attivazione interna
|
||||
|
||||
Service Broker offre code di messaggi. Con **attivazione interna**, SQL Server
|
||||
puo' avviare una stored procedure quando occorre elaborare la coda; non serve
|
||||
un processo Python esterno per questa parte. La procedura deve essere scritta
|
||||
e configurata: SQL Server non conosce da solo le regole UDC.
|
||||
[Attivazione Service Broker](https://learn.microsoft.com/en-us/sql/database-engine/service-broker/service-broker-activation?view=sql-server-ver17).
|
||||
|
||||
```text
|
||||
Trigger di cattura -> messaggio in coda -> procedura attivata da SQL Server
|
||||
|
|
||||
movimento WMS + storico
|
||||
```
|
||||
|
||||
Per la nostra applicazione la procedura dovrebbe ricevere l'evento, chiamare
|
||||
la logica comune, confermare movimento e ricezione nella transazione appropriata.
|
||||
Sono da progettare ordinamento per UDC, conversazioni, chiusura dei dialoghi,
|
||||
idempotenza e coordinamento con i menu; l'ordine non e' globale fra conversazioni
|
||||
diverse. Il codice di business non va eseguito per intero dentro il trigger SAM.
|
||||
|
||||
Un evento non elaborabile deve essere isolato e segnalato con una politica
|
||||
esplicita: i rollback ripetuti possono disabilitare la coda tramite la protezione
|
||||
poison-message. Non basta lasciarlo riprovare per sempre.
|
||||
[Gestione messaggi problematici](https://learn.microsoft.com/en-us/sql/database-engine/service-broker/handling-poison-messages?view=sql-server-ver17).
|
||||
|
||||
Vantaggio: elaborazione guidata dai messaggi, senza un servizio applicativo
|
||||
aggiuntivo. Costo: configurazione e gestione specifiche di SQL Server, minore
|
||||
portabilita' verso PostgreSQL. Serve monitoraggio anche delle code ferme.
|
||||
|
||||
Attualmente Broker e' disabilitato nei DB locali: un'eventuale abilitazione
|
||||
richiede una patch separata e una finestra concordata. Non usare automaticamente
|
||||
opzioni che interrompano sessioni o annullino transazioni. Anche restore e
|
||||
clonazione delle code vanno progettati per isolare test e produzione.
|
||||
[Stato e attivazione Broker](https://learn.microsoft.com/en-us/sql/database-engine/service-broker/how-to-activate-service-broker-message-delivery-in-databases-transact-sql?view=sql-server-ver17).
|
||||
|
||||
## 5. Avviare programmi esterni: cosa e' realmente incluso
|
||||
|
||||
### Service Broker: attivazione esterna
|
||||
|
||||
L'attivazione esterna genera un evento QUEUE_ACTIVATION; un componente esterno
|
||||
lo ascolta e avvia il programma. **Non equivale a dire che il motore SQL lanci
|
||||
automaticamente un file Python senza un componente aggiuntivo.** In alternativa
|
||||
un servizio esterno puo' restare avviato in attesa di messaggi tramite RECEIVE.
|
||||
[Strategie di avvio](https://learn.microsoft.com/en-us/sql/database-engine/service-broker/choosing-a-startup-strategy?view=sql-server-ver17).
|
||||
|
||||
Microsoft ha distribuito anche un External Activator come servizio Windows.
|
||||
E' un componente separato: la documentazione storica ne attesta l'esistenza,
|
||||
non la presenza o la compatibilita' gia' verificata sul nostro server.
|
||||
[Descrizione Microsoft External Activator](https://techcommunity.microsoft.com/blog/sqlserver/announcing-service-broker-external-activator/383497/).
|
||||
|
||||
### SQL Server Agent
|
||||
|
||||
Agent puo' eseguire job T-SQL, CmdExec (anche un interprete Python installato)
|
||||
o PowerShell, con credenziali/proxy appropriati. Gli alert possono avviare job,
|
||||
ma non sono automaticamente una sottoscrizione ai cambi della colonna CHIUSA.
|
||||
[SQL Server Agent](https://learn.microsoft.com/en-us/ssms/agent/sql-server-agent?view=sql-server-ver16).
|
||||
|
||||
L'uso piu' semplice qui sarebbe: trigger -> tabella eventi -> job periodico
|
||||
che svuota i pendenti tramite una procedura comune. La schedulazione periodica
|
||||
ha intervallo minimo documentato di **10 secondi**, non 1-2 secondi; a questo
|
||||
si aggiungono esecuzione e carico del server.
|
||||
[Schedulazioni Agent](https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-add-schedule-transact-sql?view=sql-server-ver15).
|
||||
|
||||
Questo evita un servizio Python se tutto il lavoro e' SQL. Se si usa CmdExec,
|
||||
Python e dipendenze devono esistere sul computer dove gira il job, indipendentemente
|
||||
dalle installazioni sui desktop. Agent non e' disponibile in Express secondo
|
||||
la matrice dell'edizione; verificare sempre la produzione.
|
||||
[Funzioni per edizione](https://learn.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2017).
|
||||
|
||||
Non propongo xp_cmdshell, avvio di processi nel trigger o un job nuovo per ogni
|
||||
singola UDC: renderebbero piu' difficile gestire transazioni, errori e concorrenza.
|
||||
|
||||
## 6. Alternativa portabile: servizio WMS con tabella eventi
|
||||
|
||||
Un servizio Windows senza GUI parte all'avvio del server, legge piccoli lotti
|
||||
di eventi pendenti indicizzati (ad esempio ogni due secondi, valore da scegliere)
|
||||
e invoca la procedura comune. Non scansiona l'intera EXTUC o decenni di log.
|
||||
|
||||
Se la coda e' vuota attende; se trova eventi li elabora con limiti e transazioni
|
||||
brevi. Se perde la connessione ritenta con attese crescenti. Il suo arresto non
|
||||
cancella gli eventi. Occorrono gestione del servizio, credenziali minime, log,
|
||||
controlli di salute, tentativi limitati per errori permanenti e allarme sulle code
|
||||
in ritardo. La connessione non deve essere considerata eterna: va ricreata
|
||||
quando necessario senza perdere l'identita' degli eventi.
|
||||
|
||||
Con servizio disponibile e senza arretrato, l'attesa prima della prossima lettura
|
||||
varia indicativamente da zero all'intervallo di polling; non e' una garanzia
|
||||
di completamento. I comandi manuali devono comunque coordinarsi con gli eventi
|
||||
pendenti e con gli aggiornamenti SAM. Avviare un solo processo non risolve da
|
||||
solo la concorrenza con GUI e barcode.
|
||||
|
||||
Vantaggio: minore dipendenza da Agent/Broker e struttura trasferibile in futuro
|
||||
ad altri DB. Costo: un servizio applicativo da installare e sorvegliare. Il
|
||||
trigger/cattura e l'adattatore SQL restano da portare, non diventano automaticamente
|
||||
indipendenti dal database.
|
||||
|
||||
## 7. Altri strumenti SQL Server: perche' non sono equivalenti
|
||||
|
||||
- **Change Tracking** indica quali righe sono cambiate ma non conserva tutta la
|
||||
storia dei valori. Non basta per non perdere S -> N -> S. **CDC** conserva
|
||||
cambiamenti dal log e puo' essere una fonte alternativa, ma richiede configurazione,
|
||||
gestione della conservazione e un consumatore: non e' il motore delle regole WMS.
|
||||
[Confronto CT/CDC](https://learn.microsoft.com/en-us/sql/relational-databases/track-changes/track-data-changes-sql-server).
|
||||
- **Query Notifications** segnala invalidazione del risultato di una query;
|
||||
la sottoscrizione va rinnovata. Utile per aggiornare cache/schermate, non come
|
||||
registro completo dei cambi UDC.
|
||||
[Query Notifications](https://learn.microsoft.com/en-us/sql/relational-databases/native-client/features/working-with-query-notifications?view=sql-server-ver15).
|
||||
- **Event Notifications** riguarda DDL e specifici eventi Trace, non fornisce
|
||||
automaticamente i vecchi/nuovi valori di ogni UPDATE della UDC.
|
||||
[Event Notifications](https://learn.microsoft.com/en-us/sql/relational-databases/service-broker/event-notifications?view=sql-server-ver17).
|
||||
|
||||
## 8. Scelta progettuale: servizio esterno per debugging e simulazione
|
||||
|
||||
Il responsabile delega la scelta tecnica privilegiando debugging e simulazione,
|
||||
con server online dichiarato identico al locale. PostgreSQL non e' un criterio
|
||||
di scelta in questa fase. Si sceglie **tabella eventi persistente + elaboratore
|
||||
Python esterno**, eseguibile sia da console sia come servizio Windows senza GUI.
|
||||
Questa decisione aggiorna la precedente preferenza condizionale per Broker interno.
|
||||
Non autorizza installazioni o modifiche DB in questo turno.
|
||||
|
||||
Il trigger accoda nella transazione SAM, senza lanciare eseguibili. L'elaboratore
|
||||
gia' avviato legge piccoli lotti indicizzati di eventi pendenti con intervallo
|
||||
configurabile (proposta iniziale due secondi, da misurare). Non esegue scansioni
|
||||
complete del log e non viene riavviato per ogni singola UDC.
|
||||
|
||||
Tre responsabilita' separate:
|
||||
|
||||
1. **Regole pure:** evento, contesto e stato di partenza producono una decisione
|
||||
o un rifiuto con motivo. Nessuna connessione DB, GUI o attesa temporale.
|
||||
2. **Esecutore SQL:** acquisisce dati e protezioni concorrenti, applica la
|
||||
decisione, movimenti, storico ed esito evento nella stessa transazione.
|
||||
Non si conferma l'evento separatamente dal movimento. Vincoli e verifiche
|
||||
necessarie all'integrita' rimangono nel percorso transazionale SQL.
|
||||
3. **Processo ospitante:** avvio, arresto, lettura coda, riconnessione, tentativi,
|
||||
log e segnalazione anomalie. Console e servizio usano lo stesso elaboratore.
|
||||
|
||||
Desktop e barcode devono rispettare le stesse regole e il medesimo protocollo
|
||||
transazionale di coordinamento; la posizione non si decide su una lettura vecchia
|
||||
prima di acquisire le protezioni. La forma delle procedure SQL e il modo di
|
||||
condividere le regole sono ancora da progettare senza duplicazioni divergenti.
|
||||
|
||||
### Debug e livelli di prova
|
||||
|
||||
- **Simulazione senza SQL:** eventi e stato fittizi, ad esempio riapertura in
|
||||
cella -> Confezionamento -> chiusura -> Accettazione. Confronto degli esiti
|
||||
attesi; provare anche spedita, origine vietata, duplicati e S -> N -> S.
|
||||
- **Console sul DB di test:** stesso elaboratore, esecuzione controllata di un
|
||||
lotto o evento identificato, con debugger e log. I limiti di ordinamento
|
||||
impediscono di elaborare a piacere un evento ignorando i precedenti della UDC.
|
||||
- **Integrazione SQL:** trigger, commit/rollback, blocchi, due operatori,
|
||||
riavvio e perdita di connessione prima/dopo commit. Un esito di commit incerto
|
||||
va verificato tramite identita' persistente prima di ritentare il movimento.
|
||||
- **End-to-end:** SAM simulato sul DB isolato, servizio, desktop e terminalino;
|
||||
infine prove del servizio installato con l'utenza e i permessi reali.
|
||||
|
||||
La simulazione pura prova le regole, non certifica trigger, transazioni o
|
||||
concorrenza di SQL Server. Non presentarla come sostituto delle prove integrate.
|
||||
La riproduzione dei log per debug e' senza scritture o su DB isolato, mai una
|
||||
riesecuzione incontrollata dei movimenti in produzione.
|
||||
|
||||
Ogni evento deve essere rintracciabile per ID, UDC, stato precedente/successivo,
|
||||
origine/destinazione, tempi, tentativi ed errore completo. Servono anche stato
|
||||
di salute del servizio, numero/eta' dei pendenti, eventi in errore e gestione
|
||||
degli eventi non elaborabili senza bloccare tutte le altre UDC. Le GUI devono
|
||||
segnalare sincronizzazione non disponibile e impedire i movimenti non sicuri.
|
||||
|
||||
### Ruolo di Broker e Agent
|
||||
|
||||
Service Broker non viene attivato nella prima versione. Potra' sostituire in
|
||||
futuro il trasporto della coda se misure e necessita' lo giustificassero, senza
|
||||
trasferire necessariamente le regole in T-SQL. Agent non e' l'esecutore principale
|
||||
e non serve per avviare un processo a ogni evento; puo' eventualmente ospitare
|
||||
controlli periodici di salute, da progettare separatamente. Il servizio esterno
|
||||
ha il costo di installazione, credenziali e sorveglianza: non e' robusto solo
|
||||
perche' e' Python. Packaging, avvio automatico e recupero restano da collaudare.
|
||||
|
||||
Prima del rilascio restano R4-R8, protocollo transazionale, latenza richiesta,
|
||||
prototipo isolato, patch/revert e verifiche sull'ambiente online. Nessuna
|
||||
attivazione sul server di produzione sulla sola base di questo documento.
|
||||
532
RIEPILOGO_STATI_UDC_2026-10-28.md
Normal file
532
RIEPILOGO_STATI_UDC_2026-10-28.md
Normal file
@@ -0,0 +1,532 @@
|
||||
# Stati UDC: classificazione e quattro scaffali virtuali
|
||||
|
||||
Aggiornamento: 29 ottobre 2026. Revisione: **12** (ambiente di sviluppo isolato).
|
||||
Stato: **specifica da verificare prima dell'implementazione**.
|
||||
|
||||
La preparazione dell'ambiente e' separata dall'implementazione degli stati:
|
||||
[ambiente locale XWMS](XWMS_AMBIENTE_LOCALE.md). Tutte le nuove strutture e
|
||||
procedure WMS saranno in Xwmsdb; le prove dei trigger SAM solo in SAMA1_Xwmstest.
|
||||
I riferimenti a SAMA1/Mediseawall nelle rilevazioni storiche descrivono le fonti
|
||||
originali, non autorizzano scritture su quei database.
|
||||
|
||||
Riepilogo della bozza `analisi_stati_udc_23_20_2026.txt` e delle decisioni
|
||||
successive. Le regole di questa revisione sostituiscono quelle incompatibili
|
||||
delle revisioni precedenti. Nessuna modifica a codice, trigger o giacenze.
|
||||
|
||||
Allegato: [Diagramma degli stati, automatismi e comandi](DIAGRAMMA_STATI_UDC_2026-10-28.md).
|
||||
|
||||
Esito della revisione: [ambiguita' residue e alternative SQL Server](REVISIONE_SPECIFICHE_E_SERVIZIO_UDC_2026-10-28.md).
|
||||
Il nucleo e' coerente. Le decisioni operative R1-R3 sono definite nell'allegato;
|
||||
R6 conferma che il contenuto puo' cambiare, ma la ricostruzione storica resta
|
||||
da progettare. Restano altre decisioni tecniche e di migrazione: la specifica
|
||||
non e' ancora interamente eseguibile.
|
||||
|
||||
## 1. Principio generale e decisioni superate
|
||||
|
||||
Esistono **due cause di movimentazione** che convivono:
|
||||
|
||||
- **Evento esterno SAM:** nascita o cambio effettivo di apertura/chiusura avvia
|
||||
una procedura automatica, che decide la destinazione in base al contesto.
|
||||
- **Comando operatore:** menu desktop o operazione barcode avviano un movimento
|
||||
manuale, consentito solo dalle condizioni della transizione.
|
||||
|
||||
Il movimento automatico non e' un semplice cambio di etichetta sullo schermo:
|
||||
se necessario rimuove l'associazione precedente, assegna la nuova posizione e
|
||||
registra lo storico. Il menu manuale non modifica automaticamente CHIUSA in SAM.
|
||||
|
||||
Sono superate le precedenti decisioni secondo cui:
|
||||
- Ogni trasferimento fra aree richiedeva necessariamente un menu.
|
||||
- Una UDC riaperta in una cella o Pavimento rimaneva li' con pulsante verde.
|
||||
- Validazione ammetteva un carico manuale di UDC chiuse.
|
||||
- La chiusura in Validazione non provocava l'uscita.
|
||||
- Scarico da Confezionamento era ancora da definire: ora e' **disabilitato**.
|
||||
|
||||
### Spedita: stato finale
|
||||
|
||||
**Decisione confermata:** una UDC gia' spedita non puo' essere recuperata,
|
||||
riaperta o rimessa in circolazione dalle procedure ordinarie, automatiche o
|
||||
manuali. Non esiste alcuna transizione di ritorno da Spedita. Questa regola
|
||||
prevale sull'automatismo generale di ritorno in Confezionamento alla riapertura.
|
||||
|
||||
Se una spedizione e' stata registrata per errore, la correzione viene fatta
|
||||
caso per caso tramite intervento SQL manuale del responsabile tecnico.
|
||||
Non si introduce un pulsante di recupero o una procedura automatica di reso.
|
||||
Questa decisione non autorizza alcuna correzione SQL sui dati attuali.
|
||||
|
||||
Se il programma esterno producesse comunque un evento di riapertura per
|
||||
una UDC spedita, il WMS non deve applicare un rientro: conserva lo stato
|
||||
logistico di spedizione e registra/segnala l'incoerenza per verifica manuale.
|
||||
Il rilevamento successivo non equivale a impedire la scrittura in SAM:
|
||||
un eventuale blocco preventivo nell'ERP richiede un controllo dedicato da
|
||||
progettare e verificare, non viene promesso dal solo sincronizzatore.
|
||||
|
||||
Per le UDC in documenti chiusi ma ancora in celle residue restano attive le
|
||||
protezioni esistenti: il residuo non autorizza un recupero come disponibile.
|
||||
La chiusura del documento non va pero' inventata come movimento fisico a 9999.
|
||||
|
||||
## 2. Stato produttivo, posizione e rilevamento dell'evento
|
||||
|
||||
La fonte dello stato corrente e' **`SAMA1.sam.EXTUC.CHIUSA`**:
|
||||
`N` significa aperta, `S` chiusa. NULL, vuoto o valori non riconosciuti non
|
||||
soddisfano i controlli S/N; la gestione delle anomalie va definita.
|
||||
|
||||
Lo stato logistico comprende anche posizione corrente e storia degli eventi.
|
||||
**Essere aperta non equivale a essere appena riaperta.**
|
||||
Una UDC gia' N caricata manualmente in Validazione deve restarvi finche' non
|
||||
avviene un evento o un comando pertinente. Un controllo periodico non deve
|
||||
rimandare indiscriminatamente in Confezionamento tutte le UDC con N.
|
||||
|
||||
Analogamente, un'UDC S allocata manualmente in una cella non ritorna in
|
||||
Accettazione ad ogni aggiornamento della vista.
|
||||
|
||||
Per gli automatismi conta il cambio effettivo: S -> N o N -> S, non la mera
|
||||
riscrittura dello stesso valore. Per i comandi manuali si verifica anche lo
|
||||
stato corrente, senza utilizzare una vecchia riga del log come stato attuale.
|
||||
La classificazione iniziale dei dati pregressi e' separata dagli eventi futuri.
|
||||
|
||||
## 3. I quattro scaffali virtuali
|
||||
|
||||
Il nome dell'area virtuale e' **Pavimento**, in sostituzione di NON SCAFFALATE.
|
||||
Lo stato della UDC rimane **non scaffalata**: cambia il nome dell'area, non
|
||||
la logica dei movimenti o le condizioni di appartenenza.
|
||||
Il pulsante principale **UDC non scaffalate** viene mantenuto come scorciatoia
|
||||
che apre direttamente Pavimento in Gestione layout. Non si aggiungono nuovi
|
||||
pulsanti alla barra orizzontale per i quattro gruppi virtuali.
|
||||
|
||||
Le voci si aggiungono al selettore di Gestione layout. Non implicano una
|
||||
corrispondenza automatica con gli ID legacy della tabella `Aree`.
|
||||
|
||||
| Gruppo | Contenuto ordinario | Ingresso principale |
|
||||
|---|---|---|
|
||||
| **Pavimento** | UDC disponibili a pavimento, senza separazione Area 5/6 | Disassociazione fisica oppure dichiarazione esplicita |
|
||||
| **Accettazione: UDC in transito** | UDC chiuse disponibili al trasferimento | Chiusura da Confezionamento/Validazione oppure movimento manuale ammesso |
|
||||
| **Confezionamento: UDC aperte** | UDC nuove aperte o riaperte | Nascita aperta, riapertura oppure ingresso manuale ammesso |
|
||||
| **Validazione: UDC in attesa di rivalidazione** | Soltanto UDC aperte | Carico manuale dal desktop, esclusivamente da Confezionamento con CHIUSA=N |
|
||||
|
||||
Le celle fisiche e la Spedizione rimangono distinte. Validazione e' un'unica
|
||||
cella logica multi-UDC: i pulsanti rappresentano il contenuto, non altre celle.
|
||||
Una UDC con piu' lotti compare una volta sola come contenitore.
|
||||
|
||||
## 4. Pavimento
|
||||
|
||||
La categoria significa disassociazione da una cella o dichiarazione esplicita
|
||||
del barcode, anche senza precedente allocazione. L'assenza di una registrazione
|
||||
WMS o un ripiego SQL non basta per dichiarare una UDC non scaffalata.
|
||||
|
||||
Area 5 e Area 6 confluiscono nello stesso gruppo. La provenienza rimane nello
|
||||
storico, ma non serve per scegliere una diversa destinazione virtuale.
|
||||
Un'allocazione, spedizione o altro trasferimento successivo supera la vecchia
|
||||
disassociazione; non basta cercare una qualunque cella nella storia.
|
||||
|
||||
**Scarico manuale dal gruppo**, con UDC chiusa (S), porta in Accettazione,
|
||||
non in Spedizione. Se lo stato non soddisfa la condizione, il comando non
|
||||
esegue quel percorso.
|
||||
|
||||
**Riapertura esterna S -> N:** trasferimento automatico in Confezionamento,
|
||||
rimuovendo l'associazione a Pavimento. Non si applica piu' la permanenza
|
||||
verde della prima bozza. Gli eventuali movimenti manuali contemporanei
|
||||
richiedono coordinamento, descritto nella sezione 10.
|
||||
|
||||
## 5. Accettazione
|
||||
|
||||
Accoglie le UDC chiuse automaticamente da Confezionamento o Validazione,
|
||||
anche se gia' transitate nel WMS, e quelle trasferite con comandi ammessi.
|
||||
Il vincolo "mai stata in WMS" non e' piu' una condizione generale di appartenenza.
|
||||
|
||||
Il nome "in transito" e' una convenzione operativa: una chiusura SAM non
|
||||
prova da sola l'avvenuto trasporto fisico.
|
||||
|
||||
Dopo l'ingresso, la UDC e' movimentabile manualmente verso una cella WMS o
|
||||
Pavimento con le procedure previste. Non si sposta automaticamente solo
|
||||
perche' mantiene S.
|
||||
|
||||
**Riapertura esterna S -> N:** trasferimento automatico in Confezionamento.
|
||||
L'operatore che ha chiuso per errore una UDC in Validazione la trovera' in
|
||||
Accettazione; riaprendola nel programma esterno, la fa tornare automaticamente
|
||||
in Confezionamento. Il WMS non riapre la UDC al posto di quel programma.
|
||||
|
||||
Resta il percorso manuale gia' concordato **Scarico da Accettazione con N**,
|
||||
verso Confezionamento. Puo' sovrapporsi all'automatismo: deve usare la stessa
|
||||
logica e non produrre due movimenti. Se la UDC e' gia' arrivata, non va spostata
|
||||
di nuovo ne' dichiarata ancora presente nella vecchia area.
|
||||
|
||||
## 6. Confezionamento e perimetro annuale
|
||||
|
||||
**Nascita di una UDC aperta:** ingresso automatico in Confezionamento.
|
||||
**Riapertura S -> N di una UDC disponibile:** ritorno automatico in
|
||||
Confezionamento dal contesto precedente, anche da una cella fisica o da
|
||||
Pavimento. L'associazione precedente deve cessare: il successivo ritorno
|
||||
in una cella richiede una nuova allocazione manuale.
|
||||
|
||||
**Chiusura N -> S mentre e' in Confezionamento:** trasferimento automatico
|
||||
in Accettazione, senza bisogno di un menu.
|
||||
|
||||
Sono conservati i percorsi manuali ammessi: Carico in Validazione con N,
|
||||
Carico in Accettazione con S, ingresso da Scarico in Validazione/Accettazione
|
||||
con N. Non autorizzano modifiche a CHIUSA e non duplicano gli automatismi.
|
||||
**Scarico eseguito dentro Confezionamento e' disabilitato.**
|
||||
|
||||
Per la prima ricognizione delle UDC aperte pregresse si usa anno corrente e
|
||||
precedente. Nel 2026 i codici numerici di sei caratteri iniziano per 6 e 5.
|
||||
Il responsabile ha confermato la pulizia dei codici dei vecchi decenni che
|
||||
potrebbero collidere. Il criterio e' mobile, non fissato per sempre al 2025/2026.
|
||||
La riapertura non cambia l'anno di nascita.
|
||||
|
||||
Le assegnazioni attive esplicite rimangono visibili anche fuori da tale filtro.
|
||||
La ricognizione annuale non autorizza a nascondere posizioni note o UDC rientrate
|
||||
per lavorazione. Non inventare date precise per le UDC pregresse.
|
||||
|
||||
### Vincolo di riallocazione dopo riapertura
|
||||
|
||||
Dopo la riapertura non si puo' assegnare direttamente la UDC da Confezionamento
|
||||
o Validazione a una cella WMS o a Pavimento. Occorrono prima la chiusura in SAM
|
||||
e l'effettivo passaggio in Accettazione. Il solo CHIUSA=S, con il trasferimento
|
||||
ancora pendente, non basta. Questo impedisce che una chiusura tardivamente
|
||||
elaborata cancelli una nuova allocazione.
|
||||
|
||||
Pavimento -> cella WMS resta il normale percorso di allocazione di una UDC
|
||||
chiusa e disponibile. Restano ammessi gli spostamenti ordinari fra celle:
|
||||
non occorre ripassare da Accettazione a ogni movimento, ma dopo ogni riapertura.
|
||||
Allocazioni, spostamenti e dichiarazioni a Pavimento richiedono CHIUSA=S,
|
||||
origine ammessa, protezioni di spedizione e sincronizzazione coerente.
|
||||
|
||||
Il controllo deve essere comune a desktop e barcode, nel backend e nella
|
||||
transazione del movimento, coordinato con gli eventi SAM pertinenti. Non basta
|
||||
disabilitare un pulsante. Se la UDC e' ancora aperta o in lavorazione:
|
||||
"UDC non allocabile: completare la chiusura e attendere il passaggio in Accettazione".
|
||||
Se manca solo la sincronizzazione, segnalare l'attesa senza chiedere una nuova chiusura.
|
||||
Il meccanismo tecnico di coordinamento resta da progettare.
|
||||
|
||||
## 7. Validazione
|
||||
|
||||
### Ingresso e uscite
|
||||
|
||||
- **Carico manuale:** solo desktop, esclusivamente da Confezionamento,
|
||||
verificando origine corrente ed `EXTUC.CHIUSA=N` nella transazione.
|
||||
Ingressi diretti da cella WMS, Pavimento o Accettazione sono vietati,
|
||||
anche se una schermata non ancora aggiornata mostra la UDC come aperta.
|
||||
Occorre prima completare il passaggio logico in Confezionamento.
|
||||
- Se CHIUSA=S, il tentativo di Carico e' respinto. Il solo tentativo non e'
|
||||
un evento di chiusura e non deve spostare altrove la UDC.
|
||||
- **Scarico manuale con N:** solo desktop, verso Confezionamento.
|
||||
- **Chiusura esterna N -> S:** trasferimento automatico in Accettazione,
|
||||
anche quando l'operatore ha chiuso per sbaglio. Decisione esplicitamente confermata.
|
||||
- Se viene poi riaperta in Accettazione, torna automaticamente in Confezionamento.
|
||||
Non torna automaticamente in Validazione: occorre un nuovo Carico desktop con N.
|
||||
|
||||
L'esclusivita' desktop riguarda i **comandi manuali** di Validazione.
|
||||
L'uscita automatica alla chiusura e' un percorso distinto, non un comando barcode.
|
||||
|
||||
Una UDC N puo' restare in Validazione: una riscrittura N -> N o un refresh
|
||||
non ne provoca l'uscita. La chiusura va rilevata come evento effettivo.
|
||||
Una UDC S trovata in Validazione senza evento disponibile costituisce invece
|
||||
un caso di riconciliazione da gestire, non una falsa nuova chiusura.
|
||||
|
||||
Il caricamento non duplica posizioni; la chiusura non lascia contemporaneamente
|
||||
la UDC in Validazione e Accettazione. Possono coesistere molte UDC nella
|
||||
cella virtuale di Validazione.
|
||||
|
||||
Durante la riapertura/rivalidazione il contenuto puo' cambiare: possono essere
|
||||
aggiunte o tolte bag e materiale in funzione dell'esito dei controlli. Non e'
|
||||
quindi soltanto un cambiamento di stato di un contenitore immutabile. Questa
|
||||
decisione non introduce comandi WMS di modifica del contenuto: le fonti e la
|
||||
tracciatura di tali variazioni devono essere analizzate per l'inventario.
|
||||
|
||||
## 8. Interfaccia e collegamenti agli altri moduli
|
||||
|
||||
### Layout e menu
|
||||
|
||||
- Matrice con **cinque righe e colonne secondo necessita'**, pulsanti normalmente grigi.
|
||||
- Carico nel gruppo di destinazione; Scarico sulla UDC selezionata nel gruppo origine.
|
||||
- Carico disponibile anche sullo sfondo vuoto con clic destro.
|
||||
- Scarico da Confezionamento disabilitato; altri comandi dipendono dai controlli.
|
||||
- Ordine di riempimento, scorrimento orizzontale e resa di stati in attesa/errore
|
||||
restano da perfezionare.
|
||||
|
||||
La precedente regola del verde per mantenere una UDC riaperta nella vecchia
|
||||
cella e' superata. Il trasferimento automatico libera l'associazione logica.
|
||||
Questo non attesta che qualcuno abbia gia' spostato fisicamente il pallet:
|
||||
l'operatore deve rendere coerenti posizione reale e registrazione.
|
||||
|
||||
**Decisione confermata:** tale coerenza fisica e' responsabilita' del magazziniere.
|
||||
Normalmente la UDC viene rimossa prima della riapertura per controllo; il software
|
||||
non dispone di un varco o sensore che certifichi lo spostamento. Si accetta il
|
||||
rischio residuo di una rimozione dimenticata: non si introduce una conferma
|
||||
obbligatoria di rimozione ne' un blocco aggiuntivo della vecchia cella. Il vincolo
|
||||
di riallocazione tutela la sequenza logica, non certifica la presenza fisica.
|
||||
Una futura quadratura fisico/logico resta rinviata: non viene implementata
|
||||
ne' considerata una garanzia di correttezza delle posizioni in questa fase.
|
||||
|
||||
Se la sincronizzazione e' in ritardo o in errore, la UI non deve simulare un
|
||||
trasferimento riuscito. Come evidenziare tali condizioni resta da progettare.
|
||||
|
||||
### Picking, barcode e inventario
|
||||
|
||||
Conservare separazione dei movimenti liberi dal picking, tracciamento,
|
||||
controlli di occupazione e protezioni sulle UDC spedite/documenti chiusi.
|
||||
Non cambiare implicitamente l'ordine di prelievo.
|
||||
|
||||
Le UDC in Accettazione devono essere proposte in picking come tali, non con
|
||||
il vecchio ripiego "Non scaff.". Vale pero' il vincolo specifico seguente per
|
||||
una UDC riaperta mentre e' gia' proposta per il prelievo.
|
||||
|
||||
**Riapertura accidentale durante il picking:** non e' un'operazione ordinaria,
|
||||
ma il terminalino deve gestirla. Prima di confermare lo scarico si ricontrollano
|
||||
stato SAM, posizione corrente ed eventi pertinenti nella transazione, anche
|
||||
quando la lettura avvia automaticamente il prelievo.
|
||||
|
||||
La spedizione della UDC aperta/in Validazione e' bloccata. Dopo il trasferimento
|
||||
automatico in Confezionamento il terminalino segnala:
|
||||
"UDC riaperta: si trova in Confezionamento. Chiudere la UDC e riallocarla in una cella prima della spedizione."
|
||||
Se il trasferimento e' ancora pendente, segnalare invece la sincronizzazione
|
||||
in attesa, senza dichiarare gia' raggiunta la destinazione. Se la UDC e' stata
|
||||
successivamente caricata in Validazione, mostrare quella posizione effettiva.
|
||||
|
||||
Per questa UDC il percorso di recupero obbligatorio e': riapertura ->
|
||||
Confezionamento (eventualmente Validazione) -> chiusura SAM -> Accettazione ->
|
||||
riallocazione manuale in una cella WMS -> nuovo prelievo della picking list.
|
||||
La sola chiusura o il solo arrivo in Accettazione non sbloccano quel prelievo:
|
||||
serve la riallocazione richiesta. Non estendere questo vincolo a tutte le
|
||||
altre UDC ordinariamente proposte da Accettazione o Pavimento.
|
||||
|
||||
Il tentativo bloccato non registra spedizione, non completa la riga e non
|
||||
salta automaticamente la UDC. Pausa/salto restano scelte esplicite dell'operatore.
|
||||
Alla ripresa si rileggono posizione e dati aggiornati, senza usare la vecchia
|
||||
cella conservata sul terminalino. La prova del ciclo di riapertura/riallocazione
|
||||
e il coordinamento con SAM vanno progettati, non dedotti dal solo CHIUSA corrente.
|
||||
|
||||
L'inventario deve includere correttamente i nuovi gruppi senza duplicare UDC
|
||||
o bag. L'attribuzione ad A/B/C e il trattamento di Validazione vanno verificati.
|
||||
Le ricostruzioni storiche usano gli eventi alla data richiesta, non lo stato
|
||||
corrente applicato retroattivamente.
|
||||
|
||||
**Contenuto variabile confermato:** durante la riapertura/rivalidazione possono
|
||||
cambiare bag e quantita'. L'assunzione precedente di UDC sempre intera e con
|
||||
contenuto immutabile non e' valida per questi casi. Occorre ricostruire sia la
|
||||
posizione sia la composizione alla fine della giornata scelta, usando una
|
||||
storia attendibile delle associazioni bag/UDC e delle quantita' per lotto/prodotto.
|
||||
Il log di apertura/chiusura da solo non contiene queste variazioni.
|
||||
|
||||
Esempio: alla data D la UDC contiene 100 pezzi; una rivalidazione successiva
|
||||
ne rimuove 20. L'inventario a D deve continuare a riportare 100, non gli 80
|
||||
attuali. Analogamente, una bag spostata fra contenitori non deve essere contata
|
||||
due volte. Prima del codice verificare quali dati storici SAM siano disponibili;
|
||||
se insufficienti, definire la nuova tracciatura e segnalare i limiti del pregresso,
|
||||
senza inventare valori storici. Il confronto con i quantitativi della picking
|
||||
list dopo una variazione di contenuto va anch'esso verificato, non aggiornato
|
||||
automaticamente dal WMS senza una regola concordata.
|
||||
|
||||
## 9. Dati esistenti, codifiche e migrazione
|
||||
|
||||
I nuovi ID SQL/barcode non sono ancora assegnati. `8G.1.1` per Accettazione
|
||||
resta una proposta. Non confondere l'Accettazione legacy incompleta con
|
||||
Spedizione `9999 / 7G.1.1`, ne' le aree 5/6 con gli ID della tabella Aree.
|
||||
|
||||
Prima della migrazione distinguere vere disassociazioni, dichiarazioni
|
||||
esplicite, passaggi tecnici in 1000 e ripieghi delle viste. Non convertire
|
||||
indiscriminatamente ogni vecchio "Non scaff.".
|
||||
|
||||
La prima classificazione del DB pregresso richiede una procedura separata,
|
||||
approvata e verificabile: non riprodurre anni di log come nuovi movimenti.
|
||||
Concordare perimetro delle UDC chiuse mai registrate, contenitori vuoti,
|
||||
gia' spediti o con storia insufficiente. Il legame tra Validazione, vecchia
|
||||
area 1 e codici non numerici `I...` non e' ancora accertato.
|
||||
|
||||
## 10. Sincronizzazione SAM: situazione verificata e proposta
|
||||
|
||||
### Situazione verificata sul database locale il 28 ottobre 2026
|
||||
|
||||
Esiste il trigger attivo `sam.StoricizzaVariazioniUc`, AFTER UPDATE su EXTUC:
|
||||
scrive in EXTUCLOG quando `d.CHIUSA <> i.CHIUSA`. Non registra le nascite e
|
||||
quel confronto non intercetta i passaggi da/verso NULL. Non risultava un
|
||||
trigger su EXTUCLOG. Nel codice Python esaminato non e' stato individuato
|
||||
un consumatore di questi eventi che realizzi i nuovi trasferimenti.
|
||||
|
||||
Una vista aggiorna il risultato alla lettura, ma non effettua da sola movimenti,
|
||||
non registra lo storico e non notifica automaticamente le GUI aperte.
|
||||
|
||||
### Architettura scelta per il progetto, non ancora implementata/installata
|
||||
|
||||
Su delega del responsabile si sceglie tabella eventi persistente + elaboratore
|
||||
Python esterno, avviabile da console per debug o come servizio Windows senza GUI.
|
||||
La priorita' e' la verificabilita' delle regole, non il porting ad altri DB.
|
||||
Il responsabile conferma che il server online e' identico al locale; non e'
|
||||
stata effettuata una nuova ispezione remota. Broker e Agent restano alternative
|
||||
documentate, non dipendenze dell'esecutore iniziale.
|
||||
|
||||
Le regole saranno separabili da SQL e testabili con dati fittizi. L'esecutore
|
||||
SQL resta responsabile di letture protette, vincoli, transazione del movimento,
|
||||
storico e conferma evento atomici. Simulare le regole senza DB non sostituisce
|
||||
i test integrati di trigger, rollback e concorrenza. Console e servizio useranno
|
||||
lo stesso elaboratore. L'allegato di revisione, sezione 8, descrive la scelta.
|
||||
|
||||
Il responsabile ha dichiarato disponibile l'introduzione di un trigger su
|
||||
EXTUCLOG. Il flusso previsto e':
|
||||
|
||||
1. SAM modifica EXTUC e il trigger registra il cambiamento in EXTUCLOG.
|
||||
2. Un trigger leggero su EXTUCLOG accoda un evento persistente da elaborare.
|
||||
3. Un servizio WMS, indipendente dalle GUI, elabora gli eventi e applica la
|
||||
transizione appropriata in modo atomico.
|
||||
4. Le GUI rileggono il risultato e mostrano anche eventuali errori/ritardi.
|
||||
|
||||
Il servizio parte indipendentemente dalle GUI e legge solo eventi pendenti
|
||||
indicizzati, con intervallo configurabile (due secondi come proposta da misurare).
|
||||
Il trigger non lancia il processo e non esegue tutta la movimentazione. Dettagli
|
||||
di coda, ordine, permessi, installazione e recupero sono ancora da progettare.
|
||||
|
||||
La nascita aperta deve essere catturata separatamente dall'evento S/N:
|
||||
l'evento di nascita con quattro NULL non va scambiato per riapertura.
|
||||
Definire come conservare lo stato all'inserimento per gestire una chiusura
|
||||
immediata senza perdere il primo passaggio.
|
||||
|
||||
Il trigger deve restare breve: anche il solo accodamento partecipa alla
|
||||
transazione ERP e un suo errore puo' farla fallire. Verificare permessi,
|
||||
trigger annidati, inserimenti multipli e copertura dei passaggi NULL.
|
||||
Nessuna correzione del trigger esistente e' autorizzata implicitamente.
|
||||
|
||||
### Requisiti proposti per automatico e manuale
|
||||
|
||||
- Entrambi invocano le stesse regole di transizione; non due implementazioni divergenti.
|
||||
- Un evento deve essere applicato una volta dal punto di vista degli effetti,
|
||||
anche se consegnato/riprovato piu' volte. Il doppio clic non duplica movimenti.
|
||||
- Elaborare in ordine per UDC e conservare gli eventi intermedi, anche S -> N -> S.
|
||||
Non basarsi soltanto sull'ultimo flag o su un cursore temporale che possa
|
||||
saltare transazioni concorrenti non ancora confermate.
|
||||
- Prima di un comando manuale coordinare gli eventi pendenti e rileggere lo
|
||||
stato sotto protezione transazionale. Non applicare un evento vecchio dopo
|
||||
un movimento manuale piu' recente, annullandolo.
|
||||
- Controllo, rimozione origine, assegnazione destinazione e storico devono
|
||||
riuscire insieme oppure essere annullati insieme.
|
||||
- Distinguere evento gia' elaborato, destinazione gia' raggiunta, origine
|
||||
inattesa ed errore: non trattarli tutti come nuovi trasferimenti.
|
||||
- Registrare causa automatica/manuale, evento sorgente, posizione precedente/
|
||||
successiva, data evento, data esecuzione e autore noto. HOSTNAME non e'
|
||||
automaticamente l'identita' dell'operatore SAM; non attribuire utenti inventati.
|
||||
- Il servizio deve riprendere dopo un arresto senza perdere eventi, con log
|
||||
e riconciliazione controllata. Frequenza di lettura e latenza ammissibile da concordare.
|
||||
|
||||
## 11. Nascita delle UDC: decisione precedente confermata
|
||||
|
||||
**Nessuna nuova colonna in EXTUC o EXTUCLOG.** Si prevede un nuovo trigger
|
||||
**AFTER INSERT** su `SAMA1.sam.EXTUC`, distinto dal trigger di aggiornamento.
|
||||
Per ogni riga inserita scrivera' in `sam.EXTUCLOG`:
|
||||
|
||||
| Campo | Contenuto dell'evento di nascita |
|
||||
|---|---|
|
||||
| CODICE | Codice UDC inserito |
|
||||
| DIMENSIONE | Dimensione UDC inserita |
|
||||
| PRE_CHIUSA | NULL |
|
||||
| POST_CHIUSA | NULL |
|
||||
| STAMPARE | NULL |
|
||||
| RILASCIATA | NULL |
|
||||
| HOSTNAME | Postazione che esegue l'inserimento |
|
||||
| AGGIORNAMENTO | Data e ora server dell'inserimento |
|
||||
|
||||
I quattro NULL sono il marcatore concordato dell'evento. Prima dell'attivazione
|
||||
verificare eventuali righe pregresse indistinguibili e l'eventuale cancellazione/
|
||||
reinserimento dello stesso codice da parte di SAM.
|
||||
|
||||
Il trigger deve gestire inserimenti multipli con un'operazione su `inserted`,
|
||||
senza chiamate WMS o servizi esterni. Un errore del trigger puo' far fallire
|
||||
l'inserimento ERP: testare anche con l'utenza SAM e predisporre installazione
|
||||
e rollback senza cancellare il log. Il trigger corrente di chiusura/riapertura
|
||||
non viene modificato da questa decisione.
|
||||
|
||||
Per le UDC pregresse rimane l'anno ricavato dal codice. Nessuna data di nascita
|
||||
fittizia: la prima chiusura, il primo movimento o la data della migrazione non
|
||||
diventano date di creazione. Giorno e mese restano sconosciuti senza prove.
|
||||
|
||||
## 12. Decisioni ancora aperte
|
||||
|
||||
| Tema | Da definire prima del codice |
|
||||
|---|---|
|
||||
| Controllo preventivo in SAM | Eventuale impedimento della riapertura nell'ERP; il divieto di recupero nel WMS e' gia' definitivo |
|
||||
| Eventi anomali | N -> S fuori da Confezionamento/Validazione, NULL, nuova UDC gia' S, stato non verificabile |
|
||||
| Migrazione | Perimetro iniziale e trattamento delle UDC senza storia attendibile |
|
||||
| Servizio/eventi | Elaboratore esterno scelto; restano collocazione, latenza, chiave evento, ordine, installazione e concorrenza con i menu |
|
||||
| Validazione | Permessi e conferme UI; l'unica provenienza ammessa e' Confezionamento con N |
|
||||
| Barcode/picking | Prova del ciclo di riapertura/riallocazione e coordinamento transazionale con SAM. Blocco e percorso di recupero sono definiti |
|
||||
| UI | Colori di errore/attesa, ordine matrice e scorrimento |
|
||||
| Inventario | Inclusione dei gruppi e storico delle transizioni senza duplicazioni |
|
||||
| Contenuto dopo rivalidazione | Bag/quantita' possono cambiare: verificare fonti storiche SAM, tracciatura necessaria e limiti del pregresso |
|
||||
| Picking dopo variazione del contenuto | Verificare la coerenza con lotti/quantita' del documento SAM senza modificarlo implicitamente |
|
||||
| Legacy | Codici virtuali e significato dei riferimenti area 1 / I... |
|
||||
|
||||
I movimenti non definiti non vanno abilitati per analogia. Questi punti non
|
||||
rimettono in discussione la chiusura in Validazione: porta in Accettazione,
|
||||
come confermato.
|
||||
|
||||
## 13. Casi minimi di collaudo
|
||||
|
||||
| Caso | Risultato atteso |
|
||||
|---|---|
|
||||
| Nascita UDC aperta | Ingresso automatico in Confezionamento |
|
||||
| Chiusura in Confezionamento | Trasferimento automatico in Accettazione |
|
||||
| Riapertura in Accettazione | Trasferimento automatico in Confezionamento |
|
||||
| Riapertura in cella fisica | Confezionamento, vecchia associazione rimossa, nessun ritorno automatico in cella |
|
||||
| Riapertura in Pavimento | Confezionamento, non permanenza verde |
|
||||
| Carico desktop da Confezionamento in Validazione con N | Consentito, unica posizione |
|
||||
| Carico diretto in Validazione da altra origine | Bloccato, nessun trasferimento implicito attraverso Confezionamento |
|
||||
| Carico desktop in Validazione con S | Rifiutato, nessun movimento causato dal tentativo |
|
||||
| Chiusura in Validazione, anche accidentale | Accettazione automaticamente |
|
||||
| Successiva riapertura da Accettazione | Confezionamento, non ritorno automatico in Validazione |
|
||||
| UDC N in Validazione, refresh o aggiornamento N -> N | Resta in Validazione, nessuna falsa riapertura |
|
||||
| UDC S allocata manualmente, refresh o S -> S | Resta nella cella, nessuna falsa chiusura |
|
||||
| Scarico manuale da Validazione con N | Confezionamento |
|
||||
| Scarico da Confezionamento | Disabilitato |
|
||||
| Scarico da Pavimento con S | Accettazione |
|
||||
| Allocazione da Pavimento con S | Consentita verso cella valida/libera, senza un nuovo passaggio in Accettazione |
|
||||
| Allocazione diretta da Confezionamento o Validazione | Bloccata, nessun movimento verso cella o Pavimento |
|
||||
| CHIUSA=S dopo riapertura ma chiusura ancora da elaborare | Nessuna allocazione prima del passaggio effettivo in Accettazione |
|
||||
| Riapertura, chiusura e sincronizzazione completate | Allocazione manuale nuovamente consentita da Accettazione |
|
||||
| Spostamento ordinario di UDC chiusa fra celle | Rimane consentito con i controlli WMS, senza ripassare da Accettazione |
|
||||
| Riapertura con pallet rimasto fisicamente in cella | Vecchia associazione logica rimossa; nessun blocco fisico aggiuntivo, correzione operativa a cura del magazziniere |
|
||||
| UDC proposta dal barcode e poi riaperta prima del prelievo | Scarico bloccato, messaggio e posizione aggiornata, nessuna spedizione/completamento/salto automatico |
|
||||
| UDC riaperta durante il picking, poi chiusa e in Accettazione | Prelievo ancora bloccato finche' non viene riallocata in una cella WMS |
|
||||
| Stessa UDC dopo chiusura, Accettazione e nuova allocazione | Prelievo nuovamente consentito con tutti i controlli e posizione riletta |
|
||||
| UDC aperta successivamente caricata in Validazione | Spedizione bloccata, il messaggio riporta Validazione e non una posizione obsoleta |
|
||||
| UDC ridotta da 100 a 80 pezzi dopo la data inventario | Alla data precedente risultano 100 se la storia lo documenta; altrimenti limite esplicito, non 80 retroattivamente |
|
||||
| Bag trasferita fra UDC dopo riapertura | Ricostruzione dell'associazione alla data, senza doppio conteggio |
|
||||
| Manuale e automatismo richiedono lo stesso passaggio | Un solo effetto e un solo movimento logico |
|
||||
| Manuale su UDC con eventi arretrati | Coordinamento prima del comando, nessun evento vecchio che annulla il nuovo movimento |
|
||||
| Sequenza rapida S -> N -> S | Eventi conservati e applicati nel contesto corretto |
|
||||
| Servizio fermo e successivo riavvio | Ripresa degli eventi persistenti, nessuna duplicazione |
|
||||
| Evento ripetuto | Nessun doppio movimento |
|
||||
| UDC vecchia con assegnazione attiva | Resta visibile, non sparisce per il filtro annuale |
|
||||
| Evento esterno di riapertura per UDC spedita | Nessun rientro, stato logistico Spedita conservato, incoerenza tracciata e segnalata |
|
||||
| Tentativo manuale di recupero UDC spedita | Bloccato da desktop e barcode; nessuna nuova posizione o movimento di rientro |
|
||||
| Spedizione dichiarata errata dall'operatore | Nessun recupero applicativo; verifica e correzione SQL manuale separata |
|
||||
| Guasto durante movimento | Nessun trasferimento parziale; log e stato evento verificabili |
|
||||
| Area vuota | Carico accessibile sullo sfondo |
|
||||
| UDC multi-lotto | Un pulsante UDC e nessun doppio conteggio |
|
||||
| UDC pregressa senza data precisa | Nessuna data di nascita inventata |
|
||||
| Trigger di nascita | Una riga per inserimento, quattro NULL, gestione multi-riga |
|
||||
|
||||
## 14. Ambiente di lavoro e punto di ritorno
|
||||
|
||||
- L'ambiente stabile resta sul ramo `main` in `C:\devel\python\ware_house`,
|
||||
collegato a Mediseawall/SAMA1. Non viene modificato dal nuovo sviluppo.
|
||||
- Freeze pubblicato su Gitea: **`monolista_1.0`**.
|
||||
- Commit congelato: `9d87b07648fdb4a6efc38073fe0ad787b546faff`.
|
||||
- Si riprende il ramo `xwms` nel clone `C:\devel\Xwms`, collegato soltanto a
|
||||
Xwmsdb/SAMA1_Xwmstest. La precedente scelta di continuare su main e' superata.
|
||||
- Nuove strutture/procedure WMS esclusivamente in Xwmsdb. Nessuna modifica di
|
||||
trigger su SAMA1 originale: le prove avvengono nella copia SAMA1_Xwmstest.
|
||||
- Il tag conserva i sorgenti versionati, non il DB. Le future modifiche SQL
|
||||
richiederanno backup e script specifici di ritorno.
|
||||
|
||||
Questa revisione non implementa i nuovi stati, le quattro zone o il trigger.
|
||||
|
||||
## 15. Rilevazioni precedenti: fotografia, non conteggi correnti certificati
|
||||
|
||||
Nella fotografia locale interrogata il 23 ottobre 2026 risultavano:
|
||||
|
||||
- 21 UDC aperte con prefisso 5 e 40 con prefisso 6: **61** complessive, prima
|
||||
dell'esclusione di eventuali posizioni WMS. Non e' il totale gia' validato
|
||||
del futuro scaffale Confezionamento.
|
||||
- 2.534 codici distinti di `sam.EXTUC_POST` con primo carattere non numerico,
|
||||
tutti con prefisso `I`, ad esempio `I55000`. Si tratta di CODICE, non di POSTAZIONE.
|
||||
|
||||
Questi dati non provano l'appartenenza a Validazione o ad area 1 e non autorizzano
|
||||
riclassificazioni. Devono essere interpretati con il responsabile e non
|
||||
rappresentano necessariamente il DB online o la situazione fisica attuale.
|
||||
133
XWMS_AMBIENTE_LOCALE.md
Normal file
133
XWMS_AMBIENTE_LOCALE.md
Normal file
@@ -0,0 +1,133 @@
|
||||
# XWMS: ambiente locale isolato
|
||||
|
||||
Data: 29 ottobre 2026. Preparazione dello sviluppo, non rilascio in produzione.
|
||||
|
||||
## Separazione obbligatoria
|
||||
|
||||
| Ambiente | Codice/ramo | WMS | ERP |
|
||||
|---|---|---|---|
|
||||
| Monolista stabile | C:\devel\python\ware_house / main | Mediseawall | SAMA1 |
|
||||
| Sviluppo locale | C:\devel\Xwms / xwms | Xwmsdb | SAMA1_Xwmstest |
|
||||
|
||||
Il clone Git xwms esisteva gia': riutilizzato senza cancellare lavori pregressi.
|
||||
Baseline monolista: commit `9d87b07648fdb4a6efc38073fe0ad787b546faff`, tag remoto
|
||||
`monolista_1.0`. Il commit di avvio xwms `a874d09` aggiungeva documentazione,
|
||||
non una nuova versione delle procedure di movimentazione.
|
||||
|
||||
Tutte le nuove tabelle, viste, procedure e la coda WMS devono stare in **Xwmsdb**.
|
||||
Gli interventi di cattura SAM saranno provati solo in **SAMA1_Xwmstest**.
|
||||
Non applicare patch XWMS a Mediseawall/SAMA1. Gli stati futuri, il servizio e i
|
||||
nuovi trigger di nascita/accodamento NON fanno parte di questa preparazione.
|
||||
|
||||
## Backup e copie
|
||||
|
||||
Script amministrativo locale: `tools/prepare_local_clones.py`.
|
||||
Usa il collegamento amministrativo gia' presente nella configurazione stabile,
|
||||
senza cambiarla o copiarne le credenziali nella configurazione XWMS.
|
||||
|
||||
- Backup SQL COPY_ONLY compressi con CHECKSUM, verificati con RESTORE VERIFYONLY.
|
||||
- Directory: `D:\db\XwmsTest\baseline_20261029`.
|
||||
- File: `Mediseawall_copy_only.bak` e `SAMA1_copy_only.bak`.
|
||||
- File ripristinati sotto `D:\db\XwmsTest`, nomi distinti dagli originali.
|
||||
- Nessun WITH REPLACE, nessuna sovrascrittura di database/file esistenti.
|
||||
- I backup sono sequenziali, non una fotografia distribuita atomica. Durante la
|
||||
preparazione non risultavano sessioni applicative nei sorgenti; per futuri
|
||||
reset coordinati chiudere applicazioni e impedire nuove operazioni.
|
||||
- Le definizioni e i conteggi per tabella vengono registrati in `local_setup/`.
|
||||
Il confronto dei conteggi non equivale a un confronto di ogni valore di riga.
|
||||
|
||||
Backup/restore registra normale cronologia amministrativa in SQL Server; non
|
||||
introduce modifiche ai dati o agli oggetti applicativi dei database sorgenti.
|
||||
I backup COPY_ONLY non sostituiscono un piano di backup di produzione.
|
||||
|
||||
## Isolamento dei collegamenti
|
||||
|
||||
`tools/isolate_local_clones.py` riscrive nelle copie i riferimenti qualificati
|
||||
Mediseawall -> Xwmsdb e SAMA1 -> SAMA1_Xwmstest. Conserva le definizioni precedenti
|
||||
in `local_setup/`, esclusa da Git. Le impostazioni TRUSTWORTHY, DB_CHAINING e
|
||||
Service Broker restano disabilitate nelle copie.
|
||||
|
||||
Oggetti legacy fuori perimetro vengono neutralizzati solo nei cloni:
|
||||
|
||||
- Xwmsdb: `dbo.vPreparaPackingListOld`, `dbo.vXTracciaOld`, riferite a Medisystems.
|
||||
- SAMA1_Xwmstest: `dbo.ab_viewExport_Sommatorie_2019`,
|
||||
`dbo.ViewOrdinidiProduzioneMultiLottoElenco`, riferite a SeawallMedisystem.
|
||||
- SAMA1_Xwmstest: `dbo.send_email_on_error` e `dbo.USP_IMPORT_TRACE_FILE`, che
|
||||
inviavano email o eseguivano operazioni su file esterni.
|
||||
|
||||
Le viste mantengono lo schema delle colonne ma non leggono database esterni e
|
||||
sono negate all'utenza applicativa. Le due procedure rifiutano l'esecuzione.
|
||||
Non vengono attivati o copiati job Agent. Le eventuali integrazioni ERP esterne
|
||||
non fanno parte dell'ambiente di test.
|
||||
|
||||
Anche i riferimenti nei sorgenti Python e nel batch inventario sono stati
|
||||
adattati. Le patch SQL ereditate sono destinate a Xwmsdb, ma NON sono state
|
||||
rilanciate: il restore contiene gia' la struttura del database locale attuale.
|
||||
Le vecchie tabelle di backup DDL eventualmente presenti nel clone conservano
|
||||
testi storici: non usare vecchi rollback senza revisione dei riferimenti.
|
||||
Il file `baseline_Mediseawall.json` e' uno snapshot storico, non una configurazione.
|
||||
|
||||
## Collegamento e avvio
|
||||
|
||||
`db_connection.json` locale usa **xwms_local_app**, con password generata e
|
||||
non pubblicata. L'utenza non e' sysadmin e non ha un utente nei database originali.
|
||||
Ha lettura/scrittura/esecuzione nei due cloni, non privilegi di amministrazione
|
||||
server o db_owner. Per le future migrazioni occorre il contesto amministrativo
|
||||
esplicito; non aumentare i privilegi dell'applicazione per comodita'.
|
||||
|
||||
La configurazione applicativa rifiuta database diversi da Xwmsdb e server
|
||||
diversi da HOMESERVER. I titoli mostrano **[XWMS TEST]**. Il vecchio updater
|
||||
`aggiorna_monolista.bat` e' bloccato in questo clone per non riportarlo su main.
|
||||
|
||||
```bat
|
||||
cd /d C:\devel\Xwms
|
||||
python main.py
|
||||
rem In alternativa, terminalino:
|
||||
python barcode_client.py
|
||||
```
|
||||
|
||||
Non copiare qui il db_connection.json di produzione. Non avviare i test con
|
||||
credenziali sa: l'utenza limitata e' una seconda protezione oltre ai riferimenti.
|
||||
I launcher `.pyw` utilizzano lo stesso codice della rispettiva applicazione.
|
||||
|
||||
## Prossimi passi e ritorno indietro
|
||||
|
||||
Le specifiche correnti sono in `RIEPILOGO_STATI_UDC_2026-10-28.md`, revisione 12,
|
||||
con diagramma e analisi del servizio. `XWMS_AVVIO.md` e' una bozza storica superata.
|
||||
|
||||
Prima del nuovo servizio: definire schema eventi, codici virtuali, migrazione
|
||||
dei dati e storia del contenuto. Poi creare patch e revert sulle sole copie.
|
||||
Per tornare subito all'applicazione stabile basta chiudere XWMS e avviare la
|
||||
cartella ware_house: non richiede rollback SQL sugli originali, che restano separati.
|
||||
|
||||
Per azzerare i test nei cloni serve un ripristino amministrativo pianificato dei
|
||||
backup, seguito dall'isolamento dei riferimenti e dalla riprovisionazione
|
||||
dell'utenza; non eseguire alla cieca la creazione iniziale su cloni esistenti.
|
||||
Gli script forniti rifiutano sovrascritture e non cancellano database o file.
|
||||
Un reset futuro dovra' gestire esplicitamente utenti, login ed eventuali eventi.
|
||||
|
||||
Configurazioni, password, backup, log e report completi restano locali. Non
|
||||
pubblicarli su Gitea. Il ramo da sviluppare e' xwms; main e i tag stabili restano
|
||||
invariati. La pubblicazione del nuovo lavoro e' un passaggio Git separato.
|
||||
|
||||
## Esito delle verifiche del 29 ottobre 2026
|
||||
|
||||
- Entrambi i restore completati; backup verificati prima del ripristino.
|
||||
- 27 moduli SQL adattati/neutralizzati complessivamente nelle sole copie.
|
||||
- Nessuna dipendenza cross-database dichiarata nei moduli verso database esterni
|
||||
alla coppia di test. SQL dinamico e dati di configurazione richiedono sempre
|
||||
prudenza: l'utenza limitata e' la protezione aggiuntiva contro accessi accidentali.
|
||||
- Accesso negato all'utenza XWMS per Mediseawall, SAMA1 e SeawallMedisystem.
|
||||
- Lettura riuscita delle viste di giacenza, picking residuo, sequenza e storico,
|
||||
e della EXTUC della copia SAM.
|
||||
- 111 test automatici superati, inclusi quelli SQL attivati sulla configurazione
|
||||
del clone, con fixture temporanee. Nessun test saltato nell'ultima esecuzione.
|
||||
- Prova transazionale sulla EXTUC copiata: cambio CHIUSA e riga EXTUCLOG generata
|
||||
dal trigger legacy annullati insieme con rollback; nessuna variazione persistente.
|
||||
- Confronto dei sorgenti: definizioni dei moduli SQL, stati dei trigger e conteggi
|
||||
per tabella invariati in Mediseawall/SAMA1 rispetto alla rilevazione iniziale.
|
||||
- Nessuna modifica ai file versionati del repository stabile ware_house.
|
||||
|
||||
Non e' ancora un collaudo operativo completo della GUI e del terminalino con un
|
||||
magazziniere, ne' una verifica dell'inventario storico dopo rivalidazione. Le nuove
|
||||
regole degli stati UDC e il servizio non sono ancora implementati.
|
||||
118
XWMS_AVVIO.md
Normal file
118
XWMS_AVVIO.md
Normal file
@@ -0,0 +1,118 @@
|
||||
# XWMS - avvio del ramo di sviluppo
|
||||
|
||||
> DOCUMENTO STORICO SUPERATO. Dal 29 ottobre 2026 seguire
|
||||
> [Ambiente locale XWMS](XWMS_AMBIENTE_LOCALE.md) e
|
||||
> [Specifiche aggiornate](RIEPILOGO_STATI_UDC_2026-10-28.md).
|
||||
> Le decisioni sotto sono la bozza del 23 ottobre, non le regole da implementare.
|
||||
> In particolare la permanenza verde alla riapertura, la definizione di Pavimento
|
||||
> e il divieto di dedurre l'anno dal codice sono stati successivamente sostituiti.
|
||||
|
||||
Data: 23 ottobre 2026.
|
||||
|
||||
## Baseline e separazione degli ambienti
|
||||
|
||||
- Repository Gitea: https://gitea.alessandrobonvicini.it/administrator/ware_house
|
||||
- Ramo produzione monolista: `main`.
|
||||
- Tag di congelamento: `warehouse-monolista-freeze-2026-10-23`.
|
||||
- Commit congelato: `9d87b07648fdb4a6efc38073fe0ad787b546faff`.
|
||||
- Cartella Warehouse esistente: `C:\devel\python\ware_house`, lasciata su `main`.
|
||||
- Nuovo clone indipendente: `C:\devel\Xwms`, ramo `xwms`.
|
||||
|
||||
Il nuovo clone usa lo stesso repository remoto, non un secondo repository Gitea.
|
||||
Questa preparazione non implementa ancora i nuovi stati e non cambia movimenti,
|
||||
query, stored procedure, GUI o versione applicativa della baseline.
|
||||
Le modifiche future saranno sviluppate su `xwms`, non su `main`.
|
||||
|
||||
Il freeze riguarda i file versionati da Git. NON e' un backup del database,
|
||||
dei log, delle credenziali o degli altri file locali non versionati.
|
||||
`db_connection.json` non e' stato copiato: prima di avviare XWMS occorre
|
||||
configurare esplicitamente un database di prova. Due cartelle o due rami Git
|
||||
non isolano i dati se le applicazioni usano lo stesso database.
|
||||
Non eseguire patch XWMS sul database di produzione monolista durante lo sviluppo.
|
||||
|
||||
## Fonti e decisioni concordate
|
||||
|
||||
Fonte iniziale: `docs/analisi_stati_udc_23_20_2026.txt`, copia non modificata
|
||||
del documento fornito dall'utente (il nome originale contiene `20`, non `10`).
|
||||
Le precisazioni successive riportate qui prevalgono sulla bozza iniziale.
|
||||
|
||||
1. Lo stato corrente del confezionamento deriva da `SAMA1.sam.EXTUC.CHIUSA`.
|
||||
Le riaperture per controllo sono previste. Lo storico serve per ricostruzioni
|
||||
a data passata, non sostituisce lo stato corrente.
|
||||
2. Una UDC aperta ma presente in magazzino NON deve essere spostata: resta nella
|
||||
posizione corrente, sia in cella sia non allocata. Il pulsante che la
|
||||
rappresenta deve diventare VERDE per segnalare l'anomalia. La segnalazione
|
||||
non deve provocare movimenti o modifiche automatiche alla posizione.
|
||||
3. Il nome concordato e' **Pronta per trasferimento**, non **In transito**.
|
||||
Riguarda UDC chiuse e non ancora entrate nel WMS secondo le regole da affinare.
|
||||
La chiusura del confezionamento non certifica un trasporto gia' iniziato.
|
||||
4. **Non scaffalata** e' riservato alle UDC realmente disassociate da una cella
|
||||
dello scaffale. Non e' sinonimo di UDC mai registrata in WMS. Non introdurre
|
||||
l'ipotesi alternativa di ricezione diretta a pavimento senza disassociazione.
|
||||
5. Le UDC pronte per trasferimento devono essere proposte nella picking list
|
||||
con questo stato, senza essere nascoste o rappresentate come non scaffalate.
|
||||
6. Le nuove destinazioni virtuali richiedono controlli barcode specifici:
|
||||
non basta aggiungere nomi di celle. I controlli di occupazione delle celle
|
||||
fisiche non devono essere applicati indiscriminatamente alle zone virtuali.
|
||||
7. L'inventario deve mantenere distinti WMS e confezionamento, evitare doppi
|
||||
conteggi e rispettare la situazione alla data richiesta dall'operatore.
|
||||
8. Le UDC aperte da considerare sono quelle dell'anno corrente e precedente.
|
||||
Per gli altri stati il perimetro temporale va ancora precisato. Non dedurre
|
||||
l'anno dal codice UDC o dall'ultima riapertura senza una regola concordata.
|
||||
9. Alcune UDC aperte da riselezionare si trovano in **area 1**, da analizzare.
|
||||
`CHIUSA=N` da solo non distingue tale area dal confezionamento.
|
||||
10. L'Accettazione legacy e' un residuo incompleto, non il modello da mantenere.
|
||||
La nuova Accettazione avra' un codice distinto dalla spedizione; `8G.1.1`
|
||||
e' la proposta nel documento. `6G.1.1` e i codici di area `1x`/`1y` restano
|
||||
proposte da verificare prima di creare oggetti nel DB.
|
||||
|
||||
## Questioni ancora aperte prima dell'implementazione
|
||||
|
||||
- Fonte affidabile dell'anno UDC e trattamento di contenuti con lotti di anni
|
||||
diversi. Non escludere silenziosamente giacenze WMS reali per il solo anno.
|
||||
- Criteri per escludere UDC storiche, vuote o gia' spedite dall'elenco delle
|
||||
pronte per trasferimento; l'assenza di movimenti WMS da sola non basta.
|
||||
- Regole e fonte dati dell'area 1, distinta dal normale confezionamento.
|
||||
- Proposta e comportamento in picking delle UDC ancora APERTE (`CHIUSA=N`):
|
||||
nell'ultima precisazione "in confezionamento" e "pronte per trasferimento"
|
||||
sono accostate. E' confermata la proposta delle pronte; va distinta la regola
|
||||
per le aperte, senza presumere un blocco o un'autorizzazione allo scarico.
|
||||
- Memorizzazione dell'area di provenienza dopo la disassociazione: l'attuale
|
||||
cella comune 1000 non identifica da sola area 5 o 6. Posizionamento grafico
|
||||
sotto lo scaffale originario oppure in una fascia comune dell'area.
|
||||
- Migrazione delle UDC gia' in 1000: distinguere vere disassociazioni dagli
|
||||
ingressi tecnici intermedi creati dalla logica barcode esistente.
|
||||
- Nuovi stati esposti da viste di lettura oppure persistiti mediante eventi:
|
||||
non creare giacenze o date di ingresso fittizie prima della decisione.
|
||||
- Distinguere visivamente il verde di anomalia dagli altri colori gia' usati
|
||||
nel layout, senza cambiare il significato dell'occupazione della cella.
|
||||
- Confermare codici interni, barcode e nomi simbolici delle nuove zone,
|
||||
verificando compatibilita' con WMS e dati legacy.
|
||||
|
||||
## Evidenze della fotografia DB analizzata
|
||||
|
||||
Le seguenti evidenze sono osservazioni sulla copia di lavoro, non certificazioni
|
||||
della situazione fisica attuale in reparto:
|
||||
|
||||
- `EXTUC` appartiene allo schema `sam` e contiene anche `RILASCIATA`, da chiarire.
|
||||
- `sam.EXTUCLOG` conserva variazioni di `CHIUSA`, con precedente/successivo e data.
|
||||
- Le UDC `600466` e `604194` risultavano aperte e in celle fisiche: possibili
|
||||
riaperture per controllo nella fotografia; da evidenziare nelle quadrature,
|
||||
non da movimentare automaticamente.
|
||||
- La cella legacy 9000 (Accettazione) e 9999 (Spedizione) condividono il nome
|
||||
simbolico `7G.1.1`: non riutilizzare questa ambiguita'.
|
||||
|
||||
## Ripartenza e pubblicazione
|
||||
|
||||
Per lavorare sul nuovo progetto:
|
||||
|
||||
```bat
|
||||
cd /d C:\devel\Xwms
|
||||
git switch xwms
|
||||
git status
|
||||
```
|
||||
|
||||
I PC di reparto continuano ad aggiornarsi dal ramo `main` con la procedura
|
||||
monolista esistente. Il ramo `xwms` non va installato in produzione prima dei test.
|
||||
Il tag di freeze resta il riferimento per recuperare i sorgenti iniziali;
|
||||
un eventuale rollback SQL richiedera' script dedicati, non soltanto un checkout Git.
|
||||
157
aggiorna_monolista.bat
Normal file
157
aggiorna_monolista.bat
Normal file
@@ -0,0 +1,157 @@
|
||||
@echo off
|
||||
echo BLOCCATO: questo clone XWMS di test non deve aggiornarsi dal ramo main.
|
||||
echo Usare il ramo xwms e le istruzioni in XWMS_AMBIENTE_LOCALE.md.
|
||||
exit /b 1
|
||||
setlocal EnableExtensions DisableDelayedExpansion
|
||||
rem Run a temporary copy: Git may replace this file during the update.
|
||||
if /I "%~1"=="--worker" goto worker
|
||||
set "INSTALL_DIR=%~1"
|
||||
if not defined INSTALL_DIR set "INSTALL_DIR=C:\flywms"
|
||||
set "PYTHON_EXE=%~2"
|
||||
set "WORKER=%TEMP%\warehouse-update-%RANDOM%-%RANDOM%.bat"
|
||||
copy /Y "%~f0" "%WORKER%" >nul
|
||||
if errorlevel 1 exit /b 1
|
||||
call "%WORKER%" --worker "%INSTALL_DIR%" "%PYTHON_EXE%"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:worker
|
||||
set "INSTALL_DIR=%~2"
|
||||
set "PYTHON_EXE=%~3"
|
||||
set "RESULT=1"
|
||||
echo.
|
||||
echo === Aggiornamento Warehouse MONOLISTA - ramo main ===
|
||||
echo Cartella: "%INSTALL_DIR%"
|
||||
echo Chiudere Warehouse e il barcode, anche nelle altre sessioni del server.
|
||||
echo Non vengono eseguite patch SQL o cancellazioni di file locali.
|
||||
choice /C SN /N /M "Le applicazioni sono chiuse e vuoi continuare? [S/N]: "
|
||||
if errorlevel 2 goto cancelled
|
||||
if errorlevel 1 goto checks
|
||||
goto failed
|
||||
|
||||
:checks
|
||||
where git >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo ERRORE: Git non e' installato o non e' nel PATH.
|
||||
goto failed
|
||||
)
|
||||
cd /d "%INSTALL_DIR%"
|
||||
if errorlevel 1 goto failed
|
||||
if not exist ".git" (
|
||||
echo ERRORE: questa cartella non e' la radice di un clone Git.
|
||||
echo Lo script aggiorna installazioni esistenti, non cartelle copiate da ZIP.
|
||||
goto failed
|
||||
)
|
||||
git rev-parse --verify HEAD >nul 2>&1
|
||||
if errorlevel 1 goto failed
|
||||
set "REMOTE_URL="
|
||||
for /f "delims=" %%G in ('git remote get-url origin') do set "REMOTE_URL=%%G"
|
||||
if /I not "%REMOTE_URL%"=="https://gitea.alessandrobonvicini.it/administrator/ware_house.git" (
|
||||
echo ERRORE: origin non corrisponde al repository Warehouse previsto.
|
||||
echo Verificare il clone prima di proseguire. Nessun URL viene modificato.
|
||||
goto failed
|
||||
)
|
||||
git status --porcelain --untracked-files=no >nul
|
||||
if errorlevel 1 goto failed
|
||||
set "DIRTY="
|
||||
for /f "delims=" %%G in ('git status --porcelain --untracked-files^=no') do set "DIRTY=1"
|
||||
if defined DIRTY (
|
||||
echo ERRORE: esistono modifiche locali a file tracciati.
|
||||
git status --short --untracked-files=no
|
||||
echo Nessun reset o stash automatico. Conservare e verificare le modifiche.
|
||||
goto failed
|
||||
)
|
||||
if not defined PYTHON_EXE if exist ".venv\Scripts\python.exe" set "PYTHON_EXE=%CD%\.venv\Scripts\python.exe"
|
||||
if not defined PYTHON_EXE set "PYTHON_EXE=python"
|
||||
"%PYTHON_EXE%" --version
|
||||
if errorlevel 1 (
|
||||
echo ERRORE: Python non disponibile. Indicare il percorso come secondo argomento.
|
||||
goto failed
|
||||
)
|
||||
"%PYTHON_EXE%" -m pip --version
|
||||
if errorlevel 1 goto failed
|
||||
|
||||
echo.
|
||||
echo Scaricamento di main da Gitea...
|
||||
rem Avoid repacking/deleting old pack indexes during deployment on Windows.
|
||||
rem These settings apply only to this command, not to the repository config.
|
||||
git -c maintenance.auto=false -c gc.auto=0 fetch origin refs/heads/main
|
||||
if errorlevel 1 (
|
||||
echo ERRORE: scaricamento fallito. Verificare rete, credenziali e accesso ai file .git.
|
||||
goto failed
|
||||
)
|
||||
set "TARGET="
|
||||
for /f %%G in ('git rev-parse FETCH_HEAD') do set "TARGET=%%G"
|
||||
if not defined TARGET goto failed
|
||||
set "DB_TRACKED="
|
||||
for /f "delims=" %%G in ('git ls-tree --name-only %TARGET% -- db_connection.json') do set "DB_TRACKED=1"
|
||||
if defined DB_TRACKED (
|
||||
echo ERRORE: il ramo remoto contiene db_connection.json. Aggiornamento bloccato per proteggerlo.
|
||||
goto failed
|
||||
)
|
||||
rem Refuse to silently replace a different development branch or local commits.
|
||||
git merge-base --is-ancestor HEAD %TARGET%
|
||||
if errorlevel 1 (
|
||||
echo ERRORE: la versione locale non e' un antenato del main remoto.
|
||||
echo Possibile ramo bilista o commit locali: occorre una verifica manuale.
|
||||
goto failed
|
||||
)
|
||||
git show-ref --verify --quiet refs/heads/main
|
||||
if errorlevel 1 goto backup
|
||||
git merge-base --is-ancestor main %TARGET%
|
||||
if errorlevel 1 (
|
||||
echo ERRORE: anche il main locale contiene commit non presenti sul remoto.
|
||||
goto failed
|
||||
)
|
||||
|
||||
:backup
|
||||
set "STAMP="
|
||||
for /f %%G in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMdd-HHmmss-fff"') do set "STAMP=%%G"
|
||||
if not defined STAMP goto failed
|
||||
set "BACKUP_REF=refs/warehouse-backups/pre-update-%STAMP%"
|
||||
git update-ref "%BACKUP_REF%" HEAD
|
||||
if errorlevel 1 goto failed
|
||||
echo.
|
||||
echo Riferimento di recupero: %BACKUP_REF%
|
||||
echo Per tornare ai sorgenti precedenti, con applicazioni chiuse:
|
||||
echo git switch --detach %BACKUP_REF%
|
||||
echo Il ripristino Git NON ripristina database o dipendenze Python.
|
||||
echo.
|
||||
git show-ref --verify --quiet refs/heads/main
|
||||
if errorlevel 1 (
|
||||
git switch -c main %TARGET%
|
||||
) else (
|
||||
git switch main
|
||||
)
|
||||
if errorlevel 1 goto failed
|
||||
git -c maintenance.auto=false -c gc.auto=0 merge --ff-only %TARGET%
|
||||
if errorlevel 1 goto failed
|
||||
|
||||
echo.
|
||||
echo Installazione dipendenze con "%PYTHON_EXE%"...
|
||||
"%PYTHON_EXE%" -m pip install -r requirements.txt
|
||||
if errorlevel 1 (
|
||||
echo ERRORE: file Git aggiornati, ma installazione dipendenze NON completata.
|
||||
echo Non riavviare l'applicazione finche' il problema pip non e' risolto.
|
||||
goto failed
|
||||
)
|
||||
echo.
|
||||
echo AGGIORNAMENTO COMPLETATO.
|
||||
git log -1 --format="Commit installato: %%h %%s"
|
||||
echo Ora puoi riaprire Warehouse e il barcode dai collegamenti abituali.
|
||||
echo Se il push dal PC di sviluppo non e' riuscito, il remoto puo' essere ancora vecchio.
|
||||
set "RESULT=0"
|
||||
goto finish
|
||||
|
||||
:cancelled
|
||||
echo Aggiornamento annullato.
|
||||
set "RESULT=2"
|
||||
goto finish
|
||||
|
||||
:failed
|
||||
echo.
|
||||
echo AGGIORNAMENTO NON COMPLETATO. Leggere l'errore riportato sopra.
|
||||
|
||||
:finish
|
||||
echo.
|
||||
pause
|
||||
exit /b %RESULT%
|
||||
821
analisi_bug_prenotazione_pickinglist.md
Normal file
821
analisi_bug_prenotazione_pickinglist.md
Normal file
@@ -0,0 +1,821 @@
|
||||
# Analisi bug prenotazione Picking List
|
||||
|
||||
## Obiettivo
|
||||
|
||||
Documentare in modo chiaro:
|
||||
|
||||
- il comportamento attuale della prenotazione picking list
|
||||
- il bug osservato
|
||||
- la causa tecnica del bug
|
||||
- la correzione proposta lato stored procedure
|
||||
|
||||
Il documento serve come base di riferimento prima di modificare la logica SQL legacy.
|
||||
|
||||
---
|
||||
|
||||
## Contesto operativo
|
||||
|
||||
L'operatore, dal backoffice:
|
||||
|
||||
1. seleziona una picking list
|
||||
2. preme `Prenota`
|
||||
3. si aspetta che **una sola** picking list risulti prenotata
|
||||
|
||||
Il comportamento atteso del sistema è:
|
||||
|
||||
- una sola picking list prenotata alla volta
|
||||
- quella picking list diventa la coda `F1` sul barcode
|
||||
- le altre picking list restano non prenotate e alimentano la coda `F2`
|
||||
|
||||
---
|
||||
|
||||
## Comportamento attuale
|
||||
|
||||
Il comportamento effettivamente osservato è questo:
|
||||
|
||||
1. l'operatore seleziona una sola picking list
|
||||
2. preme `Prenota`
|
||||
3. risultano prenotate **due** picking list, non una sola
|
||||
|
||||
Questo comportamento è stato osservato:
|
||||
|
||||
- nell'applicazione Python
|
||||
- anche nell'applicazione C#
|
||||
|
||||
Quindi il bug **non nasce nella UI Python**.
|
||||
|
||||
---
|
||||
|
||||
## Verifica di aderenza Python / C#
|
||||
|
||||
### Lato Python
|
||||
|
||||
La finestra [gestione_pickinglist.py](C:/devel/python/ware_house/gestione_pickinglist.py) chiama:
|
||||
|
||||
- [sp_xExePackingListPallet_async](C:/devel/python/ware_house/prenota_sprenota_sql.py)
|
||||
|
||||
che esegue direttamente la stored procedure SQL legacy:
|
||||
|
||||
- `dbo.sp_xExePackingListPallet`
|
||||
|
||||
### Lato C#
|
||||
|
||||
La finestra legacy [FRMagViewLayout.cs](C:/devel/seawall_decompiled/decompiled/SWMagViewLayout/FRMagViewLayout.cs) chiama anch'essa:
|
||||
|
||||
- `dbo.sp_xExePackingListPallet`
|
||||
|
||||
### Conclusione
|
||||
|
||||
Python e C# usano la **stessa** logica DB per la prenotazione.
|
||||
|
||||
Se il bug compare in entrambi, il problema è nella stored procedure o nel modello dati su cui essa si basa.
|
||||
|
||||
---
|
||||
|
||||
## Stato attuale della griglia picking list
|
||||
|
||||
La query summary della picking list in [gestione_pickinglist.py](C:/devel/python/ware_house/gestione_pickinglist.py) aggrega così:
|
||||
|
||||
- `GROUP BY Documento, CodNazione, NAZIONE, Stato`
|
||||
- `MAX(IDStato) AS IDStato`
|
||||
|
||||
Questo significa:
|
||||
|
||||
- se anche **una sola riga** del documento ha `IDStato = 1`
|
||||
- l'intera picking list appare come prenotata
|
||||
|
||||
Questa scelta è coerente con l'idea UI di “documento prenotato”, ma diventa problematica se la stored non lavora in modo esclusivo per documento.
|
||||
|
||||
---
|
||||
|
||||
## Stored procedure attuale
|
||||
|
||||
Stored coinvolta:
|
||||
|
||||
- [sp_xExePackingListPallet](C:/devel/python/ware_house/script.sql)
|
||||
|
||||
### Logica attuale
|
||||
|
||||
La stored:
|
||||
|
||||
1. legge da `XMag_ViewPackingList`
|
||||
2. estrae le `Cella` associate al `Documento`
|
||||
3. per ogni cella:
|
||||
- se `IDStato = 0`, la mette a `1`
|
||||
- altrimenti la rimette a `0`
|
||||
|
||||
Quindi la stored non prenota davvero una picking list come entità esclusiva.
|
||||
|
||||
Prenota invece:
|
||||
|
||||
- **le celle** toccate dal documento selezionato
|
||||
|
||||
### Conseguenza tecnica
|
||||
|
||||
Se due documenti condividono almeno una stessa cella:
|
||||
|
||||
- la prenotazione della prima list mette `IDStato = 1` sulla cella condivisa
|
||||
- anche la seconda list, leggendo quella stessa cella, eredita `IDStato = 1`
|
||||
- la griglia alta, usando `MAX(IDStato)`, la mostra come prenotata
|
||||
|
||||
---
|
||||
|
||||
## Evidenze raccolte
|
||||
|
||||
### Query 1 - celle del sottoinsieme di documenti osservati
|
||||
|
||||
Scopo:
|
||||
|
||||
- verificare quali celle sono coinvolte dai documenti sospetti
|
||||
- controllare rapidamente se esistono sovrapposizioni evidenti
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
Documento,
|
||||
Cella,
|
||||
COUNT(*) AS Righe
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE Documento IN (<doc1>, <doc2>)
|
||||
GROUP BY Documento, Cella
|
||||
ORDER BY Cella, Documento;
|
||||
```
|
||||
|
||||
Uso nel caso analizzato:
|
||||
|
||||
- ha permesso di vedere, per esempio, che documenti diversi insistono sulla stessa cella `8057`
|
||||
|
||||
### Query di controllo celle condivise
|
||||
|
||||
Risultato:
|
||||
|
||||
```text
|
||||
1000 2
|
||||
8057 2
|
||||
```
|
||||
|
||||
Interpretazione:
|
||||
|
||||
- la cella `1000` è condivisa da 2 documenti
|
||||
- la cella `8057` è condivisa da 2 documenti
|
||||
|
||||
### Query di dettaglio documenti / celle condivise
|
||||
|
||||
Risultato:
|
||||
|
||||
```text
|
||||
135 1000 16 16
|
||||
137 1000 2 1
|
||||
133 8057 1 1
|
||||
135 8057 1 1
|
||||
```
|
||||
|
||||
Interpretazione:
|
||||
|
||||
- documento `135` e documento `137` condividono la cella `1000`
|
||||
- documento `133` e documento `135` condividono la cella `8057`
|
||||
|
||||
Questa è una prova concreta del fatto che la prenotazione a livello cella può propagarsi a più documenti.
|
||||
|
||||
### Query 2 - ricerca globale delle celle condivise
|
||||
|
||||
Scopo:
|
||||
|
||||
- trovare quali celle sono condivise da più documenti
|
||||
- identificare i punti strutturalmente più critici del dataset
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
Cella,
|
||||
COUNT(DISTINCT Documento) AS NumDocumenti
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
GROUP BY Cella
|
||||
HAVING COUNT(DISTINCT Documento) > 1
|
||||
ORDER BY NumDocumenti DESC, Cella;
|
||||
```
|
||||
|
||||
Risultato osservato:
|
||||
|
||||
```text
|
||||
1000 2
|
||||
8057 2
|
||||
```
|
||||
|
||||
Interpretazione:
|
||||
|
||||
- la cella `1000` è condivisa da 2 documenti
|
||||
- la cella `8057` è condivisa da 2 documenti
|
||||
|
||||
### Query 3 - dettaglio completo delle collisioni sulle celle condivise
|
||||
|
||||
Scopo:
|
||||
|
||||
- capire esattamente quali documenti condividono le celle critiche
|
||||
- vedere quante righe e quanti pallet distinti insistono su quelle celle
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
Documento,
|
||||
Cella,
|
||||
COUNT(*) AS Righe,
|
||||
COUNT(DISTINCT Pallet) AS Pallet
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE Cella IN (1000, 8057)
|
||||
GROUP BY Documento, Cella
|
||||
ORDER BY Cella, Documento;
|
||||
```
|
||||
|
||||
Risultato osservato:
|
||||
|
||||
```text
|
||||
135 1000 16 16
|
||||
137 1000 2 1
|
||||
133 8057 1 1
|
||||
135 8057 1 1
|
||||
```
|
||||
|
||||
Interpretazione:
|
||||
|
||||
- documento `135` e documento `137` condividono la cella `1000`
|
||||
- documento `133` e documento `135` condividono la cella `8057`
|
||||
|
||||
Queste tre query, lette insieme, sono quelle che hanno permesso di evidenziare in modo oggettivo il bug.
|
||||
|
||||
---
|
||||
|
||||
## Ruolo delle celle convenzionali
|
||||
|
||||
Dalle verifiche fatte con il magazziniere:
|
||||
|
||||
- `1000` = `5E1.1`
|
||||
- `9999` = `7G.1.1`
|
||||
|
||||
La cella `1000` è una locazione convenzionale delle UDC non scaffalate.
|
||||
|
||||
Questo rende il problema ancora più frequente, perché:
|
||||
|
||||
- più documenti possono convivere sulla stessa locazione convenzionale `1000`
|
||||
- quindi la prenotazione per cella tende naturalmente a contaminare più picking list
|
||||
|
||||
---
|
||||
|
||||
## Diagnosi finale del bug
|
||||
|
||||
Il bug è dovuto alla combinazione di due scelte:
|
||||
|
||||
1. la stored `sp_xExePackingListPallet` lavora a livello **cella**
|
||||
2. la UI mostra la prenotazione a livello **documento**
|
||||
|
||||
Quando esistono celle condivise tra documenti:
|
||||
|
||||
- la prenotazione di un documento produce `IDStato = 1` anche su righe lette da altri documenti
|
||||
- quindi più picking list risultano prenotate
|
||||
|
||||
### Forma sintetica del bug
|
||||
|
||||
> Il sistema non sta prenotando una singola picking list in modo esclusivo.
|
||||
> Sta prenotando le celle associate a quel documento, e la UI deduce da lì lo stato della picking list.
|
||||
|
||||
---
|
||||
|
||||
# Correzione proposta
|
||||
|
||||
## Obiettivo della correzione
|
||||
|
||||
Allineare il comportamento del sistema alla regola di business desiderata:
|
||||
|
||||
> una sola picking list prenotata per volta
|
||||
|
||||
Questo implica che il comando `Prenota` deve produrre uno stato esclusivo a livello documento.
|
||||
|
||||
---
|
||||
|
||||
## Principio della nuova logica
|
||||
|
||||
La stored non deve più comportarsi come un semplice toggle delle celle del documento selezionato.
|
||||
|
||||
Deve invece:
|
||||
|
||||
1. rimuovere la prenotazione da tutte le altre picking list
|
||||
2. applicare la prenotazione solo al documento selezionato
|
||||
|
||||
In altre parole:
|
||||
|
||||
- **prima** si resetta lo stato prenotato degli altri documenti
|
||||
- **poi** si prenota il documento scelto
|
||||
|
||||
---
|
||||
|
||||
## Comportamento desiderato dopo la correzione
|
||||
|
||||
### Caso `Prenota`
|
||||
|
||||
Quando l'operatore prenota il documento `D`:
|
||||
|
||||
1. se il documento `D` è già prenotato, non succede nulla
|
||||
2. se il documento `D` non è prenotato:
|
||||
- tutte le celle prenotate appartenenti ad altri documenti vengono riportate a `IDStato = 0`
|
||||
- tutte le celle del documento `D` vengono portate a `IDStato = 1`
|
||||
- il log della picking list resta aggiornato come oggi
|
||||
|
||||
Effetto atteso:
|
||||
|
||||
- solo il documento `D` risulta prenotato nella griglia
|
||||
- solo il documento `D` alimenta la coda `F1`
|
||||
- tutte le altre picking list alimentano `F2`
|
||||
- premere `Prenota` più volte sulla stessa picking list già prenotata non deve produrre toggle né effetti collaterali
|
||||
|
||||
### Caso `S-prenota`
|
||||
|
||||
Quando l'operatore s-prenota il documento `D`:
|
||||
|
||||
1. se il documento `D` non è prenotato, non succede nulla
|
||||
2. se il documento `D` è prenotato:
|
||||
- le celle del documento `D` vengono riportate a `IDStato = 0`
|
||||
- nessun altro documento viene automaticamente prenotato
|
||||
|
||||
Effetto atteso:
|
||||
|
||||
- nessuna picking list resta prenotata, salvo una nuova prenotazione esplicita
|
||||
- premere `S-prenota` più volte sulla stessa picking list già non prenotata non deve produrre toggle né effetti collaterali
|
||||
|
||||
---
|
||||
|
||||
## Strategia tecnica consigliata
|
||||
|
||||
### Approccio minimo e prudente
|
||||
|
||||
La correzione più sicura, restando vicini al legacy, è mantenere una stored unica ma con una semantica esplicita guidata da un parametro azione.
|
||||
|
||||
Proposta:
|
||||
|
||||
- stored unica con parametro `@Azione`
|
||||
- `P` = Prenota
|
||||
- `S` = S-prenota
|
||||
|
||||
Logica:
|
||||
|
||||
1. determinare se il documento selezionato è già prenotato o no
|
||||
2. se `@Azione = 'P'`
|
||||
- se il documento è già prenotato: non fare nulla
|
||||
- altrimenti:
|
||||
- azzerare `IDStato = 1` sulle celle coinvolte da altri documenti prenotati
|
||||
- impostare `IDStato = 1` sulle celle del documento selezionato
|
||||
3. se `@Azione = 'S'`
|
||||
- se il documento non è prenotato: non fare nulla
|
||||
- altrimenti:
|
||||
- riportare a `0` solo le celle del documento selezionato
|
||||
|
||||
Questa logica mantiene:
|
||||
|
||||
- la semantica esistente a livello cella
|
||||
- ma aggiunge l'esclusività a livello documento
|
||||
- e mantiene pulita la semantica distinta dei pulsanti `Prenota` e `S-prenota`
|
||||
|
||||
### Vantaggi
|
||||
|
||||
- modifica contenuta
|
||||
- comportamento coerente con l'operatività reale
|
||||
- nessuna necessità immediata di cambiare UI Python o C#
|
||||
- comportamento idempotente dei pulsanti
|
||||
|
||||
---
|
||||
|
||||
## Rischi da considerare
|
||||
|
||||
### 1. Celle condivise tra documenti
|
||||
|
||||
La presenza di celle condivise resta un'anomalia logica del dominio.
|
||||
|
||||
Anche con la correzione proposta:
|
||||
|
||||
- se una cella appartiene contemporaneamente a più documenti nella vista
|
||||
- la semantica “quale documento possiede davvero la prenotazione della cella” resta concettualmente debole
|
||||
|
||||
Tuttavia la correzione proposta risolve il bug visibile di doppia picking list prenotata.
|
||||
|
||||
### 2. Effetti sul flusso barcode
|
||||
|
||||
Il barcode usa `IDStato = 1` per la coda `F1`.
|
||||
|
||||
Quindi la nuova esclusività deve essere verificata attentamente su:
|
||||
|
||||
- proposta UDC in `F1`
|
||||
- proposta UDC in `F2`
|
||||
- avanzamento dopo prelievo
|
||||
- ri-prenotazione automatica residua via `sp_ControllaPrenotazionePackingListPalletNew`
|
||||
|
||||
### 3. Interazione con `LogPackingList`
|
||||
|
||||
La stored attuale aggiorna il log del documento.
|
||||
|
||||
Questa parte va mantenuta, perché il barcode e la logica di ri-prenotazione residua si appoggiano su quel log.
|
||||
|
||||
---
|
||||
|
||||
## Criteri di accettazione della correzione
|
||||
|
||||
La correzione sarà considerata valida se, dopo `Prenota`:
|
||||
|
||||
1. una sola picking list risulta prenotata in griglia
|
||||
2. `F1` propone solo UDC del documento prenotato
|
||||
3. `F2` propone UDC delle altre picking list
|
||||
4. il problema di doppia prenotazione non si ripresenta più nemmeno in presenza di celle condivise come `1000` o `8057`
|
||||
|
||||
E dopo `S-prenota`:
|
||||
|
||||
1. il documento selezionato torna non prenotato
|
||||
2. `F1` non propone più quella picking list
|
||||
|
||||
---
|
||||
|
||||
## Decisione consigliata
|
||||
|
||||
La correzione lato stored procedure è consigliata e necessaria.
|
||||
|
||||
Motivo:
|
||||
|
||||
- il bug è reale
|
||||
- il bug è condiviso da Python e C#
|
||||
- il bug nasce dalla logica DB attuale
|
||||
- la prenotazione esclusiva è coerente con il modello operativo del magazzino
|
||||
|
||||
---
|
||||
|
||||
## Stored procedure proposta
|
||||
|
||||
Di seguito una proposta documentale di stored unica con parametro `P` / `S`.
|
||||
|
||||
```sql
|
||||
CREATE OR ALTER PROCEDURE [dbo].[sp_xExePackingListPallet]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@Azione char(1), -- 'P' = Prenota, 'S' = S-prenota
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50);
|
||||
DECLARE @DocumentoPrenotato bit = 0;
|
||||
DECLARE @Description varchar(255) = '';
|
||||
DECLARE @Message varchar(255) = '';
|
||||
DECLARE @IDResult int = 0;
|
||||
|
||||
SELECT @Nominativo = [Login]
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Azione NOT IN ('P', 'S')
|
||||
BEGIN
|
||||
SET @RC = -10;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF OBJECT_ID('tempdb..#TargetCelle') IS NOT NULL DROP TABLE #TargetCelle;
|
||||
CREATE TABLE #TargetCelle (
|
||||
IDCella int PRIMARY KEY
|
||||
);
|
||||
|
||||
INSERT INTO #TargetCelle (IDCella)
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE Documento = @Documento
|
||||
AND Cella IS NOT NULL;
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM #TargetCelle)
|
||||
BEGIN
|
||||
SET @RC = -20;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE Documento = @Documento
|
||||
AND ISNULL(IDStato, 0) = 1
|
||||
)
|
||||
BEGIN
|
||||
SET @DocumentoPrenotato = 1;
|
||||
END;
|
||||
|
||||
IF @Azione = 'P'
|
||||
BEGIN
|
||||
-- Gia' prenotata: no-op
|
||||
IF @DocumentoPrenotato = 1
|
||||
RETURN;
|
||||
|
||||
-- Azzera prenotazioni di altri documenti
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE c.ID IN (
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE ISNULL(IDStato, 0) = 1
|
||||
AND Documento <> @Documento
|
||||
AND Cella IS NOT NULL
|
||||
);
|
||||
|
||||
-- Prenota solo il documento target
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN #TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
SELECT TOP 1 @Description = NAZIONE
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE Documento = @Documento;
|
||||
|
||||
EXEC dbo.sp_LogPackingList
|
||||
@ID = 0,
|
||||
@Code = @Documento,
|
||||
@Description = @Description,
|
||||
@Message = @Message OUTPUT,
|
||||
@IDResult = @IDResult OUTPUT;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF @Azione = 'S'
|
||||
BEGIN
|
||||
-- Gia' non prenotata: no-op
|
||||
IF @DocumentoPrenotato = 0
|
||||
RETURN;
|
||||
|
||||
-- S-prenota solo il documento target
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN #TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
END;
|
||||
```
|
||||
|
||||
### Note sulla stored proposta
|
||||
|
||||
- Non esiste più il toggle implicito.
|
||||
- `Prenota` è idempotente:
|
||||
- se la list è già prenotata, non cambia nulla.
|
||||
- `S-prenota` è idempotente:
|
||||
- se la list è già non prenotata, non cambia nulla.
|
||||
- L'esclusività viene garantita solo nel ramo `P`.
|
||||
- La logica continua a usare `IDStato` sulle celle, così il barcode legacy può continuare a usare `F1` / `F2` con la semantica attuale.
|
||||
|
||||
---
|
||||
|
||||
## Prossimo passo
|
||||
|
||||
Dopo approvazione di questo documento:
|
||||
|
||||
1. modificare `sp_xExePackingListPallet` o introdurre una nuova versione compatibile
|
||||
2. testare il risultato con almeno 3 picking list attive
|
||||
3. verificare il comportamento sul backoffice
|
||||
4. verificare il comportamento sul barcode (`F1` / `F2`)
|
||||
|
||||
---
|
||||
|
||||
## Revisione dopo test reale su documenti 133 / 135 / 137
|
||||
|
||||
Dopo avere applicato la prima correzione proposta solo sulla stored, il bug **resta presente**:
|
||||
|
||||
- prenotando il documento `133`
|
||||
- la picking list `135` continua a risultare prenotata
|
||||
|
||||
Questo comportamento è coerente con le evidenze raccolte:
|
||||
|
||||
- `133` e `135` condividono la cella `8057`
|
||||
- `135` e `137` condividono la cella `1000`
|
||||
|
||||
### Conclusione aggiornata
|
||||
|
||||
La correzione che agisce **solo** su `Celle.IDStato` non è sufficiente.
|
||||
|
||||
Il motivo è strutturale:
|
||||
|
||||
1. la stored può anche rendere idempotente `Prenota` / `S-prenota`
|
||||
2. ma se la UI e il barcode continuano a dedurre lo stato della prenotazione da `Celle.IDStato`
|
||||
3. una cella condivisa continuerà a far risultare prenotati anche documenti diversi
|
||||
|
||||
Quindi il modello corretto deve spostare la **sorgente di verità** della prenotazione:
|
||||
|
||||
- **da:** stato della cella
|
||||
- **a:** documento prenotato attivo
|
||||
|
||||
### Nuova architettura proposta
|
||||
|
||||
La soluzione corretta è questa:
|
||||
|
||||
1. introdurre una piccola tabella di stato, ad esempio `dbo.PickingListReservation`
|
||||
2. salvare lì il **documento attualmente prenotato**
|
||||
3. fare in modo che `XMag_ViewPackingList.IDStato` non legga più la prenotazione da `Celle.IDStato`
|
||||
4. calcolare invece `IDStato` così:
|
||||
- `1` se `Documento = documento prenotato attivo`
|
||||
- `0` negli altri casi
|
||||
|
||||
In questo modo:
|
||||
|
||||
- il backoffice mostra prenotata una sola picking list
|
||||
- il barcode continua a usare `F1` = `IDStato 1` e `F2` = `IDStato 0`
|
||||
- le celle condivise `1000` / `8057` non contaminano più altri documenti
|
||||
|
||||
### Ruolo residuo di `Celle.IDStato`
|
||||
|
||||
`Celle.IDStato` può restare utile come supporto:
|
||||
|
||||
- per visualizzazioni legacy
|
||||
- per evidenziare le celle del documento attivo
|
||||
- per non rompere altre parti del sistema che si aspettano quel flag
|
||||
|
||||
Ma non deve più essere la **fonte primaria** della prenotazione documento.
|
||||
|
||||
### Stored definitiva da realizzare
|
||||
|
||||
La stored `sp_xExePackingListPallet` deve quindi:
|
||||
|
||||
1. mantenere il parametro `@Azione = 'P' | 'S'`
|
||||
2. aggiornare la tabella `PickingListReservation`
|
||||
3. opzionalmente riallineare anche `Celle.IDStato`
|
||||
4. mantenere il log in `LogPackingList`
|
||||
|
||||
Semantica definitiva:
|
||||
|
||||
- `Prenota`
|
||||
- se il documento è già quello attivo: nessun effetto
|
||||
- altrimenti:
|
||||
- il documento diventa l’unico prenotato attivo
|
||||
- tutte le altre picking list risultano non prenotate
|
||||
|
||||
- `S-prenota`
|
||||
- se il documento non è quello attivo: nessun effetto
|
||||
- se il documento è quello attivo:
|
||||
- la prenotazione viene rimossa
|
||||
- nessun altro documento viene acceso automaticamente
|
||||
|
||||
### Nota importante
|
||||
|
||||
Questa revisione **supera** la proposta precedente basata soltanto sul reset/set di `Celle.IDStato`.
|
||||
|
||||
La patch SQL definitiva deve quindi includere:
|
||||
|
||||
1. creazione della tabella `PickingListReservation`
|
||||
2. `CREATE OR ALTER` della stored `sp_xExePackingListPallet`
|
||||
3. `CREATE OR ALTER` della vista `XMag_ViewPackingList`
|
||||
|
||||
Questo è il primo assetto realmente coerente con il requisito di business:
|
||||
|
||||
> una sola picking list prenotata alla volta, anche in presenza di celle condivise.
|
||||
|
||||
---
|
||||
|
||||
## Evoluzione proposta: usare `ViewPackingListRestante` anche per la lista alta
|
||||
|
||||
### Situazione attuale
|
||||
|
||||
Nel legacy C# e nel Python attuale la distinzione è questa:
|
||||
|
||||
- la **griglia alta** legge la testata aggregata da `XMag_ViewPackingList`
|
||||
- la **griglia bassa** legge il dettaglio da `ViewPackingListRestante`
|
||||
|
||||
La vista `ViewPackingListRestante` è definita come:
|
||||
|
||||
```sql
|
||||
SELECT ...
|
||||
FROM XMag_ViewPackingList
|
||||
WHERE Cella <> 9999
|
||||
```
|
||||
|
||||
Quindi:
|
||||
|
||||
- `XMag_ViewPackingList` contiene anche le UDC già finite nella locazione convenzionale `9999 = 7G.1.1`
|
||||
- `ViewPackingListRestante` mostra invece solo le UDC ancora residue
|
||||
|
||||
### Conseguenza pratica
|
||||
|
||||
All’istante `t = 0` della prenotazione:
|
||||
|
||||
- se la picking list non è ancora stata lavorata, `XMag_ViewPackingList` e `ViewPackingListRestante` mostrano di fatto lo stesso insieme di UDC
|
||||
- le UDC non scaffalate **restano presenti** in entrambe, perché stanno nella cella convenzionale `1000 = 5E1.1`
|
||||
|
||||
Dopo che il magazziniere ha iniziato i prelievi:
|
||||
|
||||
- le UDC già spedite/prelevate finiscono in `9999 = 7G.1.1`
|
||||
- quindi spariscono da `ViewPackingListRestante`
|
||||
- ma restano ancora visibili in `XMag_ViewPackingList`
|
||||
|
||||
### Limite del comportamento attuale
|
||||
|
||||
Con la summary alta basata su `XMag_ViewPackingList`:
|
||||
|
||||
- il comando `Ricarica` può continuare a mostrare picking list già lavorate in parte
|
||||
- una picking list completamente esaurita può restare visibile nella lista alta
|
||||
- il contenuto della lista alta non coincide più con il “residuo operativo reale”
|
||||
|
||||
In altre parole:
|
||||
|
||||
- la griglia bassa mostra il residuo
|
||||
- la griglia alta mostra ancora lo storico completo
|
||||
|
||||
### Modifica proposta
|
||||
|
||||
La proposta è:
|
||||
|
||||
- usare `ViewPackingListRestante` anche come sorgente della **lista alta aggregata**
|
||||
|
||||
quindi sostituire, nella query summary di [gestione_pickinglist.py](C:/devel/python/ware_house/gestione_pickinglist.py):
|
||||
|
||||
- `FROM dbo.XMag_ViewPackingList`
|
||||
|
||||
con:
|
||||
|
||||
- `FROM dbo.ViewPackingListRestante`
|
||||
|
||||
mantenendo invariati:
|
||||
|
||||
- `GROUP BY Documento, CodNazione, NAZIONE, Stato`
|
||||
- `COUNT(DISTINCT Pallet)`
|
||||
- `COUNT(DISTINCT Lotto)`
|
||||
- `COUNT(DISTINCT Articolo)`
|
||||
- `SUM(Qta)`
|
||||
- `MIN(Ordinamento)`
|
||||
- `MAX(IDStato)`
|
||||
|
||||
### Effetti attesi
|
||||
|
||||
Con questa modifica:
|
||||
|
||||
1. all’inizio una picking list nuova continua a comparire normalmente
|
||||
2. durante il lavoro il pulsante `Ricarica` mostra solo ciò che resta davvero da prelevare
|
||||
3. le UDC già finite in `7G.1.1` non inquinano più i conteggi della testata
|
||||
4. una picking list completamente esaurita esce naturalmente dalla lista visibile
|
||||
5. le UDC non scaffalate continuano a comparire correttamente, perché stanno in `1000 = 5E1.1`, non in `9999`
|
||||
|
||||
### Chiusura automatica della prenotazione
|
||||
|
||||
Per mantenere coerenti:
|
||||
|
||||
- griglia alta
|
||||
- stato della prenotazione
|
||||
- comportamento del barcode `F1`
|
||||
|
||||
la prenotazione attiva non deve soltanto sparire dalla griglia: deve essere anche **azzerata logicamente** quando il residuo arriva a zero.
|
||||
|
||||
La patch SQL definitiva quindi deve fare anche questo:
|
||||
|
||||
- dopo ogni movimento, controllare se il documento prenotato ha ancora righe in `ViewPackingListRestante`
|
||||
- se non ne ha più:
|
||||
- la prenotazione attiva va portata a `NULL` / `0`
|
||||
- le eventuali celle residue marcate `IDStato = 1` vanno riportate a `0`
|
||||
|
||||
Effetto operativo:
|
||||
|
||||
- plist piena all’inizio
|
||||
- plist via via ridotta durante i prelievi
|
||||
- plist che, all’ultima UDC, sparisce dalla griglia alta
|
||||
- e nello stesso momento cessa anche di essere la coda `F1`
|
||||
|
||||
### Impatto funzionale
|
||||
|
||||
Questa modifica:
|
||||
|
||||
- **non è** una replica pedissequa del legacy C#
|
||||
- ma è un miglioramento operativo coerente con il comportamento atteso dal magazzino
|
||||
|
||||
In particolare rende la lista alta:
|
||||
|
||||
- più coerente con il significato di “picking list ancora da esaurire”
|
||||
- allineata al contenuto della griglia bassa
|
||||
- più utile nei refresh successivi durante il lavoro reale
|
||||
|
||||
### Impatto tecnico
|
||||
|
||||
Il cambiamento richiesto è piccolo lato Python:
|
||||
|
||||
- aggiornare la query summary in [gestione_pickinglist.py](C:/devel/python/ware_house/gestione_pickinglist.py)
|
||||
|
||||
Non richiede, in prima battuta:
|
||||
|
||||
- modifiche alla stored di prenotazione
|
||||
- modifiche al barcode
|
||||
- modifiche a `ViewPackingListRestante`
|
||||
|
||||
### Decisione progettuale
|
||||
|
||||
Questa modifica va considerata come una scelta esplicita di evoluzione:
|
||||
|
||||
- **se vogliamo restare 1:1 col C#**, la lista alta resta su `XMag_ViewPackingList`
|
||||
- **se vogliamo rendere il modulo più aderente al residuo operativo reale**, conviene passare a `ViewPackingListRestante`
|
||||
247
analisi_fix_pickinglist_nazione_destinazione.md
Normal file
247
analisi_fix_pickinglist_nazione_destinazione.md
Normal file
@@ -0,0 +1,247 @@
|
||||
# Picking list con nazione di destinazione mancante
|
||||
|
||||
## Scopo
|
||||
|
||||
Questo documento descrive il difetto che rendeva invisibile una picking list
|
||||
quando il documento SAM utilizzava un indirizzo di destinazione alternativo
|
||||
senza nazione valorizzata. Descrive inoltre la correzione applicata al solo
|
||||
ramo dati Python del WMS, le conseguenze funzionali e le verifiche da eseguire.
|
||||
|
||||
La correzione non modifica tabelle o viste legacy utilizzate dal programma C#
|
||||
e non aggiorna dati anagrafici o documentali in SAM.
|
||||
|
||||
## Caso che ha evidenziato il difetto
|
||||
|
||||
Il problema e' stato rilevato sulla picking list `244/2026`:
|
||||
|
||||
| Dato | Valore |
|
||||
|---|---|
|
||||
| `BAMTES.ID` | `11896` |
|
||||
| `BAMTES.NUMDOC` | `244` |
|
||||
| `BAMTES.ANNDOC` | `2026` |
|
||||
| Data documento | `24/09/2026` |
|
||||
| `BAMTES.STATO` | `P` |
|
||||
| `BAMTES.IDINDDEST` | `274` |
|
||||
| Destinazione | `c/o UNITRANS Magazzino 4 Mirandola` |
|
||||
| `BAMTES.IDNAZDEST` | `NULL` |
|
||||
|
||||
L'indirizzo alternativo `SAMA1.dbo.INDANA.ID = 274` esiste, ma anche il suo
|
||||
campo `IDNAZIONI` e' `NULL`. L'indirizzo abituale della stessa controparte ha
|
||||
invece `IDNAZIONI = 21`, corrispondente all'Italia.
|
||||
|
||||
Il documento non aveva altri problemi:
|
||||
|
||||
- anno corrente valido;
|
||||
- stato `P` valido;
|
||||
- data compresa nell'intervallo operativo;
|
||||
- 4 righe documento;
|
||||
- 494 righe lotto valide;
|
||||
- 26 UDC distinte;
|
||||
- trasportatore esistente.
|
||||
|
||||
## Causa tecnica
|
||||
|
||||
La preparazione delle picking list collegava la testata del documento alla
|
||||
tabella delle nazioni con un collegamento obbligatorio:
|
||||
|
||||
```sql
|
||||
FROM SAMA1.dbo.NAZIONI
|
||||
INNER JOIN SAMA1.dbo.BAMTES
|
||||
ON SAMA1.dbo.NAZIONI.ID = SAMA1.dbo.BAMTES.IDNAZDEST
|
||||
```
|
||||
|
||||
Un `INNER JOIN` conserva soltanto le testate per le quali esiste una nazione
|
||||
compatibile. Quando `BAMTES.IDNAZDEST` e' `NULL`, il confronto non puo' trovare
|
||||
alcuna riga e l'intero documento scompare prima che vengano elaborate righe,
|
||||
lotti e UDC.
|
||||
|
||||
Nel caso 244 la diagnosi ha prodotto:
|
||||
|
||||
```text
|
||||
Righe valide senza join obbligatorio a NAZIONI: 494
|
||||
Righe valide con join obbligatorio a NAZIONI: 0
|
||||
```
|
||||
|
||||
Il filtro della GUI a 10 giorni, la prenotazione e la sequenza di prelievo non
|
||||
erano quindi responsabili del problema.
|
||||
|
||||
## Flusso dati interessato
|
||||
|
||||
La pagina Gestione Picking List usa questa catena:
|
||||
|
||||
```text
|
||||
SAMA1.dbo.BAMTES / FATRIG / LOTTIBF / LOTSER
|
||||
|
|
||||
v
|
||||
dbo.py_XMag_ViewPackingList
|
||||
|
|
||||
v
|
||||
dbo.py_ViewPackingListRestante
|
||||
|
|
||||
v
|
||||
dbo.py_ViewPackingListPrelievo
|
||||
|
|
||||
v
|
||||
Gestione Picking List e barcode Python
|
||||
```
|
||||
|
||||
Lo storico Python utilizza inoltre:
|
||||
|
||||
```text
|
||||
SAMA1
|
||||
-> dbo.py_vPreparaPackingListSAMA1
|
||||
-> dbo.py_vPreparaPackingList
|
||||
-> dbo.py_XMag_ViewPackingListStorico
|
||||
```
|
||||
|
||||
Per evitare comportamenti diversi fra operativita' e storico, la correzione e'
|
||||
stata applicata sia alla preparazione operativa sia alla preparazione storica.
|
||||
|
||||
## Correzione applicata
|
||||
|
||||
Il collegamento e' stato reso opzionale:
|
||||
|
||||
```sql
|
||||
FROM SAMA1.dbo.BAMTES AS bt
|
||||
LEFT OUTER JOIN SAMA1.dbo.NAZIONI AS n
|
||||
ON n.ID = bt.IDNAZDEST
|
||||
```
|
||||
|
||||
Con il `LEFT OUTER JOIN` la testata BAMTES viene conservata anche quando la
|
||||
nazione e' assente. Gli altri collegamenti essenziali verso righe, lotti e
|
||||
seriali restano obbligatori.
|
||||
|
||||
Sono state modificate soltanto queste viste Python:
|
||||
|
||||
- `dbo.py_vPreparaPackingListSAMA1`;
|
||||
- `dbo.py_XMag_ViewPackingList`.
|
||||
|
||||
Le viste dipendenti ricevono automaticamente i dati corretti:
|
||||
|
||||
- `dbo.py_vPreparaPackingList`;
|
||||
- `dbo.py_XMag_ViewPackingListStorico`;
|
||||
- `dbo.py_ViewPackingListRestante`;
|
||||
- `dbo.py_ViewPackingListPrelievo`.
|
||||
|
||||
## Gestione dei valori mancanti
|
||||
|
||||
La patch non assegna automaticamente una nazione. Questo evita di trasformare
|
||||
un'anagrafica incompleta in un dato apparentemente certo.
|
||||
|
||||
Quando la nazione manca:
|
||||
|
||||
- `CodNazione` resta `NULL`;
|
||||
- `NAZIONE` resta `NULL`;
|
||||
- il documento e le sue UDC restano visibili;
|
||||
- il `CASE` applicativo gia' esistente usa il ramo generico `Stato = 4`;
|
||||
- prenotazione, dettaglio UDC e sequenza di prelievo continuano a funzionare.
|
||||
|
||||
La correzione dell'anagrafica SAM rimane comunque consigliata. La robustezza
|
||||
della vista impedisce pero' che un campo descrittivo incompleto blocchi un
|
||||
processo operativo di magazzino.
|
||||
|
||||
## Script di installazione
|
||||
|
||||
La patch autonoma e' contenuta in:
|
||||
|
||||
```text
|
||||
apply_pickinglist_optional_destination_country_patch.sql
|
||||
```
|
||||
|
||||
Lo stesso cambiamento e' stato integrato anche negli script cumulativi:
|
||||
|
||||
- `apply_pickinglist_days_filter_patch.sql`;
|
||||
- `apply_online_python_wms_full_patch.sql`.
|
||||
|
||||
Per aggiornare un database che possiede gia' le viste Python e' sufficiente
|
||||
eseguire una sola volta in SSMS la patch autonoma. Gli script usano
|
||||
`CREATE OR ALTER VIEW`, quindi possono essere rieseguiti senza duplicare dati.
|
||||
|
||||
## Verifica post-patch
|
||||
|
||||
Controllo della vista operativa:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
Documento,
|
||||
DataDocumento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
IDStato,
|
||||
COUNT(DISTINCT Pallet) AS NumeroUDC
|
||||
FROM dbo.py_ViewPackingListPrelievo
|
||||
WHERE Documento = 244
|
||||
GROUP BY
|
||||
Documento,
|
||||
DataDocumento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
IDStato;
|
||||
```
|
||||
|
||||
Risultato ottenuto dopo la correzione:
|
||||
|
||||
```text
|
||||
Documento: 244
|
||||
CodNazione: NULL
|
||||
NAZIONE: NULL
|
||||
Stato: 4
|
||||
IDStato: 0
|
||||
Numero UDC: 26
|
||||
```
|
||||
|
||||
Controllo dei quattro livelli principali:
|
||||
|
||||
```sql
|
||||
SELECT COUNT(DISTINCT UDC) AS UDC
|
||||
FROM dbo.py_vPreparaPackingListSAMA1
|
||||
WHERE NUMDOC = 244 AND StatoDocumento = 'P';
|
||||
|
||||
SELECT COUNT(DISTINCT Pallet) AS UDC
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE Documento = 244;
|
||||
|
||||
SELECT COUNT(DISTINCT Pallet) AS UDC
|
||||
FROM dbo.py_ViewPackingListRestante
|
||||
WHERE Documento = 244;
|
||||
|
||||
SELECT COUNT(DISTINCT Pallet) AS UDC
|
||||
FROM dbo.py_ViewPackingListPrelievo
|
||||
WHERE Documento = 244;
|
||||
```
|
||||
|
||||
Tutte e quattro le query devono restituire `26` per il caso analizzato.
|
||||
|
||||
## Impatto e compatibilita'
|
||||
|
||||
- Nessuna riga SAM viene inserita, aggiornata o cancellata.
|
||||
- Nessuna prenotazione viene modificata.
|
||||
- Nessuna stored procedure di movimentazione viene modificata.
|
||||
- Le picking list con nazione valida mantengono lo stesso risultato.
|
||||
- Le picking list prima invisibili per nazione nulla diventano visibili.
|
||||
- Gli oggetti legacy senza prefisso `py_` non vengono modificati.
|
||||
|
||||
## Ripristino concettuale
|
||||
|
||||
Per ripristinare il comportamento precedente occorrerebbe riportare il
|
||||
collegamento `BAMTES -> NAZIONI` da `LEFT OUTER JOIN` a `INNER JOIN` nelle due
|
||||
viste Python modificate. Tale rollback farebbe nuovamente scomparire tutti i
|
||||
documenti con `IDNAZDEST` nullo e non e' quindi raccomandato come soluzione
|
||||
operativa.
|
||||
|
||||
## Miglioramento futuro consigliato
|
||||
|
||||
Una diagnostica separata potrebbe mostrare le picking list con dati anagrafici
|
||||
incompleti, senza impedirne l'uso:
|
||||
|
||||
```sql
|
||||
SELECT ID, ANNDOC, NUMDOC, IDINDDEST, DESCRDEST
|
||||
FROM SAMA1.dbo.BAMTES
|
||||
WHERE STATO = 'P'
|
||||
AND IDNAZDEST IS NULL;
|
||||
```
|
||||
|
||||
In questo modo il WMS rimane operativo e l'amministratore puo' correggere
|
||||
l'anagrafica SAM in un secondo momento.
|
||||
46
apply_barcode_picking_skip_patch.sql
Normal file
46
apply_barcode_picking_skip_patch.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SET XACT_ABORT ON;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.py_BarcodePickingListSkip (
|
||||
ID int IDENTITY(1,1) NOT NULL CONSTRAINT PK_py_BarcodePickingListSkip PRIMARY KEY,
|
||||
Documento varchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
Pallet varchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
IDStato int NOT NULL,
|
||||
IDOperatore int NOT NULL,
|
||||
DataOra datetime2(0) NOT NULL CONSTRAINT DF_py_BarcodePickingListSkip_DataOra DEFAULT SYSDATETIME(),
|
||||
Motivo nvarchar(200) NULL,
|
||||
Risolto bit NOT NULL CONSTRAINT DF_py_BarcodePickingListSkip_Risolto DEFAULT 0,
|
||||
RisoltoDa int NULL,
|
||||
RisoltoDataOra datetime2(0) NULL
|
||||
);
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = N'UX_py_BarcodePickingListSkip_Open'
|
||||
AND object_id = OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U')
|
||||
)
|
||||
BEGIN
|
||||
CREATE UNIQUE INDEX UX_py_BarcodePickingListSkip_Open
|
||||
ON dbo.py_BarcodePickingListSkip (Documento, Pallet, IDStato)
|
||||
WHERE Risolto = 0;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = N'IX_py_BarcodePickingListSkip_Queue'
|
||||
AND object_id = OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U')
|
||||
)
|
||||
BEGIN
|
||||
CREATE INDEX IX_py_BarcodePickingListSkip_Queue
|
||||
ON dbo.py_BarcodePickingListSkip (IDStato, Documento, Pallet, Risolto);
|
||||
END;
|
||||
|
||||
COMMIT TRANSACTION;
|
||||
185
apply_online_history_forms_patch.sql
Normal file
185
apply_online_history_forms_patch.sql
Normal file
@@ -0,0 +1,185 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Patch online - form storiche Python
|
||||
|
||||
Contenuto:
|
||||
- crea/aggiorna le viste Python-only usate dalla form "Storico Picking List"
|
||||
- non modifica stored procedure legacy C#
|
||||
- non modifica le viste legacy C#
|
||||
- non crea oggetti per "Storico movimenti UDC", perche' quella form legge in sola lettura:
|
||||
dbo.MagazziniPallet, dbo.Celle, dbo.XMag_GiacenzaPalletPlistChiuse
|
||||
|
||||
Oggetti creati/aggiornati:
|
||||
- dbo.py_vPreparaPackingListSAMA1
|
||||
- dbo.py_vPreparaPackingList
|
||||
- dbo.py_XMag_ViewPackingListStorico
|
||||
*/
|
||||
|
||||
SET ANSI_NULLS ON;
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.PyPickingListReservation', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [dbo].[PyPickingListReservation](
|
||||
[ID] [tinyint] NOT NULL,
|
||||
[Documento] [varchar](8) NULL,
|
||||
[IDOperatore] [int] NULL,
|
||||
[ModUtente] [varchar](50) NULL,
|
||||
[ModDataOra] [datetime] NULL,
|
||||
CONSTRAINT [PK_PyPickingListReservation] PRIMARY KEY CLUSTERED ([ID] ASC),
|
||||
CONSTRAINT [CK_PyPickingListReservation_Singleton] CHECK ([ID] = 1)
|
||||
) ON [PRIMARY];
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PyPickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PyPickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_vPreparaPackingListSAMA1]
|
||||
AS
|
||||
SELECT
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) AS UDC,
|
||||
SUM(SAMA1_Xwmstest.dbo.LOTSER.QTTGIAI) AS Qta,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.STATO AS StatoDocumento,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE AS Expr1,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE + ' ' + SAMA1_Xwmstest.dbo.NAZIONI.DESCR AS NAZIONE,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP
|
||||
FROM SAMA1_Xwmstest.dbo.NAZIONI
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.BAMTES
|
||||
ON SAMA1_Xwmstest.dbo.NAZIONI.ID = SAMA1_Xwmstest.dbo.BAMTES.IDNAZDEST
|
||||
RIGHT OUTER JOIN SAMA1_Xwmstest.dbo.LOTTIBF
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.LOTSER
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDLOTSER = SAMA1_Xwmstest.dbo.LOTSER.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.ARTICO
|
||||
ON SAMA1_Xwmstest.dbo.LOTSER.IDARTICO = SAMA1_Xwmstest.dbo.ARTICO.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.FATRIG
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDFATRIG = SAMA1_Xwmstest.dbo.FATRIG.ID
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.ID = SAMA1_Xwmstest.dbo.FATRIG.IDBAM
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.sam.EXTUC
|
||||
ON LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) = SAMA1_Xwmstest.sam.EXTUC.CODICE
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.MTRASP
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP = SAMA1_Xwmstest.dbo.MTRASP.ID
|
||||
WHERE
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ANNDOC >= YEAR(GETDATE())
|
||||
AND SAMA1_Xwmstest.dbo.BAMTES.STATO IN ('P', 'D')
|
||||
AND SAMA1_Xwmstest.dbo.LOTSER.NUMLOT <> '00000000000'
|
||||
GROUP BY
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6),
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.STATO,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.DESCR,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_vPreparaPackingList]
|
||||
AS
|
||||
SELECT
|
||||
NUMLOT,
|
||||
CODICE,
|
||||
DESCR,
|
||||
UDC,
|
||||
Qta,
|
||||
NUMDOC,
|
||||
DATDOC,
|
||||
ID,
|
||||
DESCRDEST,
|
||||
StatoDocumento,
|
||||
Expr1,
|
||||
NAZIONE
|
||||
FROM dbo.py_vPreparaPackingListSAMA1
|
||||
WHERE NUMLOT <> '';
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_XMag_ViewPackingListStorico]
|
||||
AS
|
||||
SELECT TOP (100000)
|
||||
prep.UDC AS Pallet,
|
||||
prep.NUMLOT AS Lotto,
|
||||
prep.CODICE AS Articolo,
|
||||
prep.DESCR AS Descrizione,
|
||||
prep.Qta,
|
||||
prep.NUMDOC AS Documento,
|
||||
prep.DATDOC AS DataDocumento,
|
||||
prep.StatoDocumento,
|
||||
prep.Expr1 AS CodNazione,
|
||||
prep.NAZIONE,
|
||||
CASE
|
||||
WHEN prep.Expr1 = 'DE' THEN 10
|
||||
WHEN prep.Expr1 = 'TH' THEN
|
||||
CASE WHEN SUBSTRING(prep.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN prep.Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(g.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(g.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(g.IDArea, 5) AS Area,
|
||||
ISNULL(g.IDCella, 1000) AS Cella,
|
||||
ISNULL(c.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(prep.DESCRDEST, 1, 2) AS DEST,
|
||||
CASE
|
||||
WHEN MAX(CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(prep.NUMDOC AS varchar(8))
|
||||
THEN 1 ELSE 0 END) = 1
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet g
|
||||
ON c.ID = g.IDCella
|
||||
RIGHT OUTER JOIN dbo.py_vPreparaPackingList prep
|
||||
ON g.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = prep.UDC
|
||||
LEFT JOIN dbo.PyPickingListReservation pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
GROUP BY
|
||||
prep.Expr1,
|
||||
prep.NAZIONE,
|
||||
prep.UDC,
|
||||
prep.NUMDOC,
|
||||
prep.DATDOC,
|
||||
prep.StatoDocumento,
|
||||
prep.NUMLOT,
|
||||
prep.CODICE,
|
||||
prep.DESCR,
|
||||
prep.Qta,
|
||||
g.NumeroPallet,
|
||||
g.IDMagazzino,
|
||||
g.IDArea,
|
||||
g.IDCella,
|
||||
c.Ordinamento,
|
||||
c.Corsia,
|
||||
c.Colonna,
|
||||
c.Fila,
|
||||
prep.DESCRDEST;
|
||||
GO
|
||||
|
||||
PRINT 'Patch form storiche Python applicata.';
|
||||
PRINT 'Creato/aggiornato dbo.py_vPreparaPackingListSAMA1';
|
||||
PRINT 'Creato/aggiornato dbo.py_vPreparaPackingList';
|
||||
PRINT 'Creato/aggiornato dbo.py_XMag_ViewPackingListStorico';
|
||||
GO
|
||||
728
apply_online_python_wms_full_patch.sql
Normal file
728
apply_online_python_wms_full_patch.sql
Normal file
@@ -0,0 +1,728 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Patch cumulativa DB online - ramo Python WMS
|
||||
|
||||
Da eseguire una sola volta in SSMS sul database Xwmsdb.
|
||||
|
||||
Questa patch NON modifica gli oggetti legacy usati dal programma C#.
|
||||
|
||||
Include:
|
||||
- dbo.PyPickingListReservation
|
||||
- dbo.py_XMag_ViewPackingList
|
||||
- dbo.py_ViewPackingListRestante
|
||||
- dbo.py_sp_xExePackingListPallet
|
||||
- dbo.py_sp_xExePackingListPalletPrenota
|
||||
- dbo.py_sp_ControllaPrenotazionePackingListPalletNew
|
||||
- dbo.py_vPreparaPackingListSAMA1
|
||||
- dbo.py_vPreparaPackingList
|
||||
- dbo.py_XMag_ViewPackingListStorico
|
||||
- dbo.py_BarcodePickingListSkip
|
||||
- dbo.py_PickingListPrelievoSequenza
|
||||
- dbo.py_ViewPackingListPrelievo
|
||||
|
||||
Include inoltre:
|
||||
- intervallo operativo massimo di 30 giorni, filtrato dalla UI a 10/15/20/30;
|
||||
- destinazione senza nazione ammessa nel ramo Python mediante LEFT JOIN;
|
||||
- ordine predefinito con UDC Non scaff. prima degli scaffali;
|
||||
- ordine personalizzabile per singolo Documento.
|
||||
|
||||
Nota storico:
|
||||
dbo.py_vPreparaPackingListSAMA1 usa ANNDOC >= YEAR(GETDATE())
|
||||
per mantenere visibili solo le picking list dall'inizio dell'anno corrente.
|
||||
*/
|
||||
|
||||
SET ANSI_NULLS ON;
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
1. Stato prenotazione picking list ramo Python
|
||||
============================================================ */
|
||||
|
||||
IF OBJECT_ID(N'dbo.PyPickingListReservation', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [dbo].[PyPickingListReservation](
|
||||
[ID] [tinyint] NOT NULL,
|
||||
[Documento] [varchar](8) NULL,
|
||||
[IDOperatore] [int] NULL,
|
||||
[ModUtente] [varchar](50) NULL,
|
||||
[ModDataOra] [datetime] NULL,
|
||||
CONSTRAINT [PK_PyPickingListReservation] PRIMARY KEY CLUSTERED ([ID] ASC),
|
||||
CONSTRAINT [CK_PyPickingListReservation_Singleton] CHECK ([ID] = 1)
|
||||
) ON [PRIMARY];
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PyPickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PyPickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
2. Viste operative picking list ramo Python
|
||||
============================================================ */
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_XMag_ViewPackingList]
|
||||
AS
|
||||
SELECT TOP 10000
|
||||
legacy.Pallet,
|
||||
legacy.Lotto,
|
||||
legacy.Articolo,
|
||||
legacy.Descrizione,
|
||||
legacy.Qta,
|
||||
legacy.Documento,
|
||||
legacy.CodNazione,
|
||||
legacy.NAZIONE,
|
||||
legacy.Stato,
|
||||
legacy.PalletCella,
|
||||
legacy.Magazzino,
|
||||
legacy.Area,
|
||||
legacy.Cella,
|
||||
legacy.Ordinamento,
|
||||
legacy.Ubicazione,
|
||||
legacy.DEST,
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(legacy.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM dbo.XMag_ViewPackingList legacy
|
||||
LEFT JOIN dbo.PyPickingListReservation pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(legacy.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
legacy.Documento,
|
||||
legacy.Ordinamento;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_ViewPackingListRestante]
|
||||
AS
|
||||
SELECT
|
||||
Pallet,
|
||||
Lotto,
|
||||
Articolo,
|
||||
Descrizione,
|
||||
Qta,
|
||||
Documento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
PalletCella,
|
||||
Magazzino,
|
||||
Area,
|
||||
Cella,
|
||||
Ordinamento,
|
||||
Ubicazione,
|
||||
DEST,
|
||||
IDStato
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE Cella <> 9999;
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
3. Stored procedure operative ramo Python
|
||||
============================================================ */
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[py_sp_xExePackingListPallet]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@Azione char(1) = 'P',
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
DECLARE @DocumentoAttivo varchar(8) = NULL;
|
||||
DECLARE @Description varchar(255) = '';
|
||||
DECLARE @Message varchar(255) = '';
|
||||
DECLARE @IDResult int = 0;
|
||||
DECLARE @ID int = 0;
|
||||
|
||||
SELECT @Nominativo = [Login]
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
IF @Azione NOT IN ('P', 'S')
|
||||
BEGIN
|
||||
SET @RC = -10;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
SET @RC = -20;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PyPickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PyPickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END;
|
||||
|
||||
SELECT @DocumentoAttivo = NULLIF(LTRIM(RTRIM(Documento)), '')
|
||||
FROM dbo.PyPickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
DECLARE @TargetCelle TABLE (
|
||||
IDCella int PRIMARY KEY
|
||||
);
|
||||
|
||||
INSERT INTO @TargetCelle (IDCella)
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL;
|
||||
|
||||
IF @Azione = 'P'
|
||||
BEGIN
|
||||
IF @DocumentoAttivo = @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE ISNULL(c.IDStato, 0) <> 0;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PyPickingListReservation
|
||||
SET Documento = @Documento,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
SELECT TOP 1 @Description = NAZIONE
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento;
|
||||
|
||||
EXEC dbo.sp_LogPackingList
|
||||
@ID = @ID,
|
||||
@Code = @Documento,
|
||||
@Description = @Description,
|
||||
@Message = @Message OUTPUT,
|
||||
@IDResult = @IDResult OUTPUT;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF @Azione = 'S'
|
||||
BEGIN
|
||||
IF ISNULL(@DocumentoAttivo, '') <> @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PyPickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[py_sp_xExePackingListPalletPrenota]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
|
||||
SELECT @Nominativo = LOGIN
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE c.ID IN (
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.py_ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL
|
||||
);
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[py_sp_ControllaPrenotazionePackingListPalletNew]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @Documento varchar(8) = NULL;
|
||||
DECLARE @IDOperatore int = 0;
|
||||
DECLARE @Nominativo varchar(50) = 'SYSTEM';
|
||||
DECLARE @RC int = 0;
|
||||
|
||||
SELECT
|
||||
@Documento = NULLIF(LTRIM(RTRIM(Documento)), ''),
|
||||
@IDOperatore = ISNULL(IDOperatore, 0),
|
||||
@Nominativo = ISNULL(NULLIF(LTRIM(RTRIM(ModUtente)), ''), 'SYSTEM')
|
||||
FROM dbo.PyPickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
IF ISNULL(@Documento, '') = ''
|
||||
RETURN;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
UPDATE dbo.PyPickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
IF @IDOperatore <= 0
|
||||
BEGIN
|
||||
SELECT TOP 1 @IDOperatore = ID
|
||||
FROM dbo.Operatori
|
||||
WHERE LOGIN = @Nominativo;
|
||||
END;
|
||||
|
||||
EXEC dbo.py_sp_xExePackingListPalletPrenota
|
||||
@IDOperatore = @IDOperatore,
|
||||
@Documento = @Documento,
|
||||
@RC = @RC OUTPUT;
|
||||
END;
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
4. Viste storico picking list ramo Python
|
||||
============================================================ */
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_vPreparaPackingListSAMA1]
|
||||
AS
|
||||
SELECT
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) AS UDC,
|
||||
SUM(SAMA1_Xwmstest.dbo.LOTSER.QTTGIAI) AS Qta,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.STATO AS StatoDocumento,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE AS Expr1,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE + ' ' + SAMA1_Xwmstest.dbo.NAZIONI.DESCR AS NAZIONE,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP
|
||||
FROM SAMA1_Xwmstest.dbo.BAMTES
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.NAZIONI
|
||||
ON SAMA1_Xwmstest.dbo.NAZIONI.ID = SAMA1_Xwmstest.dbo.BAMTES.IDNAZDEST
|
||||
RIGHT OUTER JOIN SAMA1_Xwmstest.dbo.LOTTIBF
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.LOTSER
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDLOTSER = SAMA1_Xwmstest.dbo.LOTSER.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.ARTICO
|
||||
ON SAMA1_Xwmstest.dbo.LOTSER.IDARTICO = SAMA1_Xwmstest.dbo.ARTICO.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.FATRIG
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDFATRIG = SAMA1_Xwmstest.dbo.FATRIG.ID
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.ID = SAMA1_Xwmstest.dbo.FATRIG.IDBAM
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.sam.EXTUC
|
||||
ON LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) = SAMA1_Xwmstest.sam.EXTUC.CODICE
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.MTRASP
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP = SAMA1_Xwmstest.dbo.MTRASP.ID
|
||||
WHERE
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ANNDOC >= YEAR(GETDATE())
|
||||
AND SAMA1_Xwmstest.dbo.BAMTES.STATO IN ('P', 'D')
|
||||
AND SAMA1_Xwmstest.dbo.LOTSER.NUMLOT <> '00000000000'
|
||||
GROUP BY
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6),
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.STATO,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.DESCR,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_vPreparaPackingList]
|
||||
AS
|
||||
SELECT
|
||||
NUMLOT,
|
||||
CODICE,
|
||||
DESCR,
|
||||
UDC,
|
||||
Qta,
|
||||
NUMDOC,
|
||||
DATDOC,
|
||||
ID,
|
||||
DESCRDEST,
|
||||
StatoDocumento,
|
||||
Expr1,
|
||||
NAZIONE
|
||||
FROM dbo.py_vPreparaPackingListSAMA1
|
||||
WHERE NUMLOT <> '';
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_XMag_ViewPackingListStorico]
|
||||
AS
|
||||
SELECT TOP (100000)
|
||||
prep.UDC AS Pallet,
|
||||
prep.NUMLOT AS Lotto,
|
||||
prep.CODICE AS Articolo,
|
||||
prep.DESCR AS Descrizione,
|
||||
prep.Qta,
|
||||
prep.NUMDOC AS Documento,
|
||||
prep.DATDOC AS DataDocumento,
|
||||
prep.StatoDocumento,
|
||||
prep.Expr1 AS CodNazione,
|
||||
prep.NAZIONE,
|
||||
CASE
|
||||
WHEN prep.Expr1 = 'DE' THEN 10
|
||||
WHEN prep.Expr1 = 'TH' THEN
|
||||
CASE WHEN SUBSTRING(prep.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN prep.Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(g.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(g.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(g.IDArea, 5) AS Area,
|
||||
ISNULL(g.IDCella, 1000) AS Cella,
|
||||
ISNULL(c.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(prep.DESCRDEST, 1, 2) AS DEST,
|
||||
CASE
|
||||
WHEN MAX(CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(prep.NUMDOC AS varchar(8))
|
||||
THEN 1 ELSE 0 END) = 1
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet g
|
||||
ON c.ID = g.IDCella
|
||||
RIGHT OUTER JOIN dbo.py_vPreparaPackingList prep
|
||||
ON g.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = prep.UDC
|
||||
LEFT JOIN dbo.PyPickingListReservation pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
GROUP BY
|
||||
prep.Expr1,
|
||||
prep.NAZIONE,
|
||||
prep.UDC,
|
||||
prep.NUMDOC,
|
||||
prep.DATDOC,
|
||||
prep.StatoDocumento,
|
||||
prep.NUMLOT,
|
||||
prep.CODICE,
|
||||
prep.DESCR,
|
||||
prep.Qta,
|
||||
g.NumeroPallet,
|
||||
g.IDMagazzino,
|
||||
g.IDArea,
|
||||
g.IDCella,
|
||||
c.Ordinamento,
|
||||
c.Corsia,
|
||||
c.Colonna,
|
||||
c.Fila,
|
||||
prep.DESCRDEST;
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
5. Tabella salta UDC barcode picking list
|
||||
============================================================ */
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.py_BarcodePickingListSkip (
|
||||
ID int IDENTITY(1,1) NOT NULL CONSTRAINT PK_py_BarcodePickingListSkip PRIMARY KEY,
|
||||
Documento varchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
Pallet varchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
IDStato int NOT NULL,
|
||||
IDOperatore int NOT NULL,
|
||||
DataOra datetime2(0) NOT NULL CONSTRAINT DF_py_BarcodePickingListSkip_DataOra DEFAULT SYSDATETIME(),
|
||||
Motivo nvarchar(200) NULL,
|
||||
Risolto bit NOT NULL CONSTRAINT DF_py_BarcodePickingListSkip_Risolto DEFAULT 0,
|
||||
RisoltoDa int NULL,
|
||||
RisoltoDataOra datetime2(0) NULL
|
||||
);
|
||||
END;
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = N'UX_py_BarcodePickingListSkip_Open'
|
||||
AND object_id = OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U')
|
||||
)
|
||||
BEGIN
|
||||
CREATE UNIQUE INDEX UX_py_BarcodePickingListSkip_Open
|
||||
ON dbo.py_BarcodePickingListSkip (Documento, Pallet, IDStato)
|
||||
WHERE Risolto = 0;
|
||||
END;
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = N'IX_py_BarcodePickingListSkip_Queue'
|
||||
AND object_id = OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U')
|
||||
)
|
||||
BEGIN
|
||||
CREATE INDEX IX_py_BarcodePickingListSkip_Queue
|
||||
ON dbo.py_BarcodePickingListSkip (IDStato, Documento, Pallet, Risolto);
|
||||
END;
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
6. Intervallo operativo 30 giorni e sequenza di prelievo
|
||||
|
||||
La vista di preparazione Python creata al punto 4 contiene sia P sia D.
|
||||
Qui il ramo operativo viene ristretto alle sole liste P degli ultimi 30
|
||||
giorni; la UI applica successivamente il valore scelto (10/15/20/30).
|
||||
============================================================ */
|
||||
|
||||
CREATE OR ALTER VIEW dbo.py_XMag_ViewPackingList
|
||||
AS
|
||||
SELECT TOP (10000)
|
||||
prep.UDC AS Pallet,
|
||||
prep.NUMLOT AS Lotto,
|
||||
prep.CODICE AS Articolo,
|
||||
prep.DESCR AS Descrizione,
|
||||
prep.Qta,
|
||||
prep.NUMDOC AS Documento,
|
||||
prep.DATDOC AS DataDocumento,
|
||||
prep.Expr1 AS CodNazione,
|
||||
prep.NAZIONE,
|
||||
CASE
|
||||
WHEN prep.Expr1 = 'DE' THEN 10
|
||||
WHEN prep.Expr1 = 'TH' THEN
|
||||
CASE WHEN SUBSTRING(prep.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN prep.Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(g.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(g.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(g.IDArea, 5) AS Area,
|
||||
ISNULL(g.IDCella, 1000) AS Cella,
|
||||
ISNULL(c.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(prep.DESCRDEST, 1, 2) AS DEST,
|
||||
CASE
|
||||
WHEN MAX(CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(prep.NUMDOC AS varchar(8))
|
||||
THEN 1 ELSE 0 END) = 1
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM dbo.Celle AS c
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet AS g
|
||||
ON c.ID = g.IDCella
|
||||
RIGHT OUTER JOIN dbo.py_vPreparaPackingList AS prep
|
||||
ON g.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = prep.UDC
|
||||
LEFT JOIN dbo.PyPickingListReservation AS pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
WHERE prep.StatoDocumento = 'P'
|
||||
AND prep.DATDOC > CAST((GETDATE() - 30) AS int)
|
||||
GROUP BY
|
||||
prep.Expr1,
|
||||
prep.NAZIONE,
|
||||
prep.UDC,
|
||||
prep.NUMDOC,
|
||||
prep.DATDOC,
|
||||
prep.NUMLOT,
|
||||
prep.CODICE,
|
||||
prep.DESCR,
|
||||
prep.Qta,
|
||||
g.NumeroPallet,
|
||||
g.IDMagazzino,
|
||||
g.IDArea,
|
||||
g.IDCella,
|
||||
c.Ordinamento,
|
||||
c.Corsia,
|
||||
c.Colonna,
|
||||
c.Fila,
|
||||
prep.DESCRDEST;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW dbo.py_ViewPackingListRestante
|
||||
AS
|
||||
SELECT
|
||||
Pallet, Lotto, Articolo, Descrizione, Qta, Documento, DataDocumento,
|
||||
CodNazione, NAZIONE, Stato, PalletCella, Magazzino, Area, Cella,
|
||||
Ordinamento, Ubicazione, DEST, IDStato
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE Cella <> 9999;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_PickingListPrelievoSequenza', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.py_PickingListPrelievoSequenza (
|
||||
ID bigint IDENTITY(1,1) NOT NULL
|
||||
CONSTRAINT PK_py_PickingListPrelievoSequenza PRIMARY KEY,
|
||||
Documento varchar(50) NOT NULL,
|
||||
GruppoChiave varchar(160) NOT NULL,
|
||||
GruppoEtichetta varchar(100) NOT NULL,
|
||||
Ordine int NOT NULL,
|
||||
InsUtente varchar(50) NULL,
|
||||
InsDataOra datetime2(0) NOT NULL
|
||||
CONSTRAINT DF_py_PickingListPrelievoSequenza_InsDataOra DEFAULT SYSDATETIME(),
|
||||
ModUtente varchar(50) NULL,
|
||||
ModDataOra datetime2(0) NULL,
|
||||
DelUtente varchar(50) NULL,
|
||||
DelDataOra datetime2(0) NULL,
|
||||
CONSTRAINT CK_py_PickingListPrelievoSequenza_Ordine CHECK (Ordine >= 0)
|
||||
);
|
||||
END;
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.indexes
|
||||
WHERE object_id = OBJECT_ID(N'dbo.py_PickingListPrelievoSequenza', N'U')
|
||||
AND name = N'UX_py_PickingListPrelievoSequenza_DocGruppo'
|
||||
)
|
||||
BEGIN
|
||||
CREATE UNIQUE INDEX UX_py_PickingListPrelievoSequenza_DocGruppo
|
||||
ON dbo.py_PickingListPrelievoSequenza (Documento, GruppoChiave)
|
||||
WHERE DelDataOra IS NULL;
|
||||
END;
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.indexes
|
||||
WHERE object_id = OBJECT_ID(N'dbo.py_PickingListPrelievoSequenza', N'U')
|
||||
AND name = N'UX_py_PickingListPrelievoSequenza_DocOrdine'
|
||||
)
|
||||
BEGIN
|
||||
CREATE UNIQUE INDEX UX_py_PickingListPrelievoSequenza_DocOrdine
|
||||
ON dbo.py_PickingListPrelievoSequenza (Documento, Ordine)
|
||||
WHERE DelDataOra IS NULL;
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW dbo.py_ViewPackingListPrelievo
|
||||
AS
|
||||
WITH Gruppi AS (
|
||||
SELECT
|
||||
pl.*,
|
||||
CASE
|
||||
WHEN pl.Cella = 1000 THEN 'NON_SCAFF'
|
||||
ELSE CONCAT(
|
||||
'M:', pl.Magazzino, '|A:', pl.Area, '|C:',
|
||||
LTRIM(RTRIM(CASE
|
||||
WHEN CHARINDEX(' - ', pl.Ubicazione) > 0
|
||||
THEN LEFT(pl.Ubicazione, CHARINDEX(' - ', pl.Ubicazione) - 1)
|
||||
ELSE pl.Ubicazione
|
||||
END))
|
||||
)
|
||||
END AS GruppoPrelievoChiave,
|
||||
CASE
|
||||
WHEN pl.Cella = 1000 THEN 'Non scaff.'
|
||||
ELSE LTRIM(RTRIM(CASE
|
||||
WHEN CHARINDEX(' - ', pl.Ubicazione) > 0
|
||||
THEN LEFT(pl.Ubicazione, CHARINDEX(' - ', pl.Ubicazione) - 1)
|
||||
ELSE pl.Ubicazione
|
||||
END))
|
||||
END AS GruppoPrelievo,
|
||||
CASE
|
||||
WHEN pl.Cella = 1000 THEN 0
|
||||
ELSE 1000 + ISNULL(pl.Ordinamento, 99999)
|
||||
END AS OrdineGruppoDefault
|
||||
FROM dbo.py_ViewPackingListRestante AS pl
|
||||
), Sequenza AS (
|
||||
SELECT
|
||||
g.*,
|
||||
s.Ordine AS OrdineGruppoConfigurato,
|
||||
CASE WHEN EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_PickingListPrelievoSequenza AS any_s
|
||||
WHERE any_s.Documento COLLATE Latin1_General_CI_AS =
|
||||
CAST(g.Documento AS varchar(50)) COLLATE Latin1_General_CI_AS
|
||||
AND any_s.DelDataOra IS NULL
|
||||
) THEN 1 ELSE 0 END AS HaSequenzaPersonalizzata
|
||||
FROM Gruppi AS g
|
||||
LEFT JOIN dbo.py_PickingListPrelievoSequenza AS s
|
||||
ON s.Documento COLLATE Latin1_General_CI_AS =
|
||||
CAST(g.Documento AS varchar(50)) COLLATE Latin1_General_CI_AS
|
||||
AND s.GruppoChiave COLLATE Latin1_General_CI_AS =
|
||||
g.GruppoPrelievoChiave COLLATE Latin1_General_CI_AS
|
||||
AND s.DelDataOra IS NULL
|
||||
)
|
||||
SELECT
|
||||
Sequenza.*,
|
||||
CASE
|
||||
WHEN OrdineGruppoConfigurato IS NOT NULL THEN OrdineGruppoConfigurato
|
||||
WHEN HaSequenzaPersonalizzata = 1 THEN 100000 + OrdineGruppoDefault
|
||||
ELSE OrdineGruppoDefault
|
||||
END AS OrdinePrelievoGruppo
|
||||
FROM Sequenza;
|
||||
GO
|
||||
|
||||
PRINT 'Patch cumulativa Python WMS completata.';
|
||||
GO
|
||||
193
apply_pickinglist_days_filter_patch.sql
Normal file
193
apply_pickinglist_days_filter_patch.sql
Normal file
@@ -0,0 +1,193 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Patch: intervallo giorni selezionabile in Gestione Picking List Python
|
||||
|
||||
Scopo:
|
||||
- permettere alla UI Python di caricare picking list operative degli ultimi
|
||||
10, 15, 20 o 30 giorni;
|
||||
- mantenere 10 giorni come default applicativo;
|
||||
- non escludere documenti validi con nazione di destinazione non valorizzata;
|
||||
- non modificare gli oggetti legacy usati dal programma C#.
|
||||
|
||||
Oggetti modificati:
|
||||
- dbo.py_XMag_ViewPackingList
|
||||
- dbo.py_ViewPackingListRestante
|
||||
|
||||
Nota:
|
||||
La vista legacy dbo.XMag_ViewPackingList dipende da dbo.vPreparaPackingListSAMA1,
|
||||
che contiene il filtro fisso GETDATE()-10. Per questo la vista Python viene
|
||||
ricalcolata direttamente dalle tabelle SAM con un orizzonte massimo di 30 giorni.
|
||||
La UI applica poi il filtro effettivo scelto dall'operatore.
|
||||
Il collegamento a NAZIONI e' intenzionalmente LEFT OUTER JOIN: un indirizzo
|
||||
alternativo incompleto non deve rendere invisibile l'intera picking list.
|
||||
*/
|
||||
|
||||
SET ANSI_NULLS ON;
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_XMag_ViewPackingList]
|
||||
AS
|
||||
WITH PreparaPackingList AS (
|
||||
SELECT
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) AS UDC,
|
||||
SUM(SAMA1_Xwmstest.dbo.LOTSER.QTTGIAI) AS Qta,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE AS Expr1,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE + ' ' + SAMA1_Xwmstest.dbo.NAZIONI.DESCR AS NAZIONE,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP
|
||||
FROM SAMA1_Xwmstest.dbo.BAMTES
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.NAZIONI
|
||||
ON SAMA1_Xwmstest.dbo.NAZIONI.ID = SAMA1_Xwmstest.dbo.BAMTES.IDNAZDEST
|
||||
RIGHT OUTER JOIN SAMA1_Xwmstest.dbo.LOTTIBF
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.LOTSER
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDLOTSER = SAMA1_Xwmstest.dbo.LOTSER.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.ARTICO
|
||||
ON SAMA1_Xwmstest.dbo.LOTSER.IDARTICO = SAMA1_Xwmstest.dbo.ARTICO.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.FATRIG
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDFATRIG = SAMA1_Xwmstest.dbo.FATRIG.ID
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.ID = SAMA1_Xwmstest.dbo.FATRIG.IDBAM
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.sam.EXTUC
|
||||
ON LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) = SAMA1_Xwmstest.sam.EXTUC.CODICE
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.MTRASP
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP = SAMA1_Xwmstest.dbo.MTRASP.ID
|
||||
WHERE SAMA1_Xwmstest.dbo.BAMTES.ANNDOC >= YEAR(GETDATE())
|
||||
AND SAMA1_Xwmstest.dbo.BAMTES.STATO = 'P'
|
||||
AND SAMA1_Xwmstest.dbo.BAMTES.DATDOC > CAST((GETDATE() - 30) AS int)
|
||||
AND SAMA1_Xwmstest.dbo.LOTSER.NUMLOT <> '00000000000'
|
||||
GROUP BY
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6),
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.DESCR,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE
|
||||
),
|
||||
Base AS (
|
||||
SELECT
|
||||
prep.UDC AS Pallet,
|
||||
prep.NUMLOT AS Lotto,
|
||||
prep.CODICE AS Articolo,
|
||||
prep.DESCR AS Descrizione,
|
||||
prep.Qta,
|
||||
prep.NUMDOC AS Documento,
|
||||
prep.DATDOC AS DataDocumento,
|
||||
prep.Expr1 AS CodNazione,
|
||||
prep.NAZIONE,
|
||||
CASE
|
||||
WHEN prep.Expr1 = 'DE' THEN 10
|
||||
WHEN prep.Expr1 = 'TH' THEN CASE WHEN SUBSTRING(prep.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN prep.Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(g.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(g.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(g.IDArea, 5) AS Area,
|
||||
ISNULL(g.IDCella, 1000) AS Cella,
|
||||
ISNULL(c.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(prep.DESCRDEST, 1, 2) AS DEST
|
||||
FROM dbo.Celle AS c
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet AS g
|
||||
ON c.ID = g.IDCella
|
||||
RIGHT OUTER JOIN PreparaPackingList AS prep
|
||||
ON g.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = prep.UDC
|
||||
WHERE prep.NUMLOT <> ''
|
||||
GROUP BY
|
||||
prep.Expr1,
|
||||
prep.NAZIONE,
|
||||
prep.UDC,
|
||||
prep.NUMDOC,
|
||||
prep.DATDOC,
|
||||
prep.NUMLOT,
|
||||
prep.CODICE,
|
||||
prep.DESCR,
|
||||
prep.Qta,
|
||||
g.NumeroPallet,
|
||||
g.IDMagazzino,
|
||||
g.IDArea,
|
||||
g.IDCella,
|
||||
c.Ordinamento,
|
||||
c.Corsia,
|
||||
c.Colonna,
|
||||
c.Fila,
|
||||
prep.DESCRDEST
|
||||
)
|
||||
SELECT TOP 10000
|
||||
Base.Pallet,
|
||||
Base.Lotto,
|
||||
Base.Articolo,
|
||||
Base.Descrizione,
|
||||
Base.Qta,
|
||||
Base.Documento,
|
||||
Base.DataDocumento,
|
||||
Base.CodNazione,
|
||||
Base.NAZIONE,
|
||||
Base.Stato,
|
||||
Base.PalletCella,
|
||||
Base.Magazzino,
|
||||
Base.Area,
|
||||
Base.Cella,
|
||||
Base.Ordinamento,
|
||||
Base.Ubicazione,
|
||||
Base.DEST,
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM Base
|
||||
LEFT JOIN dbo.PyPickingListReservation AS pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
Base.Documento,
|
||||
Base.Ordinamento;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_ViewPackingListRestante]
|
||||
AS
|
||||
SELECT
|
||||
Pallet,
|
||||
Lotto,
|
||||
Articolo,
|
||||
Descrizione,
|
||||
Qta,
|
||||
Documento,
|
||||
DataDocumento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
PalletCella,
|
||||
Magazzino,
|
||||
Area,
|
||||
Cella,
|
||||
Ordinamento,
|
||||
Ubicazione,
|
||||
DEST,
|
||||
IDStato
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE Cella <> 9999;
|
||||
GO
|
||||
220
apply_pickinglist_optional_destination_country_patch.sql
Normal file
220
apply_pickinglist_optional_destination_country_patch.sql
Normal file
@@ -0,0 +1,220 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Patch Python WMS: picking list con nazione di destinazione non valorizzata
|
||||
|
||||
Problema risolto:
|
||||
- una testata BAMTES valida puo' avere IDNAZDEST NULL, in particolare quando
|
||||
viene scelto un indirizzo di destinazione alternativo privo di nazione;
|
||||
- l'INNER JOIN a SAMA1_Xwmstest.dbo.NAZIONI eliminava l'intero documento;
|
||||
- la picking list non compariva quindi in Gestione Picking List ne' nello
|
||||
storico Python, anche se stato, data, righe, lotti e UDC erano validi.
|
||||
|
||||
Strategia:
|
||||
- il collegamento BAMTES -> NAZIONI diventa LEFT OUTER JOIN;
|
||||
- non viene inventato alcun codice nazione: Expr1 e NAZIONE restano NULL;
|
||||
- il CASE gia' esistente assegna in questo caso lo Stato generico 4;
|
||||
- nessun oggetto legacy usato dal programma C# viene modificato.
|
||||
|
||||
Oggetti Python modificati:
|
||||
- dbo.py_vPreparaPackingListSAMA1 (storico e base condivisa);
|
||||
- dbo.py_XMag_ViewPackingList (gestione operativa).
|
||||
*/
|
||||
|
||||
SET XACT_ABORT ON;
|
||||
SET ANSI_NULLS ON;
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW dbo.py_vPreparaPackingListSAMA1
|
||||
AS
|
||||
SELECT
|
||||
ls.NUMLOT,
|
||||
a.CODICE,
|
||||
fr.DESCR,
|
||||
LEFT(ls.NUMSER, 6) AS UDC,
|
||||
SUM(ls.QTTGIAI) AS Qta,
|
||||
bt.NUMDOC,
|
||||
bt.DATDOC,
|
||||
bt.ID,
|
||||
bt.DESCRDEST,
|
||||
bt.STATO AS StatoDocumento,
|
||||
n.CODICE AS Expr1,
|
||||
mt.CODICE + ' ' + n.DESCR AS NAZIONE,
|
||||
bt.IDMTRASP
|
||||
FROM SAMA1_Xwmstest.dbo.BAMTES AS bt
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.FATRIG AS fr
|
||||
ON fr.IDBAM = bt.ID
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.LOTTIBF AS lb
|
||||
ON lb.IDFATRIG = fr.ID
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.LOTSER AS ls
|
||||
ON ls.ID = lb.IDLOTSER
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.ARTICO AS a
|
||||
ON a.ID = ls.IDARTICO
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.sam.EXTUC AS uc
|
||||
ON uc.CODICE = LEFT(ls.NUMSER, 6)
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.MTRASP AS mt
|
||||
ON mt.ID = bt.IDMTRASP
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.NAZIONI AS n
|
||||
ON n.ID = bt.IDNAZDEST
|
||||
WHERE bt.ANNDOC >= YEAR(GETDATE())
|
||||
AND bt.STATO IN ('P', 'D')
|
||||
AND ls.NUMLOT <> '00000000000'
|
||||
GROUP BY
|
||||
ls.NUMLOT,
|
||||
a.CODICE,
|
||||
fr.DESCR,
|
||||
LEFT(ls.NUMSER, 6),
|
||||
bt.NUMDOC,
|
||||
bt.DATDOC,
|
||||
bt.ID,
|
||||
bt.DESCRDEST,
|
||||
bt.STATO,
|
||||
n.CODICE,
|
||||
n.DESCR,
|
||||
bt.IDMTRASP,
|
||||
mt.CODICE;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW dbo.py_XMag_ViewPackingList
|
||||
AS
|
||||
WITH PreparaPackingList AS (
|
||||
SELECT
|
||||
ls.NUMLOT,
|
||||
a.CODICE,
|
||||
fr.DESCR,
|
||||
LEFT(ls.NUMSER, 6) AS UDC,
|
||||
SUM(ls.QTTGIAI) AS Qta,
|
||||
bt.NUMDOC,
|
||||
bt.DATDOC,
|
||||
bt.ID,
|
||||
bt.DESCRDEST,
|
||||
n.CODICE AS Expr1,
|
||||
mt.CODICE + ' ' + n.DESCR AS NAZIONE,
|
||||
bt.IDMTRASP
|
||||
FROM SAMA1_Xwmstest.dbo.BAMTES AS bt
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.FATRIG AS fr
|
||||
ON fr.IDBAM = bt.ID
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.LOTTIBF AS lb
|
||||
ON lb.IDFATRIG = fr.ID
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.LOTSER AS ls
|
||||
ON ls.ID = lb.IDLOTSER
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.ARTICO AS a
|
||||
ON a.ID = ls.IDARTICO
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.sam.EXTUC AS uc
|
||||
ON uc.CODICE = LEFT(ls.NUMSER, 6)
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.MTRASP AS mt
|
||||
ON mt.ID = bt.IDMTRASP
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.NAZIONI AS n
|
||||
ON n.ID = bt.IDNAZDEST
|
||||
WHERE bt.ANNDOC >= YEAR(GETDATE())
|
||||
AND bt.STATO = 'P'
|
||||
AND bt.DATDOC > CAST((GETDATE() - 30) AS int)
|
||||
AND ls.NUMLOT <> '00000000000'
|
||||
GROUP BY
|
||||
ls.NUMLOT,
|
||||
a.CODICE,
|
||||
fr.DESCR,
|
||||
LEFT(ls.NUMSER, 6),
|
||||
bt.NUMDOC,
|
||||
bt.DATDOC,
|
||||
bt.ID,
|
||||
bt.DESCRDEST,
|
||||
n.CODICE,
|
||||
n.DESCR,
|
||||
bt.IDMTRASP,
|
||||
mt.CODICE
|
||||
),
|
||||
Base AS (
|
||||
SELECT
|
||||
prep.UDC AS Pallet,
|
||||
prep.NUMLOT AS Lotto,
|
||||
prep.CODICE AS Articolo,
|
||||
prep.DESCR AS Descrizione,
|
||||
prep.Qta,
|
||||
prep.NUMDOC AS Documento,
|
||||
prep.DATDOC AS DataDocumento,
|
||||
prep.Expr1 AS CodNazione,
|
||||
prep.NAZIONE,
|
||||
CASE
|
||||
WHEN prep.Expr1 = 'DE' THEN 10
|
||||
WHEN prep.Expr1 = 'TH' THEN
|
||||
CASE WHEN SUBSTRING(prep.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN prep.Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(g.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(g.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(g.IDArea, 5) AS Area,
|
||||
ISNULL(g.IDCella, 1000) AS Cella,
|
||||
ISNULL(c.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(prep.DESCRDEST, 1, 2) AS DEST
|
||||
FROM dbo.Celle AS c
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet AS g
|
||||
ON c.ID = g.IDCella
|
||||
RIGHT OUTER JOIN PreparaPackingList AS prep
|
||||
ON g.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = prep.UDC
|
||||
WHERE prep.NUMLOT <> ''
|
||||
GROUP BY
|
||||
prep.Expr1,
|
||||
prep.NAZIONE,
|
||||
prep.UDC,
|
||||
prep.NUMDOC,
|
||||
prep.DATDOC,
|
||||
prep.NUMLOT,
|
||||
prep.CODICE,
|
||||
prep.DESCR,
|
||||
prep.Qta,
|
||||
g.NumeroPallet,
|
||||
g.IDMagazzino,
|
||||
g.IDArea,
|
||||
g.IDCella,
|
||||
c.Ordinamento,
|
||||
c.Corsia,
|
||||
c.Colonna,
|
||||
c.Fila,
|
||||
prep.DESCRDEST
|
||||
)
|
||||
SELECT TOP (10000)
|
||||
Base.Pallet,
|
||||
Base.Lotto,
|
||||
Base.Articolo,
|
||||
Base.Descrizione,
|
||||
Base.Qta,
|
||||
Base.Documento,
|
||||
Base.DataDocumento,
|
||||
Base.CodNazione,
|
||||
Base.NAZIONE,
|
||||
Base.Stato,
|
||||
Base.PalletCella,
|
||||
Base.Magazzino,
|
||||
Base.Area,
|
||||
Base.Cella,
|
||||
Base.Ordinamento,
|
||||
Base.Ubicazione,
|
||||
Base.DEST,
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM Base
|
||||
LEFT JOIN dbo.PyPickingListReservation AS pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
Base.Documento,
|
||||
Base.Ordinamento;
|
||||
GO
|
||||
|
||||
PRINT 'Patch nazione destinazione opzionale applicata alle viste Python.';
|
||||
GO
|
||||
139
apply_pickinglist_sequence_patch.sql
Normal file
139
apply_pickinglist_sequence_patch.sql
Normal file
@@ -0,0 +1,139 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Patch Python WMS: ordine di prelievo per singola picking list
|
||||
|
||||
Prerequisito:
|
||||
- eseguire prima apply_pickinglist_days_filter_patch.sql, che espone
|
||||
DataDocumento nelle viste operative Python.
|
||||
|
||||
Effetti:
|
||||
- crea una tabella Python-only con la sequenza personalizzata per Documento;
|
||||
- crea una vista Python-only con l'ordine effettivo condiviso da backoffice e barcode;
|
||||
- senza configurazione applica il default: Non scaff. prima degli scaffali;
|
||||
- con configurazione applica i gruppi scelti e accoda in modo sicuro quelli mancanti;
|
||||
- non modifica tabelle, viste o stored procedure legacy usate dal programma C#.
|
||||
*/
|
||||
|
||||
SET ANSI_NULLS ON;
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_PickingListPrelievoSequenza', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.py_PickingListPrelievoSequenza (
|
||||
ID bigint IDENTITY(1,1) NOT NULL
|
||||
CONSTRAINT PK_py_PickingListPrelievoSequenza PRIMARY KEY,
|
||||
Documento varchar(50) NOT NULL,
|
||||
GruppoChiave varchar(160) NOT NULL,
|
||||
GruppoEtichetta varchar(100) NOT NULL,
|
||||
Ordine int NOT NULL,
|
||||
InsUtente varchar(50) NULL,
|
||||
InsDataOra datetime2(0) NOT NULL
|
||||
CONSTRAINT DF_py_PickingListPrelievoSequenza_InsDataOra DEFAULT SYSDATETIME(),
|
||||
ModUtente varchar(50) NULL,
|
||||
ModDataOra datetime2(0) NULL,
|
||||
DelUtente varchar(50) NULL,
|
||||
DelDataOra datetime2(0) NULL,
|
||||
CONSTRAINT CK_py_PickingListPrelievoSequenza_Ordine CHECK (Ordine >= 0)
|
||||
);
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE object_id = OBJECT_ID(N'dbo.py_PickingListPrelievoSequenza', N'U')
|
||||
AND name = N'UX_py_PickingListPrelievoSequenza_DocGruppo'
|
||||
)
|
||||
BEGIN
|
||||
CREATE UNIQUE INDEX UX_py_PickingListPrelievoSequenza_DocGruppo
|
||||
ON dbo.py_PickingListPrelievoSequenza (Documento, GruppoChiave)
|
||||
WHERE DelDataOra IS NULL;
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE object_id = OBJECT_ID(N'dbo.py_PickingListPrelievoSequenza', N'U')
|
||||
AND name = N'UX_py_PickingListPrelievoSequenza_DocOrdine'
|
||||
)
|
||||
BEGIN
|
||||
CREATE UNIQUE INDEX UX_py_PickingListPrelievoSequenza_DocOrdine
|
||||
ON dbo.py_PickingListPrelievoSequenza (Documento, Ordine)
|
||||
WHERE DelDataOra IS NULL;
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW dbo.py_ViewPackingListPrelievo
|
||||
AS
|
||||
WITH Gruppi AS (
|
||||
SELECT
|
||||
pl.*,
|
||||
CASE
|
||||
WHEN pl.Cella = 1000 THEN 'NON_SCAFF'
|
||||
ELSE CONCAT(
|
||||
'M:', pl.Magazzino,
|
||||
'|A:', pl.Area,
|
||||
'|C:',
|
||||
LTRIM(RTRIM(
|
||||
CASE
|
||||
WHEN CHARINDEX(' - ', pl.Ubicazione) > 0
|
||||
THEN LEFT(pl.Ubicazione, CHARINDEX(' - ', pl.Ubicazione) - 1)
|
||||
ELSE pl.Ubicazione
|
||||
END
|
||||
))
|
||||
)
|
||||
END AS GruppoPrelievoChiave,
|
||||
CASE
|
||||
WHEN pl.Cella = 1000 THEN 'Non scaff.'
|
||||
ELSE LTRIM(RTRIM(
|
||||
CASE
|
||||
WHEN CHARINDEX(' - ', pl.Ubicazione) > 0
|
||||
THEN LEFT(pl.Ubicazione, CHARINDEX(' - ', pl.Ubicazione) - 1)
|
||||
ELSE pl.Ubicazione
|
||||
END
|
||||
))
|
||||
END AS GruppoPrelievo,
|
||||
CASE
|
||||
WHEN pl.Cella = 1000 THEN 0
|
||||
ELSE 1000 + ISNULL(pl.Ordinamento, 99999)
|
||||
END AS OrdineGruppoDefault
|
||||
FROM dbo.py_ViewPackingListRestante AS pl
|
||||
), Sequenza AS (
|
||||
SELECT
|
||||
g.*,
|
||||
s.Ordine AS OrdineGruppoConfigurato,
|
||||
CASE
|
||||
WHEN EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_PickingListPrelievoSequenza AS any_s
|
||||
WHERE any_s.Documento COLLATE Latin1_General_CI_AS =
|
||||
CAST(g.Documento AS varchar(50)) COLLATE Latin1_General_CI_AS
|
||||
AND any_s.DelDataOra IS NULL
|
||||
) THEN 1
|
||||
ELSE 0
|
||||
END AS HaSequenzaPersonalizzata
|
||||
FROM Gruppi AS g
|
||||
LEFT JOIN dbo.py_PickingListPrelievoSequenza AS s
|
||||
ON s.Documento COLLATE Latin1_General_CI_AS =
|
||||
CAST(g.Documento AS varchar(50)) COLLATE Latin1_General_CI_AS
|
||||
AND s.GruppoChiave COLLATE Latin1_General_CI_AS =
|
||||
g.GruppoPrelievoChiave COLLATE Latin1_General_CI_AS
|
||||
AND s.DelDataOra IS NULL
|
||||
)
|
||||
SELECT
|
||||
Sequenza.*,
|
||||
CASE
|
||||
WHEN OrdineGruppoConfigurato IS NOT NULL THEN OrdineGruppoConfigurato
|
||||
WHEN HaSequenzaPersonalizzata = 1 THEN 100000 + OrdineGruppoDefault
|
||||
ELSE OrdineGruppoDefault
|
||||
END AS OrdinePrelievoGruppo
|
||||
FROM Sequenza;
|
||||
GO
|
||||
|
||||
PRINT 'Patch sequenza prelievo Python applicata.';
|
||||
GO
|
||||
411
apply_plist_reservation_patch.sql
Normal file
411
apply_plist_reservation_patch.sql
Normal file
@@ -0,0 +1,411 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
Patch deploy per i test sul campo:
|
||||
- salva le definizioni correnti degli oggetti legacy coinvolti
|
||||
- applica la nuova logica di prenotazione plist a livello documento
|
||||
|
||||
Oggetti salvati:
|
||||
- dbo.sp_xExePackingListPallet
|
||||
- dbo.XMag_ViewPackingList
|
||||
- dbo.sp_xExePackingListPalletPrenota
|
||||
- dbo.sp_ControllaPrenotazionePackingListPalletNew
|
||||
|
||||
Oggetti creati/usati dalla patch:
|
||||
- dbo.WarehouseObjectBackup
|
||||
- dbo.PickingListReservation
|
||||
|
||||
Nota:
|
||||
- la tabella dbo.PickingListReservation può restare anche dopo il rollback
|
||||
perché il vecchio codice non la usa.
|
||||
*/
|
||||
|
||||
DECLARE @BackupTag varchar(64) = 'plist_reservation_fix_alpha2';
|
||||
|
||||
IF OBJECT_ID(N'dbo.WarehouseObjectBackup', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.WarehouseObjectBackup (
|
||||
BackupTag varchar(64) NOT NULL,
|
||||
ObjectName sysname NOT NULL,
|
||||
ObjectType varchar(16) NOT NULL,
|
||||
Definition nvarchar(max) NOT NULL,
|
||||
SavedAt datetime NOT NULL CONSTRAINT DF_WarehouseObjectBackup_SavedAt DEFAULT(GETDATE()),
|
||||
CONSTRAINT PK_WarehouseObjectBackup PRIMARY KEY CLUSTERED (BackupTag, ObjectName)
|
||||
);
|
||||
END;
|
||||
GO
|
||||
|
||||
DECLARE @BackupTag varchar(64) = 'plist_reservation_fix_alpha2';
|
||||
|
||||
;WITH Targets AS (
|
||||
SELECT N'dbo.sp_xExePackingListPallet' AS ObjectName, 'PROCEDURE' AS ObjectType
|
||||
UNION ALL SELECT N'dbo.XMag_ViewPackingList', 'VIEW'
|
||||
UNION ALL SELECT N'dbo.sp_xExePackingListPalletPrenota', 'PROCEDURE'
|
||||
UNION ALL SELECT N'dbo.sp_ControllaPrenotazionePackingListPalletNew', 'PROCEDURE'
|
||||
)
|
||||
INSERT INTO dbo.WarehouseObjectBackup (BackupTag, ObjectName, ObjectType, Definition)
|
||||
SELECT
|
||||
@BackupTag,
|
||||
t.ObjectName,
|
||||
t.ObjectType,
|
||||
sm.[definition]
|
||||
FROM Targets t
|
||||
INNER JOIN sys.sql_modules sm
|
||||
ON sm.object_id = OBJECT_ID(t.ObjectName)
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.WarehouseObjectBackup b
|
||||
WHERE b.BackupTag = @BackupTag
|
||||
AND b.ObjectName = t.ObjectName
|
||||
);
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
Patch prenotazione Picking List a livello documento
|
||||
|
||||
Obiettivo:
|
||||
- rendere esclusiva la prenotazione di una sola picking list
|
||||
- mantenere la stored con lo stesso nome:
|
||||
dbo.sp_xExePackingListPallet
|
||||
- introdurre una sorgente di verità per documento prenotato:
|
||||
dbo.PickingListReservation
|
||||
- far leggere XMag_ViewPackingList.IDStato da tale stato
|
||||
e non più soltanto da Celle.IDStato
|
||||
============================================================ */
|
||||
|
||||
IF OBJECT_ID(N'dbo.PickingListReservation', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [dbo].[PickingListReservation](
|
||||
[ID] [tinyint] NOT NULL,
|
||||
[Documento] [varchar](8) NULL,
|
||||
[IDOperatore] [int] NULL,
|
||||
[ModUtente] [varchar](50) NULL,
|
||||
[ModDataOra] [datetime] NULL,
|
||||
CONSTRAINT [PK_PickingListReservation] PRIMARY KEY CLUSTERED ([ID] ASC),
|
||||
CONSTRAINT [CK_PickingListReservation_Singleton] CHECK ([ID] = 1)
|
||||
) ON [PRIMARY];
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[sp_xExePackingListPallet]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@Azione char(1) = 'P',
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
DECLARE @DocumentoAttivo varchar(8) = NULL;
|
||||
DECLARE @Description varchar(255) = '';
|
||||
DECLARE @Message varchar(255) = '';
|
||||
DECLARE @IDResult int = 0;
|
||||
DECLARE @ID int = 0;
|
||||
|
||||
SELECT @Nominativo = [Login]
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
IF @Azione NOT IN ('P', 'S')
|
||||
BEGIN
|
||||
SET @RC = -10;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
SET @RC = -20;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END;
|
||||
|
||||
SELECT @DocumentoAttivo = NULLIF(LTRIM(RTRIM(Documento)), '')
|
||||
FROM dbo.PickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
DECLARE @TargetCelle TABLE (
|
||||
IDCella int PRIMARY KEY
|
||||
);
|
||||
|
||||
INSERT INTO @TargetCelle (IDCella)
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL;
|
||||
|
||||
IF @Azione = 'P'
|
||||
BEGIN
|
||||
IF @DocumentoAttivo = @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE ISNULL(c.IDStato, 0) <> 0;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PickingListReservation
|
||||
SET Documento = @Documento,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
SELECT TOP 1 @Description = NAZIONE
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento;
|
||||
|
||||
EXEC dbo.sp_LogPackingList
|
||||
@ID = @ID,
|
||||
@Code = @Documento,
|
||||
@Description = @Description,
|
||||
@Message = @Message OUTPUT,
|
||||
@IDResult = @IDResult OUTPUT;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF @Azione = 'S'
|
||||
BEGIN
|
||||
IF ISNULL(@DocumentoAttivo, '') <> @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[XMag_ViewPackingList]
|
||||
AS
|
||||
WITH Base AS (
|
||||
SELECT
|
||||
dbo.vPreparaPackingList.UDC AS Pallet,
|
||||
dbo.vPreparaPackingList.NUMLOT AS Lotto,
|
||||
dbo.vPreparaPackingList.CODICE AS Articolo,
|
||||
dbo.vPreparaPackingList.DESCR AS Descrizione,
|
||||
dbo.vPreparaPackingList.Qta,
|
||||
dbo.vPreparaPackingList.NUMDOC AS Documento,
|
||||
dbo.vPreparaPackingList.Expr1 AS CodNazione,
|
||||
dbo.vPreparaPackingList.NAZIONE,
|
||||
CASE
|
||||
WHEN Expr1 = 'DE' THEN 10
|
||||
WHEN Expr1 = 'TH' THEN CASE WHEN SUBSTRING(dbo.vPreparaPackingList.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.IDArea, 5) AS Area,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.IDCella, 1000) AS Cella,
|
||||
ISNULL(dbo.Celle.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(dbo.Celle.Corsia + ' - ' + dbo.Celle.Colonna + ' - ' + dbo.Celle.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(dbo.vPreparaPackingList.DESCRDEST, 1, 2) AS DEST
|
||||
FROM dbo.Celle
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet
|
||||
ON dbo.Celle.ID = dbo.XMag_GiacenzaPallet.IDCella
|
||||
RIGHT OUTER JOIN dbo.vPreparaPackingList
|
||||
ON dbo.XMag_GiacenzaPallet.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = dbo.vPreparaPackingList.UDC
|
||||
GROUP BY
|
||||
dbo.vPreparaPackingList.Expr1,
|
||||
dbo.vPreparaPackingList.NAZIONE,
|
||||
dbo.vPreparaPackingList.UDC,
|
||||
dbo.vPreparaPackingList.NUMDOC,
|
||||
dbo.vPreparaPackingList.NUMLOT,
|
||||
dbo.vPreparaPackingList.CODICE,
|
||||
dbo.vPreparaPackingList.DESCR,
|
||||
dbo.vPreparaPackingList.Qta,
|
||||
dbo.XMag_GiacenzaPallet.NumeroPallet,
|
||||
dbo.XMag_GiacenzaPallet.IDMagazzino,
|
||||
dbo.XMag_GiacenzaPallet.IDArea,
|
||||
dbo.XMag_GiacenzaPallet.IDCella,
|
||||
dbo.Celle.Ordinamento,
|
||||
dbo.Celle.Corsia,
|
||||
dbo.Celle.Colonna,
|
||||
dbo.Celle.Fila,
|
||||
dbo.vPreparaPackingList.DESCRDEST
|
||||
)
|
||||
SELECT TOP 10000
|
||||
Base.Pallet,
|
||||
Base.Lotto,
|
||||
Base.Articolo,
|
||||
Base.Descrizione,
|
||||
Base.Qta,
|
||||
Base.Documento,
|
||||
Base.CodNazione,
|
||||
Base.NAZIONE,
|
||||
Base.Stato,
|
||||
Base.PalletCella,
|
||||
Base.Magazzino,
|
||||
Base.Area,
|
||||
Base.Cella,
|
||||
Base.Ordinamento,
|
||||
Base.Ubicazione,
|
||||
Base.DEST,
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM Base
|
||||
LEFT JOIN dbo.PickingListReservation pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
Base.Documento,
|
||||
Base.Ordinamento;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[sp_xExePackingListPalletPrenota]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
|
||||
SELECT @Nominativo = LOGIN
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE c.ID IN (
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL
|
||||
);
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[sp_ControllaPrenotazionePackingListPalletNew]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @Documento varchar(8) = NULL;
|
||||
DECLARE @IDOperatore int = 0;
|
||||
DECLARE @Nominativo varchar(50) = 'SYSTEM';
|
||||
DECLARE @RC int = 0;
|
||||
|
||||
SELECT
|
||||
@Documento = NULLIF(LTRIM(RTRIM(Documento)), ''),
|
||||
@IDOperatore = ISNULL(IDOperatore, 0),
|
||||
@Nominativo = ISNULL(NULLIF(LTRIM(RTRIM(ModUtente)), ''), 'SYSTEM')
|
||||
FROM dbo.PickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
IF ISNULL(@Documento, '') = ''
|
||||
RETURN;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
UPDATE dbo.PickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
IF @IDOperatore <= 0
|
||||
BEGIN
|
||||
SELECT TOP 1 @IDOperatore = ID
|
||||
FROM dbo.Operatori
|
||||
WHERE LOGIN = @Nominativo;
|
||||
END;
|
||||
|
||||
EXEC dbo.sp_xExePackingListPalletPrenota
|
||||
@IDOperatore = @IDOperatore,
|
||||
@Documento = @Documento,
|
||||
@RC = @RC OUTPUT;
|
||||
END;
|
||||
GO
|
||||
331
apply_python_parallel_pickinglist_patch.sql
Normal file
331
apply_python_parallel_pickinglist_patch.sql
Normal file
@@ -0,0 +1,331 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
Patch parallela per usare C# e Python contemporaneamente.
|
||||
|
||||
Questa patch NON modifica gli oggetti legacy usati dal C#.
|
||||
|
||||
Il C# continua a usare:
|
||||
- dbo.XMag_ViewPackingList
|
||||
- dbo.ViewPackingListRestante
|
||||
- dbo.sp_xExePackingListPallet
|
||||
- dbo.sp_xExePackingListPalletPrenota
|
||||
- dbo.sp_ControllaPrenotazionePackingListPalletNew
|
||||
|
||||
Il Python usa invece:
|
||||
- dbo.py_XMag_ViewPackingList
|
||||
- dbo.py_ViewPackingListRestante
|
||||
- dbo.py_sp_xExePackingListPallet
|
||||
- dbo.py_sp_xExePackingListPalletPrenota
|
||||
- dbo.py_sp_ControllaPrenotazionePackingListPalletNew
|
||||
- dbo.PyPickingListReservation
|
||||
*/
|
||||
|
||||
IF OBJECT_ID(N'dbo.PyPickingListReservation', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [dbo].[PyPickingListReservation](
|
||||
[ID] [tinyint] NOT NULL,
|
||||
[Documento] [varchar](8) NULL,
|
||||
[IDOperatore] [int] NULL,
|
||||
[ModUtente] [varchar](50) NULL,
|
||||
[ModDataOra] [datetime] NULL,
|
||||
CONSTRAINT [PK_PyPickingListReservation] PRIMARY KEY CLUSTERED ([ID] ASC),
|
||||
CONSTRAINT [CK_PyPickingListReservation_Singleton] CHECK ([ID] = 1)
|
||||
) ON [PRIMARY];
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PyPickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PyPickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_XMag_ViewPackingList]
|
||||
AS
|
||||
SELECT TOP 10000
|
||||
legacy.Pallet,
|
||||
legacy.Lotto,
|
||||
legacy.Articolo,
|
||||
legacy.Descrizione,
|
||||
legacy.Qta,
|
||||
legacy.Documento,
|
||||
legacy.CodNazione,
|
||||
legacy.NAZIONE,
|
||||
legacy.Stato,
|
||||
legacy.PalletCella,
|
||||
legacy.Magazzino,
|
||||
legacy.Area,
|
||||
legacy.Cella,
|
||||
legacy.Ordinamento,
|
||||
legacy.Ubicazione,
|
||||
legacy.DEST,
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(legacy.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM dbo.XMag_ViewPackingList legacy
|
||||
LEFT JOIN dbo.PyPickingListReservation pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(legacy.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
legacy.Documento,
|
||||
legacy.Ordinamento;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_ViewPackingListRestante]
|
||||
AS
|
||||
SELECT
|
||||
Pallet,
|
||||
Lotto,
|
||||
Articolo,
|
||||
Descrizione,
|
||||
Qta,
|
||||
Documento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
PalletCella,
|
||||
Magazzino,
|
||||
Area,
|
||||
Cella,
|
||||
Ordinamento,
|
||||
Ubicazione,
|
||||
DEST,
|
||||
IDStato
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE Cella <> 9999;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[py_sp_xExePackingListPallet]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@Azione char(1) = 'P',
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
DECLARE @DocumentoAttivo varchar(8) = NULL;
|
||||
DECLARE @Description varchar(255) = '';
|
||||
DECLARE @Message varchar(255) = '';
|
||||
DECLARE @IDResult int = 0;
|
||||
DECLARE @ID int = 0;
|
||||
|
||||
SELECT @Nominativo = [Login]
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
IF @Azione NOT IN ('P', 'S')
|
||||
BEGIN
|
||||
SET @RC = -10;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
SET @RC = -20;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PyPickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PyPickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END;
|
||||
|
||||
SELECT @DocumentoAttivo = NULLIF(LTRIM(RTRIM(Documento)), '')
|
||||
FROM dbo.PyPickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
DECLARE @TargetCelle TABLE (
|
||||
IDCella int PRIMARY KEY
|
||||
);
|
||||
|
||||
INSERT INTO @TargetCelle (IDCella)
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL;
|
||||
|
||||
IF @Azione = 'P'
|
||||
BEGIN
|
||||
IF @DocumentoAttivo = @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE ISNULL(c.IDStato, 0) <> 0;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PyPickingListReservation
|
||||
SET Documento = @Documento,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
SELECT TOP 1 @Description = NAZIONE
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento;
|
||||
|
||||
EXEC dbo.sp_LogPackingList
|
||||
@ID = @ID,
|
||||
@Code = @Documento,
|
||||
@Description = @Description,
|
||||
@Message = @Message OUTPUT,
|
||||
@IDResult = @IDResult OUTPUT;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF @Azione = 'S'
|
||||
BEGIN
|
||||
IF ISNULL(@DocumentoAttivo, '') <> @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PyPickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[py_sp_xExePackingListPalletPrenota]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
|
||||
SELECT @Nominativo = LOGIN
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE c.ID IN (
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.py_ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL
|
||||
);
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[py_sp_ControllaPrenotazionePackingListPalletNew]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @Documento varchar(8) = NULL;
|
||||
DECLARE @IDOperatore int = 0;
|
||||
DECLARE @Nominativo varchar(50) = 'SYSTEM';
|
||||
DECLARE @RC int = 0;
|
||||
|
||||
SELECT
|
||||
@Documento = NULLIF(LTRIM(RTRIM(Documento)), ''),
|
||||
@IDOperatore = ISNULL(IDOperatore, 0),
|
||||
@Nominativo = ISNULL(NULLIF(LTRIM(RTRIM(ModUtente)), ''), 'SYSTEM')
|
||||
FROM dbo.PyPickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
IF ISNULL(@Documento, '') = ''
|
||||
RETURN;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
UPDATE dbo.PyPickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
IF @IDOperatore <= 0
|
||||
BEGIN
|
||||
SELECT TOP 1 @IDOperatore = ID
|
||||
FROM dbo.Operatori
|
||||
WHERE LOGIN = @Nominativo;
|
||||
END;
|
||||
|
||||
EXEC dbo.py_sp_xExePackingListPalletPrenota
|
||||
@IDOperatore = @IDOperatore,
|
||||
@Documento = @Documento,
|
||||
@RC = @RC OUTPUT;
|
||||
END;
|
||||
GO
|
||||
161
apply_python_pickinglist_history_views.sql
Normal file
161
apply_python_pickinglist_history_views.sql
Normal file
@@ -0,0 +1,161 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Patch SQL - viste storiche picking list per ramo Python
|
||||
|
||||
Obiettivo:
|
||||
- creare un ramo di lettura storico completamente separato dalle viste C#
|
||||
- non modificare dbo.vPreparaPackingListSAMA1
|
||||
- non modificare dbo.vPreparaPackingList
|
||||
- non modificare dbo.XMag_ViewPackingList
|
||||
- non modificare stored procedure C#
|
||||
|
||||
La form Python "Storico Picking List" legge da dbo.py_XMag_ViewPackingListStorico.
|
||||
*/
|
||||
|
||||
SET ANSI_NULLS ON;
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_vPreparaPackingListSAMA1]
|
||||
AS
|
||||
SELECT
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) AS UDC,
|
||||
SUM(SAMA1_Xwmstest.dbo.LOTSER.QTTGIAI) AS Qta,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.STATO AS StatoDocumento,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE AS Expr1,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE + ' ' + SAMA1_Xwmstest.dbo.NAZIONI.DESCR AS NAZIONE,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP
|
||||
FROM SAMA1_Xwmstest.dbo.NAZIONI
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.BAMTES
|
||||
ON SAMA1_Xwmstest.dbo.NAZIONI.ID = SAMA1_Xwmstest.dbo.BAMTES.IDNAZDEST
|
||||
RIGHT OUTER JOIN SAMA1_Xwmstest.dbo.LOTTIBF
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.LOTSER
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDLOTSER = SAMA1_Xwmstest.dbo.LOTSER.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.ARTICO
|
||||
ON SAMA1_Xwmstest.dbo.LOTSER.IDARTICO = SAMA1_Xwmstest.dbo.ARTICO.ID
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.FATRIG
|
||||
ON SAMA1_Xwmstest.dbo.LOTTIBF.IDFATRIG = SAMA1_Xwmstest.dbo.FATRIG.ID
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.ID = SAMA1_Xwmstest.dbo.FATRIG.IDBAM
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.sam.EXTUC
|
||||
ON LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6) = SAMA1_Xwmstest.sam.EXTUC.CODICE
|
||||
LEFT OUTER JOIN SAMA1_Xwmstest.dbo.MTRASP
|
||||
ON SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP = SAMA1_Xwmstest.dbo.MTRASP.ID
|
||||
WHERE
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ANNDOC >= YEAR(GETDATE())
|
||||
AND SAMA1_Xwmstest.dbo.BAMTES.STATO IN ('P', 'D')
|
||||
AND SAMA1_Xwmstest.dbo.LOTSER.NUMLOT <> '00000000000'
|
||||
GROUP BY
|
||||
SAMA1_Xwmstest.dbo.LOTSER.NUMLOT,
|
||||
SAMA1_Xwmstest.dbo.ARTICO.CODICE,
|
||||
SAMA1_Xwmstest.dbo.FATRIG.DESCR,
|
||||
LEFT(SAMA1_Xwmstest.dbo.LOTSER.NUMSER, 6),
|
||||
SAMA1_Xwmstest.dbo.BAMTES.NUMDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DATDOC,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.ID,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.DESCRDEST,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.STATO,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.CODICE,
|
||||
SAMA1_Xwmstest.dbo.NAZIONI.DESCR,
|
||||
SAMA1_Xwmstest.dbo.BAMTES.IDMTRASP,
|
||||
SAMA1_Xwmstest.dbo.MTRASP.CODICE;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_vPreparaPackingList]
|
||||
AS
|
||||
SELECT
|
||||
NUMLOT,
|
||||
CODICE,
|
||||
DESCR,
|
||||
UDC,
|
||||
Qta,
|
||||
NUMDOC,
|
||||
DATDOC,
|
||||
ID,
|
||||
DESCRDEST,
|
||||
StatoDocumento,
|
||||
Expr1,
|
||||
NAZIONE
|
||||
FROM dbo.py_vPreparaPackingListSAMA1
|
||||
WHERE NUMLOT <> '';
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_XMag_ViewPackingListStorico]
|
||||
AS
|
||||
SELECT TOP (100000)
|
||||
prep.UDC AS Pallet,
|
||||
prep.NUMLOT AS Lotto,
|
||||
prep.CODICE AS Articolo,
|
||||
prep.DESCR AS Descrizione,
|
||||
prep.Qta,
|
||||
prep.NUMDOC AS Documento,
|
||||
prep.DATDOC AS DataDocumento,
|
||||
prep.StatoDocumento,
|
||||
prep.Expr1 AS CodNazione,
|
||||
prep.NAZIONE,
|
||||
CASE
|
||||
WHEN prep.Expr1 = 'DE' THEN 10
|
||||
WHEN prep.Expr1 = 'TH' THEN
|
||||
CASE WHEN SUBSTRING(prep.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN prep.Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(g.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(g.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(g.IDArea, 5) AS Area,
|
||||
ISNULL(g.IDCella, 1000) AS Cella,
|
||||
ISNULL(c.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(prep.DESCRDEST, 1, 2) AS DEST,
|
||||
CASE
|
||||
WHEN MAX(CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(prep.NUMDOC AS varchar(8))
|
||||
THEN 1 ELSE 0 END) = 1
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet g
|
||||
ON c.ID = g.IDCella
|
||||
RIGHT OUTER JOIN dbo.py_vPreparaPackingList prep
|
||||
ON g.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = prep.UDC
|
||||
LEFT JOIN dbo.PyPickingListReservation pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
GROUP BY
|
||||
prep.Expr1,
|
||||
prep.NAZIONE,
|
||||
prep.UDC,
|
||||
prep.NUMDOC,
|
||||
prep.DATDOC,
|
||||
prep.StatoDocumento,
|
||||
prep.NUMLOT,
|
||||
prep.CODICE,
|
||||
prep.DESCR,
|
||||
prep.Qta,
|
||||
g.NumeroPallet,
|
||||
g.IDMagazzino,
|
||||
g.IDArea,
|
||||
g.IDCella,
|
||||
c.Ordinamento,
|
||||
c.Corsia,
|
||||
c.Colonna,
|
||||
c.Fila,
|
||||
prep.DESCRDEST;
|
||||
GO
|
||||
|
||||
PRINT 'Viste storiche Python create/aggiornate:';
|
||||
PRINT ' - dbo.py_vPreparaPackingListSAMA1';
|
||||
PRINT ' - dbo.py_vPreparaPackingList';
|
||||
PRINT ' - dbo.py_XMag_ViewPackingListStorico';
|
||||
GO
|
||||
@@ -7,6 +7,11 @@ singleton so every module can schedule work on the same async runtime.
|
||||
|
||||
import asyncio
|
||||
import threading
|
||||
import contextlib
|
||||
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
|
||||
class _LoopHolder:
|
||||
@@ -15,6 +20,7 @@ class _LoopHolder:
|
||||
def __init__(self):
|
||||
self.loop = None
|
||||
self.thread = None
|
||||
self.closing = False
|
||||
|
||||
|
||||
_GLOBAL = _LoopHolder()
|
||||
@@ -26,7 +32,7 @@ def get_global_loop() -> asyncio.AbstractEventLoop:
|
||||
The loop is created lazily the first time the function is called and kept
|
||||
alive for the lifetime of the application.
|
||||
"""
|
||||
if _GLOBAL.loop:
|
||||
if _GLOBAL.loop and not _GLOBAL.closing:
|
||||
return _GLOBAL.loop
|
||||
|
||||
ready = threading.Event()
|
||||
@@ -35,7 +41,23 @@ def get_global_loop() -> asyncio.AbstractEventLoop:
|
||||
_GLOBAL.loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(_GLOBAL.loop)
|
||||
ready.set()
|
||||
_GLOBAL.loop.run_forever()
|
||||
try:
|
||||
_GLOBAL.loop.run_forever()
|
||||
finally:
|
||||
loop = _GLOBAL.loop
|
||||
if loop is not None:
|
||||
pending = [task for task in asyncio.all_tasks(loop) if not task.done()]
|
||||
for task in pending:
|
||||
task.cancel()
|
||||
if pending:
|
||||
with contextlib.suppress(Exception):
|
||||
loop.run_until_complete(asyncio.gather(*pending, return_exceptions=True))
|
||||
with contextlib.suppress(Exception):
|
||||
loop.run_until_complete(loop.shutdown_asyncgens())
|
||||
with contextlib.suppress(Exception):
|
||||
loop.run_until_complete(loop.shutdown_default_executor())
|
||||
with contextlib.suppress(Exception):
|
||||
loop.close()
|
||||
|
||||
_GLOBAL.thread = threading.Thread(target=_run, name="asyncio-bg-loop", daemon=True)
|
||||
_GLOBAL.thread.start()
|
||||
@@ -46,7 +68,9 @@ def get_global_loop() -> asyncio.AbstractEventLoop:
|
||||
def stop_global_loop():
|
||||
"""Stop the shared loop and join the background thread if present."""
|
||||
if _GLOBAL.loop and _GLOBAL.loop.is_running():
|
||||
_GLOBAL.closing = True
|
||||
_GLOBAL.loop.call_soon_threadsafe(_GLOBAL.loop.stop)
|
||||
_GLOBAL.thread.join(timeout=2)
|
||||
_GLOBAL.loop = None
|
||||
_GLOBAL.thread = None
|
||||
_GLOBAL.closing = False
|
||||
|
||||
@@ -10,14 +10,84 @@ cross-loop errors.
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import inspect
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import urllib.parse
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy.pool import NullPool
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
QUERY_PROFILER_LOG = Path(__file__).with_name("warehouse_query_profiler.log")
|
||||
QUERY_PROFILER_CONFIG_PATH = Path(__file__).with_name("db_connection.json")
|
||||
|
||||
|
||||
def _load_query_profiler_config() -> dict[str, Any]:
|
||||
"""Read profiler settings from db_connection.json, with env overrides."""
|
||||
|
||||
config: dict[str, Any] = {
|
||||
"enabled": False,
|
||||
"slow_ms": 0,
|
||||
"sql_limit": 4000,
|
||||
}
|
||||
try:
|
||||
data = json.loads(QUERY_PROFILER_CONFIG_PATH.read_text(encoding="utf-8"))
|
||||
section = data.get("query_profiler") if isinstance(data, dict) else None
|
||||
if isinstance(section, dict):
|
||||
config.update(section)
|
||||
except Exception:
|
||||
pass
|
||||
if "WAREHOUSE_QUERY_PROFILER" in os.environ:
|
||||
config["enabled"] = os.environ.get("WAREHOUSE_QUERY_PROFILER", "1").strip().lower() not in {
|
||||
"0",
|
||||
"false",
|
||||
"no",
|
||||
"off",
|
||||
}
|
||||
if "WAREHOUSE_QUERY_PROFILER_SLOW_MS" in os.environ:
|
||||
config["slow_ms"] = os.environ.get("WAREHOUSE_QUERY_PROFILER_SLOW_MS", "0")
|
||||
if "WAREHOUSE_QUERY_PROFILER_SQL_LIMIT" in os.environ:
|
||||
config["sql_limit"] = os.environ.get("WAREHOUSE_QUERY_PROFILER_SQL_LIMIT", "4000")
|
||||
return config
|
||||
|
||||
|
||||
def _query_profiler_enabled() -> bool:
|
||||
value = _load_query_profiler_config().get("enabled", False)
|
||||
if isinstance(value, str):
|
||||
return value.strip().lower() not in {"0", "false", "no", "off"}
|
||||
return bool(value)
|
||||
|
||||
|
||||
def _query_profiler_slow_ms() -> float:
|
||||
try:
|
||||
return float(_load_query_profiler_config().get("slow_ms", 0) or 0)
|
||||
except Exception:
|
||||
return 0.0
|
||||
|
||||
|
||||
def _query_profiler_sql_limit() -> int:
|
||||
try:
|
||||
return int(_load_query_profiler_config().get("sql_limit", 4000) or 4000)
|
||||
except Exception:
|
||||
return 4000
|
||||
|
||||
try:
|
||||
import pyodbc
|
||||
|
||||
# The desktop app opens short-lived SQL connections from a background
|
||||
# asyncio loop. ODBC pooling can keep native handles alive for a while after
|
||||
# the GUI closes, which is especially visible with pythonw.
|
||||
pyodbc.pooling = False
|
||||
except Exception:
|
||||
pyodbc = None # type: ignore[assignment]
|
||||
|
||||
try:
|
||||
import orjson as _json
|
||||
@@ -63,6 +133,83 @@ def make_mssql_dsn(
|
||||
return f"mssql+aioodbc:///?odbc_connect={urllib.parse.quote_plus(odbc)}"
|
||||
|
||||
|
||||
def _compact_sql(sql: str, *, limit: int | None = None) -> str:
|
||||
"""Collapse SQL whitespace so profiler entries stay readable."""
|
||||
|
||||
if limit is None:
|
||||
limit = _query_profiler_sql_limit()
|
||||
text_value = " ".join(str(sql or "").split())
|
||||
if limit > 0 and len(text_value) > limit:
|
||||
return text_value[:limit] + "...<truncated>"
|
||||
return text_value
|
||||
|
||||
|
||||
def _profile_params(params: Optional[Dict[str, Any]]) -> str:
|
||||
"""Serialize SQL parameters for diagnostics."""
|
||||
|
||||
if not params:
|
||||
return "{}"
|
||||
try:
|
||||
return _dumps(params)
|
||||
except Exception:
|
||||
return repr(params)
|
||||
|
||||
|
||||
def _query_caller() -> str:
|
||||
"""Return the first external Python frame that triggered the DB call."""
|
||||
|
||||
current_file = Path(__file__).resolve()
|
||||
for frame in inspect.stack(context=0)[2:]:
|
||||
try:
|
||||
frame_file = Path(frame.filename).resolve()
|
||||
except Exception:
|
||||
continue
|
||||
if frame_file == current_file:
|
||||
continue
|
||||
return f"{frame_file.name}:{frame.lineno}:{frame.function}"
|
||||
return "unknown"
|
||||
|
||||
|
||||
def _append_query_profile(
|
||||
*,
|
||||
method: str,
|
||||
elapsed_ms: float,
|
||||
rows: int | None,
|
||||
rowcount: int | None,
|
||||
commit: bool,
|
||||
ok: bool,
|
||||
sql: str,
|
||||
params: Optional[Dict[str, Any]],
|
||||
caller: str,
|
||||
error: str = "",
|
||||
) -> None:
|
||||
"""Append one query timing line to the local profiler log."""
|
||||
|
||||
if not _query_profiler_enabled():
|
||||
return
|
||||
slow_ms = _query_profiler_slow_ms()
|
||||
if ok and slow_ms > 0 and elapsed_ms < slow_ms:
|
||||
return
|
||||
try:
|
||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
row_info = f"rows={rows}" if rows is not None else f"rowcount={rowcount}"
|
||||
lines = [
|
||||
(
|
||||
f"{timestamp} | {elapsed_ms:.3f} ms | {method} | "
|
||||
f"{row_info} | commit={int(commit)} | ok={int(ok)} | caller={caller}"
|
||||
),
|
||||
f"PARAMS: {_profile_params(params)}",
|
||||
f"SQL: {_compact_sql(sql)}",
|
||||
]
|
||||
if error:
|
||||
lines.append(f"ERROR: {error}")
|
||||
with QUERY_PROFILER_LOG.open("a", encoding="utf-8") as handle:
|
||||
handle.write("\n".join(lines) + "\n---\n")
|
||||
except Exception:
|
||||
# Profiling must never interfere with warehouse operations.
|
||||
pass
|
||||
|
||||
|
||||
class AsyncMSSQLClient:
|
||||
"""Thin async query client for SQL Server.
|
||||
|
||||
@@ -120,6 +267,7 @@ class AsyncMSSQLClient:
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
*,
|
||||
as_dict_rows: bool = False,
|
||||
commit: bool = False,
|
||||
) -> Dict[str, Any]:
|
||||
"""Execute a query and return a JSON-friendly payload.
|
||||
|
||||
@@ -128,6 +276,9 @@ class AsyncMSSQLClient:
|
||||
params: Optional named parameters bound to the statement.
|
||||
as_dict_rows: When ``True`` returns rows as dictionaries keyed by
|
||||
column name; otherwise rows are returned as lists.
|
||||
commit: When ``True`` the statement runs in a transaction that is
|
||||
committed on success. Useful for SQL batches that both mutate
|
||||
data and return a final result set.
|
||||
|
||||
Returns:
|
||||
A dictionary containing column names, rows and elapsed execution
|
||||
@@ -135,23 +286,83 @@ class AsyncMSSQLClient:
|
||||
"""
|
||||
await self._ensure_engine()
|
||||
t0 = time.perf_counter()
|
||||
async with self._engine.connect() as conn:
|
||||
res = await conn.execute(text(sql), params or {})
|
||||
rows = res.fetchall()
|
||||
cols = list(res.keys())
|
||||
caller = _query_caller()
|
||||
try:
|
||||
async with (self._engine.begin() if commit else self._engine.connect()) as conn:
|
||||
res = await conn.execute(text(sql), params or {})
|
||||
rows = res.fetchall()
|
||||
cols = list(res.keys())
|
||||
except Exception as exc:
|
||||
elapsed_ms = round((time.perf_counter() - t0) * 1000, 3)
|
||||
_append_query_profile(
|
||||
method="query_json",
|
||||
elapsed_ms=elapsed_ms,
|
||||
rows=None,
|
||||
rowcount=None,
|
||||
commit=commit,
|
||||
ok=False,
|
||||
sql=sql,
|
||||
params=params,
|
||||
caller=caller,
|
||||
error=repr(exc),
|
||||
)
|
||||
raise
|
||||
if as_dict_rows:
|
||||
rows_out = [dict(zip(cols, row)) for row in rows]
|
||||
else:
|
||||
rows_out = [list(row) for row in rows]
|
||||
elapsed_ms = round((time.perf_counter() - t0) * 1000, 3)
|
||||
_append_query_profile(
|
||||
method="query_json",
|
||||
elapsed_ms=elapsed_ms,
|
||||
rows=len(rows_out),
|
||||
rowcount=None,
|
||||
commit=commit,
|
||||
ok=True,
|
||||
sql=sql,
|
||||
params=params,
|
||||
caller=caller,
|
||||
)
|
||||
return {
|
||||
"columns": cols,
|
||||
"rows": rows_out,
|
||||
"elapsed_ms": round((time.perf_counter() - t0) * 1000, 3),
|
||||
"elapsed_ms": elapsed_ms,
|
||||
}
|
||||
|
||||
async def exec(self, sql: str, params: Optional[Dict[str, Any]] = None, *, commit: bool = False) -> int:
|
||||
"""Execute a DML statement and return its row count."""
|
||||
await self._ensure_engine()
|
||||
async with (self._engine.begin() if commit else self._engine.connect()) as conn:
|
||||
res = await conn.execute(text(sql), params or {})
|
||||
return res.rowcount or 0
|
||||
t0 = time.perf_counter()
|
||||
caller = _query_caller()
|
||||
try:
|
||||
async with (self._engine.begin() if commit else self._engine.connect()) as conn:
|
||||
res = await conn.execute(text(sql), params or {})
|
||||
rowcount = res.rowcount or 0
|
||||
except Exception as exc:
|
||||
elapsed_ms = round((time.perf_counter() - t0) * 1000, 3)
|
||||
_append_query_profile(
|
||||
method="exec",
|
||||
elapsed_ms=elapsed_ms,
|
||||
rows=None,
|
||||
rowcount=None,
|
||||
commit=commit,
|
||||
ok=False,
|
||||
sql=sql,
|
||||
params=params,
|
||||
caller=caller,
|
||||
error=repr(exc),
|
||||
)
|
||||
raise
|
||||
elapsed_ms = round((time.perf_counter() - t0) * 1000, 3)
|
||||
_append_query_profile(
|
||||
method="exec",
|
||||
elapsed_ms=elapsed_ms,
|
||||
rows=None,
|
||||
rowcount=rowcount,
|
||||
commit=commit,
|
||||
ok=True,
|
||||
sql=sql,
|
||||
params=params,
|
||||
caller=caller,
|
||||
)
|
||||
return rowcount
|
||||
|
||||
104
audit_log.py
Normal file
104
audit_log.py
Normal file
@@ -0,0 +1,104 @@
|
||||
"""Central textual audit log for user-driven warehouse operations."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from user_session import UserSession
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
AUDIT_LOG_PATH = Path(__file__).with_name("warehouse_audit.log")
|
||||
_LOGGER = logging.getLogger("warehouse_audit")
|
||||
_LOGGER_CONFIGURED = False
|
||||
|
||||
|
||||
def _configure_logger() -> None:
|
||||
"""Configure the append-only textual audit logger once."""
|
||||
|
||||
global _LOGGER_CONFIGURED
|
||||
if _LOGGER_CONFIGURED:
|
||||
return
|
||||
|
||||
_LOGGER.setLevel(logging.INFO)
|
||||
_LOGGER.propagate = False
|
||||
handler = logging.FileHandler(AUDIT_LOG_PATH, encoding="utf-8")
|
||||
handler.setFormatter(logging.Formatter("%(asctime)s | %(message)s"))
|
||||
_LOGGER.addHandler(handler)
|
||||
_LOGGER_CONFIGURED = True
|
||||
|
||||
|
||||
def _user_label(session: UserSession | None) -> str:
|
||||
"""Render the user identity consistently in the audit trail."""
|
||||
|
||||
if session is None:
|
||||
return "anonymous"
|
||||
return f"{session.login or 'anonymous'}#{session.operator_id}"
|
||||
|
||||
|
||||
def _payload(
|
||||
*,
|
||||
session: UserSession | None,
|
||||
module: str,
|
||||
action: str,
|
||||
outcome: str,
|
||||
target: str = "",
|
||||
details: dict[str, Any] | None = None,
|
||||
) -> str:
|
||||
"""Serialize one audit event as a compact text line."""
|
||||
|
||||
base = {
|
||||
"user": _user_label(session),
|
||||
"module": module,
|
||||
"action": action,
|
||||
"outcome": outcome,
|
||||
"target": target,
|
||||
"details": details or {},
|
||||
}
|
||||
return json.dumps(base, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
def log_user_action(
|
||||
session: UserSession | None,
|
||||
*,
|
||||
module: str,
|
||||
action: str,
|
||||
outcome: str,
|
||||
target: str = "",
|
||||
details: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""Write one user action event to the textual audit file."""
|
||||
|
||||
_configure_logger()
|
||||
_LOGGER.info(
|
||||
_payload(
|
||||
session=session,
|
||||
module=module,
|
||||
action=action,
|
||||
outcome=outcome,
|
||||
target=target,
|
||||
details=details,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def log_session_event(
|
||||
session: UserSession | None,
|
||||
*,
|
||||
action: str,
|
||||
outcome: str,
|
||||
details: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""Write one session lifecycle event to the textual audit file."""
|
||||
|
||||
log_user_action(
|
||||
session,
|
||||
module="session",
|
||||
action=action,
|
||||
outcome=outcome,
|
||||
details=details,
|
||||
)
|
||||
14
barcode.pyw
Normal file
14
barcode.pyw
Normal file
@@ -0,0 +1,14 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
|
||||
os.chdir(Path(__file__).resolve().parent)
|
||||
|
||||
from runtime_support import ensure_stdio, run_with_fatal_log
|
||||
|
||||
ensure_stdio("warehouse_barcode")
|
||||
|
||||
from barcode_client import main
|
||||
|
||||
|
||||
raise SystemExit(run_with_fatal_log("Barcode WMS", main))
|
||||
776
barcode_client.py
Normal file
776
barcode_client.py
Normal file
@@ -0,0 +1,776 @@
|
||||
"""Lightweight standalone barcode client for the warehouse WMS."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
import tkinter as tk
|
||||
from concurrent.futures import Future
|
||||
import error_dialog as messagebox
|
||||
from tkinter import ttk
|
||||
from typing import Callable
|
||||
|
||||
from runtime_support import configure_exception_logging, ensure_stdio, log_exception, run_with_fatal_log
|
||||
|
||||
ensure_stdio("warehouse_barcode")
|
||||
|
||||
from async_loop_singleton import get_global_loop, stop_global_loop
|
||||
from async_msssql_query import AsyncMSSQLClient
|
||||
from barcode_repository import BarcodeRepository
|
||||
from barcode_service import BarcodeActionResult, BarcodeService, BarcodeViewState
|
||||
from db_config import build_dsn_from_config, ensure_db_config
|
||||
from login_window import prompt_login_compact
|
||||
from user_session import create_user_session
|
||||
from version_info import module_version, versioned_title
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
BYPASS_LOGIN = True
|
||||
BYPASS_LOGIN_USER = {
|
||||
"operator_id": 4,
|
||||
"login": "MAG1",
|
||||
"nominativo": "MAG1",
|
||||
"privilegio": 3,
|
||||
"codice_unita": "U1",
|
||||
}
|
||||
|
||||
|
||||
def _build_bypass_session():
|
||||
"""Create the temporary MAG1 session used while field testing the barcode."""
|
||||
|
||||
return create_user_session(
|
||||
operator_id=int(BYPASS_LOGIN_USER["operator_id"]),
|
||||
login=str(BYPASS_LOGIN_USER["login"]),
|
||||
nominativo=str(BYPASS_LOGIN_USER["nominativo"]),
|
||||
privilegio=int(BYPASS_LOGIN_USER["privilegio"]),
|
||||
codice_unita=str(BYPASS_LOGIN_USER["codice_unita"]),
|
||||
)
|
||||
|
||||
|
||||
class BarcodeClientApp:
|
||||
"""Single-window Tk barcode client modeled after the C# legacy form."""
|
||||
|
||||
PALLET_BARCODE_LENGTH = 6
|
||||
NON_SCAFFALATA_BARCODE = "9001000"
|
||||
SHIPPED_BARCODE = "9000000"
|
||||
BARCODE_MAX_WIDTH = 320
|
||||
BARCODE_MAX_HEIGHT = 400
|
||||
DESKTOP_THRESHOLD_WIDTH = 1024
|
||||
DESKTOP_THRESHOLD_HEIGHT = 768
|
||||
DESKTOP_WINDOW_WIDTH = 465
|
||||
DESKTOP_WINDOW_HEIGHT = 531
|
||||
def __init__(self, root: tk.Tk, db_client: AsyncMSSQLClient, session, loop: asyncio.AbstractEventLoop):
|
||||
self.root = root
|
||||
self.db_client = db_client
|
||||
self.session = session
|
||||
self.loop = loop
|
||||
self.repository = BarcodeRepository(db_client)
|
||||
self.service = BarcodeService(self.repository, session.operator_id)
|
||||
self._pending: Future | None = None
|
||||
self._auto_advance_id: str | None = None
|
||||
self._pallet_auto_focus_id: str | None = None
|
||||
self._paused_queue_id: int | None = None
|
||||
self._paused_priority_state: BarcodeViewState | None = None
|
||||
self._pallet_user_input_serial = 0
|
||||
self._priority_loaded_input_serial = 0
|
||||
self._priority_expected_pallet = ""
|
||||
self._status_colors = {
|
||||
"red": "#f4cccc",
|
||||
"green": "#d9ead3",
|
||||
"yellow": "#e2f0cb",
|
||||
}
|
||||
self._is_barcode_desktop = False
|
||||
|
||||
self.queue_var = tk.StringVar(value="")
|
||||
self.info1_var = tk.StringVar(value="")
|
||||
self.info2_var = tk.StringVar(value="")
|
||||
self.info3_var = tk.StringVar(value="")
|
||||
self.info4_var = tk.StringVar(value="")
|
||||
self.destination_var = tk.StringVar(value="")
|
||||
self.scanned_var = tk.StringVar(value="")
|
||||
|
||||
self._build_ui()
|
||||
self._apply_state(self.service.state)
|
||||
self._bind_keys()
|
||||
self.root.protocol("WM_DELETE_WINDOW", self._shutdown)
|
||||
self.root.after(80, self._finalize_window_placement)
|
||||
self.root.after(250, self._finalize_window_placement)
|
||||
|
||||
def _build_ui(self) -> None:
|
||||
self.root.title(versioned_title("WMS", __name__))
|
||||
self.root.configure(bg="#f1f1f1")
|
||||
self._apply_responsive_geometry()
|
||||
|
||||
if self._is_barcode_desktop:
|
||||
field_font = ("Segoe UI", 9)
|
||||
entry_font = ("Segoe UI", 11)
|
||||
band_font = ("Segoe UI", 9, "bold")
|
||||
info_font = ("Segoe UI", 9)
|
||||
queue_font = ("Segoe UI", 8)
|
||||
pad_x = 5
|
||||
pad_y = 4
|
||||
band_wrap = 190
|
||||
info_wrap = 194
|
||||
button_pad_y = 1
|
||||
else:
|
||||
field_font = ("Segoe UI", 12)
|
||||
entry_font = ("Segoe UI", 15)
|
||||
band_font = ("Segoe UI", 12, "bold")
|
||||
info_font = ("Segoe UI", 12)
|
||||
queue_font = ("Segoe UI", 10)
|
||||
pad_x = 16
|
||||
pad_y = 12
|
||||
band_wrap = 400
|
||||
info_wrap = 408
|
||||
button_pad_y = 4
|
||||
|
||||
wrap = tk.Frame(self.root, bg="#f1f1f1", padx=pad_x, pady=pad_y)
|
||||
wrap.pack(fill="both", expand=True)
|
||||
wrap.rowconfigure(3, weight=1)
|
||||
wrap.columnconfigure(0, weight=1)
|
||||
|
||||
header = tk.Frame(wrap, bg="#f1f1f1")
|
||||
header.grid(row=0, column=0, sticky="ew", pady=(0, 4 if self._is_barcode_desktop else 10))
|
||||
tk.Label(
|
||||
header,
|
||||
textvariable=self.queue_var,
|
||||
bg="#f1f1f1",
|
||||
fg="#333333",
|
||||
font=queue_font,
|
||||
anchor="e",
|
||||
).pack(side="right")
|
||||
|
||||
form = tk.Frame(wrap, bg="#f1f1f1")
|
||||
form.grid(row=1, column=0, sticky="ew")
|
||||
self._add_compact_field(form, 0, "Pallet", self.scanned_var, scanned=True, label_font=field_font, entry_font=entry_font)
|
||||
self._add_compact_field(form, 1, "Cella", self.destination_var, scanned=False, label_font=field_font, entry_font=entry_font)
|
||||
|
||||
self.status_band = tk.Label(
|
||||
wrap,
|
||||
textvariable=self.info1_var,
|
||||
bg=self._status_colors["red"],
|
||||
fg="#1f2937",
|
||||
font=band_font,
|
||||
anchor="w",
|
||||
justify="left",
|
||||
padx=6,
|
||||
pady=3 if self._is_barcode_desktop else 6,
|
||||
wraplength=band_wrap,
|
||||
)
|
||||
self.status_band.grid(row=2, column=0, sticky="ew", pady=(8 if self._is_barcode_desktop else 14, 4))
|
||||
|
||||
info_box = tk.Frame(wrap, bg="#f1f1f1")
|
||||
info_box.grid(row=3, column=0, sticky="nsew")
|
||||
info_box.columnconfigure(0, weight=1)
|
||||
for row_index in range(3):
|
||||
info_box.rowconfigure(row_index, weight=1)
|
||||
self.info2_label = tk.Label(
|
||||
info_box,
|
||||
textvariable=self.info2_var,
|
||||
bg="#f1f1f1",
|
||||
fg="#222222",
|
||||
font=info_font,
|
||||
anchor="w",
|
||||
justify="left",
|
||||
wraplength=info_wrap,
|
||||
)
|
||||
self.info2_label.grid(row=0, column=0, sticky="ew", pady=(2, 0))
|
||||
self.info3_label = tk.Label(
|
||||
info_box,
|
||||
textvariable=self.info3_var,
|
||||
bg="#f1f1f1",
|
||||
fg="#222222",
|
||||
font=info_font,
|
||||
anchor="w",
|
||||
justify="left",
|
||||
wraplength=info_wrap,
|
||||
)
|
||||
self.info3_label.grid(row=1, column=0, sticky="ew", pady=(2, 0))
|
||||
self.info4_label = tk.Label(
|
||||
info_box,
|
||||
textvariable=self.info4_var,
|
||||
bg="#f1f1f1",
|
||||
fg="#222222",
|
||||
font=info_font,
|
||||
anchor="w",
|
||||
justify="left",
|
||||
wraplength=info_wrap,
|
||||
)
|
||||
self.info4_label.grid(row=2, column=0, sticky="ew", pady=(2, 4 if self._is_barcode_desktop else 10))
|
||||
|
||||
buttons = tk.Frame(wrap, bg="#f1f1f1")
|
||||
buttons.grid(row=4, column=0, sticky="ew", pady=(4, 0))
|
||||
buttons.columnconfigure(0, weight=1)
|
||||
buttons.columnconfigure(1, weight=1)
|
||||
|
||||
self.btn_f1 = ttk.Button(buttons, text="[F1] H Priority", command=lambda: self._start_queue(1))
|
||||
self.btn_f1.grid(row=0, column=0, padx=(0, 4), pady=(0, button_pad_y), sticky="ew")
|
||||
self.btn_submit = ttk.Button(buttons, text="[F3] Carica", command=self._on_f3)
|
||||
self.btn_submit.grid(row=0, column=1, padx=(4, 0), pady=(0, button_pad_y), sticky="ew")
|
||||
self.btn_f2 = ttk.Button(buttons, text="[F2] L Priority", command=lambda: self._start_queue(0))
|
||||
self.btn_f2.grid(row=1, column=0, padx=(0, 4), sticky="ew")
|
||||
self.btn_unload = ttk.Button(buttons, text="[F4] Scarica", command=self._begin_manual_unload)
|
||||
self.btn_unload.grid(row=1, column=1, padx=(4, 0), sticky="ew")
|
||||
|
||||
self.busy_cover = tk.Frame(self.root, bg="#d9d9d9")
|
||||
panel = ttk.Frame(self.busy_cover, padding=16)
|
||||
panel.place(relx=0.5, rely=0.5, anchor="center")
|
||||
self.busy_label = ttk.Label(panel, text="Attendere...", font=("Segoe UI", 11, "bold"))
|
||||
self.busy_label.pack(pady=(0, 8))
|
||||
self.busy_bar = ttk.Progressbar(panel, mode="indeterminate", length=260)
|
||||
self.busy_bar.pack()
|
||||
def _add_compact_field(
|
||||
self,
|
||||
parent: tk.Frame,
|
||||
row: int,
|
||||
label: str,
|
||||
variable: tk.StringVar,
|
||||
*,
|
||||
scanned: bool,
|
||||
label_font,
|
||||
entry_font,
|
||||
) -> None:
|
||||
tk.Label(
|
||||
parent,
|
||||
text=label,
|
||||
bg="#f1f1f1",
|
||||
fg="#1f1f1f",
|
||||
font=label_font,
|
||||
anchor="w",
|
||||
).grid(row=row, column=0, sticky="w", padx=(0, 8), pady=4 if self._is_barcode_desktop else 6)
|
||||
entry = ttk.Entry(parent, textvariable=variable, font=entry_font, width=8)
|
||||
entry.grid(row=row, column=1, sticky="ew", pady=4 if self._is_barcode_desktop else 6, ipady=1 if self._is_barcode_desktop else 4)
|
||||
parent.columnconfigure(1, weight=1)
|
||||
if scanned:
|
||||
self.pallet_entry = entry
|
||||
self.pallet_entry.bind("<KeyPress>", self._on_pallet_keypress, add="+")
|
||||
self.scanned_var.trace_add("write", lambda *_: self._on_scanned_var_changed())
|
||||
else:
|
||||
self.destination_entry = entry
|
||||
self.destination_var.trace_add("write", lambda *_: self._on_destination_var_changed())
|
||||
|
||||
def _limit_var(self, variable: tk.StringVar, max_len: int) -> None:
|
||||
value = str(variable.get() or "")
|
||||
if len(value) > max_len:
|
||||
variable.set(value[:max_len])
|
||||
|
||||
def _on_pallet_keypress(self, _event=None) -> None:
|
||||
self._pallet_user_input_serial += 1
|
||||
|
||||
def _on_scanned_var_changed(self) -> None:
|
||||
self._limit_var(self.scanned_var, 8)
|
||||
if self._pallet_auto_focus_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._pallet_auto_focus_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._pallet_auto_focus_id = None
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
if len(pallet) < self.PALLET_BARCODE_LENGTH:
|
||||
return
|
||||
self._pallet_auto_focus_id = self.root.after(80, self._auto_focus_destination_after_scan)
|
||||
|
||||
def _on_destination_var_changed(self) -> None:
|
||||
self._limit_var(self.destination_var, 8)
|
||||
self._refresh_action_labels()
|
||||
|
||||
def _auto_focus_destination_after_scan(self) -> None:
|
||||
self._pallet_auto_focus_id = None
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
if not pallet:
|
||||
return
|
||||
if self._pending is not None and not self._pending.done():
|
||||
return
|
||||
if getattr(self.service.state, "mode", "") == "confirm":
|
||||
return
|
||||
if getattr(self.service.state, "mode", "") in ("priority_high", "priority_low"):
|
||||
expected = str(getattr(self.service.state, "expected_pallet", "") or "").strip()
|
||||
if expected and pallet == expected and self._is_fresh_priority_scan(expected):
|
||||
self._submit()
|
||||
return
|
||||
if bool(getattr(self.service.state, "destination_readonly", False)):
|
||||
return
|
||||
self._focus_destination_input()
|
||||
|
||||
def _apply_responsive_geometry(self) -> None:
|
||||
"""Adapt the window size to barcode-sized or desktop-sized screens."""
|
||||
|
||||
self.root.update_idletasks()
|
||||
screen_width = max(1, int(self.root.winfo_screenwidth() or 0))
|
||||
screen_height = max(1, int(self.root.winfo_screenheight() or 0))
|
||||
|
||||
is_barcode_desktop = (
|
||||
screen_width <= self.BARCODE_MAX_WIDTH or screen_height <= self.BARCODE_MAX_HEIGHT
|
||||
)
|
||||
self._is_barcode_desktop = is_barcode_desktop
|
||||
|
||||
if is_barcode_desktop:
|
||||
width = screen_width
|
||||
height = screen_height
|
||||
x = 0
|
||||
y = 0
|
||||
self.root.minsize(max(220, width), max(300, height))
|
||||
else:
|
||||
width = min(self.DESKTOP_WINDOW_WIDTH, screen_width)
|
||||
height = min(self.DESKTOP_WINDOW_HEIGHT, screen_height)
|
||||
x = 0
|
||||
y = 0
|
||||
self.root.minsize(420, 500)
|
||||
|
||||
if (
|
||||
screen_width >= self.DESKTOP_THRESHOLD_WIDTH
|
||||
and screen_height >= self.DESKTOP_THRESHOLD_HEIGHT
|
||||
and not is_barcode_desktop
|
||||
):
|
||||
width = min(self.DESKTOP_WINDOW_WIDTH, screen_width)
|
||||
height = min(self.DESKTOP_WINDOW_HEIGHT, screen_height)
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
self.root.geometry(f"{width}x{height}+{x}+{y}")
|
||||
|
||||
def _finalize_window_placement(self) -> None:
|
||||
"""Let Windows finish frame sizing, then snap the barcode window in place."""
|
||||
|
||||
try:
|
||||
if self._is_barcode_desktop:
|
||||
self.root.state("zoomed")
|
||||
else:
|
||||
self.root.geometry("+0+0")
|
||||
self.root.update_idletasks()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _bind_keys(self) -> None:
|
||||
self.root.bind("<F1>", lambda _e: self._start_queue(1))
|
||||
self.root.bind("<F2>", lambda _e: self._start_queue(0))
|
||||
self.root.bind("<F3>", self._on_f3_key)
|
||||
self.root.bind("<F4>", self._on_unload_key)
|
||||
self.root.bind("<Escape>", self._on_escape_key)
|
||||
self.pallet_entry.bind("<Return>", self._on_pallet_enter)
|
||||
self.destination_entry.bind("<Return>", self._on_destination_enter)
|
||||
|
||||
def _set_busy(self, busy: bool, message: str = "") -> None:
|
||||
state = "disabled" if busy else "normal"
|
||||
for button in (self.btn_f1, self.btn_f2, self.btn_unload, self.btn_submit):
|
||||
try:
|
||||
button.configure(state=state)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.pallet_entry.configure(state=state)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
if str(self.destination_entry.cget("state")) != "readonly" or busy:
|
||||
self.destination_entry.configure(state=state)
|
||||
except Exception:
|
||||
pass
|
||||
if busy:
|
||||
self.busy_label.configure(text=message or "Attendere...")
|
||||
self.busy_cover.place(relx=0, rely=0, relwidth=1, relheight=1)
|
||||
self.busy_bar.start(10)
|
||||
else:
|
||||
self.busy_bar.stop()
|
||||
self.busy_cover.place_forget()
|
||||
|
||||
def _is_priority_pause(self) -> bool:
|
||||
return str(self.queue_var.get() or "") == "Pausa PL"
|
||||
|
||||
def _apply_state(self, state: BarcodeViewState) -> None:
|
||||
if self._auto_advance_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._auto_advance_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._auto_advance_id = None
|
||||
if self._pallet_auto_focus_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._pallet_auto_focus_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._pallet_auto_focus_id = None
|
||||
pause_context = self._paused_queue_id is not None and state.mode not in ("priority_high", "priority_low")
|
||||
effective_queue_label = "Pausa PL" if pause_context else state.queue_label
|
||||
self.queue_var.set(effective_queue_label)
|
||||
self.destination_var.set(state.destination_barcode)
|
||||
self.scanned_var.set(state.scanned_pallet)
|
||||
self.info1_var.set(self._status_text_with_wait_hint(state))
|
||||
self.info2_var.set(state.document)
|
||||
self.info3_var.set(state.customer)
|
||||
self.info4_var.set(state.expected_pallet)
|
||||
self.status_band.configure(bg=state.status_color or self._status_colors["red"])
|
||||
|
||||
if state.mode in ("priority_high", "priority_low"):
|
||||
self._priority_loaded_input_serial = self._pallet_user_input_serial
|
||||
self._priority_expected_pallet = str(state.expected_pallet or "").strip()
|
||||
else:
|
||||
self._priority_expected_pallet = ""
|
||||
|
||||
try:
|
||||
if str(effective_queue_label or "") != "Pausa PL":
|
||||
self._paused_queue_id = None
|
||||
resumable_queue = self._resumable_queue_from_state(state)
|
||||
if state.mode in ("priority_high", "priority_low") or resumable_queue is not None:
|
||||
self.btn_submit.configure(text="[F3] Pausa PL")
|
||||
else:
|
||||
self.btn_submit.configure(text="[F3] Carica")
|
||||
self._refresh_action_labels(state)
|
||||
queue_buttons_state = "disabled" if str(effective_queue_label or "") == "Pausa PL" else "normal"
|
||||
self.btn_f1.configure(state=queue_buttons_state)
|
||||
self.btn_f2.configure(state=queue_buttons_state)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
destination_readonly = False if pause_context else bool(getattr(state, "destination_readonly", False))
|
||||
try:
|
||||
self.destination_entry.configure(state="normal")
|
||||
if destination_readonly:
|
||||
self.destination_entry.configure(state="readonly")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if state.mode == "confirm":
|
||||
next_queue = self._resumable_queue_from_state(state)
|
||||
if next_queue is not None:
|
||||
self._auto_advance_id = self.root.after(
|
||||
int(getattr(state, "auto_advance_delay_ms", 0) or 0),
|
||||
lambda q=next_queue: self._start_queue(q),
|
||||
)
|
||||
|
||||
if bool(getattr(state, "focus_destination", False)):
|
||||
self.root.after(20, self._focus_destination_input)
|
||||
else:
|
||||
self.root.after(20, self._focus_primary_input)
|
||||
|
||||
def _refresh_action_labels(self, state: BarcodeViewState | None = None) -> None:
|
||||
current_state = state or self.service.state
|
||||
try:
|
||||
if current_state.mode in ("priority_high", "priority_low"):
|
||||
self.btn_unload.configure(text="[F4] Salta UDC")
|
||||
return
|
||||
destination = str(self.destination_var.get() or "").strip()
|
||||
if destination == self.NON_SCAFFALATA_BARCODE:
|
||||
self.btn_unload.configure(text="[F4] Non scaff.")
|
||||
elif destination:
|
||||
self.btn_unload.configure(text="[F4] Dissocia")
|
||||
else:
|
||||
self.btn_unload.configure(text="[F4] Scarica")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _focus_primary_input(self) -> None:
|
||||
try:
|
||||
self.pallet_entry.focus_force()
|
||||
self.pallet_entry.selection_range(0, "end")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _status_text_with_wait_hint(self, state: BarcodeViewState) -> str:
|
||||
text = str(getattr(state, "status_text", "") or "")
|
||||
delay_ms = int(getattr(state, "auto_advance_delay_ms", 0) or 0)
|
||||
if delay_ms <= 0:
|
||||
return text
|
||||
seconds = max(1, round(delay_ms / 1000))
|
||||
hint = f"Attendi {seconds} secondi..."
|
||||
if hint.lower() in text.lower():
|
||||
return text
|
||||
return f"{text} - {hint}" if text else hint
|
||||
|
||||
def _focus_destination_input(self) -> None:
|
||||
try:
|
||||
self.destination_entry.configure(state="normal")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.destination_entry.focus_force()
|
||||
self.destination_entry.selection_range(0, "end")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _is_fresh_priority_scan(self, expected: str) -> bool:
|
||||
mode = str(getattr(self.service.state, "mode", "") or "")
|
||||
if mode not in ("priority_high", "priority_low"):
|
||||
return False
|
||||
if str(expected or "").strip() != self._priority_expected_pallet:
|
||||
return False
|
||||
return self._pallet_user_input_serial > self._priority_loaded_input_serial
|
||||
|
||||
def _on_pallet_enter(self, _event=None) -> str:
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
destination = str(self.destination_var.get() or "").strip()
|
||||
if not pallet:
|
||||
return "break"
|
||||
if destination in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE):
|
||||
if bool(getattr(self.service.state, "destination_readonly", False)):
|
||||
mode = str(getattr(self.service.state, "mode", "") or "")
|
||||
if mode in ("priority_high", "priority_low"):
|
||||
expected = str(getattr(self.service.state, "expected_pallet", "") or "").strip()
|
||||
if expected and pallet == expected and self._is_fresh_priority_scan(expected):
|
||||
self._submit()
|
||||
else:
|
||||
self._focus_primary_input()
|
||||
else:
|
||||
self._submit()
|
||||
else:
|
||||
self._focus_destination_input()
|
||||
return "break"
|
||||
self.destination_var.set("")
|
||||
self._focus_destination_input()
|
||||
return "break"
|
||||
|
||||
def _on_destination_enter(self, _event=None) -> str:
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
if not pallet:
|
||||
self._focus_primary_input()
|
||||
else:
|
||||
self.info1_var.set("F3 per associare, F4 per disassociare")
|
||||
self.status_band.configure(bg=self._status_colors["yellow"])
|
||||
self._focus_destination_input()
|
||||
return "break"
|
||||
|
||||
def _on_unload_key(self, _event=None) -> str:
|
||||
self._begin_manual_unload()
|
||||
return "break"
|
||||
|
||||
def _on_escape_key(self, _event=None) -> str:
|
||||
if self._is_priority_pause() and self._paused_queue_id is not None:
|
||||
if self._paused_priority_state is not None:
|
||||
state = self.service.resume_priority_state(self._paused_priority_state)
|
||||
self._paused_priority_state = None
|
||||
self._paused_queue_id = None
|
||||
self._apply_state(state)
|
||||
return "break"
|
||||
self._start_queue(self._paused_queue_id, allow_during_pause=True)
|
||||
return "break"
|
||||
|
||||
def _on_f3_key(self, _event=None) -> str:
|
||||
self._on_f3()
|
||||
return "break"
|
||||
|
||||
def _on_f3(self) -> None:
|
||||
mode = getattr(self.service.state, "mode", "")
|
||||
if mode == "priority_high":
|
||||
self._paused_queue_id = 1
|
||||
self._paused_priority_state = self.service.state
|
||||
self._apply_state(self.service.begin_priority_pause(1))
|
||||
return
|
||||
if mode == "priority_low":
|
||||
self._paused_queue_id = 0
|
||||
self._paused_priority_state = self.service.state
|
||||
self._apply_state(self.service.begin_priority_pause(0))
|
||||
return
|
||||
resumable_queue = self._resumable_queue_from_state(self.service.state)
|
||||
if resumable_queue is not None:
|
||||
self._paused_queue_id = resumable_queue
|
||||
self._paused_priority_state = None
|
||||
self._apply_state(self.service.begin_priority_pause(resumable_queue))
|
||||
return
|
||||
self._submit()
|
||||
|
||||
def _begin_manual_unload(self) -> None:
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
destination = str(self.destination_var.get() or "").strip()
|
||||
mode = getattr(self.service.state, "mode", "")
|
||||
if mode in ("priority_high", "priority_low"):
|
||||
self._skip_current_picking_pallet()
|
||||
return
|
||||
if pallet:
|
||||
if destination == self.NON_SCAFFALATA_BARCODE:
|
||||
self._submit()
|
||||
else:
|
||||
self._submit_unload_with_source_check()
|
||||
return
|
||||
if self._is_priority_pause():
|
||||
return
|
||||
self._apply_state(self.service.begin_manual_unload())
|
||||
|
||||
def _start_queue(self, id_stato: int, *, allow_during_pause: bool = False) -> None:
|
||||
if self._is_priority_pause() and not allow_during_pause:
|
||||
return
|
||||
self._run_async(
|
||||
lambda: self.service.start_priority_queue(id_stato),
|
||||
busy_message="In preparazione...",
|
||||
)
|
||||
|
||||
def _submit(self) -> None:
|
||||
self._run_async(
|
||||
lambda: self.service.submit(
|
||||
scanned_pallet=self.scanned_var.get(),
|
||||
destination_barcode=self.destination_var.get(),
|
||||
),
|
||||
busy_message="In esecuzione...",
|
||||
)
|
||||
|
||||
def _submit_unload_with_source_check(self) -> None:
|
||||
self._run_async(
|
||||
lambda: self.service.submit_unload_with_source_check(
|
||||
scanned_pallet=self.scanned_var.get(),
|
||||
source_barcode=self.destination_var.get(),
|
||||
),
|
||||
busy_message="In esecuzione...",
|
||||
)
|
||||
|
||||
def _skip_current_picking_pallet(self) -> None:
|
||||
self._run_async(
|
||||
lambda: self.service.skip_current_picking_pallet(),
|
||||
busy_message="Registro salto UDC...",
|
||||
)
|
||||
|
||||
def _run_async(self, coro_factory: Callable[[], object], busy_message: str) -> None:
|
||||
if self._pending is not None and not self._pending.done():
|
||||
return
|
||||
if self._auto_advance_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._auto_advance_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._auto_advance_id = None
|
||||
self._set_busy(True, busy_message)
|
||||
self._pending = asyncio.run_coroutine_threadsafe(coro_factory(), self.loop)
|
||||
self.root.after(40, self._poll_future)
|
||||
|
||||
def _queue_id_from_label(self, queue_label: str) -> int | None:
|
||||
text = str(queue_label or "")
|
||||
if text.startswith("Alta priorita'"):
|
||||
return 1
|
||||
if text.startswith("Bassa priorita'"):
|
||||
return 0
|
||||
return None
|
||||
|
||||
def _resumable_queue_from_state(self, state: BarcodeViewState) -> int | None:
|
||||
delay_ms = int(getattr(state, "auto_advance_delay_ms", 0) or 0)
|
||||
if delay_ms <= 0:
|
||||
return None
|
||||
return self._queue_id_from_label(str(getattr(state, "queue_label", "") or ""))
|
||||
|
||||
def _poll_future(self) -> None:
|
||||
if self._pending is None:
|
||||
self._set_busy(False)
|
||||
return
|
||||
if not self._pending.done():
|
||||
self.root.after(40, self._poll_future)
|
||||
return
|
||||
|
||||
future = self._pending
|
||||
self._pending = None
|
||||
self._set_busy(False)
|
||||
try:
|
||||
result = future.result()
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context="barcode async operation")
|
||||
self._set_busy(True, "Verifico esito...")
|
||||
self._pending = asyncio.run_coroutine_threadsafe(
|
||||
self.service.reconcile_after_submit_exception(
|
||||
scanned_pallet=self.scanned_var.get(),
|
||||
destination_barcode=self.destination_var.get(),
|
||||
),
|
||||
self.loop,
|
||||
)
|
||||
self.root.after(40, lambda err=exc: self._poll_recovery_future(err))
|
||||
return
|
||||
|
||||
if isinstance(result, BarcodeActionResult):
|
||||
self._apply_state(result.state)
|
||||
if result.message and not result.ok:
|
||||
self.root.bell()
|
||||
elif isinstance(result, BarcodeViewState):
|
||||
self._apply_state(result)
|
||||
|
||||
def _show_transaction_error(self, exception: Exception) -> None:
|
||||
messagebox.showerror(
|
||||
"Barcode WMS",
|
||||
"Operazione non completata.\n\n"
|
||||
"Ripeti la lettura o avvisa il responsabile.\n"
|
||||
"Il dettaglio tecnico e' stato scritto nel log.",
|
||||
parent=self.root,
|
||||
exception=exception,
|
||||
)
|
||||
|
||||
def _poll_recovery_future(self, original_exception: Exception) -> None:
|
||||
if self._pending is None:
|
||||
self._set_busy(False)
|
||||
self._show_transaction_error(original_exception)
|
||||
return
|
||||
if not self._pending.done():
|
||||
self.root.after(40, lambda err=original_exception: self._poll_recovery_future(err))
|
||||
return
|
||||
|
||||
future = self._pending
|
||||
self._pending = None
|
||||
self._set_busy(False)
|
||||
try:
|
||||
result = future.result()
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context=f"barcode recovery after {original_exception!r}")
|
||||
current = self.service.state
|
||||
current.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
current.status_color = "#f4cccc"
|
||||
self._apply_state(current)
|
||||
# Keep both failures when reconciliation also fails asynchronously.
|
||||
self._show_transaction_error(ExceptionGroup(
|
||||
"Barcode operation and recovery failed", [original_exception, exc]))
|
||||
return
|
||||
|
||||
if isinstance(result, BarcodeActionResult):
|
||||
self._apply_state(result.state)
|
||||
if not result.ok:
|
||||
self.root.bell()
|
||||
self._show_transaction_error(original_exception)
|
||||
elif isinstance(result, BarcodeViewState):
|
||||
self._apply_state(result)
|
||||
|
||||
def _shutdown(self) -> None:
|
||||
try:
|
||||
if self._pending is not None and not self._pending.done():
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
fut = asyncio.run_coroutine_threadsafe(self.db_client.dispose(), self.loop)
|
||||
fut.result(timeout=2)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.root.destroy()
|
||||
finally:
|
||||
try:
|
||||
stop_global_loop()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def main() -> int:
|
||||
loop = get_global_loop()
|
||||
bootstrap = tk.Tk()
|
||||
bootstrap.withdraw()
|
||||
configure_exception_logging("Barcode WMS", root=bootstrap, loop=loop)
|
||||
|
||||
config = ensure_db_config(loop, parent=bootstrap)
|
||||
if not config:
|
||||
bootstrap.destroy()
|
||||
stop_global_loop()
|
||||
return 1
|
||||
|
||||
db_client = AsyncMSSQLClient(build_dsn_from_config(config))
|
||||
session = _build_bypass_session() if BYPASS_LOGIN else prompt_login_compact(bootstrap, db_client)
|
||||
if session is None:
|
||||
try:
|
||||
fut = asyncio.run_coroutine_threadsafe(db_client.dispose(), loop)
|
||||
fut.result(timeout=2)
|
||||
except Exception:
|
||||
pass
|
||||
bootstrap.destroy()
|
||||
stop_global_loop()
|
||||
return 1
|
||||
|
||||
app = BarcodeClientApp(bootstrap, db_client, session, loop)
|
||||
bootstrap.deiconify()
|
||||
bootstrap.lift()
|
||||
bootstrap.focus_force()
|
||||
app._focus_primary_input()
|
||||
bootstrap.mainloop()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(run_with_fatal_log("Barcode WMS", main))
|
||||
506
barcode_repository.py
Normal file
506
barcode_repository.py
Normal file
@@ -0,0 +1,506 @@
|
||||
"""Low-level DB access for the barcode WMS client.
|
||||
|
||||
The goal of this module is to mirror the legacy C# barcode form as closely as
|
||||
possible while keeping SQL isolated from the UI.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from runtime_support import log_exception, log_runtime_event
|
||||
from typing import Any
|
||||
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
|
||||
SQL_NEXT_PICKING = """
|
||||
SELECT TOP (1)
|
||||
Documento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
Pallet,
|
||||
Cella,
|
||||
Ubicazione,
|
||||
Ordinamento,
|
||||
IDStato
|
||||
FROM dbo.py_ViewPackingListPrelievo AS pl
|
||||
WHERE Ordinamento > 0
|
||||
AND IDStato = :id_stato
|
||||
AND (:documento IS NULL OR pl.Documento = TRY_CONVERT(int, :documento))
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_BarcodePickingListSkip AS s
|
||||
WHERE s.Documento COLLATE Latin1_General_CI_AS =
|
||||
CAST(pl.Documento AS varchar(50)) COLLATE Latin1_General_CI_AS
|
||||
AND s.Pallet COLLATE Latin1_General_CI_AS =
|
||||
CAST(pl.Pallet AS varchar(50)) COLLATE Latin1_General_CI_AS
|
||||
AND s.IDStato = pl.IDStato
|
||||
AND s.Risolto = 0
|
||||
)
|
||||
ORDER BY OrdinePrelievoGruppo, Ordinamento, Pallet, Documento;
|
||||
"""
|
||||
|
||||
SQL_PICKING_BY_PALLET = """
|
||||
SELECT TOP (1)
|
||||
Documento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
Pallet,
|
||||
Cella,
|
||||
Ubicazione,
|
||||
Ordinamento,
|
||||
IDStato
|
||||
FROM dbo.py_ViewPackingListPrelievo
|
||||
WHERE Pallet COLLATE Latin1_General_CI_AS = :pallet COLLATE Latin1_General_CI_AS
|
||||
AND (:documento IS NULL OR Documento = TRY_CONVERT(int, :documento))
|
||||
ORDER BY OrdinePrelievoGruppo, Ordinamento, Pallet;
|
||||
"""
|
||||
|
||||
SQL_TRACE_BY_PALLET = """
|
||||
SELECT TOP (1)
|
||||
Pallet,
|
||||
Lotto,
|
||||
Prodotto,
|
||||
Descrizione
|
||||
FROM dbo.vXTracciaProdotti
|
||||
WHERE Pallet COLLATE Latin1_General_CI_AS = :pallet COLLATE Latin1_General_CI_AS
|
||||
ORDER BY Lotto;
|
||||
"""
|
||||
|
||||
SQL_CURRENT_LOCATION_BY_PALLET = """
|
||||
SELECT TOP (1)
|
||||
g.BarcodePallet,
|
||||
g.IDCella,
|
||||
RTRIM(c.Corsia) AS Corsia,
|
||||
RTRIM(CAST(c.Colonna AS varchar(32))) AS Colonna,
|
||||
RTRIM(CAST(c.Fila AS varchar(32))) AS Fila
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
LEFT JOIN dbo.Celle AS c
|
||||
ON c.ID = g.IDCella
|
||||
WHERE g.BarcodePallet COLLATE Latin1_General_CI_AS = :pallet COLLATE Latin1_General_CI_AS;
|
||||
"""
|
||||
|
||||
SQL_OPEN_LOCATIONS_BY_PALLET = """
|
||||
SELECT
|
||||
g.BarcodePallet,
|
||||
g.IDCella,
|
||||
RTRIM(c.Corsia) AS Corsia,
|
||||
RTRIM(CAST(c.Colonna AS varchar(32))) AS Colonna,
|
||||
RTRIM(CAST(c.Fila AS varchar(32))) AS Fila
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
LEFT JOIN dbo.Celle AS c
|
||||
ON c.ID = g.IDCella
|
||||
WHERE g.BarcodePallet COLLATE Latin1_General_CI_AS = :pallet COLLATE Latin1_General_CI_AS
|
||||
ORDER BY g.IDCella;
|
||||
"""
|
||||
|
||||
SQL_OPEN_PALLETS_BY_CELL = """
|
||||
SELECT
|
||||
g.BarcodePallet,
|
||||
g.IDCella
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
WHERE g.IDCella = :id_cella
|
||||
ORDER BY g.BarcodePallet;
|
||||
"""
|
||||
|
||||
SQL_CLOSED_PICKING_BY_PALLET = """
|
||||
SELECT TOP (1)
|
||||
g.BarcodePallet,
|
||||
g.NumeroPallet,
|
||||
g.IDMagazzino,
|
||||
g.IDArea,
|
||||
g.IDCella,
|
||||
g.IDStato
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
WHERE g.IDCella <> 9999
|
||||
AND g.BarcodePallet COLLATE Latin1_General_CI_AS = :pallet COLLATE Latin1_General_CI_AS
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM SAMA1_Xwmstest.dbo.LOTSER AS ls
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.LOTTIBF AS lb
|
||||
ON lb.IDLOTSER = ls.ID
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.FATRIG AS fr
|
||||
ON lb.IDFATRIG = fr.ID
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.BAMTES AS bt
|
||||
ON bt.ID = fr.IDBAM
|
||||
WHERE bt.ANNDOC >= 2011
|
||||
AND bt.STATO = 'D'
|
||||
AND LEFT(ls.NUMSER, 6) COLLATE Latin1_General_CI_AS =
|
||||
:pallet COLLATE Latin1_General_CI_AS
|
||||
)
|
||||
ORDER BY g.IDCella DESC;
|
||||
"""
|
||||
|
||||
SQL_RESOLVE_PHYSICAL_CELL = """
|
||||
DECLARE @raw int = TRY_CONVERT(int, :destination);
|
||||
DECLARE @cell_id int =
|
||||
CASE
|
||||
WHEN @raw IS NULL THEN NULL
|
||||
WHEN @raw >= 9000000 THEN @raw - 9000000
|
||||
ELSE @raw
|
||||
END;
|
||||
|
||||
SELECT TOP (1)
|
||||
c.ID AS IDCella,
|
||||
CAST(9000000 + c.ID AS varchar(8)) AS BarcodeCella,
|
||||
9000000 + c.ID AS NumeroCella,
|
||||
CONCAT(RTRIM(c.Corsia), '.', RTRIM(CAST(c.Colonna AS varchar(32))), '.', RTRIM(CAST(c.Fila AS varchar(32)))) AS Ubicazione
|
||||
FROM dbo.Celle AS c
|
||||
WHERE c.ID = @cell_id
|
||||
AND c.ID <> 9999
|
||||
AND c.DelDataOra IS NULL;
|
||||
"""
|
||||
|
||||
SQL_LEGACY_MOVE = """
|
||||
SET NOCOUNT ON;
|
||||
SET XACT_ABORT ON;
|
||||
DECLARE @RC int = 0;
|
||||
DECLARE @RefreshPickingReservation bit = :refresh_picking_reservation;
|
||||
|
||||
EXEC dbo.sp_xMagGestioneMagazziniPallet
|
||||
@IDOperatore = :id_operatore,
|
||||
@BarcodeCella = :barcode_cella,
|
||||
@BarcodePallet = :barcode_pallet,
|
||||
@NumeroCella = :numero_cella,
|
||||
@RC = @RC OUTPUT;
|
||||
|
||||
IF @RefreshPickingReservation = 1
|
||||
BEGIN
|
||||
EXEC dbo.py_sp_ControllaPrenotazionePackingListPalletNew;
|
||||
END;
|
||||
|
||||
SELECT
|
||||
@RC AS RC,
|
||||
:barcode_cella AS BarcodeCella,
|
||||
:barcode_pallet AS BarcodePallet,
|
||||
:numero_cella AS NumeroCella;
|
||||
"""
|
||||
|
||||
SQL_SKIP_PICKING_PALLET = """
|
||||
SET NOCOUNT ON;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_BarcodePickingListSkip
|
||||
WHERE Documento = :documento
|
||||
AND Pallet COLLATE Latin1_General_CI_AS = :pallet COLLATE Latin1_General_CI_AS
|
||||
AND IDStato = :id_stato
|
||||
AND Risolto = 0
|
||||
)
|
||||
BEGIN
|
||||
INSERT INTO dbo.py_BarcodePickingListSkip (
|
||||
Documento,
|
||||
Pallet,
|
||||
IDStato,
|
||||
IDOperatore,
|
||||
DataOra,
|
||||
Motivo,
|
||||
Risolto
|
||||
)
|
||||
VALUES (
|
||||
:documento,
|
||||
:pallet,
|
||||
:id_stato,
|
||||
:id_operatore,
|
||||
SYSDATETIME(),
|
||||
:motivo,
|
||||
0
|
||||
);
|
||||
END;
|
||||
|
||||
SELECT
|
||||
:documento AS Documento,
|
||||
:pallet AS Pallet,
|
||||
:id_stato AS IDStato;
|
||||
"""
|
||||
|
||||
SQL_ACTIVE_SKIPPED_DOCUMENT = """
|
||||
SELECT TOP (1)
|
||||
s.Documento,
|
||||
COUNT(*) AS SkippedCount
|
||||
FROM dbo.py_BarcodePickingListSkip AS s
|
||||
WHERE s.IDStato = :id_stato
|
||||
AND (:documento IS NULL OR s.Documento = :documento)
|
||||
AND s.Risolto = 0
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_ViewPackingListRestante AS pl
|
||||
WHERE CAST(pl.Documento AS varchar(50)) COLLATE Latin1_General_CI_AS =
|
||||
s.Documento COLLATE Latin1_General_CI_AS
|
||||
AND pl.IDStato = :id_stato
|
||||
AND CAST(pl.Pallet AS varchar(50)) COLLATE Latin1_General_CI_AS =
|
||||
s.Pallet COLLATE Latin1_General_CI_AS
|
||||
)
|
||||
GROUP BY s.Documento
|
||||
ORDER BY MIN(s.DataOra);
|
||||
"""
|
||||
|
||||
SQL_PICKING_DOCUMENT_REMAINING = """
|
||||
SELECT COUNT(DISTINCT Pallet) AS RemainingCount
|
||||
FROM dbo.py_XMag_ViewPackingListStorico
|
||||
WHERE Documento = TRY_CONVERT(int, :documento)
|
||||
AND Cella <> 9999;
|
||||
"""
|
||||
|
||||
SQL_RELEASE_PICKING_DOCUMENT = """
|
||||
SET NOCOUNT ON;
|
||||
DECLARE @RC int = 0;
|
||||
|
||||
EXEC dbo.py_sp_xExePackingListPallet
|
||||
@IDOperatore = :id_operatore,
|
||||
@Documento = :documento,
|
||||
@Azione = 'S',
|
||||
@RC = @RC OUTPUT;
|
||||
|
||||
SELECT CAST(@RC AS int) AS RC;
|
||||
"""
|
||||
|
||||
|
||||
def _rows_to_dicts(res: dict[str, Any] | None) -> list[dict[str, Any]]:
|
||||
"""Convert ``query_json`` payloads to a list of row dictionaries."""
|
||||
|
||||
if not isinstance(res, dict):
|
||||
return []
|
||||
rows = res.get("rows") or []
|
||||
cols = res.get("columns") or []
|
||||
if rows and isinstance(rows[0], dict):
|
||||
return [row for row in rows if isinstance(row, dict)]
|
||||
out: list[dict[str, Any]] = []
|
||||
for row in rows:
|
||||
if isinstance(row, (list, tuple)) and cols:
|
||||
out.append({str(cols[i]): row[i] for i in range(min(len(cols), len(row)))})
|
||||
return out
|
||||
|
||||
|
||||
@dataclass
|
||||
class LegacyMoveResult:
|
||||
"""Result of one movement executed through the legacy stored procedure."""
|
||||
|
||||
rc: int
|
||||
barcode_cella: str
|
||||
barcode_pallet: str
|
||||
numero_cella: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class DestinationCell:
|
||||
"""Resolved warehouse cell accepted by the legacy movement procedure."""
|
||||
|
||||
barcode_cella: str
|
||||
numero_cella: int
|
||||
id_cella: int
|
||||
ubicazione: str
|
||||
|
||||
|
||||
class BarcodeRepository:
|
||||
"""Thin async repository used by the lightweight barcode client."""
|
||||
|
||||
def __init__(self, db_client):
|
||||
self.db_client = db_client
|
||||
|
||||
async def fetch_next_picking(self, id_stato: int, documento: str | None = None) -> dict[str, Any] | None:
|
||||
"""Select a document initially, then fetch only within that document."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_NEXT_PICKING, {
|
||||
"id_stato": int(id_stato), "documento": documento,
|
||||
})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def fetch_picking_by_pallet(self, pallet: str, documento: str | None = None) -> dict[str, Any] | None:
|
||||
"""Return one picking row for the given pallet, if still present in the queue."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_PICKING_BY_PALLET, {
|
||||
"pallet": str(pallet or "").strip(), "documento": documento,
|
||||
})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def fetch_trace_by_pallet(self, pallet: str) -> dict[str, Any] | None:
|
||||
"""Return trace information used by the C# fallback confirmation path."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_TRACE_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def fetch_current_location_by_pallet(self, pallet: str) -> dict[str, Any] | None:
|
||||
"""Return the current stock location for a pallet, if it exists in giacenza."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_CURRENT_LOCATION_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def fetch_open_locations_by_pallet(self, pallet: str) -> list[dict[str, Any]]:
|
||||
"""Return all positive stock locations currently open for a pallet."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_OPEN_LOCATIONS_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
||||
return _rows_to_dicts(res)
|
||||
|
||||
async def fetch_open_pallets_by_cell(self, id_cella: int) -> list[dict[str, Any]]:
|
||||
"""Return pallets currently present in a physical cell."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_OPEN_PALLETS_BY_CELL, {"id_cella": int(id_cella)})
|
||||
return _rows_to_dicts(res)
|
||||
|
||||
async def fetch_closed_picking_by_pallet(self, pallet: str) -> dict[str, Any] | None:
|
||||
"""Return a closed picking-list row for a pallet already considered shipped."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_CLOSED_PICKING_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def skip_picking_pallet(
|
||||
self,
|
||||
*,
|
||||
documento: str,
|
||||
pallet: str,
|
||||
id_stato: int,
|
||||
operator_id: int,
|
||||
motivo: str = "UDC non trovata dal magazziniere",
|
||||
) -> None:
|
||||
"""Persist one skipped picking-list pallet so the queue can advance."""
|
||||
|
||||
params = {
|
||||
"documento": str(documento or "").strip(),
|
||||
"pallet": str(pallet or "").strip(),
|
||||
"id_stato": int(id_stato),
|
||||
"id_operatore": int(operator_id),
|
||||
"motivo": str(motivo or "").strip(),
|
||||
}
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"PICKING SKIP START "
|
||||
f"documento={params['documento']} "
|
||||
f"pallet={params['pallet']} "
|
||||
f"id_stato={params['id_stato']} "
|
||||
f"operator={params['id_operatore']}"
|
||||
),
|
||||
)
|
||||
await self.db_client.query_json(SQL_SKIP_PICKING_PALLET, params, commit=True)
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"PICKING SKIP OK "
|
||||
f"documento={params['documento']} "
|
||||
f"pallet={params['pallet']} "
|
||||
f"id_stato={params['id_stato']}"
|
||||
),
|
||||
)
|
||||
|
||||
async def fetch_active_skipped_document(self, id_stato: int, documento: str | None = None) -> dict[str, Any] | None:
|
||||
"""Find skipped residuals, restricted to the active document when set."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_ACTIVE_SKIPPED_DOCUMENT, {
|
||||
"id_stato": int(id_stato), "documento": documento,
|
||||
})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def count_picking_document_remaining(self, documento: str) -> int:
|
||||
"""Check residuals independently of priority before declaring completion."""
|
||||
res = await self.db_client.query_json(SQL_PICKING_DOCUMENT_REMAINING, {"documento": documento})
|
||||
rows = _rows_to_dicts(res)
|
||||
return int(rows[0]["RemainingCount"]) if rows else 0
|
||||
|
||||
async def release_picking_document(self, *, documento: str, operator_id: int) -> int:
|
||||
"""Release a reserved picking-list document without closing its residual rows."""
|
||||
|
||||
params = {
|
||||
"documento": str(documento or "").strip(),
|
||||
"id_operatore": int(operator_id),
|
||||
}
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
f"PICKING AUTO RELEASE START documento={params['documento']} operator={params['id_operatore']}",
|
||||
)
|
||||
res = await self.db_client.query_json(SQL_RELEASE_PICKING_DOCUMENT, params, as_dict_rows=True, commit=True)
|
||||
rows = _rows_to_dicts(res)
|
||||
rc = 0
|
||||
if rows:
|
||||
try:
|
||||
rc = int(rows[0].get("RC") or 0)
|
||||
except Exception:
|
||||
rc = 0
|
||||
log_runtime_event("Barcode WMS", f"PICKING AUTO RELEASE END documento={params['documento']} rc={rc}")
|
||||
return rc
|
||||
|
||||
async def resolve_physical_cell(self, destination: str) -> DestinationCell | None:
|
||||
"""Accept either an internal cell ID or the scanned legacy cell barcode."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_RESOLVE_PHYSICAL_CELL, {"destination": str(destination or "").strip()})
|
||||
rows = _rows_to_dicts(res)
|
||||
if not rows:
|
||||
return None
|
||||
row = rows[0]
|
||||
return DestinationCell(
|
||||
barcode_cella=str(row.get("BarcodeCella") or ""),
|
||||
numero_cella=int(row.get("NumeroCella") or 0),
|
||||
id_cella=int(row.get("IDCella") or 0),
|
||||
ubicazione=str(row.get("Ubicazione") or ""),
|
||||
)
|
||||
|
||||
async def execute_legacy_move(
|
||||
self,
|
||||
*,
|
||||
operator_id: int,
|
||||
barcode_cella: str,
|
||||
barcode_pallet: str,
|
||||
numero_cella: int,
|
||||
refresh_picking_reservation: bool = True,
|
||||
) -> LegacyMoveResult:
|
||||
"""Execute the same stored procedure used by the C# barcode form."""
|
||||
|
||||
params = {
|
||||
"id_operatore": int(operator_id),
|
||||
"barcode_cella": str(barcode_cella or "").strip(),
|
||||
"barcode_pallet": str(barcode_pallet or "").strip(),
|
||||
"numero_cella": int(numero_cella),
|
||||
"refresh_picking_reservation": 1 if refresh_picking_reservation else 0,
|
||||
}
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE START "
|
||||
f"operator={params['id_operatore']} "
|
||||
f"cell={params['barcode_cella']} "
|
||||
f"pallet={params['barcode_pallet']} "
|
||||
f"refresh_pl={params['refresh_picking_reservation']}"
|
||||
),
|
||||
)
|
||||
try:
|
||||
res = await self.db_client.query_json(SQL_LEGACY_MOVE, params, commit=True)
|
||||
except Exception as exc:
|
||||
log_exception(
|
||||
"Barcode WMS",
|
||||
exc,
|
||||
context=(
|
||||
"execute_legacy_move "
|
||||
f"operator={params['id_operatore']} "
|
||||
f"cell={params['barcode_cella']} "
|
||||
f"pallet={params['barcode_pallet']}"
|
||||
),
|
||||
)
|
||||
raise
|
||||
rows = _rows_to_dicts(res)
|
||||
row = rows[0] if rows else {}
|
||||
result = LegacyMoveResult(
|
||||
rc=int(row.get("RC") or 0),
|
||||
barcode_cella=str(row.get("BarcodeCella") or params["barcode_cella"]),
|
||||
barcode_pallet=str(row.get("BarcodePallet") or params["barcode_pallet"]),
|
||||
numero_cella=int(row.get("NumeroCella") or params["numero_cella"]),
|
||||
)
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE OK "
|
||||
f"rc={result.rc} "
|
||||
f"cell={result.barcode_cella} "
|
||||
f"pallet={result.barcode_pallet}"
|
||||
),
|
||||
)
|
||||
return result
|
||||
779
barcode_service.py
Normal file
779
barcode_service.py
Normal file
@@ -0,0 +1,779 @@
|
||||
"""Service layer for the lightweight barcode WMS client."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, replace
|
||||
from typing import Literal
|
||||
|
||||
from barcode_repository import BarcodeRepository, LegacyMoveResult
|
||||
from runtime_support import log_exception, log_runtime_event
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
ModeName = Literal["idle", "priority_high", "priority_low", "manual_load", "manual_unload", "confirm"]
|
||||
|
||||
|
||||
@dataclass
|
||||
class BarcodeViewState:
|
||||
"""State projected from service logic into the barcode UI."""
|
||||
|
||||
mode: ModeName = "idle"
|
||||
queue_label: str = ""
|
||||
status_text: str = "Pronto."
|
||||
status_color: str = "#d9d9d9"
|
||||
source_location: str = ""
|
||||
document: str = ""
|
||||
customer: str = ""
|
||||
expected_pallet: str = ""
|
||||
destination_barcode: str = ""
|
||||
scanned_pallet: str = ""
|
||||
auto_advance_delay_ms: int = 0
|
||||
destination_readonly: bool = False
|
||||
focus_destination: bool = False
|
||||
|
||||
|
||||
@dataclass
|
||||
class BarcodeActionResult:
|
||||
"""Standard result returned by user actions."""
|
||||
|
||||
ok: bool
|
||||
state: BarcodeViewState
|
||||
message: str = ""
|
||||
|
||||
|
||||
class BarcodeService:
|
||||
"""Faithful, but cleaner, port of the legacy barcode form logic."""
|
||||
|
||||
NON_SCAFFALATA_BARCODE = "9001000"
|
||||
SHIPPED_BARCODE = "9000000"
|
||||
GRAY = "#d9d9d9"
|
||||
RED = "#f4cccc"
|
||||
LIGHT_GREEN = "#d9ead3"
|
||||
GREEN_YELLOW = "#e2f0cb"
|
||||
CONVENTIONAL_LOCATION_BY_CELL = {
|
||||
1000: "5E.1.1 - Non scaffalata",
|
||||
9999: "7G.1.1 - Spedita",
|
||||
}
|
||||
|
||||
def __init__(self, repository: BarcodeRepository, operator_id: int):
|
||||
self.repository = repository
|
||||
self.operator_id = int(operator_id)
|
||||
self._current_priority_state = -1
|
||||
# Independent document identities survive confirmations, F1/F2 and pause.
|
||||
self._priority_documents: dict[int, str] = {}
|
||||
self._state = BarcodeViewState()
|
||||
|
||||
@property
|
||||
def state(self) -> BarcodeViewState:
|
||||
"""Return a copy-safe reference to the current UI state."""
|
||||
|
||||
return self._state
|
||||
|
||||
def reset(self) -> BarcodeViewState:
|
||||
"""Return the client to its neutral state."""
|
||||
|
||||
self._current_priority_state = -1
|
||||
self._priority_documents.clear()
|
||||
self._state = BarcodeViewState()
|
||||
return self._state
|
||||
|
||||
def begin_manual_load(self) -> BarcodeViewState:
|
||||
"""Prepare a real versamento into a physical warehouse cell."""
|
||||
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_load",
|
||||
queue_label="Versamento",
|
||||
status_text="OP Carico",
|
||||
status_color=self.GRAY,
|
||||
)
|
||||
return self._state
|
||||
|
||||
def begin_manual_unload(self) -> BarcodeViewState:
|
||||
"""Prepare a direct unload toward the conventional non-shelved cell."""
|
||||
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_unload",
|
||||
queue_label="Prelievo diretto",
|
||||
status_text="OP Scarico",
|
||||
status_color=self.GRAY,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
destination_readonly=True,
|
||||
)
|
||||
return self._state
|
||||
|
||||
def begin_priority_pause(self, id_stato: int) -> BarcodeViewState:
|
||||
"""Pause the active picking queue locally for exactly one free movement."""
|
||||
|
||||
self._current_priority_state = int(id_stato)
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_unload",
|
||||
queue_label="Pausa PL",
|
||||
status_text="Premi ESC per uscire dalla pausa",
|
||||
status_color=self.GRAY,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
destination_readonly=False,
|
||||
)
|
||||
return self._state
|
||||
|
||||
def resume_priority_state(self, state: BarcodeViewState) -> BarcodeViewState:
|
||||
"""Restore the exact picking pallet that was visible before a local pause."""
|
||||
|
||||
if state.mode not in ("priority_high", "priority_low"):
|
||||
return self._state
|
||||
self._current_priority_state = 1 if state.mode == "priority_high" else 0
|
||||
self._priority_documents[self._current_priority_state] = state.document
|
||||
self._state = replace(state, scanned_pallet="", auto_advance_delay_ms=0)
|
||||
return self._state
|
||||
|
||||
async def skip_current_picking_pallet(self) -> BarcodeActionResult:
|
||||
"""Mark the currently proposed picking pallet as skipped and advance."""
|
||||
|
||||
mode = str(self._state.mode or "")
|
||||
if mode not in ("priority_high", "priority_low"):
|
||||
return BarcodeActionResult(False, self._state, "Nessuna picking list attiva.")
|
||||
|
||||
id_stato = 1 if mode == "priority_high" else 0
|
||||
documento = str(self._state.document or "").strip()
|
||||
pallet = str(self._state.expected_pallet or "").strip()
|
||||
if not documento or not pallet:
|
||||
self._state.status_text = "Nessuna UDC da saltare."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
await self.repository.skip_picking_pallet(
|
||||
documento=documento,
|
||||
pallet=pallet,
|
||||
id_stato=id_stato,
|
||||
operator_id=self.operator_id,
|
||||
)
|
||||
queue_label = "Alta priorita' (F1)" if id_stato == 1 else "Bassa priorita' (F2)"
|
||||
self._current_priority_state = id_stato
|
||||
self._state = BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label=queue_label,
|
||||
status_text="UDC saltata - chiusura manuale richiesta",
|
||||
status_color=self.RED,
|
||||
source_location=self._state.source_location,
|
||||
document=documento,
|
||||
customer="UDC non trovata",
|
||||
expected_pallet=pallet,
|
||||
destination_barcode=self.SHIPPED_BARCODE,
|
||||
auto_advance_delay_ms=1500,
|
||||
destination_readonly=True,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def start_priority_queue(self, id_stato: int) -> BarcodeActionResult:
|
||||
"""Keep each F1/F2 cycle bound to its document until the cycle stops."""
|
||||
|
||||
id_stato = int(id_stato)
|
||||
active_document = self._priority_documents.get(id_stato)
|
||||
row = await self.repository.fetch_next_picking(id_stato, documento=active_document)
|
||||
self._current_priority_state = id_stato
|
||||
queue_label = "Alta priorita' (F1)" if int(id_stato) == 1 else "Bassa priorita' (F2)"
|
||||
if not row:
|
||||
skipped_doc = await self.repository.fetch_active_skipped_document(id_stato, documento=active_document)
|
||||
if skipped_doc:
|
||||
documento = str(skipped_doc.get("Documento") or "").strip()
|
||||
skipped_count = int(skipped_doc.get("SkippedCount") or 0)
|
||||
rc = await self.repository.release_picking_document(
|
||||
documento=documento,
|
||||
operator_id=self.operator_id,
|
||||
)
|
||||
if rc != 0:
|
||||
raise RuntimeError(f"Impossibile sospendere PL {documento}: RC={rc}")
|
||||
self._priority_documents.pop(id_stato, None)
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_unload",
|
||||
queue_label=queue_label,
|
||||
status_text=f"PL {documento} sospesa: {skipped_count} UDC saltate. Riprenota per completare.",
|
||||
status_color=self.RED,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
destination_readonly=False,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state)
|
||||
status_text = "Pronto."
|
||||
remaining = 0
|
||||
if active_document:
|
||||
remaining = await self.repository.count_picking_document_remaining(active_document)
|
||||
status_text = (
|
||||
f"PL {active_document}: {remaining} UDC residue, coda non disponibile. Verifica la prenotazione."
|
||||
if remaining else f"PL {active_document} terminata. Premi F1 o F2 per iniziare."
|
||||
)
|
||||
log_runtime_event("Barcode WMS", f"PICKING CYCLE STOP documento={active_document} priority={id_stato} remaining={remaining}")
|
||||
# A changed reservation or visibility filter must not silently
|
||||
# replace an unfinished document on the next press of F1/F2.
|
||||
if not remaining:
|
||||
self._priority_documents.pop(id_stato, None)
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_unload",
|
||||
queue_label=queue_label,
|
||||
status_text=status_text,
|
||||
status_color=self.RED,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
destination_readonly=False,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state)
|
||||
|
||||
document = str(row.get("Documento") or "").strip()
|
||||
if not document or (active_document is not None and document != active_document):
|
||||
raise RuntimeError(f"Cambio inatteso documento picking: atteso={active_document}, ricevuto={document}")
|
||||
self._priority_documents[id_stato] = document
|
||||
if active_document is None:
|
||||
log_runtime_event("Barcode WMS", f"PICKING CYCLE START documento={document} priority={id_stato}")
|
||||
customer = f"{row.get('CodNazione') or ''} - {row.get('NAZIONE') or ''}".strip(" -")
|
||||
source_location = self._display_location(
|
||||
cella=row.get("Cella"),
|
||||
ubicazione=row.get("Ubicazione"),
|
||||
)
|
||||
self._state = BarcodeViewState(
|
||||
mode="priority_high" if int(id_stato) == 1 else "priority_low",
|
||||
queue_label=queue_label,
|
||||
status_text=f"Ok Cella - {source_location}",
|
||||
status_color=self.LIGHT_GREEN,
|
||||
source_location=source_location,
|
||||
document=str(row.get("Documento") or ""),
|
||||
customer=customer,
|
||||
expected_pallet=str(row.get("Pallet") or ""),
|
||||
destination_barcode=self.SHIPPED_BARCODE,
|
||||
destination_readonly=True,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state)
|
||||
|
||||
async def submit(self, *, scanned_pallet: str, destination_barcode: str) -> BarcodeActionResult:
|
||||
"""Execute the movement according to the current mode."""
|
||||
|
||||
pallet = str(scanned_pallet or "").strip()
|
||||
destination = str(destination_barcode or "").strip()
|
||||
if not pallet:
|
||||
return BarcodeActionResult(False, self._state, "Inserisci o leggi il pallet.")
|
||||
if not destination:
|
||||
return BarcodeActionResult(False, self._state, "Inserisci o leggi la destinazione.")
|
||||
if not destination.isdigit():
|
||||
return BarcodeActionResult(False, self._state, "La destinazione deve essere numerica.")
|
||||
|
||||
is_priority_mode = self._state.mode in ("priority_high", "priority_low")
|
||||
expected_before_move = str(self._state.expected_pallet or "").strip()
|
||||
is_picking_unload = bool(is_priority_mode and expected_before_move and destination == self.SHIPPED_BARCODE)
|
||||
is_direct_unload = bool(destination == self.NON_SCAFFALATA_BARCODE and not is_picking_unload)
|
||||
is_direct_load = bool(destination not in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE) and not is_picking_unload)
|
||||
|
||||
if is_priority_mode and destination == self.SHIPPED_BARCODE:
|
||||
if expected_before_move and expected_before_move != pallet:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.status_text = "Errata lettura: il pallet letto non coincide con quello atteso."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
if not is_picking_unload:
|
||||
blocked = await self._block_closed_picking_free_move(pallet, destination)
|
||||
if blocked is not None:
|
||||
return blocked
|
||||
|
||||
target_barcode = destination
|
||||
target_numero_cella = int(destination)
|
||||
target_id_cella = 9999 if destination == self.SHIPPED_BARCODE else (1000 if destination == self.NON_SCAFFALATA_BARCODE else None)
|
||||
target_display = destination
|
||||
if is_direct_load:
|
||||
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
||||
if not resolved_cell:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = f"Cella non valida: {destination}."
|
||||
self._state.status_color = self.RED
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
occupants = await self.repository.fetch_open_pallets_by_cell(resolved_cell.id_cella)
|
||||
if occupants:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED DESTINATION_OCCUPIED "
|
||||
f"pallet={pallet} "
|
||||
f"cell={resolved_cell.id_cella} "
|
||||
f"occupants={','.join(str(row.get('BarcodePallet') or '') for row in occupants)}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Errore: cella scelta occupata, cambiare cella di destinazione."
|
||||
self._state.status_color = self.RED
|
||||
self._state.destination_readonly = False
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
target_barcode = resolved_cell.barcode_cella
|
||||
target_numero_cella = resolved_cell.numero_cella
|
||||
target_id_cella = resolved_cell.id_cella
|
||||
target_display = resolved_cell.ubicazione or destination
|
||||
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
picking_before_move = (
|
||||
None
|
||||
if current_location
|
||||
else await self.repository.fetch_picking_by_pallet(
|
||||
pallet,
|
||||
documento=self._priority_documents.get(self._current_priority_state) if is_picking_unload else None,
|
||||
)
|
||||
)
|
||||
if not current_location and not picking_before_move:
|
||||
if is_direct_load:
|
||||
trace_row = await self.repository.fetch_trace_by_pallet(pallet)
|
||||
if not trace_row:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Errore: UDC non riconosciuta in ERP/SAM."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
f"AUTO INTAKE NON_SHELVED pallet={pallet} before_cell={target_id_cella}",
|
||||
)
|
||||
await self.repository.execute_legacy_move(
|
||||
operator_id=self.operator_id,
|
||||
barcode_cella=self.NON_SCAFFALATA_BARCODE,
|
||||
barcode_pallet=pallet,
|
||||
numero_cella=int(self.NON_SCAFFALATA_BARCODE),
|
||||
refresh_picking_reservation=False,
|
||||
)
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
current_id_cella = int((current_location or {}).get("IDCella") or 0)
|
||||
except Exception:
|
||||
current_id_cella = 0
|
||||
if current_id_cella != 1000:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Movimento non confermato: ingresso UDC non scaffalata non riuscito."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
else:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.status_text = "UDC non presente a magazzino."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
open_locations = await self.repository.fetch_open_locations_by_pallet(pallet)
|
||||
distinct_cells = sorted({
|
||||
int(row.get("IDCella") or 0)
|
||||
for row in open_locations
|
||||
if row.get("IDCella") is not None
|
||||
})
|
||||
if len(distinct_cells) > 1:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED MULTI_LOCATION "
|
||||
f"pallet={pallet} "
|
||||
f"cells={','.join(str(cell) for cell in distinct_cells)}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "UDC presente in piu' celle. Movimento bloccato."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
if not is_direct_load and destination not in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE):
|
||||
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
||||
if not resolved_cell:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.status_text = f"Cella non valida: {destination}."
|
||||
self._state.status_color = self.RED
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
target_barcode = resolved_cell.barcode_cella
|
||||
target_numero_cella = resolved_cell.numero_cella
|
||||
target_id_cella = resolved_cell.id_cella
|
||||
target_display = resolved_cell.ubicazione or destination
|
||||
|
||||
move = await self.repository.execute_legacy_move(
|
||||
operator_id=self.operator_id,
|
||||
barcode_cella=target_barcode,
|
||||
barcode_pallet=pallet,
|
||||
numero_cella=target_numero_cella,
|
||||
refresh_picking_reservation=is_picking_unload,
|
||||
)
|
||||
|
||||
final_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
final_cell = int((final_location or {}).get("IDCella") or 0)
|
||||
except Exception:
|
||||
final_cell = 0
|
||||
if target_id_cella is not None and final_cell != target_id_cella:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Movimento non confermato: la UDC non risulta nella cella attesa."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
try:
|
||||
self._state = await self._build_post_move_state(
|
||||
barcode_pallet=pallet,
|
||||
destination_barcode=destination,
|
||||
destination_display=target_display,
|
||||
last_priority_state=self._current_priority_state,
|
||||
auto_advance_delay_ms=3000 if is_picking_unload else 0,
|
||||
)
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context=f"post move state pallet={pallet} destination={destination}")
|
||||
self._state = BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label="Conferma movimento",
|
||||
status_text="Movimento eseguito. Dettagli non aggiornati.",
|
||||
status_color=self.GREEN_YELLOW,
|
||||
destination_barcode=destination,
|
||||
scanned_pallet=pallet,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def submit_unload_with_source_check(self, *, scanned_pallet: str, source_barcode: str) -> BarcodeActionResult:
|
||||
"""Unload to the non-shelved cell only if the scanned source cell matches DB."""
|
||||
|
||||
pallet = str(scanned_pallet or "").strip()
|
||||
source = str(source_barcode or "").strip()
|
||||
if not pallet:
|
||||
return BarcodeActionResult(False, self._state, "Inserisci o leggi il pallet.")
|
||||
if not source:
|
||||
return BarcodeActionResult(False, self._state, "Leggi il codice della cella da scaricare.")
|
||||
if not source.isdigit():
|
||||
return BarcodeActionResult(False, self._state, "La cella da scaricare deve essere numerica.")
|
||||
|
||||
blocked = await self._block_closed_picking_free_move(pallet, source)
|
||||
if blocked is not None:
|
||||
return blocked
|
||||
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
if not current_location:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.status_text = "UDC non presente a magazzino."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
open_locations = await self.repository.fetch_open_locations_by_pallet(pallet)
|
||||
distinct_cells = sorted({
|
||||
int(row.get("IDCella") or 0)
|
||||
for row in open_locations
|
||||
if row.get("IDCella") is not None
|
||||
})
|
||||
if len(distinct_cells) > 1:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED MULTI_LOCATION "
|
||||
f"pallet={pallet} "
|
||||
f"cells={','.join(str(cell) for cell in distinct_cells)}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "UDC presente in piu' celle. Movimento bloccato."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
if source == self.NON_SCAFFALATA_BARCODE:
|
||||
source_id_cella = 1000
|
||||
else:
|
||||
resolved_source = await self.repository.resolve_physical_cell(source)
|
||||
if not resolved_source:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = f"Cella non valida: {source}."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
source_id_cella = int(resolved_source.id_cella)
|
||||
|
||||
current_id_cella = int((current_location or {}).get("IDCella") or 0)
|
||||
if current_id_cella != source_id_cella:
|
||||
if source == self.NON_SCAFFALATA_BARCODE and current_id_cella != 1000:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED SOURCE_REQUIRED "
|
||||
f"pallet={pallet} "
|
||||
f"db_cell={current_id_cella} "
|
||||
f"default_cell={source_id_cella}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "Errore: leggi la cella da scaricare."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED SOURCE_MISMATCH "
|
||||
f"pallet={pallet} "
|
||||
f"db_cell={current_id_cella} "
|
||||
f"scanned_cell={source_id_cella}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "Errore: UDC in cella diversa, rileggi il codice della cella da scaricare."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
await self.repository.execute_legacy_move(
|
||||
operator_id=self.operator_id,
|
||||
barcode_cella=self.NON_SCAFFALATA_BARCODE,
|
||||
barcode_pallet=pallet,
|
||||
numero_cella=int(self.NON_SCAFFALATA_BARCODE),
|
||||
refresh_picking_reservation=False,
|
||||
)
|
||||
|
||||
final_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
final_cell = int((final_location or {}).get("IDCella") or 0)
|
||||
except Exception:
|
||||
final_cell = 0
|
||||
if final_cell != 1000:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "Movimento non confermato: la UDC non risulta non scaffalata."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
try:
|
||||
self._state = await self._build_post_move_state(
|
||||
barcode_pallet=pallet,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
destination_display=self.CONVENTIONAL_LOCATION_BY_CELL[1000],
|
||||
last_priority_state=self._current_priority_state,
|
||||
auto_advance_delay_ms=0,
|
||||
)
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context=f"post source-check unload pallet={pallet} source={source}")
|
||||
self._state = BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label="Conferma movimento",
|
||||
status_text="Movimento eseguito. Dettagli non aggiornati.",
|
||||
status_color=self.GREEN_YELLOW,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
scanned_pallet=pallet,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def _block_closed_picking_free_move(
|
||||
self,
|
||||
pallet: str,
|
||||
destination_barcode: str,
|
||||
) -> BarcodeActionResult | None:
|
||||
closed_row = await self.repository.fetch_closed_picking_by_pallet(pallet)
|
||||
if not closed_row:
|
||||
return None
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED CLOSED_PICKING "
|
||||
f"pallet={pallet} "
|
||||
f"destination={destination_barcode} "
|
||||
f"id_cella={closed_row.get('IDCella')} "
|
||||
f"id_stato={closed_row.get('IDStato')}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination_barcode
|
||||
self._state.status_text = "Errore: UDC gia' spedita, problema nella locazione o nella UDC."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
async def reconcile_after_submit_exception(
|
||||
self,
|
||||
*,
|
||||
scanned_pallet: str,
|
||||
destination_barcode: str,
|
||||
) -> BarcodeActionResult:
|
||||
"""Check whether a failed client round-trip actually committed on SQL Server."""
|
||||
|
||||
pallet = str(scanned_pallet or "").strip()
|
||||
destination = str(destination_barcode or "").strip()
|
||||
if not pallet or not destination or not destination.isdigit():
|
||||
self._state.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
target_id_cella = 9999 if destination == self.SHIPPED_BARCODE else (1000 if destination == self.NON_SCAFFALATA_BARCODE else None)
|
||||
target_display = destination
|
||||
if target_id_cella is None:
|
||||
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
||||
if not resolved_cell:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
self._state.status_color = self.RED
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
target_id_cella = int(resolved_cell.id_cella)
|
||||
target_display = resolved_cell.ubicazione or destination
|
||||
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
current_id_cella = int((current_location or {}).get("IDCella") or 0)
|
||||
except Exception:
|
||||
current_id_cella = 0
|
||||
|
||||
if current_id_cella != target_id_cella:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE RECOVERY NOT_CONFIRMED "
|
||||
f"pallet={pallet} "
|
||||
f"destination={destination} "
|
||||
f"expected_cell={target_id_cella} "
|
||||
f"actual_cell={current_id_cella}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
last_priority_state = self._current_priority_state
|
||||
is_recovered_picking = bool(destination == self.SHIPPED_BARCODE and last_priority_state in (0, 1))
|
||||
auto_advance_delay_ms = 3000 if is_recovered_picking else 0
|
||||
state = await self._build_post_move_state(
|
||||
barcode_pallet=pallet,
|
||||
destination_barcode=destination,
|
||||
destination_display=target_display,
|
||||
last_priority_state=last_priority_state,
|
||||
auto_advance_delay_ms=auto_advance_delay_ms,
|
||||
)
|
||||
state.status_text = (
|
||||
"Ok Scarico - risposta persa recuperata"
|
||||
if is_recovered_picking
|
||||
else "Movimento completato - risposta persa recuperata"
|
||||
)
|
||||
state.status_color = self.GREEN_YELLOW
|
||||
self._state = state
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE RECOVERY CONFIRMED "
|
||||
f"pallet={pallet} "
|
||||
f"destination={destination} "
|
||||
f"cell={target_id_cella}"
|
||||
),
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def _build_post_move_state(
|
||||
self,
|
||||
*,
|
||||
barcode_pallet: str,
|
||||
destination_barcode: str,
|
||||
destination_display: str,
|
||||
last_priority_state: int,
|
||||
auto_advance_delay_ms: int,
|
||||
) -> BarcodeViewState:
|
||||
"""Mirror the legacy confirmation flow after one stored-procedure move."""
|
||||
|
||||
is_priority_shipping_confirmation = (
|
||||
destination_barcode == self.SHIPPED_BARCODE
|
||||
and last_priority_state in (0, 1)
|
||||
)
|
||||
picking_row = (
|
||||
await self.repository.fetch_picking_by_pallet(
|
||||
barcode_pallet, documento=self._priority_documents.get(last_priority_state),
|
||||
)
|
||||
if is_priority_shipping_confirmation
|
||||
else None
|
||||
)
|
||||
if picking_row:
|
||||
customer = f"{picking_row.get('CodNazione') or ''} - {picking_row.get('NAZIONE') or ''}".strip(" -")
|
||||
source_location = self._display_location(
|
||||
cella=picking_row.get("Cella"),
|
||||
ubicazione=picking_row.get("Ubicazione"),
|
||||
)
|
||||
return BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label="Alta priorita' (F1)" if last_priority_state == 1 else ("Bassa priorita' (F2)" if last_priority_state == 0 else ""),
|
||||
status_text=f"Ok Cella - {source_location}",
|
||||
status_color=self.LIGHT_GREEN,
|
||||
source_location=source_location,
|
||||
document=str(picking_row.get("Documento") or ""),
|
||||
customer=customer,
|
||||
expected_pallet=str(picking_row.get("Pallet") or ""),
|
||||
destination_barcode=destination_barcode,
|
||||
auto_advance_delay_ms=auto_advance_delay_ms,
|
||||
destination_readonly=True,
|
||||
)
|
||||
|
||||
trace_row = await self.repository.fetch_trace_by_pallet(barcode_pallet)
|
||||
if trace_row:
|
||||
lotto = str(trace_row.get("Lotto") or "")
|
||||
prodotto = str(trace_row.get("Prodotto") or "")
|
||||
descrizione = str(trace_row.get("Descrizione") or "")
|
||||
queue_label = "Alta priorita' (F1)" if last_priority_state == 1 else ("Bassa priorita' (F2)" if last_priority_state == 0 else "Conferma movimento")
|
||||
destination_label = self._display_destination_location(
|
||||
destination_barcode=destination_barcode,
|
||||
destination_display=destination_display,
|
||||
)
|
||||
return BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label=queue_label,
|
||||
status_text=(
|
||||
f"Ok Scarico - {destination_label}"
|
||||
if destination_barcode in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE)
|
||||
else f"Ok Carico - {destination_label}"
|
||||
),
|
||||
status_color=self.GREEN_YELLOW,
|
||||
source_location=destination_label,
|
||||
document=(
|
||||
self.CONVENTIONAL_LOCATION_BY_CELL[9999 if destination_barcode == self.SHIPPED_BARCODE else 1000]
|
||||
if destination_barcode in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE) and last_priority_state in (0, 1)
|
||||
else lotto
|
||||
),
|
||||
customer=(
|
||||
lotto
|
||||
if destination_barcode in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE) and last_priority_state in (0, 1)
|
||||
else prodotto
|
||||
),
|
||||
expected_pallet=(
|
||||
" - ".join(part for part in (prodotto, descrizione) if part)
|
||||
if destination_barcode in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE) and last_priority_state in (0, 1)
|
||||
else descrizione
|
||||
),
|
||||
destination_barcode=destination_barcode,
|
||||
scanned_pallet=barcode_pallet,
|
||||
auto_advance_delay_ms=auto_advance_delay_ms,
|
||||
destination_readonly=destination_barcode in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE),
|
||||
)
|
||||
|
||||
return BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label="Conferma movimento",
|
||||
status_text="Movimento eseguito.",
|
||||
status_color=self.GREEN_YELLOW,
|
||||
destination_barcode=destination_barcode,
|
||||
scanned_pallet=barcode_pallet,
|
||||
)
|
||||
|
||||
def _display_destination_location(self, *, destination_barcode: str, destination_display: str) -> str:
|
||||
"""Return the confirmation label for a movement destination."""
|
||||
|
||||
if destination_barcode == self.NON_SCAFFALATA_BARCODE:
|
||||
return self.CONVENTIONAL_LOCATION_BY_CELL[1000]
|
||||
if destination_barcode == self.SHIPPED_BARCODE:
|
||||
return self.CONVENTIONAL_LOCATION_BY_CELL[9999]
|
||||
return str(destination_display or destination_barcode or "")
|
||||
|
||||
def _display_location(self, *, cella: object, ubicazione: object) -> str:
|
||||
"""Return the operator-facing location, honoring legacy conventional cells."""
|
||||
|
||||
try:
|
||||
cella_int = int(cella)
|
||||
except Exception:
|
||||
cella_int = None
|
||||
if cella_int in self.CONVENTIONAL_LOCATION_BY_CELL:
|
||||
return self.CONVENTIONAL_LOCATION_BY_CELL[cella_int]
|
||||
return str(ubicazione or cella or "")
|
||||
89
busy_overlay.py
Normal file
89
busy_overlay.py
Normal file
@@ -0,0 +1,89 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import tkinter as tk
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
from ui_theme import theme_color, theme_font, theme_padding, theme_value
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
|
||||
class InlineBusyOverlay:
|
||||
"""Busy overlay rendered inside the same window, avoiding extra toplevels."""
|
||||
|
||||
def __init__(self, parent: tk.Misc, theme_cfg: dict[str, Any] | None = None):
|
||||
self.parent = parent
|
||||
self.theme_cfg = theme_cfg or {}
|
||||
self._cover: ctk.CTkFrame | None = None
|
||||
self._label: ctk.CTkLabel | None = None
|
||||
self._bar: ctk.CTkProgressBar | None = None
|
||||
|
||||
def show(self, message: str = "Attendere..."):
|
||||
if self._cover and self._cover.winfo_exists():
|
||||
if self._label:
|
||||
self._label.configure(text=message)
|
||||
try:
|
||||
self._cover.lift()
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
cover = ctk.CTkFrame(
|
||||
self.parent,
|
||||
corner_radius=0,
|
||||
fg_color=theme_color(self.theme_cfg, "overlay_cover_fg_color", ("#d9d9d9", "#4a4a4a")),
|
||||
)
|
||||
cover.place(relx=0, rely=0, relwidth=1, relheight=1)
|
||||
try:
|
||||
cover.lift()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
wrap = ctk.CTkFrame(
|
||||
cover,
|
||||
corner_radius=int(theme_value(self.theme_cfg, "overlay_panel_corner_radius", 10)),
|
||||
fg_color=theme_color(self.theme_cfg, "overlay_panel_fg_color", ("#f2f2f2", "#353535")),
|
||||
)
|
||||
wrap.place(relx=0.5, rely=0.5, anchor="center")
|
||||
|
||||
label = ctk.CTkLabel(
|
||||
wrap,
|
||||
text=message,
|
||||
font=theme_font(self.theme_cfg, "overlay_label_font", ("Segoe UI", 11, "bold")),
|
||||
)
|
||||
label_pad = theme_padding(self.theme_cfg, "overlay_label_padding", (18, 14, 18, 8))
|
||||
label.pack(padx=(label_pad[0], label_pad[2]), pady=(label_pad[1], label_pad[3]))
|
||||
|
||||
bar = ctk.CTkProgressBar(
|
||||
wrap,
|
||||
mode="indeterminate",
|
||||
width=int(theme_value(self.theme_cfg, "overlay_progress_width", 220)),
|
||||
)
|
||||
bar_pad = theme_padding(self.theme_cfg, "overlay_progress_padding", (18, 0, 18, 14))
|
||||
bar.pack(padx=(bar_pad[0], bar_pad[2]), pady=(bar_pad[1], bar_pad[3]))
|
||||
try:
|
||||
bar.start()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._cover = cover
|
||||
self._label = label
|
||||
self._bar = bar
|
||||
|
||||
def hide(self):
|
||||
if self._bar:
|
||||
try:
|
||||
self._bar.stop()
|
||||
except Exception:
|
||||
pass
|
||||
self._bar = None
|
||||
self._label = None
|
||||
if self._cover and self._cover.winfo_exists():
|
||||
try:
|
||||
self._cover.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
self._cover = None
|
||||
188
carico.csv
Normal file
188
carico.csv
Normal file
@@ -0,0 +1,188 @@
|
||||
NULL;0xFFFE900209004D006900630072006F0073006F00660074002000530051004C00200053006500720076006500720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E00A60C000000006D006400650033005C00670065007300740065007200700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FAFBEDFB00FCFF100E00010009000A000B0006000C000E00FCFF180F000B00060009000A000C000D000E000F00100011001200FCFF101100010009000A000B0006000C000E00FCFF1A0A00090002000A0006000B000C000D000E000F00100011001200FCFF1A0C00010009000B0006000A000C000D000E000F00100011001200FCFF100D00010009000B0006000A000C000E00FCFB1C1B0001000A0006000B001200100011000D0009000C000E000F000200;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65528;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;2025-10-09 15:05:53.347;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65534;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:05:04.247;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:05:04.920;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;50046000;2025-10-09 15:05:04.920;2025-10-09 15:05:54.967;501919;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;52;2025-10-09 15:05:54.967;2025-10-09 15:05:54.967;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:05:54.967;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Ordinamento > 0 AND IDStato = 0 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:05:54.967;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Ordinamento > 0 AND IDStato = 0 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;638870;2025-10-09 15:05:54.967;2025-10-09 15:05:55.603;27771;0;640;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;51364000;2025-10-09 15:05:04.247;2025-10-09 15:05:55.610;840626;2;672;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;39;2025-10-09 15:05:55.610;2025-10-09 15:05:55.610;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:05:55.607;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 5088 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:05:55.610;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 5088 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;212;2025-10-09 15:05:55.610;2025-10-09 15:05:55.610;6;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1960000;2025-10-09 15:05:54.967;2025-10-09 15:05:56.927;529690;0;640;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;50;2025-10-09 15:05:56.927;2025-10-09 15:05:56.927;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:05:56.933;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Ordinamento > 0 AND IDStato = 1 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:05:56.927;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Ordinamento > 0 AND IDStato = 1 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;652653;2025-10-09 15:05:56.927;2025-10-09 15:05:57.580;27771;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;1974000;2025-10-09 15:05:55.607;2025-10-09 15:05:57.580;840632;2;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;27;2025-10-09 15:05:57.580;2025-10-09 15:05:57.580;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:05:57.590;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 5076 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:05:57.580;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 5076 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;184;2025-10-09 15:05:57.580;2025-10-09 15:05:57.580;6;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;17050000;2025-10-09 15:05:56.933;2025-10-09 15:06:13.983;557461;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;45;2025-10-09 15:06:13.983;2025-10-09 15:06:13.983;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:13.983;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:13.983;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;113;2025-10-09 15:06:13.983;2025-10-09 15:06:13.983;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;0;2025-10-09 15:06:13.983;2025-10-09 15:06:13.983;557465;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;24;2025-10-09 15:06:13.983;2025-10-09 15:06:13.983;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:13.983;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;708;2025-10-09 15:06:13.983;2025-10-09 15:06:13.983;64;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;3000;2025-10-09 15:06:13.983;2025-10-09 15:06:13.987;557529;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;15;2025-10-09 15:06:13.987;2025-10-09 15:06:13.987;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:13.983;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9006061',@BarcodePallet='504492',@NumeroCella=9006061,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030363036314800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343439322E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100ED6B89001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;2002542;2025-10-09 15:06:13.987;2025-10-09 15:06:15.990;83776;0;1969;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;2020000;2025-10-09 15:06:13.983;2025-10-09 15:06:16.003;641305;0;1969;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;37;2025-10-09 15:06:16.003;2025-10-09 15:06:16.003;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:16.000;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504492' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:16.003;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504492' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;651476;2025-10-09 15:06:16.003;2025-10-09 15:06:16.653;27771;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;656000;2025-10-09 15:06:16.000;2025-10-09 15:06:16.657;669076;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;37;2025-10-09 15:06:16.657;2025-10-09 15:06:16.657;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:16.657;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504492';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:16.657;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504492';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;676063;2025-10-09 15:06:16.657;2025-10-09 15:06:17.333;17798;0;672;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;19743000;2025-10-09 15:05:57.590;2025-10-09 15:06:17.333;840638;2;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;43;2025-10-09 15:06:17.333;2025-10-09 15:06:17.333;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:17.327;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006061 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:17.333;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006061 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;196;2025-10-09 15:06:17.333;2025-10-09 15:06:17.333;2;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;13080000;2025-10-09 15:06:16.657;2025-10-09 15:06:29.737;686874;0;672;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;50;2025-10-09 15:06:29.737;2025-10-09 15:06:29.737;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:29.750;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:29.737;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;123;2025-10-09 15:06:29.737;2025-10-09 15:06:29.737;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;-14000;2025-10-09 15:06:29.750;2025-10-09 15:06:29.737;686878;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;82;2025-10-09 15:06:29.737;2025-10-09 15:06:29.737;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:29.750;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1465;2025-10-09 15:06:29.737;2025-10-09 15:06:29.737;64;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;-10000;2025-10-09 15:06:29.750;2025-10-09 15:06:29.740;686942;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;61;2025-10-09 15:06:29.740;2025-10-09 15:06:29.740;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:29.750;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9006062',@BarcodePallet='504488',@NumeroCella=9006062,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030363036324800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343438382E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100EE6B89001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;2004070;2025-10-09 15:06:29.740;2025-10-09 15:06:31.743;83776;0;1985;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;2000000;2025-10-09 15:06:29.750;2025-10-09 15:06:31.750;770718;0;1985;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;29;2025-10-09 15:06:31.750;2025-10-09 15:06:31.750;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:31.750;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504488' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:31.750;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504488' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;649185;2025-10-09 15:06:31.750;2025-10-09 15:06:32.400;27771;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;650000;2025-10-09 15:06:31.750;2025-10-09 15:06:32.400;798489;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;102;2025-10-09 15:06:32.400;2025-10-09 15:06:32.400;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:32.407;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504488';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:32.400;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504488';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;722020;2025-10-09 15:06:32.400;2025-10-09 15:06:33.123;17798;0;719;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;15804000;2025-10-09 15:06:17.327;2025-10-09 15:06:33.130;840640;2;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;45;2025-10-09 15:06:33.130;2025-10-09 15:06:33.130;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:33.127;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006062 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:33.130;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006062 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;221;2025-10-09 15:06:33.130;2025-10-09 15:06:33.130;2;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;6740000;2025-10-09 15:06:32.407;2025-10-09 15:06:39.147;816287;0;719;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;51;2025-10-09 15:06:39.147;2025-10-09 15:06:39.147;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:39.140;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:39.147;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;120;2025-10-09 15:06:39.147;2025-10-09 15:06:39.147;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;6000;2025-10-09 15:06:39.140;2025-10-09 15:06:39.147;816291;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;23;2025-10-09 15:06:39.147;2025-10-09 15:06:39.147;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:39.140;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;664;2025-10-09 15:06:39.147;2025-10-09 15:06:39.147;64;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;6000;2025-10-09 15:06:39.140;2025-10-09 15:06:39.147;816355;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;22;2025-10-09 15:06:39.147;2025-10-09 15:06:39.147;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:39.140;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9006066',@BarcodePallet='504191',@NumeroCella=9006066,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030363036364800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343139312E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100F26B89001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1964689;2025-10-09 15:06:39.147;2025-10-09 15:06:41.110;83776;0;1922;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1976000;2025-10-09 15:06:39.140;2025-10-09 15:06:41.117;900131;0;1922;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;27;2025-10-09 15:06:41.117;2025-10-09 15:06:41.117;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:41.110;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504191' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:41.117;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504191' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;869803;2025-10-09 15:06:41.117;2025-10-09 15:06:41.987;27771;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;876000;2025-10-09 15:06:41.110;2025-10-09 15:06:41.987;927902;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;25;2025-10-09 15:06:41.987;2025-10-09 15:06:41.987;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:41.983;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504191';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:41.987;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504191';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;718108;2025-10-09 15:06:41.987;2025-10-09 15:06:42.703;17798;0;719;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;9577000;2025-10-09 15:06:33.127;2025-10-09 15:06:42.703;840642;2;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;87;2025-10-09 15:06:42.703;2025-10-09 15:06:42.703;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:42.703;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006066 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:42.703;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006066 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;9103;2025-10-09 15:06:42.703;2025-10-09 15:06:42.713;40;0;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;5797000;2025-10-09 15:06:41.983;2025-10-09 15:06:47.780;945700;0;719;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;53;2025-10-09 15:06:47.780;2025-10-09 15:06:47.780;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:47.783;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:47.780;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;130;2025-10-09 15:06:47.780;2025-10-09 15:06:47.780;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;-3000;2025-10-09 15:06:47.783;2025-10-09 15:06:47.780;945704;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;23;2025-10-09 15:06:47.780;2025-10-09 15:06:47.780;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:47.783;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;664;2025-10-09 15:06:47.780;2025-10-09 15:06:47.780;64;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;0;2025-10-09 15:06:47.783;2025-10-09 15:06:47.783;945768;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;23;2025-10-09 15:06:47.783;2025-10-09 15:06:47.783;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:47.783;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9006067',@BarcodePallet='504177',@NumeroCella=9006067,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030363036374800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343137372E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100F36B89001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1986102;2025-10-09 15:06:47.783;2025-10-09 15:06:49.770;83789;21;1968;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;2003000;2025-10-09 15:06:47.783;2025-10-09 15:06:49.787;1029557;21;1968;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;28;2025-10-09 15:06:49.787;2025-10-09 15:06:49.787;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:49.783;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504177' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:06:49.787;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504177' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;646532;2025-10-09 15:06:49.787;2025-10-09 15:06:50.433;27771;0;641;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;7720000;2025-10-09 15:06:42.703;2025-10-09 15:06:50.423;840682;2;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;41;2025-10-09 15:06:50.423;2025-10-09 15:06:50.423;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:50.423;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 6067 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:06:50.423;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 6067 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;6513;2025-10-09 15:06:50.423;2025-10-09 15:06:50.430;44;0;16;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;11240000;2025-10-09 15:06:49.783;2025-10-09 15:07:01.023;1057328;21;641;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;98;2025-10-09 15:07:01.023;2025-10-09 15:07:01.023;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:01.017;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:01.023;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;230;2025-10-09 15:07:01.023;2025-10-09 15:07:01.023;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;10000;2025-10-09 15:07:01.017;2025-10-09 15:07:01.027;1057332;21;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;69;2025-10-09 15:07:01.027;2025-10-09 15:07:01.027;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:01.017;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1495;2025-10-09 15:07:01.027;2025-10-09 15:07:01.027;64;0;16;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;10000;2025-10-09 15:07:01.017;2025-10-09 15:07:01.027;1057396;21;16;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;57;2025-10-09 15:07:01.027;2025-10-09 15:07:01.027;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:01.030;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9006071',@BarcodePallet='504288',@NumeroCella=9006071,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030363037314800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343238382E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100F76B89001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1924493;2025-10-09 15:07:01.027;2025-10-09 15:07:02.950;83784;0;1891;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1916000;2025-10-09 15:07:01.030;2025-10-09 15:07:02.947;1141180;21;1891;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;28;2025-10-09 15:07:02.947;2025-10-09 15:07:02.947;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:02.953;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504288' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:02.947;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504288' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;636493;2025-10-09 15:07:02.947;2025-10-09 15:07:03.583;27771;0;640;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;630000;2025-10-09 15:07:02.953;2025-10-09 15:07:03.583;1168951;21;640;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;28;2025-10-09 15:07:03.583;2025-10-09 15:07:03.583;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:03.593;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504288';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:03.583;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504288';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;694868;2025-10-09 15:07:03.583;2025-10-09 15:07:04.277;17798;0;688;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;13857000;2025-10-09 15:06:50.423;2025-10-09 15:07:04.280;840726;2;16;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;38;2025-10-09 15:07:04.280;2025-10-09 15:07:04.280;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:07:04.280;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006071 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:07:04.280;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006071 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;6203;2025-10-09 15:07:04.280;2025-10-09 15:07:04.287;40;0;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;17617000;2025-10-09 15:07:03.593;2025-10-09 15:07:21.210;1186749;21;688;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;51;2025-10-09 15:07:21.210;2025-10-09 15:07:21.210;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:21.203;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:21.210;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;123;2025-10-09 15:07:21.210;2025-10-09 15:07:21.210;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;7000;2025-10-09 15:07:21.203;2025-10-09 15:07:21.210;1186753;21;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;74;2025-10-09 15:07:21.210;2025-10-09 15:07:21.210;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:21.220;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1496;2025-10-09 15:07:21.210;2025-10-09 15:07:21.210;64;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;-7000;2025-10-09 15:07:21.220;2025-10-09 15:07:21.213;1186817;21;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;73;2025-10-09 15:07:21.213;2025-10-09 15:07:21.213;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:21.220;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9006072',@BarcodePallet='504289',@NumeroCella=9006072,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030363037324800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343238392E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100F86B89001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1936981;2025-10-09 15:07:21.213;2025-10-09 15:07:23.150;83784;0;1922;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;1940000;2025-10-09 15:07:21.220;2025-10-09 15:07:23.160;1270601;21;1922;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;60;2025-10-09 15:07:23.160;2025-10-09 15:07:23.160;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:23.157;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504289' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:23.160;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504289' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;656345;2025-10-09 15:07:23.160;2025-10-09 15:07:23.817;27771;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;660000;2025-10-09 15:07:23.157;2025-10-09 15:07:23.817;1298372;21;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;25;2025-10-09 15:07:23.817;2025-10-09 15:07:23.817;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:23.813;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504289';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;NULL;2025-10-09 15:07:23.817;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504289';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;115;702678;2025-10-09 15:07:23.817;2025-10-09 15:07:24.520;17798;0;704;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;20233000;2025-10-09 15:07:04.280;2025-10-09 15:07:24.513;840766;2;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;89;2025-10-09 15:07:24.513;2025-10-09 15:07:24.513;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:07:24.517;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006072 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 15:07:24.513;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9006072 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;12313;2025-10-09 15:07:24.513;2025-10-09 15:07:24.527;40;0;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;2025-10-09 15:08:53.563;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65533;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
|
69
checklist_test_campo_pickinglist.md
Normal file
69
checklist_test_campo_pickinglist.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Checklist Test Campo Picking List
|
||||
|
||||
## Deploy patch
|
||||
|
||||
1. Apri [apply_plist_reservation_patch.sql](C:/devel/python/ware_house/apply_plist_reservation_patch.sql) in SSMS.
|
||||
2. Verifica di essere collegato al database corretto.
|
||||
3. Esegui lo script completo.
|
||||
4. Controlla che l'esecuzione termini senza errori SQL.
|
||||
|
||||
## Verifica oggetti DB
|
||||
|
||||
1. Verifica che esista la tabella `dbo.PickingListReservation`.
|
||||
2. Verifica che siano stati aggiornati questi oggetti:
|
||||
- `dbo.sp_xExePackingListPallet`
|
||||
- `dbo.XMag_ViewPackingList`
|
||||
- `dbo.sp_xExePackingListPalletPrenota`
|
||||
- `dbo.sp_ControllaPrenotazionePackingListPalletNew`
|
||||
3. Verifica che in `dbo.WarehouseObjectBackup` esistano le copie con tag `plist_reservation_fix_alpha2`.
|
||||
|
||||
## Test backoffice Gestione Picking List
|
||||
|
||||
1. Apri `Gestione Picking List`.
|
||||
2. Verifica che la griglia alta mostri solo le UDC residue.
|
||||
3. Prenota una picking list.
|
||||
4. Verifica che risulti prenotata solo quella.
|
||||
5. Premi di nuovo `Prenota` sulla stessa lista.
|
||||
- Atteso: non cambia nulla.
|
||||
6. Premi `S-prenota` sulla lista prenotata.
|
||||
- Atteso: la lista passa a non prenotata.
|
||||
7. Premi di nuovo `S-prenota`.
|
||||
- Atteso: non cambia nulla.
|
||||
8. Prenota una lista con UDC non scaffalate.
|
||||
- Atteso: non devono accendersi altre liste per effetto della locazione `1000 / 5E1.1`.
|
||||
9. Prenota una lista che in passato collideva sulla cella `8057`.
|
||||
- Atteso: non deve più prenotare anche l'altra.
|
||||
|
||||
## Test barcode
|
||||
|
||||
1. Con una sola lista prenotata, premi `F1`.
|
||||
- Atteso: viene proposta la coda alta della lista prenotata.
|
||||
2. Premi `F2`.
|
||||
- Atteso: viene proposta la coda bassa non prenotata.
|
||||
3. Preleva una UDC della picking list.
|
||||
- Atteso: compare `Ok Scarico`.
|
||||
- Atteso: compare `7G.1.1`.
|
||||
4. Se la UDC è non scaffalata:
|
||||
- Atteso: compare `5E1.1`.
|
||||
5. Dopo il prelievo, se restano altre UDC della stessa plist:
|
||||
- Atteso: compare la UDC successiva.
|
||||
|
||||
## Test fine lista
|
||||
|
||||
1. Lavora una picking list fino all'ultima UDC.
|
||||
2. Verifica che la plist sparisca dalla griglia alta.
|
||||
3. Verifica che la prenotazione venga automaticamente disattivata.
|
||||
4. Verifica che `F1` non continui più a considerarla attiva.
|
||||
|
||||
## Test Ricarica
|
||||
|
||||
1. Durante il lavoro su una plist, premi `Ricarica`.
|
||||
2. Verifica che la griglia alta mostri solo il residuo reale.
|
||||
3. Verifica che la plist esaurita non ricompaia.
|
||||
|
||||
## Rollback
|
||||
|
||||
1. Apri [rollback_plist_reservation_patch.sql](C:/devel/python/ware_house/rollback_plist_reservation_patch.sql) in SSMS.
|
||||
2. Verifica di essere sullo stesso database usato per il deploy.
|
||||
3. Esegui lo script completo.
|
||||
4. Controlla che il comportamento legacy sia ripristinato.
|
||||
256
comandi_git_per_installare.txt
Normal file
256
comandi_git_per_installare.txt
Normal file
@@ -0,0 +1,256 @@
|
||||
# Prontuario Git per installare/aggiornare Warehouse da remoto
|
||||
|
||||
Repository Gitea:
|
||||
|
||||
https://gitea.alessandrobonvicini.it/administrator/ware_house.git
|
||||
|
||||
Cartella consigliata sul PC di produzione:
|
||||
|
||||
C:\flywms
|
||||
|
||||
Ramo principale da usare in produzione:
|
||||
|
||||
main
|
||||
|
||||
Ultimo tag stabile al momento della stesura:
|
||||
|
||||
alpha7-stabilizzazione-non-scaffalate
|
||||
|
||||
|
||||
1. Prima installazione su PC nuovo
|
||||
----------------------------------
|
||||
|
||||
Aprire PowerShell nella macchina di produzione ed eseguire:
|
||||
|
||||
cd C:\
|
||||
git clone https://gitea.alessandrobonvicini.it/administrator/ware_house.git C:\flywms
|
||||
cd C:\flywms
|
||||
git switch main
|
||||
git pull origin main
|
||||
|
||||
Installare le dipendenze Python:
|
||||
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
Avvio applicazione desktop:
|
||||
|
||||
python main.py
|
||||
|
||||
Oppure senza finestra console:
|
||||
|
||||
pythonw warehouse.pyw
|
||||
|
||||
Avvio applicazione barcode:
|
||||
|
||||
python barcode_client.py
|
||||
|
||||
Oppure senza finestra console:
|
||||
|
||||
pythonw barcode.pyw
|
||||
|
||||
|
||||
2. Aggiornare un'installazione gia' esistente
|
||||
--------------------------------------------
|
||||
|
||||
Sul PC di produzione:
|
||||
|
||||
cd C:\flywms
|
||||
git fetch --all --tags
|
||||
git switch main
|
||||
git pull origin main
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
Poi rilanciare l'applicazione.
|
||||
|
||||
|
||||
2.bis Aggiornare produzione dopo merge su main gia' fatto
|
||||
---------------------------------------------------------
|
||||
|
||||
Questo e' il caso piu' normale:
|
||||
|
||||
- sul PC di sviluppo hai gia' fatto merge del ramo di lavoro dentro main;
|
||||
- hai gia' fatto push su Gitea;
|
||||
- sul PC di produzione devi solo scaricare l'ultima versione ufficiale.
|
||||
|
||||
Sul PC di produzione eseguire:
|
||||
|
||||
cd C:\flywms
|
||||
git fetch --all --tags
|
||||
git switch main
|
||||
git pull origin main
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
Poi chiudere e riaprire l'applicazione.
|
||||
|
||||
Controllo consigliato dopo l'aggiornamento:
|
||||
|
||||
git log --oneline --decorate -3
|
||||
git describe --tags --abbrev=0 main
|
||||
|
||||
|
||||
3. Controllare che versione/tag si sta usando
|
||||
---------------------------------------------
|
||||
|
||||
Dentro C:\flywms:
|
||||
|
||||
git status
|
||||
git log --oneline --decorate -5
|
||||
|
||||
Vedere l'ultimo tag raggiungibile da main:
|
||||
|
||||
git describe --tags --abbrev=0 main
|
||||
|
||||
Vedere tutti i tag, dal piu' recente:
|
||||
|
||||
git tag --sort=-creatordate
|
||||
|
||||
Vedere graficamente branch, commit e tag:
|
||||
|
||||
git log --oneline --decorate --graph --all -20
|
||||
|
||||
|
||||
4. Installare esattamente una versione taggata
|
||||
---------------------------------------------
|
||||
|
||||
Usare questa modalita' quando si vuole installare una fotografia precisa e non
|
||||
necessariamente l'ultima versione di main.
|
||||
|
||||
Esempio:
|
||||
|
||||
cd C:\
|
||||
git clone --branch alpha7-stabilizzazione-non-scaffalate https://gitea.alessandrobonvicini.it/administrator/ware_house.git C:\flywms_alpha7
|
||||
|
||||
Nota:
|
||||
|
||||
Un tag e' una fotografia ferma. Non avanza con git pull come un branch.
|
||||
Per produzione ordinaria e' piu' comodo usare main.
|
||||
|
||||
|
||||
5. Portare l'ultimo sviluppo dentro main
|
||||
---------------------------------------
|
||||
|
||||
Da fare sulla macchina di sviluppo, non sul PC di produzione.
|
||||
|
||||
Se l'ultima versione buona e' su sviluppo3 e vuoi renderla ufficiale su main:
|
||||
|
||||
cd C:\devel\python\ware_house
|
||||
git fetch --all --tags
|
||||
git status
|
||||
git switch main
|
||||
git pull origin main
|
||||
git merge sviluppo3
|
||||
git push origin main
|
||||
|
||||
Se vuoi anche creare un tag stabile:
|
||||
|
||||
git tag nome-del-tag
|
||||
git push origin nome-del-tag
|
||||
|
||||
Esempio:
|
||||
|
||||
git tag alpha8-nome-breve-della-modifica
|
||||
git push origin alpha8-nome-breve-della-modifica
|
||||
|
||||
|
||||
6. Se il PC di produzione ha modifiche locali
|
||||
---------------------------------------------
|
||||
|
||||
Prima di aggiornare controllare:
|
||||
|
||||
cd C:\flywms
|
||||
git status
|
||||
|
||||
Se compaiono file modificati che non devono essere conservati, NON fare comandi
|
||||
distruttivi senza sapere cosa sono. Prima copiare o rinominare i file modificati.
|
||||
|
||||
File che normalmente NON devono essere messi nel repository:
|
||||
|
||||
db_connection.json
|
||||
*.log
|
||||
__pycache__
|
||||
*.pyc
|
||||
*.zip
|
||||
|
||||
|
||||
7. Script SQL
|
||||
-------------
|
||||
|
||||
Gli script SQL sono nel repository e vanno lanciati in SSMS solo quando serve
|
||||
preparare o aggiornare il database per le funzioni Python.
|
||||
|
||||
Patch principali:
|
||||
|
||||
apply_python_parallel_pickinglist_patch.sql
|
||||
apply_python_pickinglist_history_views.sql
|
||||
apply_online_history_forms_patch.sql
|
||||
|
||||
Rollback principali:
|
||||
|
||||
rollback_python_parallel_pickinglist_patch.sql
|
||||
rollback_python_pickinglist_history_views.sql
|
||||
rollback_online_history_forms_patch.sql
|
||||
|
||||
Nota:
|
||||
|
||||
Prima di lanciare patch SQL in produzione, fare sempre backup o snapshot del
|
||||
database, oppure verificare di avere una procedura di rollback sicura.
|
||||
|
||||
|
||||
8. Comando rapido piu' usato
|
||||
----------------------------
|
||||
|
||||
Aggiornamento standard del PC di produzione:
|
||||
|
||||
cd C:\flywms
|
||||
git fetch --all --tags
|
||||
git switch main
|
||||
git pull origin main
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
|
||||
9. Per vedere cosa ho installato
|
||||
------------------------------------------------------
|
||||
git log --oneline --decorate -3
|
||||
git describe --tags --abbrev=0 main
|
||||
|
||||
|
||||
10. Salvare questo prontuario su Gitea
|
||||
-------------------------------------
|
||||
|
||||
Da fare sul PC di sviluppo, dentro la cartella del repository:
|
||||
|
||||
cd C:\devel\python\ware_house
|
||||
git status
|
||||
git add comandi_git_per_installare.txt
|
||||
git commit -m "Aggiungi prontuario Git per installazione remota"
|
||||
git push origin main
|
||||
|
||||
Dopo il push, il file sara' disponibile anche sui PC di produzione al prossimo:
|
||||
|
||||
cd C:\flywms
|
||||
git pull origin main
|
||||
|
||||
|
||||
11. Aggiornare il prontuario se lo modifico in locale
|
||||
----------------------------------------------------
|
||||
|
||||
Se modifichi questo file sul PC di sviluppo e vuoi sincronizzarlo su Gitea:
|
||||
|
||||
cd C:\devel\python\ware_house
|
||||
git status
|
||||
git diff -- comandi_git_per_installare.txt
|
||||
git add comandi_git_per_installare.txt
|
||||
git commit -m "Aggiorna prontuario Git installazione"
|
||||
git push origin main
|
||||
|
||||
Se invece lo hai modificato su un PC di produzione e vuoi prima recuperare
|
||||
eventuali aggiornamenti online:
|
||||
|
||||
cd C:\flywms
|
||||
git status
|
||||
git pull origin main
|
||||
|
||||
Se Git segnala conflitti, fermarsi e risolverli prima di rilanciare
|
||||
l'applicazione. Per evitare confusione, e' meglio modificare questo prontuario
|
||||
solo sul PC di sviluppo e poi fare push su Gitea.
|
||||
442
db_config.py
Normal file
442
db_config.py
Normal file
@@ -0,0 +1,442 @@
|
||||
"""Database connection bootstrap helpers for first-run configuration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import tkinter as tk
|
||||
from pathlib import Path
|
||||
import error_dialog as messagebox
|
||||
from tkinter import ttk
|
||||
from typing import Any
|
||||
|
||||
from async_msssql_query import AsyncMSSQLClient, make_mssql_dsn
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from tooltips import WidgetToolTip, load_tooltip_catalog, tooltip_text
|
||||
from ui_theme import theme_section, theme_value
|
||||
from version_info import module_version, versioned_title
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
CONFIG_PATH = Path(__file__).with_name("db_connection.json")
|
||||
DEFAULT_DB_CONFIG: dict[str, Any] = {
|
||||
"server": "HOMESERVER",
|
||||
"database": "Xwmsdb",
|
||||
"user": "xwms_local_app",
|
||||
"password": "",
|
||||
"driver": "ODBC Driver 17 for SQL Server",
|
||||
"trust_server_certificate": True,
|
||||
"encrypt": "",
|
||||
"query_profiler": {
|
||||
"enabled": False,
|
||||
"slow_ms": 0,
|
||||
"sql_limit": 4000,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def load_db_config(path: Path = CONFIG_PATH) -> dict[str, Any] | None:
|
||||
"""Return the DB config from disk, or ``None`` when missing/invalid."""
|
||||
|
||||
try:
|
||||
if not path.exists():
|
||||
return None
|
||||
data = json.loads(path.read_text(encoding="utf-8"))
|
||||
if not isinstance(data, dict):
|
||||
return None
|
||||
return {**DEFAULT_DB_CONFIG, **data}
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def save_db_config(config: dict[str, Any], path: Path = CONFIG_PATH) -> None:
|
||||
"""Persist the DB config as UTF-8 JSON."""
|
||||
|
||||
payload = {**DEFAULT_DB_CONFIG, **config}
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
def build_dsn_from_config(config: dict[str, Any]) -> str:
|
||||
"""Build the SQLAlchemy DSN from the saved configuration."""
|
||||
|
||||
if str(config.get("database", "")).strip().lower() != "xwmsdb":
|
||||
raise ValueError("XWMS TEST: e' consentito soltanto il database Xwmsdb")
|
||||
if str(config.get("server", "")).strip().lower() != "homeserver":
|
||||
raise ValueError("XWMS TEST: e' consentita soltanto l'istanza locale HOMESERVER")
|
||||
return make_mssql_dsn(
|
||||
server=str(config.get("server") or "").strip(),
|
||||
database=str(config.get("database") or "").strip(),
|
||||
user=str(config.get("user") or "").strip() or None,
|
||||
password=str(config.get("password") or "").strip() or None,
|
||||
driver=str(config.get("driver") or DEFAULT_DB_CONFIG["driver"]).strip(),
|
||||
trust_server_certificate=bool(config.get("trust_server_certificate", True)),
|
||||
encrypt=(str(config.get("encrypt") or "").strip() or None),
|
||||
)
|
||||
|
||||
|
||||
def _is_complete(config: dict[str, Any] | None) -> bool:
|
||||
"""Return True when the config contains the required connection fields."""
|
||||
|
||||
if not isinstance(config, dict):
|
||||
return False
|
||||
required = ("server", "database", "user", "password")
|
||||
return all(str(config.get(key) or "").strip() for key in required)
|
||||
|
||||
|
||||
def test_db_config_sync(config: dict[str, Any], loop: asyncio.AbstractEventLoop, timeout: float = 6.0) -> None:
|
||||
"""Raise an exception when the DB configuration cannot open a connection."""
|
||||
|
||||
client = AsyncMSSQLClient(build_dsn_from_config(config), log=False)
|
||||
|
||||
async def _job() -> None:
|
||||
try:
|
||||
await client.query_json("SELECT 1 AS Ok", {}, as_dict_rows=True)
|
||||
finally:
|
||||
try:
|
||||
await client.dispose()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
fut = asyncio.run_coroutine_threadsafe(_job(), loop)
|
||||
fut.result(timeout=timeout)
|
||||
|
||||
|
||||
class DatabaseConfigWindow(tk.Toplevel):
|
||||
"""Modal first-run form that collects the SQL Server connection settings."""
|
||||
|
||||
def __init__(self, parent: tk.Misc, loop: asyncio.AbstractEventLoop, initial: dict[str, Any] | None = None):
|
||||
super().__init__(parent)
|
||||
self._loop = loop
|
||||
self._theme = theme_section("db_config_window", {})
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self._tooltip_catalog = load_tooltip_catalog()
|
||||
self.result_config: dict[str, Any] | None = None
|
||||
merged = {**DEFAULT_DB_CONFIG, **(initial or {})}
|
||||
|
||||
self.title(versioned_title(loc_text("dbconfig.title", catalog=self._locale_catalog, default="Configurazione Database"), __name__))
|
||||
self.geometry(str(theme_value(self._theme, "window_geometry", "520x360")))
|
||||
self.resizable(False, False)
|
||||
try:
|
||||
if parent is not None and parent.winfo_viewable():
|
||||
self.transient(parent)
|
||||
except Exception:
|
||||
pass
|
||||
self.protocol("WM_DELETE_WINDOW", self._on_cancel)
|
||||
|
||||
self.server_var = tk.StringVar(value=str(merged.get("server") or ""))
|
||||
self.database_var = tk.StringVar(value=str(merged.get("database") or ""))
|
||||
self.user_var = tk.StringVar(value=str(merged.get("user") or ""))
|
||||
self.password_var = tk.StringVar(value=str(merged.get("password") or ""))
|
||||
self.driver_var = tk.StringVar(value=str(merged.get("driver") or DEFAULT_DB_CONFIG["driver"]))
|
||||
self.encrypt_var = tk.StringVar(value=str(merged.get("encrypt") or ""))
|
||||
self.tsc_var = tk.BooleanVar(value=bool(merged.get("trust_server_certificate", True)))
|
||||
self._status_var = tk.StringVar(value="")
|
||||
|
||||
self._busy_cover: tk.Frame | None = None
|
||||
self._busy_label: ttk.Label | None = None
|
||||
self._busy_bar: ttk.Progressbar | None = None
|
||||
self._build_ui()
|
||||
self.update_idletasks()
|
||||
req_w = self.winfo_reqwidth()
|
||||
req_h = self.winfo_reqheight()
|
||||
try:
|
||||
current_w, current_h = [int(v) for v in str(theme_value(self._theme, "window_geometry", "520x360")).split("x", 1)]
|
||||
except Exception:
|
||||
current_w, current_h = 520, 360
|
||||
final_w = max(current_w, req_w + 16)
|
||||
final_h = max(current_h, req_h + 20)
|
||||
self.geometry(f"{final_w}x{final_h}")
|
||||
self.minsize(final_w, final_h)
|
||||
self.grab_set()
|
||||
self.deiconify()
|
||||
self.lift()
|
||||
self.attributes("-topmost", True)
|
||||
self.after(50, self._show_ready)
|
||||
|
||||
def _build_ui(self) -> None:
|
||||
body = ttk.Frame(self, padding=14)
|
||||
body.pack(fill="both", expand=True)
|
||||
body.columnconfigure(1, weight=1)
|
||||
|
||||
heading = ttk.Label(
|
||||
body,
|
||||
text=loc_text(
|
||||
"dbconfig.heading",
|
||||
catalog=self._locale_catalog,
|
||||
default="Configura la connessione al database del magazzino",
|
||||
),
|
||||
font=("Segoe UI", 11, "bold"),
|
||||
)
|
||||
heading.grid(row=0, column=0, columnspan=2, sticky="w", pady=(2, 12))
|
||||
|
||||
fields = [
|
||||
("dbconfig.label.server", "Server", self.server_var, "dbconfig.field.server"),
|
||||
("dbconfig.label.database", "Database", self.database_var, "dbconfig.field.database"),
|
||||
("dbconfig.label.user", "Utente", self.user_var, "dbconfig.field.user"),
|
||||
("dbconfig.label.password", "Password", self.password_var, "dbconfig.field.password"),
|
||||
("dbconfig.label.driver", "Driver ODBC", self.driver_var, "dbconfig.field.driver"),
|
||||
("dbconfig.label.encrypt", "Encrypt", self.encrypt_var, "dbconfig.field.encrypt"),
|
||||
]
|
||||
|
||||
self._entries: list[ttk.Entry] = []
|
||||
for row_idx, (key, default, var, tip_key) in enumerate(fields, start=1):
|
||||
label = ttk.Label(body, text=loc_text(key, catalog=self._locale_catalog, default=default))
|
||||
label.grid(
|
||||
row=row_idx, column=0, sticky="w", padx=(0, 10), pady=6
|
||||
)
|
||||
entry = ttk.Entry(body, textvariable=var, width=34, show="*" if var is self.password_var else "")
|
||||
entry.grid(row=row_idx, column=1, sticky="ew", pady=6)
|
||||
self._entries.append(entry)
|
||||
self._attach_tooltip(label, tip_key)
|
||||
self._attach_tooltip(entry, tip_key)
|
||||
|
||||
tsc = ttk.Checkbutton(
|
||||
body,
|
||||
text=loc_text(
|
||||
"dbconfig.label.trust_server_certificate",
|
||||
catalog=self._locale_catalog,
|
||||
default="Trust server certificate",
|
||||
),
|
||||
variable=self.tsc_var,
|
||||
)
|
||||
tsc.grid(row=7, column=0, columnspan=2, sticky="w", pady=(8, 4))
|
||||
self._attach_tooltip(tsc, "dbconfig.field.trust_server_certificate")
|
||||
|
||||
info = ttk.Label(
|
||||
body,
|
||||
text=loc_text(
|
||||
"dbconfig.info",
|
||||
catalog=self._locale_catalog,
|
||||
default="Il file verra' salvato localmente e non verra' piu' richiesto ai prossimi avvii.",
|
||||
),
|
||||
wraplength=420,
|
||||
justify="left",
|
||||
)
|
||||
info.grid(row=8, column=0, columnspan=2, sticky="w", pady=(6, 8))
|
||||
|
||||
ttk.Label(body, textvariable=self._status_var, foreground="#555555").grid(
|
||||
row=9, column=0, columnspan=2, sticky="w", pady=(2, 2)
|
||||
)
|
||||
|
||||
actions = ttk.Frame(body)
|
||||
actions.grid(row=10, column=0, columnspan=2, sticky="ew", pady=(10, 0))
|
||||
actions.columnconfigure(0, weight=1)
|
||||
self._cancel_btn = ttk.Button(
|
||||
actions,
|
||||
text=loc_text("dbconfig.button.cancel", catalog=self._locale_catalog, default="Annulla"),
|
||||
command=self._on_cancel,
|
||||
)
|
||||
self._cancel_btn.grid(row=0, column=1, padx=(0, 8))
|
||||
self._attach_tooltip(self._cancel_btn, "dbconfig.button.cancel")
|
||||
self._test_btn = ttk.Button(
|
||||
actions,
|
||||
text=loc_text("dbconfig.button.test", catalog=self._locale_catalog, default="Test connessione"),
|
||||
command=self._on_test,
|
||||
)
|
||||
self._test_btn.grid(row=0, column=2, padx=(0, 8))
|
||||
self._attach_tooltip(self._test_btn, "dbconfig.button.test")
|
||||
self._save_btn = ttk.Button(
|
||||
actions,
|
||||
text=loc_text("dbconfig.button.save", catalog=self._locale_catalog, default="Salva"),
|
||||
command=self._on_save,
|
||||
)
|
||||
self._save_btn.grid(row=0, column=3)
|
||||
self._attach_tooltip(self._save_btn, "dbconfig.button.save")
|
||||
|
||||
self._attach_tooltip(heading, "dbconfig.heading")
|
||||
self._attach_tooltip(info, "dbconfig.info")
|
||||
|
||||
def _attach_tooltip(self, widget: tk.Misc, key: str) -> None:
|
||||
"""Attach a localized tooltip when a text exists for the given key."""
|
||||
|
||||
tip = tooltip_text(key, catalog=self._tooltip_catalog)
|
||||
if tip:
|
||||
WidgetToolTip(widget, tip)
|
||||
|
||||
def _show_ready(self) -> None:
|
||||
"""Ensure the modal is visible even with a hidden bootstrap root."""
|
||||
|
||||
try:
|
||||
self.attributes("-topmost", True)
|
||||
self.deiconify()
|
||||
self.lift()
|
||||
self.focus_force()
|
||||
if self._entries:
|
||||
self._entries[0].focus_force()
|
||||
finally:
|
||||
try:
|
||||
self.after(250, lambda: self.attributes("-topmost", False))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _show_busy_overlay(self, message: str) -> None:
|
||||
"""Show a lightweight inline overlay without CustomTkinter callbacks."""
|
||||
|
||||
if self._busy_cover and self._busy_cover.winfo_exists():
|
||||
if self._busy_label is not None:
|
||||
self._busy_label.configure(text=message)
|
||||
try:
|
||||
self._busy_cover.lift()
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
cover = tk.Frame(self, bg="#d9d9d9")
|
||||
cover.place(relx=0, rely=0, relwidth=1, relheight=1)
|
||||
panel = ttk.Frame(cover, padding=14)
|
||||
panel.place(relx=0.5, rely=0.5, anchor="center")
|
||||
label = ttk.Label(panel, text=message, font=("Segoe UI", 10, "bold"))
|
||||
label.pack(padx=16, pady=(4, 8))
|
||||
bar = ttk.Progressbar(panel, mode="indeterminate", length=220)
|
||||
bar.pack(padx=16, pady=(0, 6))
|
||||
try:
|
||||
bar.start(10)
|
||||
except Exception:
|
||||
pass
|
||||
self._busy_cover = cover
|
||||
self._busy_label = label
|
||||
self._busy_bar = bar
|
||||
|
||||
def _hide_busy_overlay(self) -> None:
|
||||
"""Hide the lightweight inline overlay."""
|
||||
|
||||
if self._busy_bar is not None:
|
||||
try:
|
||||
self._busy_bar.stop()
|
||||
except Exception:
|
||||
pass
|
||||
self._busy_bar = None
|
||||
self._busy_label = None
|
||||
if self._busy_cover is not None and self._busy_cover.winfo_exists():
|
||||
try:
|
||||
self._busy_cover.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
self._busy_cover = None
|
||||
|
||||
def _set_busy(self, busy: bool, message: str = "") -> None:
|
||||
state = "disabled" if busy else "normal"
|
||||
try:
|
||||
for entry in self._entries:
|
||||
entry.configure(state=state)
|
||||
self._cancel_btn.configure(state=state)
|
||||
self._test_btn.configure(state=state)
|
||||
self._save_btn.configure(state=state)
|
||||
self.configure(cursor="watch" if busy else "")
|
||||
self._status_var.set(message)
|
||||
if busy:
|
||||
self._show_busy_overlay(message or loc_text("dbconfig.busy", catalog=self._locale_catalog, default="Verifico..."))
|
||||
else:
|
||||
self._hide_busy_overlay()
|
||||
self.update_idletasks()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _collect(self) -> dict[str, Any]:
|
||||
return {
|
||||
"server": str(self.server_var.get() or "").strip(),
|
||||
"database": str(self.database_var.get() or "").strip(),
|
||||
"user": str(self.user_var.get() or "").strip(),
|
||||
"password": str(self.password_var.get() or "").strip(),
|
||||
"driver": str(self.driver_var.get() or "").strip() or str(DEFAULT_DB_CONFIG["driver"]),
|
||||
"encrypt": str(self.encrypt_var.get() or "").strip(),
|
||||
"trust_server_certificate": bool(self.tsc_var.get()),
|
||||
}
|
||||
|
||||
def _validate(self, config: dict[str, Any]) -> bool:
|
||||
required = ("server", "database", "user", "password")
|
||||
missing = [name for name in required if not str(config.get(name) or "").strip()]
|
||||
if not missing:
|
||||
return True
|
||||
messagebox.showwarning(
|
||||
loc_text("dbconfig.msg.title", catalog=self._locale_catalog, default="Configurazione Database"),
|
||||
loc_text(
|
||||
"dbconfig.msg.missing",
|
||||
catalog=self._locale_catalog,
|
||||
default="Compila almeno server, database, utente e password.",
|
||||
),
|
||||
parent=self,
|
||||
)
|
||||
return False
|
||||
|
||||
def _test(self, config: dict[str, Any]) -> None:
|
||||
self._set_busy(True, loc_text("dbconfig.busy", catalog=self._locale_catalog, default="Verifico connessione..."))
|
||||
try:
|
||||
test_db_config_sync(config, self._loop)
|
||||
finally:
|
||||
self._set_busy(False, "")
|
||||
|
||||
def _on_test(self) -> None:
|
||||
config = self._collect()
|
||||
if not self._validate(config):
|
||||
return
|
||||
try:
|
||||
self._test(config)
|
||||
except Exception as ex:
|
||||
messagebox.showerror(
|
||||
loc_text("dbconfig.msg.title", catalog=self._locale_catalog, default="Configurazione Database"),
|
||||
loc_text("dbconfig.msg.test_error", catalog=self._locale_catalog, default="Connessione fallita:\n{error}").format(error=ex),
|
||||
parent=self,
|
||||
exception=ex,
|
||||
)
|
||||
return
|
||||
messagebox.showinfo(
|
||||
loc_text("dbconfig.msg.title", catalog=self._locale_catalog, default="Configurazione Database"),
|
||||
loc_text("dbconfig.msg.test_ok", catalog=self._locale_catalog, default="Connessione riuscita."),
|
||||
parent=self,
|
||||
)
|
||||
|
||||
def _on_save(self) -> None:
|
||||
config = self._collect()
|
||||
if not self._validate(config):
|
||||
return
|
||||
try:
|
||||
self._test(config)
|
||||
save_db_config(config)
|
||||
except Exception as ex:
|
||||
messagebox.showerror(
|
||||
loc_text("dbconfig.msg.title", catalog=self._locale_catalog, default="Configurazione Database"),
|
||||
loc_text("dbconfig.msg.save_error", catalog=self._locale_catalog, default="Salvataggio fallito:\n{error}").format(error=ex),
|
||||
parent=self,
|
||||
exception=ex,
|
||||
)
|
||||
return
|
||||
self.result_config = config
|
||||
self.destroy()
|
||||
|
||||
def _on_cancel(self) -> None:
|
||||
self.result_config = None
|
||||
try:
|
||||
self.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def ensure_db_config(loop: asyncio.AbstractEventLoop, parent: tk.Misc | None = None) -> dict[str, Any] | None:
|
||||
"""Return a valid DB config, prompting the user the first time when needed."""
|
||||
|
||||
existing = load_db_config()
|
||||
if _is_complete(existing):
|
||||
return existing
|
||||
|
||||
owns_root = False
|
||||
if parent is None:
|
||||
parent = tk.Tk()
|
||||
parent.geometry("1x1+0+0")
|
||||
parent.overrideredirect(True)
|
||||
parent.attributes("-alpha", 0.0)
|
||||
parent.deiconify()
|
||||
parent.update_idletasks()
|
||||
owns_root = True
|
||||
|
||||
dlg = DatabaseConfigWindow(parent, loop=loop, initial=existing or DEFAULT_DB_CONFIG)
|
||||
try:
|
||||
parent.wait_window(dlg)
|
||||
finally:
|
||||
if owns_root:
|
||||
try:
|
||||
parent.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
return dlg.result_config
|
||||
549
diagnostica.py
Normal file
549
diagnostica.py
Normal file
@@ -0,0 +1,549 @@
|
||||
"""Operational diagnostic checks for warehouse data quadrature."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tkinter as tk
|
||||
from datetime import datetime
|
||||
import error_dialog as messagebox
|
||||
from tkinter import filedialog, ttk
|
||||
from typing import Any
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from gestione_aree import AsyncRunner
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from runtime_support import log_exception
|
||||
from ui_tables import style_treeview, zebra_tag
|
||||
from ui_theme import theme_color, theme_font, theme_section, theme_value
|
||||
from version_info import module_version, versioned_title
|
||||
from window_placement import place_window_fullsize_below_parent_later
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
|
||||
SQL_SHIPPED_NOT_DISASSOCIATED = """
|
||||
SELECT DISTINCT
|
||||
LTRIM(RTRIM(g.BarcodePallet)) AS UDC,
|
||||
CAST('Spedita ma non disassociata' AS varchar(64)) AS Diagnostica,
|
||||
CONCAT(
|
||||
RTRIM(c.Corsia),
|
||||
' - ',
|
||||
RTRIM(CAST(c.Colonna AS varchar(32))),
|
||||
' - ',
|
||||
RTRIM(CAST(c.Fila AS varchar(32)))
|
||||
) AS NomeSimbolicoCella
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
INNER JOIN dbo.Celle AS c
|
||||
ON c.ID = g.IDCella
|
||||
INNER JOIN dbo.py_XMag_ViewPackingListStorico AS chiuse
|
||||
ON LTRIM(RTRIM(chiuse.Pallet)) COLLATE Latin1_General_CI_AS =
|
||||
LTRIM(RTRIM(g.BarcodePallet)) COLLATE Latin1_General_CI_AS
|
||||
WHERE chiuse.StatoDocumento = 'D'
|
||||
AND g.IDCella <> 9999
|
||||
ORDER BY NomeSimbolicoCella, UDC;
|
||||
"""
|
||||
|
||||
SQL_MULTIPLE_UDC_BY_CELL = """
|
||||
WITH celle_multiple AS (
|
||||
SELECT
|
||||
g.IDCella
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
WHERE g.IDCella NOT IN (1000, 9999)
|
||||
GROUP BY g.IDCella
|
||||
HAVING COUNT(DISTINCT LTRIM(RTRIM(g.BarcodePallet))) > 1
|
||||
)
|
||||
SELECT
|
||||
CONCAT(
|
||||
RTRIM(c.Corsia),
|
||||
' - ',
|
||||
RTRIM(CAST(c.Colonna AS varchar(32))),
|
||||
' - ',
|
||||
RTRIM(CAST(c.Fila AS varchar(32)))
|
||||
) AS CELLA,
|
||||
LTRIM(RTRIM(g.BarcodePallet)) AS UDC
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
INNER JOIN celle_multiple AS cm
|
||||
ON cm.IDCella = g.IDCella
|
||||
INNER JOIN dbo.Celle AS c
|
||||
ON c.ID = g.IDCella
|
||||
ORDER BY CELLA, UDC;
|
||||
"""
|
||||
|
||||
SQL_SAM_UDC_NOT_IN_WMS = """
|
||||
WITH recent_lotser AS (
|
||||
SELECT TOP (5000)
|
||||
ls.ID,
|
||||
LEFT(ls.NUMSER, 6) AS UDC,
|
||||
ls.NUMLOT AS Lotto,
|
||||
ls.IDARTICO
|
||||
FROM SAMA1_Xwmstest.dbo.LOTSER AS ls
|
||||
WHERE NULLIF(LTRIM(RTRIM(LEFT(ls.NUMSER, 6))), '') IS NOT NULL
|
||||
AND TRY_CONVERT(int, LTRIM(RTRIM(LEFT(ls.NUMSER, 6)))) > 0
|
||||
AND LEN(LTRIM(RTRIM(LEFT(ls.NUMSER, 6)))) = 6
|
||||
AND ls.NUMLOT LIKE CONCAT('P', RIGHT(CONVERT(varchar(4), YEAR(GETDATE())), 2), '%')
|
||||
ORDER BY ls.ID DESC
|
||||
), sam_udc AS (
|
||||
SELECT
|
||||
LTRIM(RTRIM(r.UDC)) AS UDC,
|
||||
MIN(r.Lotto) AS Lotto,
|
||||
MIN(a.CODICE) AS Prodotto,
|
||||
MIN(a.DESCR) AS Descrizione,
|
||||
MAX(r.ID) AS UltimoIDLotSer
|
||||
FROM recent_lotser AS r
|
||||
INNER JOIN SAMA1_Xwmstest.dbo.ARTICO AS a
|
||||
ON a.ID = r.IDARTICO
|
||||
GROUP BY LTRIM(RTRIM(r.UDC))
|
||||
)
|
||||
SELECT TOP (100)
|
||||
s.UDC,
|
||||
s.Lotto,
|
||||
s.Prodotto,
|
||||
s.Descrizione
|
||||
FROM sam_udc AS s
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.MagazziniPallet AS mp
|
||||
WHERE LTRIM(RTRIM(mp.Attributo)) COLLATE Latin1_General_CI_AS =
|
||||
s.UDC COLLATE Latin1_General_CI_AS
|
||||
)
|
||||
ORDER BY s.UltimoIDLotSer DESC;
|
||||
"""
|
||||
|
||||
SHIPPED_NOT_DISASSOCIATED_COLUMNS = (
|
||||
("UDC", "diagnostics.col.udc", "UDC", 130, "w"),
|
||||
(
|
||||
"Diagnostica",
|
||||
"diagnostics.col.shipped_not_disassociated",
|
||||
"Spedita ma non disassociata",
|
||||
280,
|
||||
"w",
|
||||
),
|
||||
("NomeSimbolicoCella", "diagnostics.col.symbolic_cell", "Nome simbolico cella", 240, "w"),
|
||||
)
|
||||
|
||||
MULTIPLE_UDC_COLUMNS = (
|
||||
("CELLA", "diagnostics.col.cell", "CELLA", 220, "w"),
|
||||
("UDC", "diagnostics.col.udc", "UDC", 160, "w"),
|
||||
)
|
||||
|
||||
SAM_UDC_NOT_IN_WMS_COLUMNS = (
|
||||
("UDC", "diagnostics.col.udc", "UDC", 130, "w"),
|
||||
("Lotto", "diagnostics.col.lot", "Lotto", 160, "w"),
|
||||
("Prodotto", "diagnostics.col.product", "Prodotto", 150, "w"),
|
||||
("Descrizione", "diagnostics.col.description", "Descrizione", 360, "w"),
|
||||
)
|
||||
|
||||
|
||||
def _rows_to_dicts(res: dict[str, Any] | None) -> list[dict[str, Any]]:
|
||||
if not isinstance(res, dict):
|
||||
return []
|
||||
rows = res.get("rows") or []
|
||||
cols = res.get("columns") or []
|
||||
if rows and isinstance(rows[0], dict):
|
||||
return [row for row in rows if isinstance(row, dict)]
|
||||
|
||||
out: list[dict[str, Any]] = []
|
||||
for row in rows:
|
||||
if isinstance(row, (list, tuple)) and cols:
|
||||
out.append({str(cols[i]): row[i] for i in range(min(len(cols), len(row)))})
|
||||
return out
|
||||
|
||||
|
||||
class DiagnosticaWindow(ctk.CTkToplevel):
|
||||
"""Window collecting read-only diagnostic queries."""
|
||||
|
||||
def __init__(self, parent: tk.Widget, db_client, session=None):
|
||||
super().__init__(parent)
|
||||
self.db_client = db_client
|
||||
self.session = session
|
||||
self._theme = theme_section("diagnostics_window", theme_section("search_window", {}))
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self._async = AsyncRunner(self)
|
||||
self._busy = InlineBusyOverlay(self, self._theme)
|
||||
self._load_in_progress = False
|
||||
self._current_check = ""
|
||||
self.var_status = tk.StringVar(value="")
|
||||
self._last_export_slug = "diagnostica"
|
||||
self._current_columns = SHIPPED_NOT_DISASSOCIATED_COLUMNS
|
||||
self._column_titles: dict[str, str] = {}
|
||||
self._sort_column = ""
|
||||
self._sort_descending = False
|
||||
|
||||
self.title(
|
||||
versioned_title(
|
||||
loc_text("diagnostics.title", catalog=self._locale_catalog, default="Diagnostica"),
|
||||
__name__,
|
||||
)
|
||||
)
|
||||
self.geometry(str(theme_value(self._theme, "window_geometry", "1100x680")))
|
||||
minsize = theme_value(self._theme, "window_minsize", [900, 560])
|
||||
self.minsize(int(minsize[0]), int(minsize[1]))
|
||||
try:
|
||||
self.configure(fg_color=theme_color(self._theme, "window_fg_color", ("#efefef", "#2f2f2f")))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._build_ui()
|
||||
|
||||
def _is_alive(self) -> bool:
|
||||
try:
|
||||
return bool(self.winfo_exists())
|
||||
except tk.TclError:
|
||||
return False
|
||||
|
||||
def _hide_busy_safe(self) -> None:
|
||||
try:
|
||||
self._busy.hide()
|
||||
except Exception as exc:
|
||||
log_exception(__name__, exc, context="hide busy diagnostica")
|
||||
|
||||
def _build_ui(self) -> None:
|
||||
self.grid_rowconfigure(2, weight=1)
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
|
||||
top = ctk.CTkFrame(
|
||||
self,
|
||||
fg_color=theme_color(self._theme, "toolbar_frame_fg_color", ("#d7d7d7", "#3b3b3b")),
|
||||
)
|
||||
top.grid(row=0, column=0, sticky="ew", padx=8, pady=8)
|
||||
top.grid_columnconfigure(3, weight=1)
|
||||
|
||||
button_font = theme_font(self._theme, "toolbar_button_font", ("Segoe UI", 10, "bold"))
|
||||
ctk.CTkButton(
|
||||
top,
|
||||
text=loc_text(
|
||||
"diagnostics.button.shipped_not_disassociated",
|
||||
catalog=self._locale_catalog,
|
||||
default="UDC spedite non disassociate",
|
||||
),
|
||||
command=self._load_shipped_not_disassociated,
|
||||
font=button_font,
|
||||
).grid(row=0, column=0, sticky="w", padx=(0, 8))
|
||||
|
||||
ctk.CTkButton(
|
||||
top,
|
||||
text=loc_text(
|
||||
"diagnostics.button.multiple_udc_by_cell",
|
||||
catalog=self._locale_catalog,
|
||||
default="Celle con multiple UDC",
|
||||
),
|
||||
command=self._load_multiple_udc_by_cell,
|
||||
font=button_font,
|
||||
).grid(row=0, column=1, sticky="w", padx=(0, 8))
|
||||
|
||||
ctk.CTkButton(
|
||||
top,
|
||||
text=loc_text(
|
||||
"diagnostics.button.sam_udc_not_in_wms",
|
||||
catalog=self._locale_catalog,
|
||||
default="Ultime UDC SAM non in WMS",
|
||||
),
|
||||
command=self._load_sam_udc_not_in_wms,
|
||||
font=button_font,
|
||||
).grid(row=0, column=2, sticky="w", padx=(0, 8))
|
||||
|
||||
self.btn_export = ctk.CTkButton(
|
||||
top,
|
||||
text=loc_text("diagnostics.button.export", catalog=self._locale_catalog, default="Esporta XLSX"),
|
||||
command=self._export_xlsx,
|
||||
font=button_font,
|
||||
state="disabled",
|
||||
)
|
||||
self.btn_export.grid(row=0, column=4, sticky="e")
|
||||
|
||||
ctk.CTkLabel(
|
||||
self,
|
||||
textvariable=self.var_status,
|
||||
anchor="w",
|
||||
font=theme_font(self._theme, "status_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(row=1, column=0, sticky="ew", padx=10, pady=(0, 6))
|
||||
|
||||
wrap = ctk.CTkFrame(self)
|
||||
wrap.grid(row=2, column=0, sticky="nsew", padx=8, pady=(0, 8))
|
||||
wrap.grid_rowconfigure(0, weight=1)
|
||||
wrap.grid_columnconfigure(0, weight=1)
|
||||
|
||||
self.tree = ttk.Treeview(wrap, show="headings")
|
||||
self._configure_tree_columns(self._current_columns)
|
||||
style_treeview(
|
||||
self.tree,
|
||||
style_name="Diagnostics.Treeview",
|
||||
rowheight=22,
|
||||
font=("", 9),
|
||||
heading_font=("", 9, "bold"),
|
||||
)
|
||||
|
||||
sy = ttk.Scrollbar(wrap, orient="vertical", command=self.tree.yview)
|
||||
sx = ttk.Scrollbar(wrap, orient="horizontal", command=self.tree.xview)
|
||||
self.tree.configure(yscrollcommand=sy.set, xscrollcommand=sx.set)
|
||||
self.tree.grid(row=0, column=0, sticky="nsew")
|
||||
sy.grid(row=0, column=1, sticky="ns")
|
||||
sx.grid(row=1, column=0, sticky="ew")
|
||||
|
||||
def _set_status(self, text: str) -> None:
|
||||
self.var_status.set(text)
|
||||
|
||||
def _configure_tree_columns(self, columns) -> None:
|
||||
self.tree.delete(*self.tree.get_children(""))
|
||||
keys = tuple(str(col[0]) for col in columns)
|
||||
self.tree.configure(columns=keys, show="headings")
|
||||
self._sort_column = ""
|
||||
self._sort_descending = False
|
||||
self._column_titles = {}
|
||||
for key, locale_key, default, width, anchor in columns:
|
||||
title = loc_text(str(locale_key), catalog=self._locale_catalog, default=str(default))
|
||||
self._column_titles[str(key)] = title
|
||||
self.tree.heading(
|
||||
key,
|
||||
text=title,
|
||||
command=lambda col=str(key): self._sort_by_column(col),
|
||||
)
|
||||
self.tree.column(key, width=int(width), anchor=str(anchor), stretch=True)
|
||||
|
||||
def _refresh_sort_headings(self) -> None:
|
||||
for key, title in self._column_titles.items():
|
||||
suffix = ""
|
||||
if key == self._sort_column:
|
||||
suffix = " v" if self._sort_descending else " ^"
|
||||
self.tree.heading(key, text=f"{title}{suffix}", command=lambda col=key: self._sort_by_column(col))
|
||||
|
||||
def _sort_key(self, value: Any) -> tuple[int, Any]:
|
||||
text = str(value or "").strip()
|
||||
if not text:
|
||||
return (2, "")
|
||||
normalized = text.replace(".", "").replace(",", ".")
|
||||
try:
|
||||
return (0, float(normalized))
|
||||
except ValueError:
|
||||
return (1, text.casefold())
|
||||
|
||||
def _sort_by_column(self, column: str) -> None:
|
||||
columns = list(self.tree["columns"])
|
||||
if column not in columns:
|
||||
return
|
||||
descending = not self._sort_descending if self._sort_column == column else False
|
||||
col_index = columns.index(column)
|
||||
rows = []
|
||||
for iid in self.tree.get_children(""):
|
||||
values = self.tree.item(iid, "values")
|
||||
value = values[col_index] if col_index < len(values) else ""
|
||||
rows.append((self._sort_key(value), iid))
|
||||
rows.sort(key=lambda item: item[0], reverse=descending)
|
||||
for index, (_key, iid) in enumerate(rows):
|
||||
self.tree.move(iid, "", index)
|
||||
self.tree.item(iid, tags=(zebra_tag(index),))
|
||||
self._sort_column = column
|
||||
self._sort_descending = descending
|
||||
self._refresh_sort_headings()
|
||||
|
||||
def _load_shipped_not_disassociated(self) -> None:
|
||||
self._run_check(
|
||||
key="shipped_not_disassociated",
|
||||
sql=SQL_SHIPPED_NOT_DISASSOCIATED,
|
||||
columns=SHIPPED_NOT_DISASSOCIATED_COLUMNS,
|
||||
busy_text=loc_text(
|
||||
"diagnostics.busy.shipped_not_disassociated",
|
||||
catalog=self._locale_catalog,
|
||||
default="Cerco UDC spedite ma ancora in cella...",
|
||||
),
|
||||
)
|
||||
|
||||
def _load_multiple_udc_by_cell(self) -> None:
|
||||
self._run_check(
|
||||
key="multiple_udc_by_cell",
|
||||
sql=SQL_MULTIPLE_UDC_BY_CELL,
|
||||
columns=MULTIPLE_UDC_COLUMNS,
|
||||
busy_text=loc_text(
|
||||
"diagnostics.busy.multiple_udc_by_cell",
|
||||
catalog=self._locale_catalog,
|
||||
default="Cerco celle con multiple UDC...",
|
||||
),
|
||||
)
|
||||
|
||||
def _load_sam_udc_not_in_wms(self) -> None:
|
||||
self._run_check(
|
||||
key="sam_udc_not_in_wms",
|
||||
sql=SQL_SAM_UDC_NOT_IN_WMS,
|
||||
columns=SAM_UDC_NOT_IN_WMS_COLUMNS,
|
||||
busy_text=loc_text(
|
||||
"diagnostics.busy.sam_udc_not_in_wms",
|
||||
catalog=self._locale_catalog,
|
||||
default="Cerco le ultime UDC presenti in SAM ma non ancora in WMS...",
|
||||
),
|
||||
)
|
||||
|
||||
def _run_check(self, *, key: str, sql: str, columns, busy_text: str) -> None:
|
||||
if self._load_in_progress or not self._is_alive():
|
||||
return
|
||||
|
||||
async def job():
|
||||
return await self.db_client.query_json(sql, as_dict_rows=True)
|
||||
|
||||
self._load_in_progress = True
|
||||
self._current_check = key
|
||||
self._last_export_slug = key
|
||||
self._current_columns = columns
|
||||
self._configure_tree_columns(columns)
|
||||
try:
|
||||
self.btn_export.configure(state="disabled")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self._busy.show(busy_text)
|
||||
self._async.run(job(), self._on_loaded, self._on_error)
|
||||
except Exception as exc:
|
||||
self._load_in_progress = False
|
||||
self._hide_busy_safe()
|
||||
log_exception(__name__, exc, context=f"avvio diagnostica {key}")
|
||||
messagebox.showerror(
|
||||
loc_text("diagnostics.title", catalog=self._locale_catalog, default="Diagnostica"),
|
||||
str(exc),
|
||||
parent=self if self._is_alive() else None,
|
||||
exception=exc,
|
||||
)
|
||||
|
||||
def _on_loaded(self, res: dict[str, Any] | None) -> None:
|
||||
self._load_in_progress = False
|
||||
self._hide_busy_safe()
|
||||
if not self._is_alive():
|
||||
return
|
||||
try:
|
||||
rows = _rows_to_dicts(res)
|
||||
self.tree.delete(*self.tree.get_children(""))
|
||||
keys = [str(col[0]) for col in self._current_columns]
|
||||
for index, row in enumerate(rows):
|
||||
self.tree.insert(
|
||||
"",
|
||||
"end",
|
||||
values=tuple(row.get(key) or "" for key in keys),
|
||||
tags=(zebra_tag(index),),
|
||||
)
|
||||
try:
|
||||
self.btn_export.configure(state="normal" if rows else "disabled")
|
||||
except Exception:
|
||||
pass
|
||||
self._set_status(
|
||||
loc_text(
|
||||
"diagnostics.status.rows",
|
||||
catalog=self._locale_catalog,
|
||||
default="Righe trovate: {count}",
|
||||
).format(count=len(rows))
|
||||
)
|
||||
except Exception as exc:
|
||||
log_exception(__name__, exc, context="render diagnostica")
|
||||
messagebox.showerror(
|
||||
loc_text("diagnostics.title", catalog=self._locale_catalog, default="Diagnostica"),
|
||||
str(exc),
|
||||
parent=self,
|
||||
exception=exc,
|
||||
)
|
||||
|
||||
def _on_error(self, exc: BaseException) -> None:
|
||||
self._load_in_progress = False
|
||||
self._hide_busy_safe()
|
||||
log_exception(__name__, exc, context=f"query diagnostica {self._current_check}")
|
||||
if not self._is_alive():
|
||||
return
|
||||
messagebox.showerror(
|
||||
loc_text("diagnostics.title", catalog=self._locale_catalog, default="Diagnostica"),
|
||||
str(exc),
|
||||
parent=self,
|
||||
exception=exc,
|
||||
)
|
||||
|
||||
def _export_xlsx(self) -> None:
|
||||
"""Export the currently visible diagnostic grid to an Excel file."""
|
||||
|
||||
rows = [self.tree.item(iid, "values") for iid in self.tree.get_children("")]
|
||||
if not rows:
|
||||
messagebox.showinfo(
|
||||
loc_text("diagnostics.export.title", catalog=self._locale_catalog, default="Esporta"),
|
||||
loc_text(
|
||||
"diagnostics.export.empty",
|
||||
catalog=self._locale_catalog,
|
||||
default="Non ci sono righe da esportare.",
|
||||
),
|
||||
parent=self,
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Alignment, Font
|
||||
from openpyxl.utils import get_column_letter
|
||||
except Exception as exc:
|
||||
messagebox.showerror(
|
||||
loc_text("diagnostics.export.title", catalog=self._locale_catalog, default="Esporta"),
|
||||
loc_text(
|
||||
"diagnostics.export.dep",
|
||||
catalog=self._locale_catalog,
|
||||
default="Per l'esportazione serve 'openpyxl' (pip install openpyxl).",
|
||||
).format(error=exc),
|
||||
parent=self,
|
||||
exception=exc,
|
||||
)
|
||||
return
|
||||
|
||||
ts = datetime.now().strftime("%Y%m%d_%H%M")
|
||||
default_name = f"{self._last_export_slug}_{ts}.xlsx"
|
||||
path = filedialog.asksaveasfilename(
|
||||
parent=self,
|
||||
title=loc_text("diagnostics.export.title", catalog=self._locale_catalog, default="Esporta"),
|
||||
defaultextension=".xlsx",
|
||||
filetypes=[("Excel Workbook", "*.xlsx")],
|
||||
initialfile=default_name,
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
|
||||
try:
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "Diagnostica"
|
||||
columns = list(self.tree["columns"])
|
||||
headers = [str(self.tree.heading(col, "text") or col) for col in columns]
|
||||
|
||||
for col_index, header in enumerate(headers, start=1):
|
||||
cell = ws.cell(row=1, column=col_index, value=header)
|
||||
cell.font = Font(bold=True)
|
||||
cell.alignment = Alignment(horizontal="center", vertical="center")
|
||||
|
||||
for row_index, row in enumerate(rows, start=2):
|
||||
for col_index, value in enumerate(row, start=1):
|
||||
ws.cell(row=row_index, column=col_index, value=value)
|
||||
|
||||
widths: dict[int, int] = {}
|
||||
for row in ws.iter_rows(values_only=True):
|
||||
for col_index, value in enumerate(row, start=1):
|
||||
widths[col_index] = max(widths.get(col_index, 0), len("" if value is None else str(value)))
|
||||
for col_index, width in widths.items():
|
||||
ws.column_dimensions[get_column_letter(col_index)].width = min(max(width + 2, 12), 70)
|
||||
|
||||
wb.save(path)
|
||||
messagebox.showinfo(
|
||||
loc_text("diagnostics.export.title", catalog=self._locale_catalog, default="Esporta"),
|
||||
loc_text("diagnostics.export.ok", catalog=self._locale_catalog, default="File creato:\n{path}").format(path=path),
|
||||
parent=self,
|
||||
)
|
||||
except Exception as exc:
|
||||
log_exception(__name__, exc, context="export diagnostica xlsx")
|
||||
messagebox.showerror(
|
||||
loc_text("diagnostics.export.title", catalog=self._locale_catalog, default="Esporta"),
|
||||
loc_text(
|
||||
"diagnostics.export.error",
|
||||
catalog=self._locale_catalog,
|
||||
default="Errore durante l'esportazione:\n{error}",
|
||||
).format(error=exc),
|
||||
parent=self,
|
||||
exception=exc,
|
||||
)
|
||||
|
||||
|
||||
def open_diagnostica_window(parent: tk.Misc, db_client, session=None) -> tk.Misc:
|
||||
"""Open the diagnostics window."""
|
||||
|
||||
win = DiagnosticaWindow(parent, db_client, session=session)
|
||||
place_window_fullsize_below_parent_later(parent, win)
|
||||
win.bind("<Escape>", lambda _e: win.destroy())
|
||||
return win
|
||||
235
diagnostica_scarico_celle_multiple.md
Normal file
235
diagnostica_scarico_celle_multiple.md
Normal file
@@ -0,0 +1,235 @@
|
||||
# Diagnostica Scarico Celle Multiple
|
||||
|
||||
## Contesto
|
||||
|
||||
La finestra `Scarico` aperta da `Gestione layout` serve a gestire celle fisiche che contengono piu' UDC.
|
||||
Nel database legacy non esisteva un vincolo rigido `una cella = una UDC`, quindi una cella rossa puo' contenere:
|
||||
|
||||
- UDC realmente compresenti nella stessa cella;
|
||||
- UDC rimaste in cella anche se appartenenti a picking list gia' chiuse/spedite.
|
||||
|
||||
L'obiettivo della diagnostica non e' ricostruire tutta la storia della UDC, ma aiutare l'operatore a capire quali righe scaricare come spedite.
|
||||
|
||||
## Fonti Dati
|
||||
|
||||
La griglia della dialog parte dalla giacenza corrente:
|
||||
|
||||
```sql
|
||||
dbo.XMag_GiacenzaPallet
|
||||
```
|
||||
|
||||
Questa vista indica quali UDC risultano presenti nella cella aperta dal layout.
|
||||
|
||||
La diagnostica controlla anche:
|
||||
|
||||
```sql
|
||||
dbo.XMag_GiacenzaPalletPlistChiuse
|
||||
```
|
||||
|
||||
Questa vista non e' uno storico documentale puro. E' una vista ibrida che incrocia la giacenza corrente con i documenti SAM chiusi.
|
||||
In pratica serve a individuare UDC ancora presenti in una cella fisica, ma appartenenti a una picking list/documento gia' chiuso.
|
||||
|
||||
## Conclusione Operativa
|
||||
|
||||
Per una cella fisica aperta da `Gestione layout`, i casi realmente utili sono solo due.
|
||||
|
||||
### 1. Nessuna Diagnostica
|
||||
|
||||
La UDC e' presente nella cella multipla e non compare in `XMag_GiacenzaPalletPlistChiuse`.
|
||||
|
||||
Significato:
|
||||
|
||||
```text
|
||||
UDC normalmente presente in cella.
|
||||
```
|
||||
|
||||
Non viene mostrato nessun messaggio nella colonna diagnostica.
|
||||
|
||||
### 2. Spedita Ma Non Scaricata Dalla Cella
|
||||
|
||||
La UDC e' presente nella cella fisica aperta, ma compare anche in `XMag_GiacenzaPalletPlistChiuse`.
|
||||
|
||||
Diagnostica mostrata:
|
||||
|
||||
```text
|
||||
Motivo: spedita ma non scaricata dalla cella
|
||||
```
|
||||
|
||||
Significato:
|
||||
|
||||
```text
|
||||
La UDC appartiene a una picking list chiusa, ma non e' stata scaricata dalla cella fisica.
|
||||
```
|
||||
|
||||
Operativamente questa UDC va selezionata e scaricata come spedita, quindi verso la cella virtuale:
|
||||
|
||||
```text
|
||||
7G.1.1 / IDCella 9999 / barcode cella 9000000
|
||||
```
|
||||
|
||||
## Casi Teorici Scartati Dalla Dialog
|
||||
|
||||
Durante l'analisi erano stati ipotizzati altri casi, ma sono stati esclusi dalla diagnostica della dialog per non confondere l'operatore.
|
||||
|
||||
### UDC Gia' In 7G.1.1
|
||||
|
||||
Se una UDC risulta davvero in `IDCella = 9999`, normalmente non dovrebbe comparire nella cella fisica aperta dal layout.
|
||||
Se accadesse, sarebbe un'incoerenza tra viste o dati non sincronizzati.
|
||||
|
||||
Per questo la dialog di scarico da layout fisico non mostra piu' il messaggio:
|
||||
|
||||
```text
|
||||
Motivo: spedita
|
||||
```
|
||||
|
||||
### UDC In Picking List Chiusa Ma Non Spedita
|
||||
|
||||
Questo caso e' teoricamente possibile ma raro e ambiguo nel modello dati attuale.
|
||||
Le viste disponibili non forniscono una distinzione documentale/storica abbastanza pulita da renderlo utile in questa dialog operativa.
|
||||
|
||||
Per questo la dialog non mostra piu':
|
||||
|
||||
```text
|
||||
Motivo: in plist chiusa, non spedita e non scaricata dalla cella
|
||||
```
|
||||
|
||||
Eventuali analisi piu' profonde vanno fatte nelle finestre di storico, non nella dialog rapida di scarico.
|
||||
|
||||
## Regola Finale Implementata
|
||||
|
||||
La diagnostica della dialog `Scarico` e' volutamente semplice:
|
||||
|
||||
```text
|
||||
se UDC in XMag_GiacenzaPalletPlistChiuse:
|
||||
"Motivo: spedita ma non scaricata dalla cella"
|
||||
altrimenti:
|
||||
diagnostica vuota
|
||||
```
|
||||
|
||||
Questa scelta riduce il rischio di falsi positivi e mantiene chiaro il comportamento per l'operatore.
|
||||
|
||||
## Aggiornamento 04/07/2026 - Barcode Picking List
|
||||
|
||||
Durante i test sul barcode sono state introdotte alcune modifiche operative collegate alla gestione delle picking list, agli skip UDC e alla ripresa del lavoro dopo movimenti liberi.
|
||||
|
||||
### Anti Autosubmit Su Cambio Lista
|
||||
|
||||
Problema osservato:
|
||||
|
||||
```text
|
||||
passando rapidamente da una picking list prenotata a una non prenotata,
|
||||
il barcode poteva considerare come lettura valida un valore gia' presente nel campo Pallet
|
||||
e scaricare automaticamente una UDC della nuova lista.
|
||||
```
|
||||
|
||||
Correzione implementata:
|
||||
|
||||
```text
|
||||
lo scarico automatico in picking list parte solo se il campo Pallet e' stato modificato
|
||||
dall'operatore dopo il caricamento della UDC proposta.
|
||||
```
|
||||
|
||||
In pratica, quando il programma carica una nuova UDC attesa, il valore visualizzato non puo' piu' generare da solo lo scarico. Serve una nuova lettura o digitazione effettiva.
|
||||
|
||||
### Skip UDC In Picking List
|
||||
|
||||
Durante l'evasione di una picking list, il tasto F4 assume il significato:
|
||||
|
||||
```text
|
||||
[F4] Salta UDC
|
||||
```
|
||||
|
||||
La UDC saltata viene registrata nella tabella:
|
||||
|
||||
```sql
|
||||
dbo.py_BarcodePickingListSkip
|
||||
```
|
||||
|
||||
Le righe aperte hanno:
|
||||
|
||||
```text
|
||||
Risolto = 0
|
||||
```
|
||||
|
||||
La query del barcode esclude le UDC saltate aperte, quindi la lista puo' proseguire sulle UDC successive senza chiudere definitivamente quelle non trovate.
|
||||
|
||||
### Fine Lista Con UDC Saltate
|
||||
|
||||
Quando una picking list non ha piu' UDC immediatamente lavorabili, ma contiene una o piu' UDC saltate, il barcode:
|
||||
|
||||
```text
|
||||
non chiude la picking list;
|
||||
rilascia la prenotazione;
|
||||
lascia la lista riprenotabile;
|
||||
mostra un messaggio di sospensione con numero UDC saltate.
|
||||
```
|
||||
|
||||
La lista resta quindi aperta e potra' essere ripresa in un secondo momento.
|
||||
|
||||
### Riprenotazione E Ripresa UDC Saltate
|
||||
|
||||
Quando la picking list viene riprenotata, gli skip aperti del documento vengono marcati come risolti:
|
||||
|
||||
```sql
|
||||
UPDATE dbo.py_BarcodePickingListSkip
|
||||
SET Risolto = 1,
|
||||
RisoltoDa = <operatore>,
|
||||
RisoltoDataOra = SYSDATETIME()
|
||||
WHERE Documento = <documento>
|
||||
AND Risolto = 0;
|
||||
```
|
||||
|
||||
Questo permette al barcode di riproporre le UDC saltate rimaste da evadere.
|
||||
|
||||
### Posizione UDC Dopo Movimenti Liberi
|
||||
|
||||
Una UDC saltata puo' essere movimentata in pausa tramite operazioni libere, ad esempio:
|
||||
|
||||
```text
|
||||
versamento in una nuova cella fisica;
|
||||
dissociazione verso 9001000 / Non scaffalata.
|
||||
```
|
||||
|
||||
Alla ripresa della picking list, la posizione mostrata dal barcode riflette la giacenza corrente, perche' la vista operativa deriva `Cella` e `Ubicazione` da:
|
||||
|
||||
```sql
|
||||
dbo.XMag_GiacenzaPallet
|
||||
```
|
||||
|
||||
Quindi una UDC prima saltata e poi spostata verra' proposta con la nuova cella, oppure come:
|
||||
|
||||
```text
|
||||
Non scaffalata
|
||||
```
|
||||
|
||||
se e' stata dissociata verso la locazione virtuale `9001000`.
|
||||
|
||||
### Regola Conservata
|
||||
|
||||
Resta confermata la regola operativa:
|
||||
|
||||
```text
|
||||
una UDC diventa Spedita / 7G.1.1 / 9000000 solo nel flusso picking list.
|
||||
```
|
||||
|
||||
Le operazioni libere non spediscono una UDC. Possono solo versarla in una cella fisica oppure metterla in `9001000 / Non scaffalata`.
|
||||
|
||||
### File Coinvolti
|
||||
|
||||
Le modifiche principali sono nei moduli:
|
||||
|
||||
```text
|
||||
barcode_client.py
|
||||
barcode_repository.py
|
||||
barcode_service.py
|
||||
prenota_sprenota_sql.py
|
||||
version_info.py
|
||||
```
|
||||
|
||||
La patch DB cumulativa da usare sul database online e':
|
||||
|
||||
```text
|
||||
apply_online_python_wms_full_patch.sql
|
||||
```
|
||||
|
||||
La patch contiene gli oggetti SQL necessari al ramo Python e puo' essere eseguita una sola volta da SSMS.
|
||||
115
diagramma_scarico_udc.md
Normal file
115
diagramma_scarico_udc.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# Diagramma Operativo - Scarico UDC / Prelievo
|
||||
|
||||
## Obiettivo
|
||||
Prelevare una UDC dal magazzino e scaricarla verso la cella virtuale `9000000`.
|
||||
|
||||
## Nota importante
|
||||
Dal codice C# emergono **due sottocasi diversi**:
|
||||
|
||||
- `scarico picking list`
|
||||
- parte da `F1` o `F2`
|
||||
- valida il pallet atteso della coda
|
||||
- `scarico diretto`
|
||||
- parte dal pulsante `F4 Elimina`
|
||||
- non richiede una picking list prenotata
|
||||
|
||||
Questo diagramma descrive il **primo scarico UDC diretto**, cioe' il prelievo senza navigazione picking list.
|
||||
|
||||
## Stato iniziale del barcode
|
||||
|
||||
- form aperta
|
||||
- nessuna operazione pendente
|
||||
- focus sul campo `Pallet`
|
||||
- prima label di stato neutra o grigia
|
||||
- campo `Cella` non significativo finche' non si entra nel comando
|
||||
|
||||
## Come si entra nello stato iniziale dello scarico
|
||||
|
||||
Dal comportamento C# la strada piu' fedele e':
|
||||
|
||||
1. l'operatore preme `F4`
|
||||
2. la form entra in modalita' scarico diretto
|
||||
3. la prima label deve indicare:
|
||||
- `OP Scarico`
|
||||
4. il campo `Cella` viene preimpostato a:
|
||||
- `9000000`
|
||||
5. il focus va sul campo `Pallet`
|
||||
|
||||
## Stato operativo durante lo scarico
|
||||
|
||||
- `Pallet` = da leggere
|
||||
- `Cella` = `9000000`
|
||||
- focus sul campo `Pallet`
|
||||
- label 1 grigia con:
|
||||
- `OP Scarico`
|
||||
|
||||
## Sequenza operativa
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A["Stato neutro"] --> B["Operatore preme F4"]
|
||||
B --> C["Form entra in OP Scarico"]
|
||||
C --> D["Cella preimpostata a 9000000"]
|
||||
D --> E["Focus sul campo Pallet"]
|
||||
E --> F["Operatore legge barcode pallet"]
|
||||
F --> G{"Invio automatico del lettore o Enter manuale"}
|
||||
G --> H["Esecuzione stored sp_xMagGestioneMagazziniPallet"]
|
||||
H --> I{"Esito OK?"}
|
||||
I -- Si --> L["Label 1 verde/giallo: Ok Scarico"]
|
||||
L --> M["Label 2 = lotto"]
|
||||
M --> N["Label 3 = codice prodotto"]
|
||||
N --> O["Label 4 = descrizione articolo"]
|
||||
O --> P["Focus torna su Pallet per operazione successiva"]
|
||||
I -- No --> Q["Label 1 rossa con errore"]
|
||||
Q --> R["Focus torna su Pallet"]
|
||||
```
|
||||
|
||||
## Stato finale se l'operazione va bene
|
||||
|
||||
- prima label:
|
||||
- verde chiaro o giallo-verde
|
||||
- testo tipo `Ok Scarico`
|
||||
- seconda label:
|
||||
- lotto del pallet movimentato
|
||||
- terza label:
|
||||
- codice prodotto
|
||||
- quarta label:
|
||||
- descrizione articolo
|
||||
- focus:
|
||||
- torna sul campo `Pallet`
|
||||
- campo `Cella`:
|
||||
- resta `9000000`
|
||||
|
||||
## Stato finale se l'operazione fallisce
|
||||
|
||||
- prima label rossa
|
||||
- testo di errore operativo
|
||||
- focus sul campo `Pallet`
|
||||
- nessun avanzamento di coda
|
||||
|
||||
## Coerenza con il C#
|
||||
|
||||
I punti dedotti direttamente dal codice C# sono:
|
||||
|
||||
- `F4 Elimina` forza uno scarico verso `9000000`
|
||||
- lo scarico usa:
|
||||
- `sp_xMagGestioneMagazziniPallet`
|
||||
- dopo il movimento il C# richiama:
|
||||
- `GetDatiPallet(...)`
|
||||
- e se il pallet non e' piu' nella vista picking passa a:
|
||||
- `GetDatiPalletLotto(...)`
|
||||
- da quest'ultima lettura arrivano:
|
||||
- `Ok Scarico`
|
||||
- lotto
|
||||
- codice prodotto
|
||||
- descrizione articolo
|
||||
|
||||
## Punto ancora da verificare sul campo
|
||||
|
||||
Da confermare in prova reale:
|
||||
|
||||
- se nel client legacy il colore di successo finale dello scarico diretto sia:
|
||||
- verde chiaro
|
||||
- oppure giallo-verde
|
||||
- se il focus torni sempre al campo `Pallet` anche dopo errore
|
||||
- se il lettore genera davvero `Enter` automatico in ogni scenario di scansione
|
||||
107
docs/aggiornamento_monolista_bat.md
Normal file
107
docs/aggiornamento_monolista_bat.md
Normal file
@@ -0,0 +1,107 @@
|
||||
# Aggiornare un desktop di reparto con il file BAT
|
||||
|
||||
Il file `aggiorna_monolista.bat` si esegue SUL COMPUTER DA AGGIORNARE, anche da
|
||||
una sessione Desktop Remoto. Non e' un comando che aggiorna tutti i PC da solo.
|
||||
Prima deve essere riuscito il push del PC di sviluppo su Gitea: lo script puo'
|
||||
scaricare solo cio' che e' effettivamente online.
|
||||
|
||||
## Avvio
|
||||
|
||||
Chiudere applicazione desktop e barcode in tutte le sessioni che usano la stessa
|
||||
cartella. Non e' normalmente necessario eseguire come amministratore: l'utente
|
||||
deve avere i permessi sulla cartella e sull'ambiente Python utilizzato.
|
||||
|
||||
Per la cartella standard `C:\flywms`, doppio clic sul BAT, oppure dal prompt CMD:
|
||||
|
||||
```bat
|
||||
aggiorna_monolista.bat
|
||||
```
|
||||
|
||||
Per scegliere cartella e interprete (lo stesso usato dal collegamento dell'app):
|
||||
|
||||
```bat
|
||||
aggiorna_monolista.bat "C:\flywms" "C:\Python314\python.exe"
|
||||
```
|
||||
|
||||
Se non si indica l'interprete, cerca prima `.venv\Scripts\python.exe` nella
|
||||
cartella dell'applicazione, poi `python` nel PATH. Usare python.exe, non pythonw.exe,
|
||||
per vedere gli errori di installazione. Lo script mostra la versione Python e pip.
|
||||
|
||||
## Comportamento
|
||||
|
||||
1. Chiede conferma che le applicazioni siano chiuse; non uccide processi.
|
||||
2. Controlla clone Git, URL origin, Python/pip e assenza di modifiche ai file tracciati.
|
||||
3. Scarica main da Gitea e verifica che non contenga db_connection.json.
|
||||
4. Si ferma se HEAD o il main locale hanno commit non contenuti nel main remoto.
|
||||
5. Salva un riferimento locale alla versione precedente, passa a main e aggiorna
|
||||
con fast-forward, senza merge automatici di codice o reset distruttivi.
|
||||
6. Esegue `python -m pip install -r requirements.txt` nell'interprete selezionato.
|
||||
7. Mostra il commit installato; solo in caso di successo si puo' riaprire l'app.
|
||||
|
||||
Il BAT gira da una copia in TEMP per non essere interrotto se Git aggiorna il BAT
|
||||
stesso. Non cancella log, ZIP, configurazioni o altri file non tracciati. Se un file
|
||||
non tracciato impedisce il checkout, Git interrompe l'operazione anziche' sovrascriverlo.
|
||||
Non esegue alcuna patch SQL. Le modifiche del 22 ottobre (svuotamento corsie e
|
||||
ricerca UDC nello storico) non richiedono nuove patch SQL.
|
||||
|
||||
## Errori e ripristino
|
||||
|
||||
- Autenticazione: servono credenziali/token Git validi sul PC di reparto; il BAT
|
||||
non contiene password e non modifica le credenziali memorizzate.
|
||||
- Modifiche locali: il BAT si ferma. Non usare reset/clean alla cieca.
|
||||
- Installazione da ZIP: occorre prima predisporre un clone Git, separatamente.
|
||||
- Pip fallito: i sorgenti possono essere gia' aggiornati; risolvere l'errore prima
|
||||
di riavviare. Il BAT non promette un rollback automatico dell'ambiente Python.
|
||||
|
||||
La finestra mostra il comando per recuperare i sorgenti precedenti:
|
||||
|
||||
```bat
|
||||
git switch --detach refs/warehouse-backups/pre-update-DATA-ORA
|
||||
```
|
||||
|
||||
Usare il riferimento esatto stampato dal BAT. Per ritrovarlo:
|
||||
|
||||
```bat
|
||||
git for-each-ref --sort=-refname --format="%(refname) %(objectname:short)" refs/warehouse-backups/
|
||||
```
|
||||
|
||||
Il ripristino riguarda esclusivamente i file Git: non annulla movimenti sul DB,
|
||||
patch SQL, configurazioni locali o aggiornamenti dei pacchetti Python. La copia
|
||||
locale db_connection.json non viene caricata da Gitea e rimane quella del reparto.
|
||||
|
||||
Il codice di uscita e' 0 per successo, 1 per errore, 2 per annullamento.
|
||||
|
||||
## Errore Unlink su .git/objects/pack/*.idx
|
||||
|
||||
Durante fetch Git puo' lanciare automaticamente manutenzione/ricompattazione.
|
||||
Su Windows questa puo' fallire quando un vecchio indice pack e' bloccato da un
|
||||
processo o non puo' essere eliminato per motivi di permessi. Il messaggio da solo
|
||||
non identifica chi blocca il file. Non cancellare manualmente file .idx o .pack.
|
||||
|
||||
Il BAT disabilita la manutenzione automatica SOLO per fetch e merge, tramite
|
||||
`git -c maintenance.auto=false -c gc.auto=0 ...`. Non modifica la configurazione
|
||||
permanente di Git e non arresta eventuali manutenzioni gia' in corso o pianificate.
|
||||
Non risolve permessi mancanti o blocchi che impediscono la normale scrittura Git.
|
||||
|
||||
Per recuperare il nuovo BAT mentre si dispone ancora di quello precedente, dopo
|
||||
aver terminato l'operazione Git precedente, dal prompt CMD:
|
||||
|
||||
```bat
|
||||
cd /d C:\flywms
|
||||
git -c maintenance.auto=false -c gc.auto=0 fetch origin refs/heads/main
|
||||
```
|
||||
|
||||
Solo se fetch ha successo, estrarre il BAT in una cartella esterna gia' esistente:
|
||||
|
||||
```bat
|
||||
git show FETCH_HEAD:aggiorna_monolista.bat > C:\tmp\aggiorna_monolista_nuovo.bat
|
||||
```
|
||||
|
||||
Solo se anche questo comando ha successo:
|
||||
|
||||
```bat
|
||||
C:\tmp\aggiorna_monolista_nuovo.bat C:\flywms C:\Python314\python.exe
|
||||
```
|
||||
|
||||
Questa procedura non modifica singolarmente il BAT tracciato nella cartella
|
||||
installata (che altrimenti risulterebbe modificato e bloccherebbe i controlli).
|
||||
21
docs/analisi_stati_udc_23_20_2026.txt
Normal file
21
docs/analisi_stati_udc_23_20_2026.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
analisi degli stati di movimentazine di una udc
|
||||
|
||||
finora abbiao gestito sostanzialmente due stati : udc scaffalata, udc non scaffalata. Le udc che non ricadono in questi due stati diciamo il loro stato in merito all'inventario pteva essere dedotto in qalcosa tipo "in elaborazione" nel magazzino confezionamento.
|
||||
|
||||
|
||||
Ho visto che ,in realtà una udc che si trovi "in elaborazione " ha uno stato dentro sam nella tabella sam.extuc che è "chiusa" s|n (si,no) , fino a quando la UDC è in lavorazione lo stato CHIUSA è N, quando la UDC è chiusa e pronta per andare in magazzino lo stato CHIUSA è S.
|
||||
|
||||
Quanid in virtuàù di uesto possiamo perfettamente dire che gli stati delle udc sono 4:
|
||||
1- "in lavorazione" -> sulla tabella sam.extuc -> chiusa =N
|
||||
2- "in transito" -> sulla tabella sam.extuc -> chiusa =S mai assengnata ad una cella e mai disassociata
|
||||
3- "non scaffalata" -> sulla tabella sam.extuc -> chiusa =S , ma è stata fisicamente disassociata da una cella di uno scaffale tramite barcode, fisicamente si trova nell'area in cui si trovava prima quando era scaffalata, ma sul pavimento.
|
||||
4- "in cella" ->sulla tabella sam.extuc -> chiusa =S, e assegnata ad una cella tramite il lettore di barcode
|
||||
|
||||
|
||||
Come conseguenza di ciò dobbiamo aggiungere una nuova "area accettazione" ,dove staranno tutte le udc che sono "in transito" associate al codice ad es: 8G.1.1 e una "area confezionamento" in cui si trovano tutte le UDC che sono chiuse->N e sono quindi assegnate all'atto della nascita in sam al codice ad es: 6G.1.1.
|
||||
|
||||
Le udc "non scaffalate" dovranno comparire nel modulo gui "gestione layout" nella stessa area in cui si trovavano prima di essere disaassociate , e visivamente come un elenco orizzontale di pulsanti aventi le stesse caratteristiche di quelli che rappresetano le celle degli scaffali ma grigie. Devono riportare il codice della udc,nella riga sotto la scritta "non scaff" e devono essere fuori,staccate una riga sotto la griglia dello scaffale di quell'area, come a rappresentare proprio il livello del pavimento.
|
||||
|
||||
Ora l'area accettazione e l'area confezionamemto avranno codice 1x e 1y, la loro rappresentazione grafica sarà sempre nel modulo gui gestione layout , ma non ci sarà uno scaffare traversa/montante come ora bensì una griglia di di pulsanti grigi, ad esempio 2 righe per n colonne quante ne servono, per rappresentare le udc che si trovano in tali aree, nell'area confezionamento quelle ancora aperte "chiusa N" e in area accettazione quelle "in transito" "chiusa S",che hanno 0 scaffalature.
|
||||
|
||||
Ti chiedo di analizzare approfonditamente specifiche per capire se cin sono incongruenze che dobbiamo approfondire poi procederemoall'implementazione di queste nuove parti
|
||||
@@ -20,18 +20,18 @@ async_msssql_query.py
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
gestione_aree_frame_async.py
|
||||
gestione_aree.py
|
||||
----------------------------
|
||||
|
||||
.. automodule:: gestione_aree_frame_async
|
||||
.. automodule:: gestione_aree
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
layout_window.py
|
||||
----------------
|
||||
gestione_layout.py
|
||||
------------------
|
||||
|
||||
.. automodule:: layout_window
|
||||
.. automodule:: gestione_layout
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -44,10 +44,10 @@ reset_corsie.py
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
view_celle_multiple.py
|
||||
----------------------
|
||||
view_celle_multi_udc.py
|
||||
-----------------------
|
||||
|
||||
.. automodule:: view_celle_multiple
|
||||
.. automodule:: view_celle_multi_udc
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -12,12 +12,12 @@ flowchart TD
|
||||
Main --> DB["AsyncMSSQLClient"]
|
||||
|
||||
Launcher --> Reset["reset_corsie.py"]
|
||||
Launcher --> Layout["layout_window.py"]
|
||||
Launcher --> Ghost["view_celle_multiple.py"]
|
||||
Launcher --> Layout["gestione_layout.py"]
|
||||
Launcher --> Ghost["view_celle_multi_udc.py"]
|
||||
Launcher --> Search["search_pallets.py"]
|
||||
Launcher --> Picking["gestione_pickinglist.py"]
|
||||
|
||||
Reset --> Runner["gestione_aree_frame_async.AsyncRunner"]
|
||||
Reset --> Runner["gestione_aree.AsyncRunner"]
|
||||
Layout --> Runner
|
||||
Ghost --> Runner
|
||||
Search --> Runner
|
||||
|
||||
74
docs/finestre_errori.md
Normal file
74
docs/finestre_errori.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Finestre di errore unificate
|
||||
|
||||
## Modifica del 23 ottobre 2026
|
||||
|
||||
I dialoghi di errore del programma monolista, desktop e barcode, usano ora
|
||||
`error_dialog.py`, invece della messagebox nativa di Tkinter. Il testo non viene
|
||||
riassunto, accorciato o ridotto di dimensione per farlo entrare nello schermo.
|
||||
|
||||
La finestra offre:
|
||||
|
||||
- Ridimensionamento e scorrimento verticale e orizzontale.
|
||||
- Selezione del testo con il mouse, Ctrl+A e Ctrl+C.
|
||||
- Pulsante **Copia tutto**, per copiare l'intero report, anche fuori dalla vista.
|
||||
- Pulsante **Salva su file**, con scelta del percorso e formato TXT UTF-8.
|
||||
- Pulsante **Chiudi**, tasto Esc e chiusura dalla barra del titolo.
|
||||
|
||||
Su terminali piccoli i pulsanti vengono disposti in colonna. La dimensione
|
||||
iniziale tiene conto della risoluzione. Tema e testi sono definiti in
|
||||
`ui_theme.json` e `locale.json` (IT/ENG).
|
||||
|
||||
## Contenuto e integrazione
|
||||
|
||||
Il report conserva il messaggio originale, data/ora con fuso orario, versione
|
||||
applicativa e Python, e, quando fornita, l'eccezione originale con traceback e
|
||||
catena delle cause. Sono aggiunti gli attributi SQL `statement` e `params` per
|
||||
evitare le abbreviazioni della rappresentazione standard di SQLAlchemy.
|
||||
La finestra chiamante, quando indicata, contribuisce con il proprio titolo e
|
||||
la versione visibile. Una segnalazione di validazione senza eccezione conserva
|
||||
il messaggio, senza inventare uno stack di errore.
|
||||
|
||||
I callback asincroni passano esplicitamente `exception=exc`: convertire prima
|
||||
l'errore in stringa farebbe perdere il traceback. Nel barcode, se falliscono
|
||||
sia l'operazione sia la verifica del suo esito, il report contiene entrambe le
|
||||
eccezioni. La logica di verifica, le transazioni e i movimenti non cambiano.
|
||||
|
||||
Sono stati collegati inventario, diagnostica, layout, gestione e storico picking
|
||||
list, storico UDC, ricerca, UDC non scaffalate/multiple, scarico, reset corsie,
|
||||
sequenza di prelievo, autenticazione, configurazione DB, barcode, errori dei
|
||||
callback Tk e messaggi di avvio gestiti da `runtime_support`.
|
||||
|
||||
Informazioni, avvisi e conferme continuano a usare i dialoghi nativi: in
|
||||
particolare non cambiano le risposte Si/No delle operazioni di magazzino.
|
||||
Non viene applicata alcuna modifica globale alla libreria Tkinter: i moduli
|
||||
importano esplicitamente il componente condiviso.
|
||||
|
||||
Il dialogo e' modale come la precedente messagebox. Alla chiusura ripristina
|
||||
l'eventuale precedente finestra modale e il focus. Va chiamato sul thread Tk;
|
||||
non apre finestre direttamente dai thread di lavoro. Gli errori di background
|
||||
non destinati alla UI continuano a essere gestiti dai log esistenti.
|
||||
|
||||
Il salvataggio e' manuale, non sostituisce il logging gia' presente. Se viene
|
||||
annullato non scrive nulla; se fallisce, la finestra rimane aperta e indica
|
||||
l'errore. Copia e salvataggio usano lo stesso testo immutabile visualizzato.
|
||||
I report possono contenere parametri SQL e dati aziendali: conservarli e
|
||||
condividerli solo con personale autorizzato.
|
||||
|
||||
## Estensione email futura
|
||||
|
||||
Non viene inviata posta e non e' presente un pulsante non funzionante.
|
||||
Il report separato dalla visualizzazione potra' diventare l'allegato di un
|
||||
futuro pulsante **Invia al manutentore**, previa configurazione del destinatario,
|
||||
del servizio di invio e conferma dell'operatore. L'invio dovra' essere asincrono.
|
||||
|
||||
## Verifica e installazione
|
||||
|
||||
I test usano eccezioni sintetiche e widget Tk reali, senza operazioni sul DB:
|
||||
report lunghi, traceback e parametri, scroll, copia integrale/selezione,
|
||||
salvataggio UTF-8, annullamento/errori di salvataggio, schermi piccoli,
|
||||
ripristino della modalita' modale, errori asincroni e recupero barcode.
|
||||
|
||||
Non occorrono patch SQL o nuove dipendenze. Aggiornare anche il nuovo modulo,
|
||||
il catalogo delle lingue, il tema e `version_info.py`, non solo `inventario.py`.
|
||||
Questa modifica migliora la consultazione degli errori: non risolve da sola
|
||||
il lock timeout SQL 1222 rilevato nell'inventario.
|
||||
@@ -12,12 +12,13 @@ I diagrammi sono scritti in Mermaid, quindi possono essere:
|
||||
## Indice
|
||||
|
||||
- [main](./main_flow.md)
|
||||
- [layout_window](./layout_window_flow.md)
|
||||
- [gestione_layout](./gestione_layout_flow.md)
|
||||
- [reset_corsie](./reset_corsie_flow.md)
|
||||
- [view_celle_multiple](./view_celle_multiple_flow.md)
|
||||
- [view_celle_multi_udc](./view_celle_multi_udc_flow.md)
|
||||
- [search_pallets](./search_pallets_flow.md)
|
||||
- [gestione_pickinglist](./gestione_pickinglist_flow.md)
|
||||
- [infrastruttura async/db](./async_db_flow.md)
|
||||
- [warehouse operational flow](./warehouse_operational_flow.md)
|
||||
|
||||
## Convenzioni
|
||||
|
||||
|
||||
@@ -35,5 +35,5 @@ flowchart TD
|
||||
## Note
|
||||
|
||||
- E un helper minimale usato da `main.py`.
|
||||
- Il modulo esiste separato da `gestione_aree_frame_async.py`, ma concettualmente
|
||||
- Il modulo esiste separato da `gestione_aree.py`, ma concettualmente
|
||||
svolge lo stesso ruolo di gestione del loop condiviso.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# `gestione_aree_frame_async.py`
|
||||
# `gestione_aree.py`
|
||||
|
||||
## Scopo
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# `layout_window.py`
|
||||
# `gestione_layout.py`
|
||||
|
||||
## Scopo
|
||||
|
||||
Questo modulo visualizza il layout delle corsie come matrice di celle, mostra
|
||||
lo stato di occupazione, consente di cercare una UDC e permette l'export della
|
||||
matrice.
|
||||
matrice. La griglia ad alte prestazioni e' resa con `tksheet`, mantenendo la
|
||||
stessa semantica visiva delle celle operative.
|
||||
|
||||
## Flusso operativo
|
||||
|
||||
@@ -57,5 +58,7 @@ flowchart LR
|
||||
- Il modulo usa un token `_req_counter` per evitare che risposte async vecchie
|
||||
aggiornino la UI fuori ordine.
|
||||
- La statistica globale viene ricalcolata da query SQL, mentre quella della
|
||||
corsia corrente usa la matrice già caricata in memoria.
|
||||
- `destroy()` marca la finestra come non più attiva per evitare callback tardive.
|
||||
corsia corrente usa la matrice gia' caricata in memoria.
|
||||
- Il click destro su una cella riusa lo stesso menu contestuale della versione
|
||||
precedente basata su pulsanti CTk.
|
||||
- `destroy()` marca la finestra come non piu' attiva per evitare callback tardive.
|
||||
@@ -13,7 +13,7 @@ Questo modulo gestisce la vista master/detail delle picking list e permette di:
|
||||
|
||||
```{mermaid}
|
||||
flowchart TD
|
||||
A["open_pickinglist_window() da main.py"] --> B["create_pickinglist_frame()"]
|
||||
A["open_pickinglist_window() in gestione_pickinglist.py"] --> B["create_frame()"]
|
||||
B --> C["GestionePickingListFrame.__init__()"]
|
||||
C --> D["_build_layout()"]
|
||||
D --> E["after_idle(_first_show)"]
|
||||
|
||||
@@ -9,12 +9,13 @@ infrastrutturali.
|
||||
|
||||
README.md
|
||||
main_flow.md
|
||||
layout_window_flow.md
|
||||
gestione_layout_flow.md
|
||||
reset_corsie_flow.md
|
||||
view_celle_multiple_flow.md
|
||||
view_celle_multi_udc_flow.md
|
||||
search_pallets_flow.md
|
||||
gestione_pickinglist_flow.md
|
||||
warehouse_operational_flow.md
|
||||
async_db_flow.md
|
||||
async_msssql_query_flow.md
|
||||
gestione_aree_frame_async_flow.md
|
||||
gestione_aree_flow.md
|
||||
async_loop_singleton_flow.md
|
||||
|
||||
@@ -22,7 +22,7 @@ flowchart TD
|
||||
I --> K["open_layout_window()"]
|
||||
I --> L["open_celle_multiple_window()"]
|
||||
I --> M["open_search_window()"]
|
||||
I --> N["open_pickinglist_window()"]
|
||||
I --> N["gestione_pickinglist.open_pickinglist_window()"]
|
||||
```
|
||||
|
||||
## Schema di chiamata
|
||||
@@ -33,13 +33,13 @@ flowchart LR
|
||||
Launcher --> Layout["open_layout_window"]
|
||||
Launcher --> Ghost["open_celle_multiple_window"]
|
||||
Launcher --> Search["open_search_window"]
|
||||
Launcher --> Pick["open_pickinglist_window"]
|
||||
Pick --> PickFactory["create_pickinglist_frame"]
|
||||
Launcher --> Pick["gestione_pickinglist.open_pickinglist_window"]
|
||||
Pick --> PickFactory["gestione_pickinglist.create_frame"]
|
||||
```
|
||||
|
||||
## Note
|
||||
|
||||
- `db_app` viene creato una sola volta e poi passato a tutte le finestre.
|
||||
- Alla chiusura del launcher viene chiamato `db_app.dispose()` sul loop globale.
|
||||
- `open_pickinglist_window()` costruisce la finestra in modo nascosto e la rende
|
||||
- `gestione_pickinglist.open_pickinglist_window()` costruisce la finestra in modo nascosto e la rende
|
||||
visibile solo a layout pronto, per ridurre lo sfarfallio iniziale.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# `view_celle_multiple.py`
|
||||
# `view_celle_multi_udc.py`
|
||||
|
||||
## Scopo
|
||||
|
||||
167
docs/flows/warehouse_operational_flow.md
Normal file
167
docs/flows/warehouse_operational_flow.md
Normal file
@@ -0,0 +1,167 @@
|
||||
# Warehouse Operational Flow
|
||||
|
||||
Questo diagramma descrive il flusso operativo integrato tra:
|
||||
|
||||
- layout di magazzino;
|
||||
- gestione picking list;
|
||||
- movimentazione fisica dei pallet;
|
||||
- viste SQL e stored procedure coinvolte;
|
||||
- aggiornamento dell'interfaccia dopo ogni operazione.
|
||||
|
||||
## Vista d'insieme
|
||||
|
||||
```{mermaid}
|
||||
flowchart TD
|
||||
UI["Operatore su interfaccia"] --> LAY["Gestione Layout"]
|
||||
UI --> PL["Gestione Picking List"]
|
||||
|
||||
subgraph Layout["Flusso Layout"]
|
||||
LAY --> LC1["Caricamento corsie e metadati layout"]
|
||||
LC1 --> LC2["vViewMappaturaDescrizioneCorsia"]
|
||||
LC1 --> LC3["vViewMappaturaPosizCorsia"]
|
||||
LC1 --> LC4["MagLayout"]
|
||||
LC1 --> LC5["Celle / Magazzini"]
|
||||
LC2 --> GRID["Rendering griglia scaffale"]
|
||||
LC3 --> GRID
|
||||
LC4 --> GRID
|
||||
LC5 --> GRID
|
||||
GRID --> LX["Click su cella / ricerca UDC / menu contestuale"]
|
||||
end
|
||||
|
||||
subgraph Picking["Flusso Picking List"]
|
||||
PL --> PC1["Caricamento elenco documenti"]
|
||||
PC1 --> PV1["XMag_ViewPackingList"]
|
||||
PV1 --> PGRID["Griglia documenti aggregata"]
|
||||
PGRID --> PSEL["Selezione documento"]
|
||||
PSEL --> PV2["vViewPackingListRestante"]
|
||||
PV2 --> PDET["Griglia dettaglio documento"]
|
||||
PDET --> PACT["Prenota / S-prenota / consultazione"]
|
||||
end
|
||||
|
||||
subgraph Mov["Movimentazione pallet"]
|
||||
LX --> MOVE{"Operazione fisica?"}
|
||||
MOVE -->|Carico o spostamento| SP1["sp_xMagGestioneMagazziniPallet"]
|
||||
MOVE -->|Scarico pallet| SP1
|
||||
PACT -->|Prenota o s-prenota| SP2["sp_xExePackingListPallet"]
|
||||
SP1 --> M1["Aggiorna movimenti MagazziniPallet"]
|
||||
SP1 --> M2["Aggiorna cella destinazione / origine"]
|
||||
SP1 --> M3["Controlla prenotazione automatica"]
|
||||
M3 --> SP3["sp_ControllaPrenotazionePackingListPalletNew"]
|
||||
SP3 --> SP4["sp_xExePackingListPalletPrenota"]
|
||||
SP2 --> M4["Aggiorna Celle.IDStato"]
|
||||
SP2 --> M5["Scrive LogPackingList"]
|
||||
SP4 --> M4
|
||||
end
|
||||
|
||||
subgraph Views["Ricostruzione contesto"]
|
||||
M1 --> GV["XMag_GiacenzaPallet"]
|
||||
M2 --> CV["Celle"]
|
||||
GV --> XP["XMag_ViewPackingList"]
|
||||
GV --> TP["vXTracciaProdotti"]
|
||||
CV --> XP
|
||||
XP --> RL1["Stato documento / pallet / ubicazione"]
|
||||
TP --> RL2["Articolo / lotto / descrizione"]
|
||||
end
|
||||
|
||||
RL1 --> LREF["Refresh Layout / Picking List"]
|
||||
RL2 --> LREF
|
||||
LREF --> GRID
|
||||
LREF --> PGRID
|
||||
LREF --> PDET
|
||||
```
|
||||
|
||||
## Flusso del layout
|
||||
|
||||
```{mermaid}
|
||||
flowchart TD
|
||||
A["Apertura Gestione Layout"] --> B["Legge mappatura corsie"]
|
||||
B --> B1["vViewMappaturaDescrizioneCorsia"]
|
||||
B --> B2["vViewMappaturaPosizCorsia"]
|
||||
B --> B3["MagLayout"]
|
||||
B --> B4["Celle / Magazzini"]
|
||||
B1 --> C["Costruisce geometria scaffale"]
|
||||
B2 --> C
|
||||
B3 --> C
|
||||
B4 --> C
|
||||
C --> D["Query giacenza pallet per corsia"]
|
||||
D --> E["Colora celle: vuota / piena / multipla"]
|
||||
E --> F["Mostra UDC piu recente nella cella"]
|
||||
F --> G{"Interazione utente"}
|
||||
G -->|Ricerca UDC| H["Evidenzia cella in blu"]
|
||||
G -->|Tasto destro su cella rossa| I["Menu contestuale"]
|
||||
I --> J["Dialog scarico / analisi multi UDC"]
|
||||
J --> K["Movimentazione fisica pallet"]
|
||||
K --> L["Refresh layout"]
|
||||
```
|
||||
|
||||
## Flusso della picking list
|
||||
|
||||
```{mermaid}
|
||||
flowchart TD
|
||||
A["Apertura Gestione Picking List"] --> B["Query aggregata documenti"]
|
||||
B --> C["XMag_ViewPackingList"]
|
||||
C --> D["Una riga per documento"]
|
||||
D --> E["Utente seleziona il documento"]
|
||||
E --> F["Query dettaglio documento"]
|
||||
F --> G["vViewPackingListRestante"]
|
||||
G --> H["Mostra pallet ancora rilevanti per il documento"]
|
||||
H --> I{"Azione utente"}
|
||||
I -->|Prenota o s-prenota| J["sp_xExePackingListPallet"]
|
||||
I -->|Consulta dettaglio| H
|
||||
J --> K["Aggiorna IDStato delle celle del documento"]
|
||||
K --> L["LogPackingList"]
|
||||
K --> M["Refresh lista documenti"]
|
||||
K --> N["Refresh dettaglio documento"]
|
||||
```
|
||||
|
||||
## Flusso della movimentazione pallet
|
||||
|
||||
```{mermaid}
|
||||
flowchart TD
|
||||
A["Utente legge barcode pallet e cella"] --> B["sp_xMagGestioneMagazziniPallet"]
|
||||
B --> C{"Il pallet esiste gia in giacenza?"}
|
||||
C -->|No| D["Inserisce movimento V sulla nuova cella"]
|
||||
C -->|Si| E["Inserisce movimento P sulla vecchia cella"]
|
||||
E --> F["Inserisce movimento V sulla nuova cella"]
|
||||
D --> G["Aggiorna ricostruzione giacenza"]
|
||||
F --> G
|
||||
G --> H["XMag_GiacenzaPallet"]
|
||||
H --> I["XMag_ViewPackingList"]
|
||||
H --> J["vXTracciaProdotti"]
|
||||
I --> K["Ubicazione e stato documento"]
|
||||
J --> L["Dati articolo e lotto"]
|
||||
K --> M["Refresh interfaccia"]
|
||||
L --> M
|
||||
```
|
||||
|
||||
## Significato delle viste e delle stored procedure
|
||||
|
||||
- `XMag_ViewPackingList`:
|
||||
ricostruisce il collegamento tra pallet, documento, ubicazione e stato
|
||||
logistico. E' la vista principale per la schermata picking list.
|
||||
- `vViewPackingListRestante`:
|
||||
mostra il dettaglio operativo del documento, cioe' le righe ancora visibili
|
||||
e ordinate per ubicazione.
|
||||
- `vXTracciaProdotti`:
|
||||
arricchisce il pallet con lotto, codice articolo e descrizione.
|
||||
- `sp_xMagGestioneMagazziniPallet`:
|
||||
esegue il movimento fisico del pallet nel magazzino.
|
||||
- `sp_xExePackingListPallet`:
|
||||
fa il toggle di prenotazione delle celle coinvolte in una picking list.
|
||||
- `sp_xExePackingListPalletPrenota`:
|
||||
forza la prenotazione a `IDStato = 1`.
|
||||
- `sp_ControllaPrenotazionePackingListPalletNew`:
|
||||
controlla se, dopo una movimentazione fisica, debba essere riapplicata una
|
||||
prenotazione automatica sulle celle coinvolte.
|
||||
|
||||
## Lettura pratica del sistema
|
||||
|
||||
- Il layout risponde alla domanda:
|
||||
"dove sono i pallet e come sono distribuiti nello scaffale?"
|
||||
- La picking list risponde alla domanda:
|
||||
"quali pallet fanno parte di un documento e quali celle sono prenotate?"
|
||||
- La movimentazione pallet risponde alla domanda:
|
||||
"cosa succede nel tracciato quando un pallet viene caricato, spostato o
|
||||
scaricato?"
|
||||
- Le viste vengono rilette dopo l'operazione per riportare la UI in uno stato
|
||||
coerente con il database.
|
||||
44
docs/review/README.md
Normal file
44
docs/review/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Documentazione review Warehouse / FlyWMS bridge
|
||||
|
||||
Questa cartella contiene la documentazione tecnica destinata alla review del codice Python e SQL.
|
||||
|
||||
## Obiettivi
|
||||
|
||||
- Descrivere il processo logico implementato da ogni modulo.
|
||||
- Documentare firme, parametri, ritorni e responsabilita' di funzioni e classi.
|
||||
- Documentare SQL, viste, stored procedure, tabelle coinvolte ed effetti collaterali.
|
||||
- Aggiungere commenti inline nel codice solo dove il comportamento non e' auto-evidente.
|
||||
|
||||
## Criterio di documentazione
|
||||
|
||||
La documentazione e' divisa in tre livelli.
|
||||
|
||||
1. Processo logico: flussi operativi, eventi UI, query, effetti sul database.
|
||||
2. API interna: classi, funzioni, parametri, valori di ritorno, errori, dipendenze.
|
||||
3. Dettaglio implementativo: strutture dati, cicli, dedupliche, transazioni, side effect.
|
||||
|
||||
## Ambito escluso
|
||||
|
||||
Questa review non considera:
|
||||
|
||||
- `__pycache__`
|
||||
- log applicativi
|
||||
- zip di distribuzione
|
||||
- cartelle `_package_*`
|
||||
- cartella `trash`
|
||||
- build HTML generata in `docs/_build`
|
||||
|
||||
## Primo lotto documentato
|
||||
|
||||
- [Modulo storico picking list](module_storico_pickinglist.md)
|
||||
- [SQL storico picking list](sql_storico_pickinglist.md)
|
||||
- [Modulo gestione picking list](module_gestione_pickinglist.md)
|
||||
- [Modulo prenota/sprenota SQL](module_prenota_sprenota_sql.md)
|
||||
- [SQL prenotazione picking list](sql_pickinglist_reservation.md)
|
||||
|
||||
## Prossimi lotti consigliati
|
||||
|
||||
1. `gestione_scarico.py`
|
||||
2. `barcode_service.py` e `barcode_repository.py`
|
||||
3. `main.py`, `login_window.py`, `db_config.py`
|
||||
4. Moduli di visualizzazione: `gestione_layout.py`, `reset_corsie.py`, `search_pallets.py`, `view_celle_multi_udc.py`
|
||||
68
docs/review/barcode_error_handling.md
Normal file
68
docs/review/barcode_error_handling.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# Barcode: logging errori e transazioni
|
||||
|
||||
## Problema rilevato
|
||||
|
||||
Durante uno scarico picking list dal lettore barcode, l'operazione DB e' arrivata a buon fine ma il client ha mostrato un'eccezione. I file standard output/error erano vuoti.
|
||||
|
||||
Con `pythonw` non e' sufficiente affidarsi a stdout/stderr: eccezioni Tk, future asincrone o callback possono non arrivare al wrapper principale.
|
||||
|
||||
## Strategia adottata
|
||||
|
||||
Il client barcode ora registra errori in modo esplicito su `warehouse_fatal.log` e su `barcode_wms_launch.log`.
|
||||
|
||||
Canali coperti:
|
||||
|
||||
- `sys.excepthook`
|
||||
- `threading.excepthook`
|
||||
- `Tk.report_callback_exception`
|
||||
- exception handler del loop `asyncio`
|
||||
- eccezioni delle operazioni asincrone barcode
|
||||
- errori del repository durante movimento DB
|
||||
- errori post-movimento durante ricostruzione stato UI
|
||||
|
||||
## Transazione movimento DB
|
||||
|
||||
Il movimento barcode passa da `BarcodeRepository.execute_legacy_move`.
|
||||
|
||||
La batch SQL usa:
|
||||
|
||||
```sql
|
||||
SET XACT_ABORT ON;
|
||||
```
|
||||
|
||||
ed e' eseguita con:
|
||||
|
||||
```python
|
||||
query_json(..., commit=True)
|
||||
```
|
||||
|
||||
Questo significa:
|
||||
|
||||
- successo: commit;
|
||||
- eccezione SQL/Python: rollback automatico della transazione SQLAlchemy;
|
||||
- il valore `@RC` restituito dalla stored legacy non viene interpretato come errore.
|
||||
|
||||
Nota importante: in `sp_xMagGestioneMagazziniPallet`, quando il movimento va a buon fine, `@RC` viene valorizzato con `@@IDENTITY`, cioe' con l'identificativo del movimento inserito. Quindi un valore diverso da zero e' compatibile con un movimento riuscito e non deve causare rollback.
|
||||
|
||||
## Distinzione tra movimento e refresh UI
|
||||
|
||||
Dopo un movimento riuscito, il service ricostruisce il messaggio UI interrogando picking list e tracciabilita'.
|
||||
|
||||
Se questa fase post-movimento fallisce:
|
||||
|
||||
- il movimento resta valido;
|
||||
- l'errore viene loggato;
|
||||
- l'utente vede `Movimento eseguito. Dettagli non aggiornati.`;
|
||||
- non viene mostrato il messaggio "transazione non completata".
|
||||
|
||||
Se invece fallisce la transazione vera:
|
||||
|
||||
- l'utente vede `Transazione non completata, ripeti l'operazione.`;
|
||||
- il dettaglio tecnico viene scritto nel log.
|
||||
|
||||
## File principali
|
||||
|
||||
- `runtime_support.py`
|
||||
- `barcode_client.py`
|
||||
- `barcode_repository.py`
|
||||
- `barcode_service.py`
|
||||
119
docs/review/documentation_plan.md
Normal file
119
docs/review/documentation_plan.md
Normal file
@@ -0,0 +1,119 @@
|
||||
# Piano operativo documentazione review
|
||||
|
||||
## Strategia
|
||||
|
||||
La documentazione viene prodotta per lotti piccoli e verificabili. Ogni lotto deve contenere:
|
||||
|
||||
- descrizione del processo logico;
|
||||
- tabella firme funzioni/classi;
|
||||
- documentazione SQL collegata;
|
||||
- eventuali commenti inline mirati;
|
||||
- compilazione Python dei moduli modificati.
|
||||
|
||||
## Lotto 1 - Storico picking list
|
||||
|
||||
Stato: completato.
|
||||
|
||||
File documentati:
|
||||
|
||||
- `storico_pickinglist.py`
|
||||
- `apply_python_pickinglist_history_views.sql`
|
||||
- `apply_online_history_forms_patch.sql`
|
||||
- query runtime `SQL_STORICO_PL`
|
||||
- query runtime `SQL_STORICO_PL_DETAILS`
|
||||
- movimento collegato `move_pallet_async`
|
||||
|
||||
Motivo priorita:
|
||||
|
||||
- contiene una nuova funzione con effetti sul database;
|
||||
- gestisce casi critici `Chiusa ERP con residui`;
|
||||
- usa convenzioni operative `1000 / Non scaff.` e `9999 / 7G.1.1`.
|
||||
|
||||
## Lotto 2 - Gestione picking list
|
||||
|
||||
Stato: completato.
|
||||
|
||||
File target:
|
||||
|
||||
- `gestione_pickinglist.py`
|
||||
- `prenota_sprenota_sql.py`
|
||||
- `apply_python_parallel_pickinglist_patch.sql`
|
||||
- `rollback_python_parallel_pickinglist_patch.sql`
|
||||
|
||||
Aspetti da documentare:
|
||||
|
||||
- prenotazione/sprenotazione Python-only;
|
||||
- differenza tra vista residua e vista storica;
|
||||
- aggiornamento griglia alta/bassa;
|
||||
- stato `IDStato`;
|
||||
- separazione da C# legacy;
|
||||
- limiti concorrenza.
|
||||
|
||||
## Lotto 3 - Movimento UDC e scarico
|
||||
|
||||
File target:
|
||||
|
||||
- `gestione_scarico.py`
|
||||
- `storico_udc.py`
|
||||
|
||||
Aspetti da documentare:
|
||||
|
||||
- batch `SQL_SCARICA_UDC`;
|
||||
- movimento `P` e `V`;
|
||||
- audit utenti/date;
|
||||
- cella source e target;
|
||||
- fallback SPED in storico UDC.
|
||||
|
||||
## Lotto 4 - Barcode
|
||||
|
||||
File target:
|
||||
|
||||
- `barcode_client.py`
|
||||
- `barcode_service.py`
|
||||
- `barcode_repository.py`
|
||||
|
||||
Aspetti da documentare:
|
||||
|
||||
- stati operativi del barcode;
|
||||
- F1/F2 e priorita picking list;
|
||||
- gestione `9000000`;
|
||||
- mappatura 1:1 con comportamento C#;
|
||||
- stabilita di connessione DB.
|
||||
|
||||
## Lotto 5 - Avvio, autenticazione e configurazione
|
||||
|
||||
File target:
|
||||
|
||||
- `main.py`
|
||||
- `login_window.py`
|
||||
- `db_config.py`
|
||||
- `runtime_support.py`
|
||||
- `user_session.py`
|
||||
|
||||
Aspetti da documentare:
|
||||
|
||||
- single instance;
|
||||
- login operatore;
|
||||
- creazione configurazione DB;
|
||||
- gestione errori in `pythonw`;
|
||||
- shutdown ordinato.
|
||||
|
||||
## Lotto 6 - Visualizzazioni operative
|
||||
|
||||
File target:
|
||||
|
||||
- `gestione_layout.py`
|
||||
- `reset_corsie.py`
|
||||
- `search_pallets.py`
|
||||
- `view_celle_multi_udc.py`
|
||||
- `ui_tables.py`
|
||||
- `ui_theme.py`
|
||||
|
||||
Aspetti da documentare:
|
||||
|
||||
- griglie e layout;
|
||||
- query diagnostiche;
|
||||
- overlay async;
|
||||
- colori semantici;
|
||||
- export XLSX;
|
||||
- bonifica UDC fantasma.
|
||||
154
docs/review/module_gestione_pickinglist.md
Normal file
154
docs/review/module_gestione_pickinglist.md
Normal file
@@ -0,0 +1,154 @@
|
||||
# Modulo `gestione_pickinglist.py`
|
||||
|
||||
## Scopo
|
||||
|
||||
Il modulo implementa la finestra operativa "Gestione Picking List". La finestra serve al backoffice/magazzino per:
|
||||
|
||||
- visualizzare le picking list ancora lavorabili;
|
||||
- selezionare una sola lista alla volta;
|
||||
- visualizzare le UDC residue della lista selezionata;
|
||||
- prenotare una lista per darle priorita' alta sul barcode;
|
||||
- s-prenotare la lista correntemente prenotata;
|
||||
- mantenere UI reattiva tramite query asincrone, overlay e spinner.
|
||||
|
||||
La finestra lavora sulla vista residuale `dbo.py_ViewPackingListRestante`, quindi mostra cio' che resta da scaricare, non necessariamente il documento ERP completo. Il documento completo e' invece esposto dalla form "Storico Picking List".
|
||||
|
||||
## Processo logico
|
||||
|
||||
### Apertura finestra
|
||||
|
||||
1. `open_pickinglist_window` crea o riporta in primo piano una singola finestra.
|
||||
2. La finestra viene inizialmente nascosta con `withdraw` e alpha `0.0`.
|
||||
3. Viene creato `GestionePickingListFrame`.
|
||||
4. Dopo la stabilizzazione layout, `_first_show` avvia il primo caricamento.
|
||||
5. La finestra viene mostrata solo quando il layout e' pronto, riducendo flicker.
|
||||
|
||||
### Caricamento lista alta
|
||||
|
||||
1. `reload_from_db` esegue `SQL_PL`.
|
||||
2. `SQL_PL` legge da `dbo.py_ViewPackingListRestante`.
|
||||
3. Il risultato viene normalizzato con `_rows_to_dicts`.
|
||||
4. `_refresh_mid_rows` ricrea la tabella alta.
|
||||
5. Ogni riga e' rappresentata da un `PLRow`, che incapsula dizionario dati e checkbox.
|
||||
|
||||
### Selezione lista
|
||||
|
||||
1. Il click sul checkbox chiama `on_row_checked`.
|
||||
2. La selezione e' esclusiva: eventuali altre righe selezionate vengono deselezionate.
|
||||
3. Il documento selezionato viene salvato in `detail_doc`.
|
||||
4. Viene eseguita `SQL_PL_DETAILS`.
|
||||
5. Il dettaglio viene messo in cache in `_detail_cache`.
|
||||
6. `_refresh_details_incremental` ordina e renderizza il dettaglio con `tksheet`.
|
||||
|
||||
### Ricarica
|
||||
|
||||
`reload_from_db` preserva il documento selezionato quando possibile. Questo e' importante per il caso operativo in cui il barcode sta scaricando UDC mentre l'operatore aggiorna la finestra.
|
||||
|
||||
Flusso:
|
||||
|
||||
1. `_selected_documento_for_reload` determina il documento da mantenere.
|
||||
2. La griglia alta viene ricaricata.
|
||||
3. `_reselect_documento_after_reload` riseleziona la stessa lista se ancora presente.
|
||||
4. Il dettaglio viene ricaricato dalla vista residuale.
|
||||
|
||||
### Prenotazione
|
||||
|
||||
1. `on_prenota` verifica il permesso `pickinglist.prenota`.
|
||||
2. Richiede una riga selezionata.
|
||||
3. Se `IDStato == 1`, l'operazione e' no-op.
|
||||
4. Verifica sessione operatore valida.
|
||||
5. Chiama `sp_xExePackingListPallet_async(..., Azione="P")`.
|
||||
6. Se `rc == 0`, logga audit e ricarica la griglia mantenendo il documento.
|
||||
|
||||
### S-prenotazione
|
||||
|
||||
1. `on_sprenota` verifica il permesso `pickinglist.sprenota`.
|
||||
2. Richiede una riga selezionata.
|
||||
3. Se `IDStato == 0`, l'operazione e' no-op.
|
||||
4. Chiama `sp_xExePackingListPallet_async(..., Azione="S")`.
|
||||
5. Se `rc == 0`, logga audit e ricarica.
|
||||
|
||||
## Semantica operativa
|
||||
|
||||
La UI non implementa toggle implicito. I pulsanti hanno semantica esplicita:
|
||||
|
||||
| Pulsante | Effetto |
|
||||
| --- | --- |
|
||||
| `Prenota` | porta la lista selezionata a priorita' alta se non gia' prenotata |
|
||||
| `S-prenota` | libera la lista selezionata se e' la lista attiva |
|
||||
|
||||
Premere piu' volte `Prenota` sulla stessa lista gia' prenotata non la libera. Premere piu' volte `S-prenota` su lista non prenotata non la prenota.
|
||||
|
||||
## Strutture dati principali
|
||||
|
||||
| Nome | Tipo | Ruolo |
|
||||
| --- | --- | --- |
|
||||
| `rows_models` | `list[PLRow]` | modelli riga della griglia alta |
|
||||
| `_detail_cache` | `dict[Any, list]` | cache righe dettaglio per documento |
|
||||
| `detail_doc` | `Any` | documento correntemente selezionato |
|
||||
| `_detail_sort_key` | `str | None` | colonna dettaglio ordinata |
|
||||
| `_detail_sort_reverse` | `bool` | verso ordinamento dettaglio |
|
||||
| `pl_table` | `ScrollTable` | tabella custom griglia alta |
|
||||
| `detail_sheet` | `tksheet.Sheet` | griglia dettaglio ad alto volume |
|
||||
| `spinner` | `ToolbarSpinner` | feedback leggero toolbar |
|
||||
| `busy` | `InlineBusyOverlay` | overlay query/operazioni lente |
|
||||
|
||||
## Funzioni e classi principali
|
||||
|
||||
| Oggetto | Firma | Ruolo |
|
||||
| --- | --- | --- |
|
||||
| `_rows_to_dicts` | `_rows_to_dicts(res: Dict[str, Any]) -> List[Dict[str, Any]]` | normalizza payload DB |
|
||||
| `_s` | `_s(v) -> str` | converte `None` in stringa vuota |
|
||||
| `_first` | `_first(d: Dict[str, Any], keys: List[str], default: str = "")` | estrae il primo campo valorizzato |
|
||||
| `ColSpec` | `dataclass(title, key, width, anchor)` | descrive una colonna tabellare |
|
||||
| `ToolbarSpinner` | classe | animazione leggera toolbar |
|
||||
| `ScrollTable` | classe | tabella custom per griglia alta |
|
||||
| `PLRow` | classe | modello riga PL + checkbox |
|
||||
| `GestionePickingListFrame` | classe | frame principale |
|
||||
| `_build_detail_sheet` | `_build_detail_sheet(self)` | crea tksheet dettaglio |
|
||||
| `_detail_rows_to_sheet_data` | `_detail_rows_to_sheet_data(self, rows)` | converte righe DB in righe tksheet |
|
||||
| `_load_detail_sheet_data` | `_load_detail_sheet_data(self, data)` | applica headers, dati e zebra |
|
||||
| `_refresh_mid_rows` | `_refresh_mid_rows(self, rows)` | ricrea griglia alta |
|
||||
| `_get_selected_model` | `_get_selected_model(self) -> Optional[PLRow]` | ritorna riga selezionata |
|
||||
| `on_row_checked` | `on_row_checked(self, model: PLRow, is_checked: bool)` | carica dettaglio della lista |
|
||||
| `reload_from_db` | `reload_from_db(self, first=False, reselect_documento=None)` | aggiorna griglia alta |
|
||||
| `_refresh_details` | `_refresh_details(self)` | ridisegna dettaglio da cache |
|
||||
| `_refresh_details_incremental` | `_refresh_details_incremental(self, batch_size=25)` | render dettaglio con overlay |
|
||||
| `on_prenota` | `on_prenota(self)` | prenota lista selezionata |
|
||||
| `on_sprenota` | `on_sprenota(self)` | s-prenota lista selezionata |
|
||||
| `create_frame` | `create_frame(parent, *, db_client=None, conn_str=None, session=None)` | factory frame |
|
||||
| `open_pickinglist_window` | `open_pickinglist_window(parent, db_client, session=None) -> tk.Misc` | entry point finestra |
|
||||
|
||||
## Query runtime
|
||||
|
||||
### `SQL_PL`
|
||||
|
||||
Aggrega `dbo.py_ViewPackingListRestante` per documento. Conta UDC con:
|
||||
|
||||
```sql
|
||||
COUNT(DISTINCT NULLIF(LTRIM(RTRIM(CAST(Pallet AS varchar(32)))), '')) AS Pallet
|
||||
```
|
||||
|
||||
Questo evita il doppio conteggio di UDC multi-lotto.
|
||||
|
||||
### `SQL_PL_DETAILS`
|
||||
|
||||
Ritorna tutte le righe residuali della lista selezionata, ordinate per `Ordinamento`.
|
||||
|
||||
## Effetti sul database
|
||||
|
||||
Il modulo UI non aggiorna direttamente tabelle. Tutte le modifiche passano da `sp_xExePackingListPallet_async`, che esegue `dbo.py_sp_xExePackingListPallet`.
|
||||
|
||||
Effetti indiretti:
|
||||
|
||||
- aggiorna `dbo.PyPickingListReservation`;
|
||||
- aggiorna `dbo.Celle.IDStato`;
|
||||
- scrive audit applicativo con `log_user_action`;
|
||||
- la stored puo' scrivere log legacy tramite `sp_LogPackingList`.
|
||||
|
||||
## Rischi e note review
|
||||
|
||||
- La vista residuale cambia mentre il barcode scarica UDC: per questo `Ricarica` conserva la selezione e ricarica il dettaglio.
|
||||
- La tabella alta e il dettaglio possono non avere lo stesso numero di righe dello storico, perche' qui si vedono solo residui.
|
||||
- La convivenza C#/Python dipende dalla presenza degli oggetti `py_*`.
|
||||
- La selezione e' esclusiva lato UI, ma il secondo livello F2 barcode dipende dalla logica barcode/stato DB, non da una seconda prenotazione backoffice.
|
||||
97
docs/review/module_prenota_sprenota_sql.md
Normal file
97
docs/review/module_prenota_sprenota_sql.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Modulo `prenota_sprenota_sql.py`
|
||||
|
||||
## Scopo
|
||||
|
||||
Il modulo contiene il port asincrono della stored procedure di prenotazione picking list. E' il ponte tra la UI Python e la stored SQL Python-only `dbo.py_sp_xExePackingListPallet`.
|
||||
|
||||
La funzione pubblica principale e':
|
||||
|
||||
```python
|
||||
async def sp_xExePackingListPallet_async(db, IDOperatore: int, Documento: str, Azione: str = "P") -> SPResult
|
||||
```
|
||||
|
||||
## Motivazione
|
||||
|
||||
Durante la fase di test sul campo devono convivere:
|
||||
|
||||
- applicazione C# legacy;
|
||||
- applicazione Python.
|
||||
|
||||
Per evitare collisioni, il Python non chiama `dbo.sp_xExePackingListPallet` legacy ma `dbo.py_sp_xExePackingListPallet`.
|
||||
|
||||
## Semantica parametro `Azione`
|
||||
|
||||
| Azione | Significato |
|
||||
| --- | --- |
|
||||
| `P` | prenota il documento |
|
||||
| `S` | s-prenota il documento |
|
||||
|
||||
Ogni altra azione ritorna:
|
||||
|
||||
```python
|
||||
SPResult(rc=-10, message="Azione non valida: ...")
|
||||
```
|
||||
|
||||
## Classe `SPResult`
|
||||
|
||||
Firma:
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class SPResult:
|
||||
rc: int = 0
|
||||
message: Optional[str] = ""
|
||||
id_result: Optional[int] = None
|
||||
```
|
||||
|
||||
Campi:
|
||||
|
||||
| Campo | Ruolo |
|
||||
| --- | --- |
|
||||
| `rc` | codice ritorno della stored |
|
||||
| `message` | messaggio errore o vuoto |
|
||||
| `id_result` | predisposizione per ID risultato, non usato oggi |
|
||||
|
||||
## Funzioni helper
|
||||
|
||||
| Funzione | Firma | Ruolo |
|
||||
| --- | --- | --- |
|
||||
| `_query_one_value` | `_query_one_value(db, sql: str, params: Dict[str, Any]) -> Optional[Any]` | helper generico scalar, oggi non centrale nel flusso |
|
||||
| `_query_all` | `_query_all(db, sql: str, params: Dict[str, Any]) -> List[Dict[str, Any]]` | normalizza query multi-riga |
|
||||
| `_execute` | `_execute(db, sql: str, params: Dict[str, Any]) -> int` | helper generico DML |
|
||||
| `sp_xExePackingListPallet_async` | vedi sopra | esegue stored Python-only |
|
||||
|
||||
## Processo logico `sp_xExePackingListPallet_async`
|
||||
|
||||
1. Normalizza `Azione` a maiuscolo.
|
||||
2. Valida `Azione in ("P", "S")`.
|
||||
3. Costruisce una batch SQL con output parameter `@RC`.
|
||||
4. Esegue:
|
||||
|
||||
```sql
|
||||
EXEC dbo.py_sp_xExePackingListPallet
|
||||
@IDOperatore = :IDOperatore,
|
||||
@Documento = :Documento,
|
||||
@Azione = :Azione,
|
||||
@RC = @RC OUTPUT;
|
||||
```
|
||||
|
||||
5. Legge il valore `RC`.
|
||||
6. Ritorna `SPResult(rc=rc, message="", id_result=None)`.
|
||||
7. In caso di eccezione ritorna `SPResult(rc=-1, message=str(exc), id_result=None)`.
|
||||
|
||||
## Commit
|
||||
|
||||
La chiamata usa:
|
||||
|
||||
```python
|
||||
commit=True
|
||||
```
|
||||
|
||||
Motivo: la stored modifica `PyPickingListReservation` e `Celle.IDStato`.
|
||||
|
||||
## Rischi e note review
|
||||
|
||||
- Gli helper `_query_one_value`, `_query_all`, `_execute` sono generici e non tutti sono essenziali al percorso attuale.
|
||||
- La funzione cattura le eccezioni e ritorna `SPResult(rc=-1)`, quindi la UI deve controllare sempre `rc`.
|
||||
- La transazione reale dipende dal comportamento di `query_json(..., commit=True)` nel client DB.
|
||||
150
docs/review/module_storico_pickinglist.md
Normal file
150
docs/review/module_storico_pickinglist.md
Normal file
@@ -0,0 +1,150 @@
|
||||
# Modulo `storico_pickinglist.py`
|
||||
|
||||
## Scopo
|
||||
|
||||
Il modulo implementa la finestra "Storico Picking List". La finestra permette di:
|
||||
|
||||
- cercare picking list storiche per numero documento;
|
||||
- visualizzare lo stato operativo sintetico di ciascuna lista;
|
||||
- visualizzare il dettaglio UDC/lotto/articolo della lista selezionata;
|
||||
- evidenziare liste chiuse, liste attive e casi anomali;
|
||||
- versare in blocco in `7G.1.1` le UDC residue di una lista classificata come `Chiusa ERP con residui`.
|
||||
|
||||
Il modulo legge da viste SQL dedicate al ramo Python. Non usa le viste legacy C# per evitare collisioni durante il periodo in cui i due programmi convivono sullo stesso database.
|
||||
|
||||
## Dipendenze principali
|
||||
|
||||
- `customtkinter` e `tkinter.ttk`: UI e griglie.
|
||||
- `AsyncRunner`: esecuzione asincrona delle query senza bloccare la GUI.
|
||||
- `InlineBusyOverlay`: indicatore visivo durante query e movimenti.
|
||||
- `move_pallet_async`: funzione centrale per registrare un movimento UDC verso una cella.
|
||||
- `ui_tables`: stile comune delle griglie.
|
||||
- `version_info`: versione visibile nel titolo finestra.
|
||||
- `window_placement`: posizionamento della finestra rispetto al launcher.
|
||||
|
||||
## Processo logico
|
||||
|
||||
### Apertura finestra
|
||||
|
||||
1. `open_storico_pickinglist_window(parent, db_client, session)` crea `StoricoPickingListWindow`.
|
||||
2. La finestra viene posizionata sotto il launcher con `place_window_fullsize_below_parent_later`.
|
||||
3. Dopo 300 ms viene chiamato `_load_master`.
|
||||
|
||||
### Caricamento griglia alta
|
||||
|
||||
1. `_load_master` legge il filtro `Documento`.
|
||||
2. Viene eseguita `SQL_STORICO_PL`.
|
||||
3. `_rows_to_dicts` normalizza il payload del DB.
|
||||
4. `_fill_master` svuota griglia alta e dettaglio.
|
||||
5. Per ogni documento viene calcolato il tag visuale:
|
||||
- `warning` se lista aperta con UDC gia' spedite;
|
||||
- `done` se lista chiusa o esaurita;
|
||||
- `active` se lista prenotata;
|
||||
- zebra tag per alternanza righe.
|
||||
6. La riga viene inserita nella griglia alta.
|
||||
|
||||
### Selezione documento
|
||||
|
||||
1. `_on_master_select` legge la riga selezionata.
|
||||
2. Memorizza:
|
||||
- `_selected_documento`
|
||||
- `_selected_stato_operativo`
|
||||
- `_detail_rows`
|
||||
3. Abilita o disabilita il pulsante "Versa residui in 7G.1.1".
|
||||
4. Esegue `SQL_STORICO_PL_DETAILS`.
|
||||
5. `_fill_detail` carica la griglia bassa.
|
||||
|
||||
### Versamento residui in 7G.1.1
|
||||
|
||||
Il pulsante e' abilitato solo se `_selected_stato_operativo == "Chiusa ERP con residui"`.
|
||||
|
||||
Flusso:
|
||||
|
||||
1. `_ship_selected_residuals` verifica lo stato selezionato.
|
||||
2. Calcola una stima delle UDC residue gia' presenti nel dettaglio UI.
|
||||
3. Mostra una conferma all'operatore.
|
||||
4. Dentro il job asincrono rilegge il dettaglio dal DB, cosi' evita dati UI obsoleti.
|
||||
5. `_residual_pallets_from_rows` deduplica le UDC e scarta quelle gia' in `IDCella = 9999`.
|
||||
6. Per ogni UDC residua chiama `move_pallet_async` con:
|
||||
- `target_idcella = 9999`
|
||||
- `target_barcode_cella = "9000000"`
|
||||
- `utente = login sessione` oppure `warehouse_ui`
|
||||
7. Al termine mostra un riepilogo.
|
||||
8. Ricarica la griglia alta e tenta di ripristinare la selezione del documento.
|
||||
|
||||
## Stati operativi
|
||||
|
||||
La colonna `Stato` della griglia alta deriva da SQL:
|
||||
|
||||
| Stato operativo | Condizione |
|
||||
| --- | --- |
|
||||
| `Chiusa ERP con residui` | `StatoDocumento = 'D'` e almeno una UDC non e' in `9999` |
|
||||
| `Chiusa` | `StatoDocumento = 'D'` e nessuna UDC residua |
|
||||
| `Esaurita` | tutte le UDC risultano spedite |
|
||||
| `In corso` | almeno una UDC e' spedita e almeno una resta da lavorare |
|
||||
| `Da lavorare` | nessuna UDC ancora spedita |
|
||||
|
||||
## Strutture dati interne
|
||||
|
||||
| Nome | Tipo | Ruolo |
|
||||
| --- | --- | --- |
|
||||
| `var_documento` | `tk.StringVar` | filtro documento digitato dall'utente |
|
||||
| `_selected_documento` | `str | None` | documento correntemente selezionato |
|
||||
| `_selected_stato_operativo` | `str` | stato operativo della riga selezionata |
|
||||
| `_detail_rows` | `list[dict[str, Any]]` | ultimo dettaglio normalizzato caricato nella griglia bassa |
|
||||
| `master_tree` | `ttk.Treeview` | griglia alta documenti |
|
||||
| `detail_tree` | `ttk.Treeview` | griglia bassa righe UDC |
|
||||
| `btn_ship_residuals` | `ctk.CTkButton` | azione di versamento massivo residui |
|
||||
|
||||
## Funzioni e classi
|
||||
|
||||
| Oggetto | Firma | Ruolo |
|
||||
| --- | --- | --- |
|
||||
| `_rows_to_dicts` | `_rows_to_dicts(res: dict[str, Any] | None) -> list[dict[str, Any]]` | normalizza payload DB in lista di dizionari |
|
||||
| `_format_date` | `_format_date(value: Any) -> str` | converte date SQL/SAMA in `dd/mm/yyyy` |
|
||||
| `StoricoPickingListWindow.__init__` | `__init__(self, parent: tk.Widget, db_client, session=None)` | costruisce stato, tema, runner async e UI |
|
||||
| `_build_ui` | `_build_ui(self) -> None` | crea toolbar, griglia alta e griglia dettaglio |
|
||||
| `_make_tree` | `_make_tree(self, *, row: int, columns: tuple[str, ...], widths: dict[str, int]) -> ttk.Treeview` | factory griglia con stile comune |
|
||||
| `_load_master` | `_load_master(self) -> None` | lancia query master asincrona |
|
||||
| `_fill_master` | `_fill_master(self, rows: list[dict[str, Any]]) -> None` | popola griglia alta |
|
||||
| `_on_master_select` | `_on_master_select(self, _event=None) -> None` | gestisce selezione documento e carica dettaglio |
|
||||
| `_fill_detail` | `_fill_detail(self, rows: list[dict[str, Any]]) -> None` | popola griglia bassa |
|
||||
| `_update_residual_button` | `_update_residual_button(self) -> None` | abilita azione solo su `Chiusa ERP con residui` |
|
||||
| `_restore_master_selection` | `_restore_master_selection(self, documento: str) -> None` | riseleziona documento dopo reload |
|
||||
| `_residual_pallets_from_rows` | `_residual_pallets_from_rows(self, rows: list[dict[str, Any]]) -> list[str]` | deduplica UDC residue non gia' spedite |
|
||||
| `_operator_login` | `_operator_login(self) -> str` | determina utente per movimenti |
|
||||
| `_ship_selected_residuals` | `_ship_selected_residuals(self) -> None` | esegue versamento massivo verso `7G.1.1` |
|
||||
| `open_storico_pickinglist_window` | `open_storico_pickinglist_window(parent: tk.Misc, db_client, session=None) -> tk.Misc` | entry point chiamato dal launcher |
|
||||
|
||||
## Effetti sul database
|
||||
|
||||
Il modulo e' in sola lettura tranne `_ship_selected_residuals`.
|
||||
|
||||
`_ship_selected_residuals` non esegue SQL diretto di update. Delega ogni UDC a `move_pallet_async`, che:
|
||||
|
||||
- trova l'ultimo movimento `V` positivo della UDC;
|
||||
- aggiorna `ModUtente` e `ModDataOra` della riga sorgente;
|
||||
- inserisce un movimento `P` sulla cella sorgente;
|
||||
- libera `Celle.IDStato` della cella sorgente;
|
||||
- inserisce un movimento `V` sulla cella target `9999`;
|
||||
- esegue `dbo.py_sp_ControllaPrenotazionePackingListPalletNew`.
|
||||
|
||||
## Rischi e note review
|
||||
|
||||
- Il versamento massivo non e' atomico a livello di intera lista: ogni UDC viene movimentata con una chiamata separata. Se una UDC fallisce, quelle precedenti potrebbero essere gia' state registrate.
|
||||
- La rilettura del dettaglio riduce il rischio di dato UI obsoleto, ma non sostituisce un lock transazionale su documento.
|
||||
- Le UDC multi-lotto sono deduplicate per `Pallet`, per evitare doppio movimento fisico.
|
||||
- Le UDC gia' in `9999` vengono saltate.
|
||||
- Le UDC non scaffalate risultano `IDCella = 1000`; vengono considerate residue e quindi movimentate verso `9999`.
|
||||
|
||||
## Test consigliati
|
||||
|
||||
1. Selezionare una lista `Da lavorare`: il pulsante deve restare disabilitato.
|
||||
2. Selezionare una lista `Chiusa`: il pulsante deve restare disabilitato.
|
||||
3. Selezionare una lista `Chiusa ERP con residui`: il pulsante deve abilitarsi.
|
||||
4. Confermare il versamento su una lista con UDC non scaffalate.
|
||||
5. Verificare in `Storico movimenti UDC` che ogni UDC abbia:
|
||||
- ultimo passaggio sorgente;
|
||||
- movimento `P` sulla sorgente;
|
||||
- movimento `V` su `9999 / 7G.1.1`.
|
||||
6. Ricaricare lo storico picking list: la lista non deve piu' risultare con residui se tutte le UDC sono in `9999`.
|
||||
153
docs/review/sql_pickinglist_reservation.md
Normal file
153
docs/review/sql_pickinglist_reservation.md
Normal file
@@ -0,0 +1,153 @@
|
||||
# SQL prenotazione picking list Python-only
|
||||
|
||||
## Script
|
||||
|
||||
- `apply_python_parallel_pickinglist_patch.sql`
|
||||
- `rollback_python_parallel_pickinglist_patch.sql`
|
||||
|
||||
## Obiettivo
|
||||
|
||||
Permettere a Python e C# di lavorare sullo stesso database senza condividere le stesse stored procedure operative.
|
||||
|
||||
Il C# continua a usare gli oggetti legacy:
|
||||
|
||||
- `dbo.XMag_ViewPackingList`
|
||||
- `dbo.ViewPackingListRestante`
|
||||
- `dbo.sp_xExePackingListPallet`
|
||||
- `dbo.sp_xExePackingListPalletPrenota`
|
||||
- `dbo.sp_ControllaPrenotazionePackingListPalletNew`
|
||||
|
||||
Il Python usa oggetti separati:
|
||||
|
||||
- `dbo.py_XMag_ViewPackingList`
|
||||
- `dbo.py_ViewPackingListRestante`
|
||||
- `dbo.py_sp_xExePackingListPallet`
|
||||
- `dbo.py_sp_xExePackingListPalletPrenota`
|
||||
- `dbo.py_sp_ControllaPrenotazionePackingListPalletNew`
|
||||
- `dbo.PyPickingListReservation`
|
||||
|
||||
## Tabella `dbo.PyPickingListReservation`
|
||||
|
||||
### Scopo
|
||||
|
||||
Contiene la singola picking list prenotata dal programma Python.
|
||||
|
||||
### Schema
|
||||
|
||||
| Colonna | Tipo | Ruolo |
|
||||
| --- | --- | --- |
|
||||
| `ID` | `tinyint` | sempre `1`, enforced da check constraint |
|
||||
| `Documento` | `varchar(8)` | documento prenotato |
|
||||
| `IDOperatore` | `int` | operatore che ha fatto l'ultima azione |
|
||||
| `ModUtente` | `varchar(50)` | login operatore |
|
||||
| `ModDataOra` | `datetime` | timestamp modifica |
|
||||
|
||||
### Vincoli
|
||||
|
||||
- Primary key su `ID`.
|
||||
- Check `ID = 1`.
|
||||
|
||||
Questa scelta implementa un singleton DB: il Python puo' avere una sola lista prenotata dal backoffice.
|
||||
|
||||
## Vista `dbo.py_XMag_ViewPackingList`
|
||||
|
||||
### Scopo
|
||||
|
||||
Replica la vista legacy `dbo.XMag_ViewPackingList` ma calcola `IDStato` usando `PyPickingListReservation`, non `Celle.IDStato` legacy.
|
||||
|
||||
### Logica `IDStato`
|
||||
|
||||
```sql
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(legacy.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
```
|
||||
|
||||
## Vista `dbo.py_ViewPackingListRestante`
|
||||
|
||||
### Scopo
|
||||
|
||||
Espone solo le UDC non ancora spedite:
|
||||
|
||||
```sql
|
||||
WHERE Cella <> 9999
|
||||
```
|
||||
|
||||
La UI "Gestione Picking List" usa questa vista sia per la griglia alta sia per il dettaglio.
|
||||
|
||||
## Stored `dbo.py_sp_xExePackingListPallet`
|
||||
|
||||
### Parametri
|
||||
|
||||
| Parametro | Tipo | Ruolo |
|
||||
| --- | --- | --- |
|
||||
| `@IDOperatore` | `int` | operatore corrente |
|
||||
| `@Documento` | `varchar(8)` | documento da prenotare/sprenotare |
|
||||
| `@Azione` | `char(1)` | `P` prenota, `S` s-prenota |
|
||||
| `@RC` | `int OUTPUT` | codice ritorno |
|
||||
|
||||
### Validazioni
|
||||
|
||||
- `@Azione` deve essere `P` o `S`, altrimenti `@RC = -10`.
|
||||
- Il documento deve esistere in `py_XMag_ViewPackingList`, altrimenti `@RC = -20`.
|
||||
- Se manca la riga singleton in `PyPickingListReservation`, viene creata.
|
||||
|
||||
### Prenotazione `P`
|
||||
|
||||
1. Se il documento e' gia' attivo, ritorna senza modifiche.
|
||||
2. Azzera `IDStato` su tutte le celle con stato diverso da zero.
|
||||
3. Mette `IDStato = 1` sulle celle del documento target.
|
||||
4. Aggiorna `PyPickingListReservation` con documento, operatore e timestamp.
|
||||
5. Scrive log tramite `sp_LogPackingList`.
|
||||
|
||||
### S-prenotazione `S`
|
||||
|
||||
1. Se il documento attivo non e' quello richiesto, ritorna senza modifiche.
|
||||
2. Azzera `IDStato` sulle celle target.
|
||||
3. Pulisce `PyPickingListReservation.Documento`.
|
||||
|
||||
## Stored `dbo.py_sp_xExePackingListPalletPrenota`
|
||||
|
||||
### Scopo
|
||||
|
||||
Mette `IDStato = 1` sulle celle ancora residue del documento. Viene usata dal controllo automatico prenotazione.
|
||||
|
||||
## Stored `dbo.py_sp_ControllaPrenotazionePackingListPalletNew`
|
||||
|
||||
### Scopo
|
||||
|
||||
Mantiene coerente la prenotazione mentre la picking list viene consumata dal barcode.
|
||||
|
||||
### Logica
|
||||
|
||||
1. Legge documento attivo da `PyPickingListReservation`.
|
||||
2. Se non c'e' documento attivo, termina.
|
||||
3. Se non esistono piu' righe residue in `py_ViewPackingListRestante`:
|
||||
- azzera `Celle.IDStato`;
|
||||
- svuota `PyPickingListReservation.Documento`;
|
||||
- termina.
|
||||
4. Se esistono ancora residui:
|
||||
- azzera tutti gli `IDStato`;
|
||||
- richiama `py_sp_xExePackingListPalletPrenota` per prenotare le celle residue.
|
||||
|
||||
## Rollback
|
||||
|
||||
`rollback_python_parallel_pickinglist_patch.sql` elimina:
|
||||
|
||||
- `py_sp_ControllaPrenotazionePackingListPalletNew`
|
||||
- `py_sp_xExePackingListPalletPrenota`
|
||||
- `py_sp_xExePackingListPallet`
|
||||
- `py_ViewPackingListRestante`
|
||||
- `py_XMag_ViewPackingList`
|
||||
- `PyPickingListReservation`
|
||||
|
||||
Non tocca gli oggetti legacy C#.
|
||||
|
||||
## Note review
|
||||
|
||||
- La stored Python usa una prenotazione singleton, quindi non gestisce due liste prenotate backoffice.
|
||||
- L'azzeramento globale di `Celle.IDStato` e' coerente con la semantica attuale, ma in futuro dovra' essere rivalutato se piu' operatori o magazzini lavorano in parallelo.
|
||||
- Le UDC non scaffalate condividono il fallback dati del modello legacy; questo e' noto e andra' riprogettato nel nuovo schema FlyWMS.
|
||||
236
docs/review/sql_storico_pickinglist.md
Normal file
236
docs/review/sql_storico_pickinglist.md
Normal file
@@ -0,0 +1,236 @@
|
||||
# SQL storico picking list
|
||||
|
||||
## Oggetti SQL coinvolti
|
||||
|
||||
La form "Storico Picking List" usa un ramo SQL Python-only:
|
||||
|
||||
- `dbo.py_vPreparaPackingListSAMA1`
|
||||
- `dbo.py_vPreparaPackingList`
|
||||
- `dbo.py_XMag_ViewPackingListStorico`
|
||||
- `dbo.PyPickingListReservation`
|
||||
|
||||
Gli script principali sono:
|
||||
|
||||
- `apply_python_pickinglist_history_views.sql`
|
||||
- `apply_online_history_forms_patch.sql`
|
||||
- `rollback_python_pickinglist_history_views.sql`
|
||||
- `rollback_online_history_forms_patch.sql`
|
||||
|
||||
## Motivazione del ramo Python-only
|
||||
|
||||
Il progetto deve convivere temporaneamente con l'applicazione C# legacy. Per questo lo storico Python non modifica:
|
||||
|
||||
- `dbo.vPreparaPackingListSAMA1`
|
||||
- `dbo.vPreparaPackingList`
|
||||
- `dbo.XMag_ViewPackingList`
|
||||
- stored procedure legacy C#
|
||||
|
||||
Le viste prefissate `py_` permettono di evolvere il comportamento Python senza cambiare la semantica legacy.
|
||||
|
||||
## Vista `dbo.py_vPreparaPackingListSAMA1`
|
||||
|
||||
### Scopo
|
||||
|
||||
Legge dal database ERP `SAMA1` le informazioni documentali e di riga necessarie a ricostruire la picking list.
|
||||
|
||||
### Tabelle ERP coinvolte
|
||||
|
||||
- `SAMA1.dbo.LOTSER`
|
||||
- `SAMA1.dbo.ARTICO`
|
||||
- `SAMA1.dbo.FATRIG`
|
||||
- `SAMA1.dbo.LOTTIBF`
|
||||
- `SAMA1.dbo.BAMTES`
|
||||
- `SAMA1.dbo.NAZIONI`
|
||||
- `SAMA1.sam.EXTUC`
|
||||
- `SAMA1.dbo.MTRASP`
|
||||
|
||||
### Campi principali
|
||||
|
||||
| Campo | Significato |
|
||||
| --- | --- |
|
||||
| `NUMLOT` | lotto |
|
||||
| `CODICE` | codice articolo |
|
||||
| `DESCR` | descrizione riga/articolo |
|
||||
| `UDC` | prime 6 cifre di `LOTSER.NUMSER` |
|
||||
| `Qta` | somma quantita giacente ERP |
|
||||
| `NUMDOC` | numero documento/picking list |
|
||||
| `DATDOC` | data documento ERP |
|
||||
| `StatoDocumento` | stato ERP, filtrato su `P` o `D` |
|
||||
| `NAZIONE` | trasporto + descrizione nazione |
|
||||
|
||||
### Filtri
|
||||
|
||||
- anno documento >= anno corrente;
|
||||
- stato documento in `P`, `D`;
|
||||
- lotto diverso da `00000000000`.
|
||||
|
||||
## Vista `dbo.py_vPreparaPackingList`
|
||||
|
||||
### Scopo
|
||||
|
||||
E' una vista di pulizia sopra `py_vPreparaPackingListSAMA1`.
|
||||
|
||||
### Filtro
|
||||
|
||||
Esclude righe con `NUMLOT = ''`.
|
||||
|
||||
## Vista `dbo.py_XMag_ViewPackingListStorico`
|
||||
|
||||
### Scopo
|
||||
|
||||
Unisce il contenuto ERP della picking list con la posizione WMS corrente della UDC.
|
||||
|
||||
### Tabelle WMS coinvolte
|
||||
|
||||
- `dbo.XMag_GiacenzaPallet`
|
||||
- `dbo.Celle`
|
||||
- `dbo.Aree`
|
||||
- `dbo.PyPickingListReservation`
|
||||
|
||||
### Join principale
|
||||
|
||||
La vista usa una `RIGHT OUTER JOIN` tra posizione WMS e preparazione ERP:
|
||||
|
||||
```sql
|
||||
RIGHT OUTER JOIN dbo.py_vPreparaPackingList prep
|
||||
ON g.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = prep.UDC
|
||||
```
|
||||
|
||||
Questo garantisce che una UDC presente nella picking list ERP compaia anche se non e' scaffalata nel WMS.
|
||||
|
||||
### Convenzioni celle
|
||||
|
||||
| IDCella | Ubicazione | Significato |
|
||||
| --- | --- | --- |
|
||||
| `9999` | `7G - 1 - 1` | spedizione / UDC scaricata |
|
||||
| `1000` | `Non scaff.` | fallback per UDC non trovata in `XMag_GiacenzaPallet` |
|
||||
|
||||
La vista usa:
|
||||
|
||||
```sql
|
||||
ISNULL(g.IDCella, 1000) AS Cella
|
||||
ISNULL(c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila, 'Non scaff.') AS Ubicazione
|
||||
```
|
||||
|
||||
Quindi le UDC ERP non presenti in giacenza WMS sono rappresentate come non scaffalate.
|
||||
|
||||
## Query Python `SQL_STORICO_PL`
|
||||
|
||||
### Scopo
|
||||
|
||||
Costruisce la griglia alta della form.
|
||||
|
||||
### CTE
|
||||
|
||||
| CTE | Ruolo |
|
||||
| --- | --- |
|
||||
| `base` | normalizza `Pallet` in `PalletKey` |
|
||||
| `pallets` | aggrega righe multi-lotto per singola UDC |
|
||||
| `meta` | calcola metadati documento |
|
||||
| `agg` | calcola totale UDC, UDC spedite e UDC residue |
|
||||
|
||||
### Stato operativo
|
||||
|
||||
La query produce `StatoOperativo` con questa logica:
|
||||
|
||||
```sql
|
||||
CASE
|
||||
WHEN m.StatoDocumento = 'D' AND COALESCE(a.RigheResidue, 0) > 0 THEN 'Chiusa ERP con residui'
|
||||
WHEN m.StatoDocumento = 'D' THEN 'Chiusa'
|
||||
WHEN COALESCE(a.RigheResidue, 0) = 0 THEN 'Esaurita'
|
||||
WHEN COALESCE(a.RigheSpedite, 0) > 0 THEN 'In corso'
|
||||
ELSE 'Da lavorare'
|
||||
END
|
||||
```
|
||||
|
||||
### Deduplica UDC
|
||||
|
||||
La deduplica avviene su `PalletKey`, non sulle righe. Questo evita che una UDC con piu' lotti venga contata come piu' pallet.
|
||||
|
||||
## Query Python `SQL_STORICO_PL_DETAILS`
|
||||
|
||||
### Scopo
|
||||
|
||||
Costruisce la griglia bassa della form.
|
||||
|
||||
### Output
|
||||
|
||||
| Campo | Ruolo |
|
||||
| --- | --- |
|
||||
| `Documento` | numero picking list |
|
||||
| `Pallet` | UDC fisica |
|
||||
| `Lotto` | lotto |
|
||||
| `Articolo` | codice articolo |
|
||||
| `Descrizione` | descrizione articolo/riga |
|
||||
| `Qta` | quantita |
|
||||
| `DataDocumento` | data ERP |
|
||||
| `StatoDocumento` | stato ERP |
|
||||
| `Cella` | cella WMS corrente/fallback |
|
||||
| `Ubicazione` | descrizione cella |
|
||||
| `Ordinamento` | ordine operativo |
|
||||
| `IDStato` | prenotazione Python |
|
||||
|
||||
## Effetti SQL del versamento residui
|
||||
|
||||
La form non contiene direttamente update/insert SQL per il versamento residui. Chiama `move_pallet_async` in `gestione_scarico.py`.
|
||||
|
||||
La batch SQL associata e' `SQL_SCARICA_UDC` e produce:
|
||||
|
||||
1. ricerca dell'ultimo movimento `V` positivo della UDC;
|
||||
2. update audit della riga sorgente;
|
||||
3. insert movimento `P` sulla cella sorgente;
|
||||
4. update `Celle.IDStato = 0` sulla cella sorgente;
|
||||
5. insert movimento `V` sulla cella target;
|
||||
6. esecuzione `dbo.py_sp_ControllaPrenotazionePackingListPalletNew`.
|
||||
|
||||
Per la funzione storico picking list il target e':
|
||||
|
||||
- `target_idcella = 9999`
|
||||
- `target_barcode_cella = '9000000'`
|
||||
|
||||
## Note di consistenza dati
|
||||
|
||||
- Una UDC non scaffalata viene vista come `Cella = 1000`, quindi e' residua.
|
||||
- Una UDC in `9999` non e' residua e viene esclusa dal movimento massivo.
|
||||
- Una UDC multi-lotto puo' comparire piu' volte nel dettaglio ma deve generare un solo movimento fisico.
|
||||
- Lo stato `Chiusa ERP con residui` evidenzia disallineamento tra documento ERP chiuso e WMS non completamente versato in spedizione.
|
||||
|
||||
## Query diagnostiche utili
|
||||
|
||||
Verificare righe documento:
|
||||
|
||||
```sql
|
||||
SELECT *
|
||||
FROM dbo.py_XMag_ViewPackingListStorico
|
||||
WHERE Documento = 155
|
||||
ORDER BY Ordinamento, Pallet;
|
||||
```
|
||||
|
||||
Verificare UDC residue:
|
||||
|
||||
```sql
|
||||
SELECT DISTINCT Pallet, Cella, Ubicazione
|
||||
FROM dbo.py_XMag_ViewPackingListStorico
|
||||
WHERE Documento = 155
|
||||
AND ISNULL(Cella, 0) <> 9999
|
||||
ORDER BY Pallet;
|
||||
```
|
||||
|
||||
Verificare movimenti UDC dopo versamento:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
ID,
|
||||
Tipo,
|
||||
IDRiferimento,
|
||||
Attributo,
|
||||
IDCella,
|
||||
DataMagazzino,
|
||||
InsUtente,
|
||||
InsDataOra,
|
||||
ModUtente,
|
||||
ModDataOra
|
||||
FROM dbo.MagazziniPallet
|
||||
WHERE Attributo = '655560'
|
||||
ORDER BY ID;
|
||||
```
|
||||
59
docs/ricerca_udc_storico_pickinglist.md
Normal file
59
docs/ricerca_udc_storico_pickinglist.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Ricerca UDC nello storico picking list
|
||||
|
||||
Modifica del 22 ottobre 2026. Storico Picking List versione 1.0.5, ramo monolista.
|
||||
|
||||
## Uso
|
||||
|
||||
- Campo UDC vuoto: rimane la consultazione annuale esistente, con il filtro
|
||||
facoltativo sul numero documento e ordinamento dalla data piu' recente.
|
||||
- Campo UDC compilato: premere Invio o Ricarica per trovare le picking list
|
||||
contenenti quella UDC nell'anno corrente e nel precedente. Nel 2026 sono
|
||||
2025 e 2026; nel 2027 saranno 2026 e 2027. L'anno e' quello documento SAM,
|
||||
rispetto alla data del server SQL, non l'anno di creazione della UDC.
|
||||
- Si cerca il codice UDC completo, non una sua parte; non inserire il suffisso
|
||||
della bag dopo lo slash. Sono ammessi codici numerici fino a sei cifre,
|
||||
conservando gli eventuali zeri iniziali.
|
||||
- Se sono compilati sia Documento sia UDC, i filtri si combinano (AND).
|
||||
Documento mantiene la ricerca parziale esistente.
|
||||
- L'anno compare accanto al documento nella griglia. Se ci sono piu' documenti
|
||||
contenenti la UDC vengono mostrati tutti, anche P e D, non solo l'ultimo.
|
||||
- Selezionando un risultato si vede il contenuto COMPLETO della lista.
|
||||
Anche i totali e i residui si riferiscono alla lista intera, non alla sola UDC
|
||||
cercata. Piu' lotti della stessa UDC non aumentano il numero pallet.
|
||||
- Per tornare all'elenco annuale, cancellare UDC e premere Ricarica.
|
||||
|
||||
## Dati e isolamento
|
||||
|
||||
La ricerca dedicata usa query parametrizzate in pickinglist_history_search.py,
|
||||
attraverso BAMTES, FATRIG, LOTTIBF e LOTSER di SAMA1. Usa LEFT(NUMSER,6) come
|
||||
identificativo UDC e seleziona documenti P o D, escludendo i lotti vuoti/fittizi
|
||||
come la vista storica. Le anagrafiche di destinazione sono facoltative: la loro
|
||||
assenza non nasconde il documento.
|
||||
|
||||
La vista annuale esistente non viene allargata. Nessuna tabella, vista o stored
|
||||
procedure e' creata o modificata; nessuna patch SQL aggiuntiva e' necessaria.
|
||||
Non cambiano il barcode, la prenotazione o gli oggetti legacy C#.
|
||||
|
||||
Il numero documento non e' univoco fra anni. La ricerca conserva BAMTES.ID per
|
||||
aggregazione, selezione, dettaglio e comando di versamento residui. Non vengono
|
||||
mescolate, per esempio, la lista 244 del 2025 e la lista 244 del 2026. Una
|
||||
prenotazione corrente non viene attribuita a una lista omonima dell'anno scorso.
|
||||
|
||||
Le ubicazioni e gli stati operativi sono quelli WMS correnti, come nello storico
|
||||
esistente, non una fotografia delle celle al momento della spedizione. Anche
|
||||
l'appartenenza della UDC dipende dalle associazioni LOTSER/documenti oggi presenti
|
||||
nel database, non da un nuovo archivio immutabile.
|
||||
|
||||
Le query mantengono esecuzione asincrona e overlay. Risposte tardive di una ricerca
|
||||
o selezione precedente non sostituiscono il risultato corrente. Il versamento
|
||||
residui rimane una distinta azione con conferma, mai un effetto della ricerca.
|
||||
|
||||
## Distribuzione e verifiche
|
||||
|
||||
Distribuire anche pickinglist_history_search.py insieme a storico_pickinglist.py,
|
||||
version_info.py e locale.json. Non occorre rilanciare full_patch per questa modifica.
|
||||
|
||||
tests/test_pickinglist_history_search.py include test con widget Tk reali e query
|
||||
SQL su sole fixture temporanee: finestra biennale, passaggio di anno, omonimia
|
||||
dei documenti, UDC multilotto, filtri combinati, dettagli e conteggi completi,
|
||||
assenza di ubicazione e protezione dalle risposte asincrone obsolete.
|
||||
81
docs/svuotamento_corsie.md
Normal file
81
docs/svuotamento_corsie.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Svuotamento scaffale/corsia con destinazione automatica
|
||||
|
||||
Modifica del 22 ottobre 2026, ramo monolista. Gestione Corsie: versione 1.0.1.
|
||||
|
||||
## Obiettivo e confini
|
||||
|
||||
Svuotare uno scaffale per rileggere le ubicazioni non equivale a spedire tutte
|
||||
le UDC. I movimenti eseguiti prima di questa modifica, incluso lo svuotamento
|
||||
del 21 ottobre, non vengono corretti o riscritti automaticamente.
|
||||
|
||||
La selezione continua a essere la corsia/scaffale della finestra Gestione Corsie.
|
||||
Non vengono coinvolte le altre corsie, le UDC assenti dal WMS o le locazioni
|
||||
virtuali. Le procedure del barcode e lo scarico manuale da layout non cambiano.
|
||||
|
||||
## Regola di destinazione
|
||||
|
||||
Per ogni UDC attualmente presente nella corsia si verifica la relazione
|
||||
`LOTSER -> LOTTIBF -> FATRIG -> BAMTES` in SAMA1. I primi sei caratteri di
|
||||
`LOTSER.NUMSER` identificano la UDC. Il criterio di definitivo e' `BAMTES.STATO = 'D'`,
|
||||
lo stesso stato ERP usato nello storico picking list; non e' la prenotazione WMS.
|
||||
|
||||
- Almeno un documento definitivo associato: destinazione ID 9999, 7G.1.1, spedita.
|
||||
- Nessun documento definitivo associato, anche con documento P o senza documento:
|
||||
destinazione ID 1000, non scaffalata (barcode 9001000).
|
||||
|
||||
La ricerca non dipende dall'anno visualizzato nello storico, dai giorni di
|
||||
visibilita' delle liste o dalla presenza della UDC nelle liste prenotabili.
|
||||
Piu' lotti/righe/documenti non moltiplicano il movimento: si usa EXISTS.
|
||||
Se una UDC compare sia in un documento D sia in uno P, prevale D, coerentemente
|
||||
con il controllo legacy sulle UDC gia' spedite. Il modello presuppone codici UDC
|
||||
non riutilizzati; eventuali riusi/resi richiedono analisi separata.
|
||||
|
||||
## Transazione, controlli e tracciamento
|
||||
|
||||
`reset_corsie_service.reset_pallet_async` esegue un singolo batch SQL con
|
||||
`query_json(commit=True)` e `XACT_ABORT ON`. Ogni UDC ha una propria transazione:
|
||||
|
||||
1. Blocca le righe di movimento della UDC durante il controllo e la scrittura.
|
||||
2. Verifica che la UDC sia ancora nella cella originariamente selezionata e non
|
||||
presenti altre ubicazioni attive. Le celle virtuali non sono sorgenti valide.
|
||||
3. Determina la destinazione dalla situazione ERP al momento del movimento.
|
||||
4. Verifica la presenza della cella virtuale e del versamento sorgente.
|
||||
5. Registra P dalla sorgente e V nella destinazione, con riferimenti, data e utente;
|
||||
azzera lo stato della cella sorgente secondo la logica di movimento esistente.
|
||||
6. Verifica che l'unica ubicazione attiva risultante sia la destinazione attesa.
|
||||
7. Richiama il controllo prenotazioni Python gia' esistente e conferma.
|
||||
|
||||
Un errore annulla la transazione della UDC corrente. Le altre UDC gia' confermate
|
||||
rimangono movimentate; lo svuotamento non e' una transazione unica di scaffale.
|
||||
La finestra riporta successi, spedite, non scaffalate ed eventuali errori. Nel log
|
||||
`reset_corsie.log` ogni successo indica UDC, cella sorgente, destinazione e utente;
|
||||
ogni errore include la UDC e il dettaglio tecnico. Un'interruzione di rete durante
|
||||
il commit richiede di ricaricare e verificare la situazione, non di presumere che
|
||||
il movimento sia certamente annullato. Eseguire lo svuotamento senza movimenti
|
||||
operativi concorrenti sulla corsia; i controlli non sostituiscono questa cautela.
|
||||
|
||||
## Effetto sullo storico picking list
|
||||
|
||||
Lo storico calcola i residui dalle ubicazioni correnti: ogni UDC con almeno una
|
||||
posizione diversa da 9999 e' residua; anche 1000 o l'assenza di un'associazione WMS
|
||||
sono rappresentati come residui dalla vista storica.
|
||||
|
||||
Un documento D passa da **Chiusa ERP con residui** a **Chiusa**, al successivo
|
||||
aggiornamento della finestra, solo quando TUTTE le sue UDC risultano spedite.
|
||||
Se lo scaffale svuotato contiene tutti gli ultimi residui, basta questa operazione.
|
||||
Se rimangono UDC in altri scaffali, non scaffalate o mai registrate nel WMS,
|
||||
la lista resta correttamente **Chiusa ERP con residui**. Non vengono modificate
|
||||
le intestazioni o le righe documento SAM. Per chiudere tutti i residui di un
|
||||
documento esiste gia' il comando dedicato nello storico, con conferma separata.
|
||||
|
||||
## Distribuzione e verifica
|
||||
|
||||
Non vengono create o alterate tabelle, viste o stored procedure: nessuna nuova
|
||||
patch SQL da lanciare. Il nuovo modulo Python deve essere distribuito insieme
|
||||
a reset_corsie.py, version_info.py, locale.json e tooltip.json. Restano necessarie
|
||||
le patch precedenti e la procedura Python di controllo prenotazioni gia' installata.
|
||||
|
||||
I test in tests/test_reset_corsie.py coprono la classificazione, le destinazioni,
|
||||
la registrazione P/V, i blocchi e il rollback. I test SQL sono attivabili con
|
||||
RESET_TEST_CONFIG: sostituiscono tutti gli oggetti reali con fixture temporanee
|
||||
locali alla connessione e non movimentano UDC reali.
|
||||
193
error_dialog.py
Normal file
193
error_dialog.py
Normal file
@@ -0,0 +1,193 @@
|
||||
"""Shared error dialogs; call on the Tk thread, like tkinter.messagebox.
|
||||
|
||||
Informational dialogs and confirmations retain their native implementations.
|
||||
Error reports are immutable text, shared by the viewer, clipboard and export.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
import tkinter as tk
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from tkinter import filedialog, messagebox as native_messagebox, ttk
|
||||
|
||||
from locale_text import text
|
||||
from ui_theme import theme_font, theme_section
|
||||
from version_info import APP_VERSION, module_version, versioned_title
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
"""Delegate non-error dialogs without changing answers or confirmation flow."""
|
||||
return getattr(native_messagebox, name)
|
||||
|
||||
|
||||
def build_error_report(title, message, exception=None, *, context="") -> str:
|
||||
"""Keep the original message and chained traceback, with unabridged SQL data."""
|
||||
parts = [f"{datetime.now().astimezone().isoformat(timespec='seconds')} | {title}",
|
||||
f"Warehouse {APP_VERSION} | Python {sys.version}"]
|
||||
if context:
|
||||
parts.append(context)
|
||||
parts.append(str(message))
|
||||
if exception is not None:
|
||||
trace = traceback.TracebackException.from_exception(
|
||||
exception, max_group_width=sys.maxsize, max_group_depth=sys.maxsize)
|
||||
parts.append("".join(trace.format()))
|
||||
# SQLAlchemy's exception text may abbreviate parameter collections.
|
||||
seen = set()
|
||||
pending = [exception]
|
||||
while pending:
|
||||
current = pending.pop()
|
||||
if id(current) in seen:
|
||||
continue
|
||||
seen.add(id(current))
|
||||
for name in ("statement", "params"):
|
||||
value = getattr(current, name, None)
|
||||
if value is not None:
|
||||
parts.append(f"{type(current).__name__}.{name}:\n"
|
||||
+ (value if isinstance(value, str) else repr(value)))
|
||||
linked = current.__cause__ or (
|
||||
None if current.__suppress_context__ else current.__context__)
|
||||
if linked is not None:
|
||||
pending.append(linked)
|
||||
if isinstance(current, BaseExceptionGroup):
|
||||
pending.extend(reversed(current.exceptions))
|
||||
return "\n\n".join(parts)
|
||||
|
||||
|
||||
class ErrorDialog(tk.Toplevel):
|
||||
"""Resizable, selectable read-only report, also usable on small terminals."""
|
||||
|
||||
def __init__(self, parent, title, report):
|
||||
super().__init__(parent)
|
||||
self.withdraw()
|
||||
self.report = report
|
||||
self.title(versioned_title(title, __name__))
|
||||
self.resizable(True, True)
|
||||
theme = theme_section("error_dialog")
|
||||
width = min(int(theme.get("width", 900)), max(200, self.winfo_screenwidth() - 24))
|
||||
height = min(int(theme.get("height", 620)), max(200, self.winfo_screenheight() - 80))
|
||||
self.geometry(f"{width}x{height}+0+0")
|
||||
self.minsize(min(width, 420), min(height, 260))
|
||||
if parent.winfo_viewable():
|
||||
self.transient(parent.winfo_toplevel())
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
self.grid_rowconfigure(0, weight=1)
|
||||
|
||||
frame = ttk.Frame(self, padding=6)
|
||||
frame.grid(row=0, column=0, sticky="nsew")
|
||||
frame.grid_rowconfigure(0, weight=1)
|
||||
frame.grid_columnconfigure(0, weight=1)
|
||||
self.textbox = tk.Text(frame, wrap="none", width=1, height=1,
|
||||
font=theme_font(theme, "font", ("Consolas", 10)),
|
||||
background=theme.get("background", "#ffffff"),
|
||||
foreground=theme.get("foreground", "#202020"), exportselection=False)
|
||||
self.textbox.grid(row=0, column=0, sticky="nsew")
|
||||
self.vertical = ttk.Scrollbar(frame, orient="vertical", command=self.textbox.yview)
|
||||
self.vertical.grid(row=0, column=1, sticky="ns")
|
||||
self.horizontal = ttk.Scrollbar(frame, orient="horizontal", command=self.textbox.xview)
|
||||
self.horizontal.grid(row=1, column=0, sticky="ew")
|
||||
self.textbox.configure(yscrollcommand=self.vertical.set, xscrollcommand=self.horizontal.set)
|
||||
self.textbox.insert("1.0", report)
|
||||
self.textbox.configure(state="disabled")
|
||||
self.textbox.bind("<Control-a>", self.select_all)
|
||||
self.textbox.bind("<Control-c>", self.copy_selection)
|
||||
self.status = tk.StringVar(self, "")
|
||||
ttk.Label(self, textvariable=self.status, wraplength=max(150, width - 20)).grid(
|
||||
row=1, column=0, sticky="ew", padx=6)
|
||||
buttons = ttk.Frame(self, padding=6)
|
||||
buttons.grid(row=2, column=0, sticky="ew")
|
||||
self.buttons = []
|
||||
for i, (key, callback) in enumerate((("copy", self.copy_all),
|
||||
("save", self.save_report), ("close", self.destroy))):
|
||||
button = ttk.Button(buttons, text=text("errors." + key), command=callback)
|
||||
row, col = (i, 0) if width < 480 else (0, i)
|
||||
button.grid(row=row, column=col, sticky="ew", padx=2, pady=2)
|
||||
buttons.grid_columnconfigure(col, weight=1)
|
||||
self.buttons.append(button)
|
||||
self.bind("<Escape>", lambda _: self.destroy())
|
||||
self.deiconify()
|
||||
|
||||
def select_all(self, event=None):
|
||||
self.textbox.tag_add("sel", "1.0", "end-1c")
|
||||
return "break"
|
||||
|
||||
def _copy(self, value):
|
||||
try:
|
||||
self.clipboard_clear()
|
||||
self.clipboard_append(value)
|
||||
self.status.set(text("errors.copied"))
|
||||
except tk.TclError as exc:
|
||||
self.status.set(text("errors.copy_failed").format(error=exc))
|
||||
|
||||
def copy_selection(self, event=None):
|
||||
if self.textbox.tag_ranges("sel"):
|
||||
self._copy(self.textbox.get("sel.first", "sel.last"))
|
||||
return "break"
|
||||
|
||||
def copy_all(self):
|
||||
self._copy(self.report)
|
||||
|
||||
def save_report(self):
|
||||
"""Save UTF-8 without truncation; a failed save leaves the report open."""
|
||||
path = filedialog.asksaveasfilename(parent=self, title=text("errors.save"),
|
||||
defaultextension=".txt", initialfile=f"warehouse_error_{datetime.now():%Y%m%d_%H%M%S}.txt",
|
||||
filetypes=[(text("errors.text_file"), "*.txt"), (text("errors.all_files"), "*.*")])
|
||||
if not path:
|
||||
return
|
||||
try:
|
||||
Path(path).write_text(self.report, encoding="utf-8")
|
||||
except OSError as exc:
|
||||
self.status.set(text("errors.save_failed").format(error=exc))
|
||||
else:
|
||||
self.status.set(text("errors.saved").format(path=path))
|
||||
|
||||
|
||||
def showerror(title=None, message=None, *, parent=None, exception=None, context="", **options):
|
||||
"""Messagebox-compatible modal error; confirmations are never rerouted here.
|
||||
|
||||
Async callbacks must pass ``exception`` explicitly to retain their traceback.
|
||||
Within an except block the active exception is captured automatically.
|
||||
"""
|
||||
if exception is None:
|
||||
exception = message if isinstance(message, BaseException) else sys.exc_info()[1]
|
||||
title = title or text("errors.title")
|
||||
if not context and parent is not None:
|
||||
context = parent.winfo_toplevel().title()
|
||||
report = build_error_report(title, "" if message is None else message, exception, context=context)
|
||||
if options.get("detail"):
|
||||
report += "\n\n" + str(options["detail"])
|
||||
owned_root = None
|
||||
parent = parent if parent is not None else tk._default_root
|
||||
if parent is None:
|
||||
owned_root = parent = tk.Tk()
|
||||
parent.withdraw()
|
||||
previous_grab = parent.grab_current()
|
||||
previous_grab_status = previous_grab.grab_status() if previous_grab else None
|
||||
previous_focus = parent.focus_get()
|
||||
dialog = None
|
||||
try:
|
||||
dialog = ErrorDialog(parent, title, report)
|
||||
dialog.wait_visibility()
|
||||
dialog.grab_set()
|
||||
dialog.textbox.focus_set()
|
||||
dialog.wait_window()
|
||||
finally:
|
||||
if dialog is not None and dialog.winfo_exists():
|
||||
dialog.destroy()
|
||||
try:
|
||||
if previous_grab is not None and previous_grab.winfo_exists():
|
||||
if previous_grab_status == "global":
|
||||
previous_grab.grab_set_global()
|
||||
else:
|
||||
previous_grab.grab_set()
|
||||
if previous_focus is not None and previous_focus.winfo_exists():
|
||||
previous_focus.focus_set()
|
||||
except tk.TclError:
|
||||
pass
|
||||
if owned_root is not None:
|
||||
owned_root.destroy()
|
||||
return "ok"
|
||||
65
fix_barcode_documento_fisso_f1_f2.md
Normal file
65
fix_barcode_documento_fisso_f1_f2.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# Documento fisso durante il ciclo barcode F1/F2
|
||||
|
||||
## Difetto e requisito
|
||||
|
||||
Prima della correzione ogni avanzamento interrogava tutte le UDC con IDStato
|
||||
uguale alla priorita' richiesta. Per F2, che include tutte le liste non
|
||||
prenotate, il documento poteva quindi cambiare senza intervento dell'operatore.
|
||||
|
||||
Una volta proposta una lista, ogni successiva UDC del ciclo deve appartenere
|
||||
a quel documento. F1 e F2 ricordano ciascuno la propria lista: F2 -> F1 -> F2
|
||||
deve riportare al documento inizialmente assegnato a F2, anche se cambia
|
||||
l'ordine globale delle UDC disponibili.
|
||||
|
||||
## Implementazione locale
|
||||
|
||||
- BarcodeService conserva un documento per priorita', separato dallo stato
|
||||
visuale temporaneo di conferma o pausa.
|
||||
- La prima richiesta senza documento usa il criterio di ordinamento vigente.
|
||||
Non viene introdotta una selezione per data del documento.
|
||||
- Le successive richieste applicano il filtro Documento nelle query di
|
||||
avanzamento, ricerca skip e ricerca della UDC per conferma del movimento.
|
||||
- Un documento differente ricevuto dal repository causa un errore esplicito.
|
||||
- La pausa per movimenti liberi e il passaggio tra F1/F2 conservano i documenti.
|
||||
- Quando termina il documento, il ciclo si ferma e mostra il relativo messaggio.
|
||||
Una successiva pressione esplicita di un tasto priorita' puo' avviare un nuovo
|
||||
ciclo; la fine del precedente non attiva automaticamente un altro documento.
|
||||
- Quando rimangono soltanto UDC saltate, viene gestita la sospensione della
|
||||
lista corrente senza passare a un'altra lista disponibile nella coda.
|
||||
- Se cambiano prenotazione o visibilita' e ci sono ancora residui nello storico,
|
||||
compare un messaggio di verifica e il documento viene mantenuto in memoria.
|
||||
- Un errore della query non cancella il documento memorizzato.
|
||||
|
||||
Gli skip sono conteggiati soltanto se la relativa UDC e' ancora residua.
|
||||
Le movimentazioni libere mantengono la loro logica; il filtro Documento e'
|
||||
applicato soltanto alle ricerche nel contesto del picking.
|
||||
|
||||
## Limiti e installazione
|
||||
|
||||
Questa correzione riguarda la sessione del terminalino. La memoria dei documenti
|
||||
viene azzerata con reset del servizio o riavvio del programma. Non introduce
|
||||
ancora due prenotazioni persistenti o un percorso automatico comune per colonna:
|
||||
questi appartengono alla successiva modifica funzionale da specificare.
|
||||
|
||||
Non serve una patch SQL: cambiano le SELECT eseguite dal codice Python, non gli
|
||||
oggetti del database. Versioni: barcode_client 1.0.27 (titolo visibile),
|
||||
barcode_repository 1.0.14, barcode_service 1.0.25.
|
||||
|
||||
## Verifiche
|
||||
|
||||
Esecuzione senza GUI e senza movimentazioni reali:
|
||||
|
||||
```bat
|
||||
python -m unittest discover -s tests -p test_barcode_document_binding.py -v
|
||||
```
|
||||
|
||||
Gli 11 test coprono avanzamento con documenti intercalati, passaggi ripetuti
|
||||
F2/F1/F2, pausa con movimento libero, salto UDC, sospensione con soli skip,
|
||||
fine lista, cambio prenotazione, errore query, rifiuto di documento inatteso,
|
||||
isolamento della conferma e passaggio del parametro al repository.
|
||||
|
||||
Ulteriori 5 verifiche SELECT su SQL Server, con righe sintetiche in CTE,
|
||||
hanno controllato selezione iniziale, filtro documento, assenza di fallback,
|
||||
skip effettivamente residui e isolamento della conferma. Nessun dato reale
|
||||
e' stato aggiornato per questi test. Il collaudo fisico sul terminalino resta
|
||||
da effettuare.
|
||||
@@ -1,4 +1,4 @@
|
||||
"""One-off maintenance script to sanitize ``border_color`` usage in ``layout_window``.
|
||||
"""One-off maintenance script to sanitize ``border_color`` usage in ``gestione_layout``.
|
||||
|
||||
The script removes incompatible ``border_color='transparent'`` assignments from
|
||||
widget configuration calls while preserving explicit highlight colors that are
|
||||
@@ -9,7 +9,7 @@ import re
|
||||
from pathlib import Path
|
||||
|
||||
# Path default (modifica se serve)
|
||||
p = Path("./layout_window.py")
|
||||
p = Path("./gestione_layout.py")
|
||||
if not p.exists():
|
||||
raise SystemExit(f"File non trovato: {p}")
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""One-off maintenance script to patch performance issues in ``layout_window``.
|
||||
"""One-off maintenance script to patch performance issues in ``gestione_layout``.
|
||||
|
||||
The script was used during development to remove an expensive resize-triggered
|
||||
refresh and to inject some lifecycle guards into the window implementation.
|
||||
@@ -8,7 +8,7 @@ It is kept in the repository as an auditable patch recipe.
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
p = Path("./layout_window.py")
|
||||
p = Path("./gestione_layout.py")
|
||||
src = p.read_text(encoding="utf-8")
|
||||
|
||||
backup = p.with_suffix(".py.bak_perf")
|
||||
|
||||
78
flussi operativi.txt
Normal file
78
flussi operativi.txt
Normal file
@@ -0,0 +1,78 @@
|
||||
Flusso delle procedure del barcode così come le compie il magazziniere con il barcode.
|
||||
Le procudere analizzate sono 3: carico(versamento), scarico(prelievo), prelievo pickinglist
|
||||
|
||||
1 reset iniziale
|
||||
|
||||
Il magazziniere entra nello stato iniziale premendo f1
|
||||
Poichè non c'è nessuna pickinglist prenotata (stato 1) , (questo è il pre-requisito) questo è lo stato iniziale
|
||||
|
||||
Input text e label diventano:
|
||||
|
||||
L'input text Pallet diventa vuoto e acquisisce il focus
|
||||
L'input text Cella diventa 9000000
|
||||
La label 1 , dall'alto , diventa rossa
|
||||
Le altre 3 sono vuote e grige.
|
||||
|
||||
Questo stato iniziale è identico per carico e scarico , la discriminante tra le due operazioni è ciò che l'operatore farà dopo essere entrato in questo stato.
|
||||
|
||||
2 prelievo
|
||||
|
||||
Il passaggio 2 è sempre la lettura di un codice udc. Che può essere fatta da barcode oppure da tastiera, se è fatta da barcode la lettura implica uno spostamento del focus sull'input text Cella. Se è fatta da tastiera all'input del 6° carattere il focus salta automaticamente all'inputtext Cella.
|
||||
|
||||
Se ora l'operatore preme "f4 elimina" il pallet corrente viene associato alla cella 9000000 e di fatto prelevato.
|
||||
Questo chiude il prelievo, il dato viene inviato al server e la 4 label diventano
|
||||
|
||||
Ok scarico - 698345 -> verde
|
||||
P2506000007
|
||||
S-174
|
||||
Center ring
|
||||
|
||||
Questo è lo scarico , dopo 2 secondi la form si resetta come in 1.
|
||||
|
||||
|
||||
3 versamento
|
||||
|
||||
Se all'atto della lettura del codice udc anzichè lasciare 9000000 nell'input text l'operatore leggesse un codice di cella questo implicherebbe un versamento di quell'udc in quella cella.
|
||||
La lettura del codice di cella può avvenire solo da barcode e non da tastiera, a meno che l'oepratore non conosca effettivamente quel codice.
|
||||
|
||||
Nel momento in cui l'operatore legge il barcode della cella automaticamente parte l'aggiornamento del versameto sul server. Se l'operazine è andata a buona fine le label intermendi diventano
|
||||
|
||||
OK carico . --> verde
|
||||
Lotto
|
||||
codice
|
||||
descrizione
|
||||
|
||||
dopo 2 secondi dall'ok il form si resetta come in 1.
|
||||
|
||||
4 pickinglkist
|
||||
|
||||
se esiste una picking list con id stato 1 questa può essere prelevata mediante f1, con f2 si salta alla lista successiva con numdoc più basso. Se non c'è nessuna picking list prenotata f1 resetta il barcode alla condizione 1 . Se premo f2 salto alla picking list successiva per numdoc a quella con il numdoc più basso di tutte. In pratica quella con il numdoc più basso può andare in f1 solo se viene prenotata.
|
||||
|
||||
Supponiamo di avere prentato una pickinglist e quindi di premere f1, oppure di andare sulla successiva a quella con il numdoc più basso con f2. Premere f1 o f2 se ci sono plist prenotate o più plist, non perdispone più al prelievo o versamento di cui ai punti 1 e 2 ma allo scorrimento/prelievo di una picking list.
|
||||
|
||||
L'operatore preme f1 , gli inputtext e le label diventano
|
||||
pallet : vuoto con focus
|
||||
cella: 9000000
|
||||
|
||||
Ok Cella indirizzo cella
|
||||
numdoc della pickinglist
|
||||
descrizione picking list
|
||||
num udc
|
||||
|
||||
Questa informazioni sono quelle prese dal contneuto dle picking list
|
||||
, cioè la prima udc da prelevare, la sua locazione e la descrizone del docuemnto corrente selezionato.
|
||||
L'operatore va quindi a cercare la cella, il focus si è posizionato su inputtext pallet.
|
||||
L'operatore legge il barcode della UDC, oppure digita il codice e al sesto carattere scatta il tab sull'input successivo.
|
||||
|
||||
Qui , in automatico, parte il controllo ce codice udc sia quello giusto, se ciè è vero parte il dato per il database che associa l'udc alla cella 7G etc. non ricordo, che significa che l'udc è stata spedita. Cosa avvenga in questo punto è da verificare sul codice
|
||||
|
||||
Se è tutto ok la prima label diviene "ok scarico " -- verde
|
||||
e occorre vedere sul codice c# cosa compare nelle altre labels.
|
||||
|
||||
Dopo 2 secondi al form si posiziona sulla successiva udc e il ciclo ricomincia.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
"""Shared Tk/async helpers used by multiple warehouse windows.
|
||||
|
||||
The module bundles three concerns used throughout the GUI:
|
||||
The module bundles two concerns used throughout the GUI:
|
||||
|
||||
* lifecycle of the shared background asyncio loop;
|
||||
* a modal-like busy overlay shown during long-running tasks;
|
||||
* an ``AsyncRunner`` that schedules coroutines and re-enters Tk safely.
|
||||
* an ``AsyncRunner`` that schedules coroutines on the shared loop and
|
||||
re-enters Tk safely.
|
||||
|
||||
The shared loop itself is defined only in :mod:`async_loop_singleton` and is
|
||||
reused here instead of being recreated locally.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import threading
|
||||
import tkinter as tk
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
__VERSION__ = "GestioneAreeFrame v3.2.5-singleloop"
|
||||
from async_loop_singleton import get_global_loop
|
||||
from runtime_support import log_exception
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
try:
|
||||
from async_msssql_query import AsyncMSSQLClient # noqa: F401
|
||||
@@ -24,50 +30,6 @@ except Exception:
|
||||
AsyncMSSQLClient = object # type: ignore
|
||||
|
||||
|
||||
class _LoopHolder:
|
||||
"""Keep references to the shared event loop and its worker thread."""
|
||||
|
||||
def __init__(self):
|
||||
self.loop: Optional[asyncio.AbstractEventLoop] = None
|
||||
self.thread: Optional[threading.Thread] = None
|
||||
self.ready = threading.Event()
|
||||
|
||||
|
||||
_GLOBAL = _LoopHolder()
|
||||
|
||||
|
||||
def _run_loop():
|
||||
"""Create and run the shared event loop inside the worker thread."""
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
_GLOBAL.loop = loop
|
||||
_GLOBAL.ready.set()
|
||||
loop.run_forever()
|
||||
|
||||
|
||||
def get_global_loop() -> asyncio.AbstractEventLoop:
|
||||
"""Return the shared background event loop, creating it if needed."""
|
||||
if _GLOBAL.loop is not None:
|
||||
return _GLOBAL.loop
|
||||
_GLOBAL.thread = threading.Thread(target=_run_loop, name="warehouse-asyncio", daemon=True)
|
||||
_GLOBAL.thread.start()
|
||||
_GLOBAL.ready.wait(timeout=5.0)
|
||||
if _GLOBAL.loop is None:
|
||||
raise RuntimeError("Impossibile avviare l'event loop globale")
|
||||
return _GLOBAL.loop
|
||||
|
||||
|
||||
def stop_global_loop():
|
||||
"""Stop the shared event loop and release thread references."""
|
||||
if _GLOBAL.loop and _GLOBAL.loop.is_running():
|
||||
_GLOBAL.loop.call_soon_threadsafe(_GLOBAL.loop.stop)
|
||||
if _GLOBAL.thread:
|
||||
_GLOBAL.thread.join(timeout=2.0)
|
||||
_GLOBAL.loop = None
|
||||
_GLOBAL.thread = None
|
||||
_GLOBAL.ready.clear()
|
||||
|
||||
|
||||
class BusyOverlay:
|
||||
"""Semi-transparent overlay used to block interaction during async tasks."""
|
||||
|
||||
@@ -167,21 +129,53 @@ class AsyncRunner:
|
||||
busy.show(message)
|
||||
fut = asyncio.run_coroutine_threadsafe(awaitable, self.loop)
|
||||
|
||||
def _widget_alive() -> bool:
|
||||
try:
|
||||
return bool(self.widget.winfo_exists())
|
||||
except tk.TclError:
|
||||
return False
|
||||
|
||||
def _dispatch_success(res: Any) -> None:
|
||||
try:
|
||||
on_success(res)
|
||||
except BaseException as ex:
|
||||
log_exception(__name__, ex, context="AsyncRunner on_success")
|
||||
|
||||
def _dispatch_error(ex: BaseException) -> None:
|
||||
if on_error:
|
||||
try:
|
||||
on_error(ex)
|
||||
except BaseException as callback_ex:
|
||||
log_exception(__name__, callback_ex, context="AsyncRunner on_error")
|
||||
else:
|
||||
log_exception(__name__, ex, context="AsyncRunner unhandled error")
|
||||
|
||||
def _poll():
|
||||
if not _widget_alive():
|
||||
return
|
||||
if fut.done():
|
||||
if busy:
|
||||
busy.hide()
|
||||
try:
|
||||
busy.hide()
|
||||
except Exception as ex:
|
||||
log_exception(__name__, ex, context="AsyncRunner hide busy")
|
||||
try:
|
||||
res = fut.result()
|
||||
except BaseException as ex:
|
||||
if on_error:
|
||||
self.widget.after(0, lambda e=ex: on_error(e))
|
||||
else:
|
||||
print("[AsyncRunner] Unhandled error:", repr(ex))
|
||||
try:
|
||||
self.widget.after(0, lambda e=ex: _dispatch_error(e))
|
||||
except tk.TclError:
|
||||
log_exception(__name__, ex, context="AsyncRunner error after destroyed")
|
||||
else:
|
||||
self.widget.after(0, lambda r=res: on_success(r))
|
||||
try:
|
||||
self.widget.after(0, lambda r=res: _dispatch_success(r))
|
||||
except tk.TclError as ex:
|
||||
log_exception(__name__, ex, context="AsyncRunner success after destroyed")
|
||||
else:
|
||||
self.widget.after(60, _poll)
|
||||
try:
|
||||
self.widget.after(60, _poll)
|
||||
except tk.TclError:
|
||||
return
|
||||
|
||||
_poll()
|
||||
|
||||
1446
gestione_layout.py
Normal file
1446
gestione_layout.py
Normal file
File diff suppressed because it is too large
Load Diff
62
gestione_layout_picking_list.csv
Normal file
62
gestione_layout_picking_list.csv
Normal file
@@ -0,0 +1,62 @@
|
||||
NULL;0xFFFE900209004D006900630072006F0073006F00660074002000530051004C00200053006500720076006500720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E00A60C000000006D006400650033005C00670065007300740065007200700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FAFBEDFB00FCFF100E00010009000A000B0006000C000E00FCFF180F000B00060009000A000C000D000E000F00100011001200FCFF101100010009000A000B0006000C000E00FCFF1A0A00090002000A0006000B000C000D000E000F00100011001200FCFF1A0C00010009000B0006000A000C000D000E000F00100011001200FCFF100D00010009000B0006000A000C000E00FCFB1C1B0001000A0006000B001200100011000D0009000C000E000F000200;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65528;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;2025-10-09 10:05:23.670;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65534;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;106;NULL;2025-10-09 10:04:07.890;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;112;NULL;2025-10-09 10:04:07.903;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;113;NULL;2025-10-09 10:04:07.997;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:04:08.280;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;NULL;2025-10-09 10:04:07.997;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;88930000;2025-10-09 10:04:08.280;2025-10-09 10:05:37.210;21;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;43;2025-10-09 10:05:37.210;2025-10-09 10:05:37.210;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:37.210;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewMappaturaDescrizioneCorsia WHERE ( Area > 0) ORDER BY Area Desc ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:37.210;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewMappaturaDescrizioneCorsia WHERE ( Area > 0) ORDER BY Area Desc ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;296;2025-10-09 10:05:37.210;2025-10-09 10:05:37.210;26;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;20000;2025-10-09 10:05:37.210;2025-10-09 10:05:37.230;47;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;32;2025-10-09 10:05:37.230;2025-10-09 10:05:37.230;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:37.227;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewMappaturaDescrizioneCorsia WHERE ( Area > 0) ORDER BY Area Desc ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:37.230;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewMappaturaDescrizioneCorsia WHERE ( Area > 0) ORDER BY Area Desc ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;243;2025-10-09 10:05:37.230;2025-10-09 10:05:37.230;26;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;4000;2025-10-09 10:05:37.227;2025-10-09 10:05:37.230;73;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;17;2025-10-09 10:05:37.230;2025-10-09 10:05:37.230;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:37.227;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM Celle WHERE ( ID > 0) ORDER BY ID Desc ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:37.230;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM Celle WHERE ( ID > 0) ORDER BY ID Desc ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;6561990;2025-10-09 10:05:37.230;2025-10-09 10:05:43.790;3941578;11835;6328;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;6570000;2025-10-09 10:05:37.227;2025-10-09 10:05:43.797;3941651;11835;6328;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;20;2025-10-09 10:05:43.797;2025-10-09 10:05:43.797;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.787;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT TOP 1000 [mc_X] ,[minFila] ,[maxFila] ,[minColonna] ,[maxColonna] ,[mc_Numero_Magazzino] ,[mc_Numero_Area] FROM vViewMappaturaPosizCorsia WHERE [mc_Numero_Area] =1 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.797;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT TOP 1000 [mc_X] ,[minFila] ,[maxFila] ,[minColonna] ,[maxColonna] ,[mc_Numero_Magazzino] ,[mc_Numero_Area] FROM vViewMappaturaPosizCorsia WHERE [mc_Numero_Area] =1 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;334;2025-10-09 10:05:43.797;2025-10-09 10:05:43.797;56;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;95804000;2025-10-09 10:04:07.997;2025-10-09 10:05:43.800;5;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;16;2025-10-09 10:05:43.800;2025-10-09 10:05:43.800;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;NULL;2025-10-09 10:05:43.787;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT CASE WHEN Nota = 'ASC' THEN 0 ELSE CASE WHEN Nota = 'DESC' THEN 1 END END AS Nota FROM MagLayout WHERE (IDArea = 1) ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;NULL;2025-10-09 10:05:43.800;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT CASE WHEN Nota = 'ASC' THEN 0 ELSE CASE WHEN Nota = 'DESC' THEN 1 END END AS Nota FROM MagLayout WHERE (IDArea = 1) ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;74;2025-10-09 10:05:43.800;2025-10-09 10:05:43.800;2;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;44000;2025-10-09 10:05:43.787;2025-10-09 10:05:43.830;3941707;11835;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;36;2025-10-09 10:05:43.830;2025-10-09 10:05:43.830;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.820;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Descrizione FROM Magazzini ORDER BY Descrizione;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.830;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Descrizione FROM Magazzini ORDER BY Descrizione;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;155;2025-10-09 10:05:43.830;2025-10-09 10:05:43.830;2;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;13000;2025-10-09 10:05:43.820;2025-10-09 10:05:43.833;3941709;11835;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;17;2025-10-09 10:05:43.833;2025-10-09 10:05:43.833;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.837;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Descrizione FROM Celle ORDER BY Descrizione;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.833;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Descrizione FROM Celle ORDER BY Descrizione;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;2130;2025-10-09 10:05:43.833;2025-10-09 10:05:43.837;56;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;84000;2025-10-09 10:05:43.837;2025-10-09 10:05:43.920;3941765;11835;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;37;2025-10-09 10:05:43.920;2025-10-09 10:05:43.920;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.913;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT [ID],[CorsiaDescrizione] FROM vViewMappaturaDescrizioneCorsia;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.920;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT [ID],[CorsiaDescrizione] FROM vViewMappaturaDescrizioneCorsia;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;195;2025-10-09 10:05:43.920;2025-10-09 10:05:43.920;26;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;23000;2025-10-09 10:05:43.913;2025-10-09 10:05:43.937;3941791;11835;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;20;2025-10-09 10:05:43.937;2025-10-09 10:05:43.937;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.930;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT COUNT(DISTINCT Pallet) AS Pallet, COUNT(DISTINCT Lotto) AS Lotto, COUNT(DISTINCT Articolo) AS Articolo, COUNT(DISTINCT Descrizione) AS Descrizione, SUM(Qta) AS Qta, Documento, CodNazione, NAZIONE, Stato, MAX(PalletCella) AS PalletCella, MAX(Magazzino) AS Magazzino, MAX(Area) AS Area, MAX(Cella) AS Cella, MIN(Ordinamento) AS Ordinamento, MAX(IDStato) AS IDStato FROM dbo.XMag_ViewPackingList GROUP BY Documento, CodNazione, NAZIONE, Stato ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:05:43.937;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT COUNT(DISTINCT Pallet) AS Pallet, COUNT(DISTINCT Lotto) AS Lotto, COUNT(DISTINCT Articolo) AS Articolo, COUNT(DISTINCT Descrizione) AS Descrizione, SUM(Qta) AS Qta, Documento, CodNazione, NAZIONE, Stato, MAX(PalletCella) AS PalletCella, MAX(Magazzino) AS Magazzino, MAX(Area) AS Area, MAX(Cella) AS Cella, MIN(Ordinamento) AS Ordinamento, MAX(IDStato) AS IDStato FROM dbo.XMag_ViewPackingList GROUP BY Documento, CodNazione, NAZIONE, Stato ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;718618;2025-10-09 10:05:43.937;2025-10-09 10:05:44.653;37512;5;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;874000;2025-10-09 10:05:43.787;2025-10-09 10:05:44.660;7;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;21;2025-10-09 10:05:44.660;2025-10-09 10:05:44.660;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;NULL;2025-10-09 10:05:44.663;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 237 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;NULL;2025-10-09 10:05:44.660;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 237 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;117;667783;2025-10-09 10:05:44.660;2025-10-09 10:05:45.327;37056;0;594;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;37156000;2025-10-09 10:05:43.930;2025-10-09 10:06:21.087;3979303;11840;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;66;2025-10-09 10:06:21.087;2025-10-09 10:06:21.087;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:06:21.087;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 240 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;NULL;2025-10-09 10:06:21.087;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 240 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;9796;.Net SqlClient Data Provider;magazzino;115;719071;2025-10-09 10:06:21.087;2025-10-09 10:06:21.807;37056;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
|
File diff suppressed because it is too large
Load Diff
889
gestione_scarico.py
Normal file
889
gestione_scarico.py
Normal file
@@ -0,0 +1,889 @@
|
||||
"""Modal dialog used to unload one or more UDCs from a multi-occupancy cell."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
import tkinter as tk
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from functools import wraps
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable
|
||||
|
||||
import customtkinter as ctk
|
||||
import error_dialog as messagebox
|
||||
from tkinter import ttk
|
||||
|
||||
from gestione_aree import AsyncRunner
|
||||
from audit_log import log_user_action
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from ui_theme import theme_color, theme_font, theme_section, theme_value
|
||||
from ui_tables import style_treeview, zebra_tag
|
||||
from user_session import UserSession
|
||||
from version_info import module_version, versioned_title
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
try:
|
||||
from loguru import logger
|
||||
except Exception: # pragma: no cover - fallback used only when Loguru is not available
|
||||
class _FallbackLogger:
|
||||
"""Minimal adapter used only when Loguru is not installed yet."""
|
||||
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger(MODULE_LOG_NAME if "MODULE_LOG_NAME" in globals() else __name__)
|
||||
self._logger.setLevel(logging.DEBUG)
|
||||
self._logger.propagate = False
|
||||
|
||||
def bind(self, **_kwargs):
|
||||
return self
|
||||
|
||||
def add(self, sink, level="INFO", format=None, encoding="utf-8", **_kwargs):
|
||||
handler: logging.Handler
|
||||
if hasattr(sink, "write"):
|
||||
handler = logging.StreamHandler(sink)
|
||||
else:
|
||||
handler = logging.FileHandler(str(sink), encoding=encoding)
|
||||
handler.setLevel(getattr(logging, str(level).upper(), logging.INFO))
|
||||
handler.setFormatter(
|
||||
logging.Formatter("%(asctime)s | %(levelname)-8s | %(name)s | %(message)s")
|
||||
)
|
||||
self._logger.addHandler(handler)
|
||||
return 0
|
||||
|
||||
def log(self, level, message):
|
||||
getattr(self._logger, str(level).lower(), self._logger.info)(message)
|
||||
|
||||
def debug(self, message):
|
||||
self._logger.debug(message)
|
||||
|
||||
def info(self, message):
|
||||
self._logger.info(message)
|
||||
|
||||
def exception(self, message):
|
||||
self._logger.exception(message)
|
||||
|
||||
logger = _FallbackLogger()
|
||||
|
||||
|
||||
SCARICO_LOG_MODE = "INFO" # "OFF" | "INFO" | "DEBUG"
|
||||
MODULE_LOG_NAME = Path(__file__).stem
|
||||
MODULE_LOG_PATH = Path(__file__).with_suffix(".log")
|
||||
_MODULE_LOG_ENABLED = SCARICO_LOG_MODE.upper() != "OFF"
|
||||
_MODULE_LOG_LEVEL = "DEBUG" if SCARICO_LOG_MODE.upper() == "DEBUG" else "INFO"
|
||||
_MODULE_LOGGER = logger.bind(warehouse_module=MODULE_LOG_NAME)
|
||||
_MODULE_LOGGING_CONFIGURED = False
|
||||
DEFAULT_SCARICO_USER = "warehouse_ui"
|
||||
SHIPPED_IDCELLA = 9999
|
||||
SHIPPED_BARCODE = "9000000"
|
||||
SHIPPED_LABEL = "7G.1.1"
|
||||
NON_SCAFF_IDCELLA = 1000
|
||||
NON_SCAFF_BARCODE = "9001000"
|
||||
NON_SCAFF_LABEL = "5E1.1"
|
||||
|
||||
|
||||
def _session_login(session: UserSession | None, fallback: str | None = None) -> str:
|
||||
"""Return the current application login, falling back to a technical user."""
|
||||
|
||||
if session and str(session.login or "").strip():
|
||||
return str(session.login).strip()
|
||||
return str((fallback or DEFAULT_SCARICO_USER) or DEFAULT_SCARICO_USER).strip()
|
||||
|
||||
|
||||
def _configure_module_logger():
|
||||
"""Configure console and file logging for this module."""
|
||||
global _MODULE_LOGGING_CONFIGURED
|
||||
if _MODULE_LOGGING_CONFIGURED:
|
||||
return
|
||||
if not _MODULE_LOG_ENABLED:
|
||||
_MODULE_LOGGING_CONFIGURED = True
|
||||
return
|
||||
|
||||
record_filter = lambda record: record["extra"].get("warehouse_module") == MODULE_LOG_NAME
|
||||
logger.add(
|
||||
sys.stderr,
|
||||
level=_MODULE_LOG_LEVEL,
|
||||
colorize=True,
|
||||
filter=record_filter,
|
||||
format=(
|
||||
"<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
|
||||
"<level>{level: <8}</level> | "
|
||||
"<cyan>" + MODULE_LOG_NAME + "</cyan> | "
|
||||
"<level>{message}</level>"
|
||||
),
|
||||
)
|
||||
logger.add(
|
||||
MODULE_LOG_PATH,
|
||||
level=_MODULE_LOG_LEVEL,
|
||||
colorize=False,
|
||||
encoding="utf-8",
|
||||
filter=record_filter,
|
||||
format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | " + MODULE_LOG_NAME + " | {message}",
|
||||
)
|
||||
_MODULE_LOGGING_CONFIGURED = True
|
||||
|
||||
|
||||
def _format_payload(payload: Any) -> str:
|
||||
"""Serialize payloads for human-readable logging."""
|
||||
try:
|
||||
return json.dumps(payload, ensure_ascii=False, indent=2, default=str)
|
||||
except Exception:
|
||||
return repr(payload)
|
||||
|
||||
|
||||
def _log_call(level: str | None = None):
|
||||
"""Trace entry, exit and failure of selected high-level functions."""
|
||||
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
effective_level = level or _MODULE_LOG_LEVEL
|
||||
_MODULE_LOGGER.log(
|
||||
effective_level,
|
||||
f"CALL {func.__qualname__} args={_format_payload(args[1:] if args else ())} kwargs={_format_payload(kwargs)}",
|
||||
)
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
except Exception:
|
||||
_MODULE_LOGGER.exception(f"FAIL {func.__qualname__}")
|
||||
raise
|
||||
_MODULE_LOGGER.log(effective_level, f"RETURN {func.__qualname__}")
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
def _log_sql(query_name: str, sql: str, params: dict[str, Any]):
|
||||
"""Log one SQL statement and its parameters."""
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"SQL {query_name} params={_format_payload(params)}")
|
||||
_MODULE_LOGGER.debug(f"SQL {query_name} text:\n{sql.strip()}")
|
||||
|
||||
|
||||
def _log_dataset(query_name: str, rows: list[Any]):
|
||||
"""Log query results at summary or full-debug level depending on the flag."""
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"SQL {query_name} returned {len(rows)} rows")
|
||||
if SCARICO_LOG_MODE.upper() == "DEBUG":
|
||||
_MODULE_LOGGER.debug(f"SQL {query_name} dataset:\n{_format_payload(rows)}")
|
||||
|
||||
|
||||
_configure_module_logger()
|
||||
if _MODULE_LOG_ENABLED:
|
||||
_MODULE_LOGGER.info(
|
||||
f"Logging inizializzato su {MODULE_LOG_PATH.name} livello={_MODULE_LOG_LEVEL} mode={SCARICO_LOG_MODE.upper()}"
|
||||
)
|
||||
|
||||
|
||||
SQL_UDC_IN_CELLA = """
|
||||
WITH cell_pallets AS (
|
||||
SELECT DISTINCT
|
||||
g.BarcodePallet
|
||||
FROM dbo.XMag_GiacenzaPallet g
|
||||
WHERE g.IDCella = :idcella
|
||||
),
|
||||
last_in_cell AS (
|
||||
SELECT
|
||||
mp.Attributo AS BarcodePallet,
|
||||
MAX(mp.ID) AS LastID
|
||||
FROM dbo.MagazziniPallet mp
|
||||
JOIN cell_pallets cp
|
||||
ON cp.BarcodePallet COLLATE Latin1_General_CI_AS =
|
||||
mp.Attributo COLLATE Latin1_General_CI_AS
|
||||
WHERE mp.IDCella = :idcella
|
||||
AND mp.Tipo = 'V'
|
||||
GROUP BY mp.Attributo
|
||||
),
|
||||
last_move AS (
|
||||
SELECT
|
||||
mp.Attributo AS BarcodePallet,
|
||||
mp.ID,
|
||||
mp.DataMagazzino
|
||||
FROM dbo.MagazziniPallet mp
|
||||
JOIN last_in_cell lic ON lic.LastID = mp.ID
|
||||
),
|
||||
closed_plist AS (
|
||||
SELECT DISTINCT
|
||||
shipped.BarcodePallet
|
||||
FROM dbo.XMag_GiacenzaPalletPlistChiuse shipped
|
||||
JOIN cell_pallets cp
|
||||
ON cp.BarcodePallet COLLATE Latin1_General_CI_AS =
|
||||
shipped.BarcodePallet COLLATE Latin1_General_CI_AS
|
||||
)
|
||||
SELECT
|
||||
cp.BarcodePallet AS UDC,
|
||||
lm.ID AS SourceID,
|
||||
lm.DataMagazzino AS LastEventAt,
|
||||
:idcella AS CurrentIDCella,
|
||||
CASE
|
||||
WHEN :idcella <> 9999
|
||||
AND closed_plist.BarcodePallet IS NOT NULL
|
||||
THEN CAST(1 AS int)
|
||||
ELSE CAST(0 AS int)
|
||||
END AS IsMissingUnload
|
||||
FROM cell_pallets cp
|
||||
LEFT JOIN last_move lm
|
||||
ON lm.BarcodePallet COLLATE Latin1_General_CI_AS =
|
||||
cp.BarcodePallet COLLATE Latin1_General_CI_AS
|
||||
LEFT JOIN closed_plist
|
||||
ON closed_plist.BarcodePallet COLLATE Latin1_General_CI_AS =
|
||||
cp.BarcodePallet COLLATE Latin1_General_CI_AS
|
||||
ORDER BY
|
||||
lm.ID DESC,
|
||||
cp.BarcodePallet DESC;
|
||||
"""
|
||||
|
||||
|
||||
SQL_SCARICA_UDC = """
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @Now datetime = GETDATE();
|
||||
DECLARE @SourceID int = 0;
|
||||
DECLARE @NumeroPallet int = 0;
|
||||
DECLARE @PesoUnitario float = 1;
|
||||
DECLARE @Tara float = 0;
|
||||
DECLARE @SourceIDCella int = 0;
|
||||
|
||||
SELECT TOP (1)
|
||||
@SourceID = src.ID,
|
||||
@NumeroPallet = ISNULL(src.NumeroPallet, 0),
|
||||
@PesoUnitario = ISNULL(NULLIF(src.PesoUnitario, 0), 1),
|
||||
@Tara = ISNULL(src.Tara, 0),
|
||||
@SourceIDCella = ISNULL(src.IDCella, 0)
|
||||
FROM dbo.MagazziniPallet src
|
||||
WHERE src.Attributo = :barcode_pallet
|
||||
AND src.Tipo = 'V'
|
||||
AND src.PesoUnitario > 0
|
||||
ORDER BY src.ID DESC;
|
||||
|
||||
IF @SourceID > 0
|
||||
BEGIN
|
||||
UPDATE dbo.MagazziniPallet
|
||||
SET ModUtente = :utente,
|
||||
ModDataOra = @Now
|
||||
WHERE ID = @SourceID;
|
||||
|
||||
INSERT INTO dbo.MagazziniPallet (
|
||||
Tipo,
|
||||
IDRiferimento,
|
||||
NumeroPallet,
|
||||
Attributo,
|
||||
IDMagazzino,
|
||||
IDArea,
|
||||
IDCella,
|
||||
DataMagazzino,
|
||||
PesoUnitario,
|
||||
Tara,
|
||||
InsUtente,
|
||||
InsDataOra
|
||||
)
|
||||
SELECT
|
||||
'P',
|
||||
@SourceID,
|
||||
ISNULL(src.NumeroPallet, 0),
|
||||
src.Attributo,
|
||||
src.IDMagazzino,
|
||||
src.IDArea,
|
||||
src.IDCella,
|
||||
@Now,
|
||||
ISNULL(NULLIF(src.PesoUnitario, 0), 1),
|
||||
ISNULL(src.Tara, 0),
|
||||
:utente,
|
||||
@Now
|
||||
FROM dbo.MagazziniPallet src
|
||||
WHERE src.ID = @SourceID;
|
||||
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = :utente,
|
||||
ModDataOra = @Now
|
||||
WHERE ID = @SourceIDCella;
|
||||
END;
|
||||
|
||||
INSERT INTO dbo.MagazziniPallet (
|
||||
Tipo,
|
||||
IDRiferimento,
|
||||
NumeroPallet,
|
||||
Attributo,
|
||||
IDMagazzino,
|
||||
IDArea,
|
||||
IDCella,
|
||||
DataMagazzino,
|
||||
PesoUnitario,
|
||||
Tara,
|
||||
InsUtente,
|
||||
InsDataOra
|
||||
)
|
||||
SELECT
|
||||
'V',
|
||||
@SourceID,
|
||||
@NumeroPallet,
|
||||
:barcode_pallet,
|
||||
target.IDMagazzino,
|
||||
target.IDArea,
|
||||
target.ID,
|
||||
@Now,
|
||||
@PesoUnitario,
|
||||
@Tara,
|
||||
:utente,
|
||||
@Now
|
||||
FROM (
|
||||
SELECT c.ID, c.IDArea, a.IDMagazzino
|
||||
FROM dbo.Celle c
|
||||
JOIN dbo.Aree a ON a.ID = c.IDArea
|
||||
WHERE c.ID = :target_idcella
|
||||
) AS target;
|
||||
|
||||
EXEC dbo.py_sp_ControllaPrenotazionePackingListPalletNew;
|
||||
|
||||
SELECT
|
||||
CAST(1 AS int) AS Ok,
|
||||
@SourceID AS SourceID,
|
||||
:target_idcella AS TargetIDCella,
|
||||
:target_barcode_cella AS TargetBarcodeCella;
|
||||
"""
|
||||
|
||||
|
||||
async def move_pallet_async(
|
||||
db_client,
|
||||
*,
|
||||
barcode_pallet: str,
|
||||
target_idcella: int,
|
||||
target_barcode_cella: str,
|
||||
utente: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Move one pallet to a target cell using the same movement semantics as the legacy app.
|
||||
|
||||
The original C# application delegates load, transfer and unload to
|
||||
``sp_xMagGestioneMagazziniPallet``. The Python app mirrors the same
|
||||
behavior with an explicit SQL batch that:
|
||||
1. finds the latest positive row for the pallet,
|
||||
2. registers a compensating ``P`` move on the source cell,
|
||||
3. frees the previous cell reservation,
|
||||
4. inserts a new ``V`` move on the target cell,
|
||||
5. re-runs the packing-list reservation check.
|
||||
"""
|
||||
params = {
|
||||
"barcode_pallet": str(barcode_pallet or "").strip(),
|
||||
"target_idcella": int(target_idcella),
|
||||
"target_barcode_cella": str(target_barcode_cella or "").strip(),
|
||||
"utente": str((utente or DEFAULT_SCARICO_USER) or "warehouse_ui").strip(),
|
||||
}
|
||||
_log_sql("move_pallet", SQL_SCARICA_UDC, params)
|
||||
res = await db_client.query_json(SQL_SCARICA_UDC, params, commit=True)
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
_log_dataset("move_pallet", rows)
|
||||
first = rows[0] if rows else [1, 0, params["target_idcella"], params["target_barcode_cella"]]
|
||||
return {
|
||||
"ok": int(first[0] or 0),
|
||||
"source_id": int(first[1] or 0),
|
||||
"target_idcella": int(first[2] or 0),
|
||||
"target_barcode_cella": str(first[3] or ""),
|
||||
"barcode_pallet": params["barcode_pallet"],
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScaricoRow:
|
||||
"""View-model describing one unloadable UDC currently present in a cell."""
|
||||
|
||||
udc: str
|
||||
source_id: int | None
|
||||
last_event_at: str
|
||||
current_idcella: int
|
||||
diagnostic_note: str
|
||||
selected: tk.BooleanVar
|
||||
|
||||
|
||||
def _build_diagnostic_note(is_missing_unload: int | bool = False) -> str:
|
||||
"""Translate low-level anomaly flags into one operator-facing note."""
|
||||
|
||||
if bool(is_missing_unload):
|
||||
return "Motivo: spedita ma non scaricata dalla cella"
|
||||
return ""
|
||||
|
||||
|
||||
def _is_missing_unload_row(row: ScaricoRow) -> bool:
|
||||
"""Return True when the row must be corrected only with shipped unload."""
|
||||
|
||||
return "spedita ma non scaricata dalla cella" in str(row.diagnostic_note or "").lower()
|
||||
|
||||
|
||||
class ScaricoDialog(ctk.CTkToplevel):
|
||||
"""Modal dialog that allows unloading selected UDCs from one cell."""
|
||||
|
||||
CHECKBOX_COL_W = 56
|
||||
UDC_COL_W = 130
|
||||
DATE_COL_W = 180
|
||||
DIAG_COL_W = 320
|
||||
|
||||
@_log_call()
|
||||
def __init__(
|
||||
self,
|
||||
parent: tk.Misc,
|
||||
*,
|
||||
db_client,
|
||||
idcella: int,
|
||||
ubicazione: str,
|
||||
on_completed: Callable[[], None] | None = None,
|
||||
session: UserSession | None = None,
|
||||
):
|
||||
super().__init__(parent)
|
||||
self.parent = parent
|
||||
self.db_client = db_client
|
||||
self.idcella = idcella
|
||||
self.ubicazione = ubicazione
|
||||
self.on_completed = on_completed
|
||||
self.session = session
|
||||
self.rows: list[ScaricoRow] = []
|
||||
self._theme = theme_section("scarico_dialog", {})
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self._busy = InlineBusyOverlay(self, self._theme)
|
||||
self._async = AsyncRunner(self)
|
||||
self.rows_tree: ttk.Treeview | None = None
|
||||
|
||||
self.title(versioned_title(loc_text("scarico.title", catalog=self._locale_catalog, default="Scarica {ubicazione}").format(ubicazione=ubicazione), __name__))
|
||||
self.resizable(False, False)
|
||||
self.transient(parent)
|
||||
self.protocol("WM_DELETE_WINDOW", self._close)
|
||||
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
self.grid_rowconfigure(1, weight=1)
|
||||
|
||||
self._build_ui()
|
||||
self._load_rows()
|
||||
|
||||
self.update_idletasks()
|
||||
self.grab_set()
|
||||
try:
|
||||
self.wait_visibility()
|
||||
except Exception:
|
||||
pass
|
||||
if self.winfo_exists():
|
||||
self.lift()
|
||||
self.focus_force()
|
||||
|
||||
def _build_ui(self):
|
||||
"""Build the compact modal layout."""
|
||||
top = ctk.CTkFrame(self)
|
||||
top.grid(row=0, column=0, sticky="ew", padx=10, pady=(10, 6))
|
||||
top.grid_columnconfigure(0, weight=1)
|
||||
ctk.CTkLabel(
|
||||
top,
|
||||
text=loc_text("scarico.label.location", catalog=self._locale_catalog, default="Ubicazione: {ubicazione}").format(ubicazione=self.ubicazione),
|
||||
font=theme_font(self._theme, "header_font", ("Segoe UI", 13, "bold")),
|
||||
).grid(
|
||||
row=0, column=0, sticky="w"
|
||||
)
|
||||
ctk.CTkLabel(
|
||||
top,
|
||||
text=loc_text("scarico.label.select", catalog=self._locale_catalog, default="Seleziona le UDC da scaricare"),
|
||||
anchor="w",
|
||||
font=theme_font(self._theme, "body_font", ("Segoe UI", 10)),
|
||||
).grid(
|
||||
row=1, column=0, sticky="w", pady=(4, 0)
|
||||
)
|
||||
|
||||
table = ctk.CTkFrame(self)
|
||||
table.grid(row=1, column=0, sticky="nsew", padx=10, pady=(0, 8))
|
||||
table.grid_rowconfigure(0, weight=1)
|
||||
table.grid_columnconfigure(0, weight=1)
|
||||
|
||||
tree_host = tk.Frame(table, bd=0, highlightthickness=0, background="#DBDBDB")
|
||||
tree_host.grid(row=0, column=0, sticky="nsew", padx=8, pady=(8, 8))
|
||||
tree_host.grid_rowconfigure(0, weight=1)
|
||||
tree_host.grid_columnconfigure(0, weight=1)
|
||||
|
||||
self.rows_tree = ttk.Treeview(
|
||||
tree_host,
|
||||
columns=("sel", "udc", "last", "diag"),
|
||||
show="headings",
|
||||
style="Scarico.Treeview",
|
||||
selectmode="none",
|
||||
)
|
||||
style_treeview(
|
||||
self.rows_tree,
|
||||
style_name="Scarico.Treeview",
|
||||
rowheight=28,
|
||||
font=theme_font(self._theme, "tree_body_font", ("Segoe UI", 10)),
|
||||
heading_font=theme_font(self._theme, "tree_heading_font", ("Segoe UI", 10, "bold")),
|
||||
)
|
||||
self.rows_tree.heading("sel", text="Sel")
|
||||
self.rows_tree.heading("udc", text=loc_text("scarico.col.udc", catalog=self._locale_catalog, default="UDC"))
|
||||
self.rows_tree.heading("last", text=loc_text("scarico.col.last_insert", catalog=self._locale_catalog, default="Ultimo inserimento"))
|
||||
self.rows_tree.heading("diag", text=loc_text("scarico.col.diagnostic", catalog=self._locale_catalog, default="Diagnostica"))
|
||||
self.rows_tree.column("sel", width=self.CHECKBOX_COL_W, stretch=False, anchor="center")
|
||||
self.rows_tree.column("udc", width=self.UDC_COL_W, stretch=False, anchor="w")
|
||||
self.rows_tree.column("last", width=self.DATE_COL_W, stretch=False, anchor="w")
|
||||
self.rows_tree.column("diag", width=self.DIAG_COL_W, stretch=True, anchor="w")
|
||||
self.rows_tree.grid(row=0, column=0, sticky="nsew")
|
||||
self.rows_tree.bind("<Button-1>", self._on_tree_click, add="+")
|
||||
|
||||
tree_scroll = ttk.Scrollbar(tree_host, orient="vertical", command=self.rows_tree.yview)
|
||||
tree_scroll.grid(row=0, column=1, sticky="ns")
|
||||
self.rows_tree.configure(yscrollcommand=tree_scroll.set)
|
||||
|
||||
actions = ctk.CTkFrame(self)
|
||||
actions.grid(row=2, column=0, sticky="ew", padx=10, pady=(0, 10))
|
||||
actions.grid_columnconfigure(0, weight=1)
|
||||
ctk.CTkButton(
|
||||
actions,
|
||||
text=loc_text("scarico.button.shipped", catalog=self._locale_catalog, default="Scarico come spedita"),
|
||||
command=self._on_scarica_spedita,
|
||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(
|
||||
row=0, column=1, padx=(8, 0), pady=8
|
||||
)
|
||||
ctk.CTkButton(
|
||||
actions,
|
||||
text=loc_text("scarico.button.non_shelved", catalog=self._locale_catalog, default="Scarico come non scaff."),
|
||||
command=self._on_scarica_non_scaff,
|
||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(
|
||||
row=0, column=2, padx=(8, 0), pady=8
|
||||
)
|
||||
ctk.CTkButton(
|
||||
actions,
|
||||
text=loc_text("scarico.button.close", catalog=self._locale_catalog, default="Chiudi"),
|
||||
command=self._close,
|
||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(
|
||||
row=0, column=3, padx=(8, 8), pady=8
|
||||
)
|
||||
|
||||
def _render_rows(self):
|
||||
"""Recreate the compact list of unloadable UDC rows."""
|
||||
if self.rows_tree is None:
|
||||
return
|
||||
for item in self.rows_tree.get_children():
|
||||
self.rows_tree.delete(item)
|
||||
|
||||
for idx, row in enumerate(self.rows):
|
||||
self.rows_tree.insert(
|
||||
"",
|
||||
"end",
|
||||
iid=str(idx),
|
||||
values=(
|
||||
"[x]" if row.selected.get() else "[ ]",
|
||||
row.udc,
|
||||
row.last_event_at,
|
||||
row.diagnostic_note or "",
|
||||
),
|
||||
tags=(zebra_tag(idx),),
|
||||
)
|
||||
|
||||
self.update_idletasks()
|
||||
width = max(900, min(1040, self.winfo_reqwidth() + 20))
|
||||
total_height = max(210, min(460, self.winfo_reqheight() + 8))
|
||||
self.geometry(f"{width}x{total_height}")
|
||||
|
||||
def _on_tree_click(self, event):
|
||||
"""Toggle the pseudo-checkbox when the operator clicks the first column."""
|
||||
|
||||
if self.rows_tree is None:
|
||||
return
|
||||
region = self.rows_tree.identify("region", event.x, event.y)
|
||||
if region != "cell":
|
||||
return
|
||||
column = self.rows_tree.identify_column(event.x)
|
||||
item_id = self.rows_tree.identify_row(event.y)
|
||||
if column != "#1" or not item_id:
|
||||
return
|
||||
try:
|
||||
row = self.rows[int(item_id)]
|
||||
except Exception:
|
||||
return
|
||||
row.selected.set(not row.selected.get())
|
||||
self.rows_tree.set(item_id, "sel", "[x]" if row.selected.get() else "[ ]")
|
||||
return "break"
|
||||
|
||||
@_log_call()
|
||||
def _load_rows(self):
|
||||
"""Load the list of current UDCs ordered from newest to oldest."""
|
||||
params = {"idcella": self.idcella}
|
||||
_log_sql("scarico_load_rows", SQL_UDC_IN_CELLA, params)
|
||||
|
||||
def _ok(res):
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
_log_dataset("scarico_load_rows", rows)
|
||||
self.rows = []
|
||||
for (
|
||||
udc,
|
||||
source_id,
|
||||
last_event_at,
|
||||
current_idcella,
|
||||
is_missing_unload,
|
||||
) in rows:
|
||||
if isinstance(last_event_at, datetime):
|
||||
last_event = last_event_at.strftime("%d/%m/%Y %H:%M:%S")
|
||||
else:
|
||||
last_event = str(last_event_at or "")
|
||||
self.rows.append(
|
||||
ScaricoRow(
|
||||
udc=str(udc or ""),
|
||||
source_id=int(source_id) if source_id is not None else None,
|
||||
last_event_at=last_event,
|
||||
current_idcella=int(current_idcella or 0),
|
||||
diagnostic_note=_build_diagnostic_note(is_missing_unload),
|
||||
selected=tk.BooleanVar(value=False),
|
||||
)
|
||||
)
|
||||
self._render_rows()
|
||||
self._busy.hide()
|
||||
|
||||
def _err(ex):
|
||||
self._busy.hide()
|
||||
_MODULE_LOGGER.exception(f"Errore caricamento righe scarico idcella={self.idcella}: {ex}")
|
||||
messagebox.showerror(
|
||||
loc_text("scarico.msg.title", catalog=self._locale_catalog, default="Scarica"),
|
||||
loc_text("scarico.msg.load_error", catalog=self._locale_catalog, default="Caricamento UDC fallito:\n{error}").format(error=ex),
|
||||
parent=self,
|
||||
exception=ex,
|
||||
)
|
||||
self._close()
|
||||
|
||||
self._async.run(
|
||||
self.db_client.query_json(SQL_UDC_IN_CELLA, params),
|
||||
_ok,
|
||||
_err,
|
||||
busy=self._busy,
|
||||
message="Carico UDC...",
|
||||
)
|
||||
|
||||
@_log_call()
|
||||
def _selected_rows_or_warn(self) -> list[ScaricoRow] | None:
|
||||
"""Return selected rows or show the standard selection warning."""
|
||||
|
||||
selected = [row for row in self.rows if row.selected.get()]
|
||||
if not selected:
|
||||
messagebox.showinfo(
|
||||
loc_text("scarico.msg.title", catalog=self._locale_catalog, default="Scarica"),
|
||||
loc_text("scarico.msg.select_one", catalog=self._locale_catalog, default="Seleziona almeno una UDC da scaricare."),
|
||||
parent=self,
|
||||
)
|
||||
return selected
|
||||
|
||||
@_log_call()
|
||||
def _on_scarica_spedita(self):
|
||||
"""Unload selected UDCs to the shipped conventional location."""
|
||||
|
||||
self._scarica_selected_to_target(
|
||||
target_idcella=SHIPPED_IDCELLA,
|
||||
target_barcode_cella=SHIPPED_BARCODE,
|
||||
target_label=SHIPPED_LABEL,
|
||||
title="Scarico come spedita",
|
||||
confirm_text="Scaricare come spedite {count} UDC da {ubicazione}?",
|
||||
busy_message="Scarico UDC come spedite...",
|
||||
block_shipped_for_non_scaff=False,
|
||||
)
|
||||
|
||||
@_log_call()
|
||||
def _on_scarica_non_scaff(self):
|
||||
"""Unload selected UDCs to the non-shelved conventional location."""
|
||||
|
||||
self._scarica_selected_to_target(
|
||||
target_idcella=NON_SCAFF_IDCELLA,
|
||||
target_barcode_cella=NON_SCAFF_BARCODE,
|
||||
target_label=NON_SCAFF_LABEL,
|
||||
title="Scarico come non scaff.",
|
||||
confirm_text="Scaricare come non scaffalate {count} UDC da {ubicazione}?",
|
||||
busy_message="Scarico UDC come non scaffalate...",
|
||||
block_shipped_for_non_scaff=True,
|
||||
)
|
||||
|
||||
def _scarica_selected_to_target(
|
||||
self,
|
||||
*,
|
||||
target_idcella: int,
|
||||
target_barcode_cella: str,
|
||||
target_label: str,
|
||||
title: str,
|
||||
confirm_text: str,
|
||||
busy_message: str,
|
||||
block_shipped_for_non_scaff: bool,
|
||||
):
|
||||
"""Move selected UDCs to one conventional unload location."""
|
||||
|
||||
selected = self._selected_rows_or_warn()
|
||||
if not selected:
|
||||
return
|
||||
|
||||
shipped_rows: list[ScaricoRow] = []
|
||||
missing_unload_rows: list[ScaricoRow] = []
|
||||
movable_rows = list(selected)
|
||||
if block_shipped_for_non_scaff:
|
||||
shipped_rows = [
|
||||
row for row in selected
|
||||
if int(row.current_idcella or 0) == SHIPPED_IDCELLA
|
||||
]
|
||||
missing_unload_rows = [row for row in selected if _is_missing_unload_row(row)]
|
||||
blocked_udcs = {row.udc for row in shipped_rows + missing_unload_rows}
|
||||
movable_rows = [row for row in selected if row.udc not in blocked_udcs]
|
||||
|
||||
if (shipped_rows or missing_unload_rows) and not movable_rows:
|
||||
message_lines = ["Nessuna UDC movimentata."]
|
||||
if shipped_rows:
|
||||
message_lines.append(f"UDC gia' in {SHIPPED_LABEL}: " + ", ".join(row.udc for row in shipped_rows))
|
||||
if missing_unload_rows:
|
||||
message_lines.append(
|
||||
"UDC spedite ma non scaricate: "
|
||||
+ ", ".join(row.udc for row in missing_unload_rows)
|
||||
)
|
||||
message_lines.append("Usare 'Scarico come spedita'.")
|
||||
messagebox.showwarning(
|
||||
title,
|
||||
"\n".join(message_lines),
|
||||
parent=self,
|
||||
)
|
||||
return
|
||||
|
||||
if not messagebox.askyesno(
|
||||
title,
|
||||
confirm_text.format(count=len(movable_rows), ubicazione=self.ubicazione),
|
||||
parent=self,
|
||||
):
|
||||
return
|
||||
|
||||
async def _job():
|
||||
results: list[dict[str, Any]] = []
|
||||
for row in movable_rows:
|
||||
result = await move_pallet_async(
|
||||
self.db_client,
|
||||
barcode_pallet=row.udc,
|
||||
target_idcella=target_idcella,
|
||||
target_barcode_cella=target_barcode_cella,
|
||||
utente=_session_login(self.session),
|
||||
)
|
||||
results.append({"udc": row.udc, "affected": int(result.get("ok") or 0)})
|
||||
return results
|
||||
|
||||
def _ok(results):
|
||||
_log_dataset("scarica_udc", results)
|
||||
done = [item["udc"] for item in results if int(item.get("affected") or 0) > 0]
|
||||
skipped = [item["udc"] for item in results if int(item.get("affected") or 0) <= 0]
|
||||
if not done:
|
||||
messagebox.showwarning(
|
||||
title,
|
||||
"Nessuna UDC e' stata scaricata. Verifica che le unita' siano ancora presenti in cella.",
|
||||
parent=self,
|
||||
)
|
||||
return
|
||||
if skipped:
|
||||
shipped_note = (
|
||||
f"\nGia' in {SHIPPED_LABEL} non toccate: " + ", ".join(row.udc for row in shipped_rows)
|
||||
if shipped_rows
|
||||
else ""
|
||||
)
|
||||
missing_unload_note = (
|
||||
"\nSpedite ma non scaricate, usare 'Scarico come spedita': "
|
||||
+ ", ".join(row.udc for row in missing_unload_rows)
|
||||
if missing_unload_rows
|
||||
else ""
|
||||
)
|
||||
target_note = (
|
||||
f"\nUDC in {target_label}: " + ", ".join(done)
|
||||
if done
|
||||
else ""
|
||||
)
|
||||
messagebox.showwarning(
|
||||
title,
|
||||
"Scarico parziale.\nCompletate: "
|
||||
+ ", ".join(done)
|
||||
+ "\nNon scaricate: "
|
||||
+ ", ".join(skipped)
|
||||
+ shipped_note
|
||||
+ missing_unload_note
|
||||
+ target_note,
|
||||
parent=self,
|
||||
)
|
||||
else:
|
||||
msg = f"Scarico completato verso {target_label} per:\n" + "\n".join(done)
|
||||
if shipped_rows:
|
||||
msg += f"\n\nUDC gia' in {SHIPPED_LABEL} non toccate:\n" + "\n".join(row.udc for row in shipped_rows)
|
||||
msg += f"\n\nUDC in {target_label}: " + ", ".join(done)
|
||||
if missing_unload_rows:
|
||||
msg += (
|
||||
"\n\nUDC spedite ma non scaricate non toccate:\n"
|
||||
+ "\n".join(row.udc for row in missing_unload_rows)
|
||||
+ "\nUsare 'Scarico come spedita'."
|
||||
)
|
||||
messagebox.showinfo(title, msg, parent=self)
|
||||
log_user_action(
|
||||
self.session,
|
||||
module=MODULE_LOG_NAME,
|
||||
action="layout.scarico.spedita" if int(target_idcella) == SHIPPED_IDCELLA else "layout.scarico.non_scaff",
|
||||
outcome="ok",
|
||||
target=self.ubicazione,
|
||||
details={
|
||||
"scaricate": done,
|
||||
"saltate": skipped,
|
||||
"target_idcella": target_idcella,
|
||||
"target_barcode_cella": target_barcode_cella,
|
||||
"gia_spedite": [row.udc for row in shipped_rows],
|
||||
"spedite_non_scaricate": [row.udc for row in missing_unload_rows],
|
||||
},
|
||||
)
|
||||
if self.on_completed:
|
||||
self.on_completed()
|
||||
self._close()
|
||||
|
||||
def _err(ex):
|
||||
_MODULE_LOGGER.exception(f"Errore scarico idcella={self.idcella}: {ex}")
|
||||
log_user_action(
|
||||
self.session,
|
||||
module=MODULE_LOG_NAME,
|
||||
action="layout.scarico.spedita" if int(target_idcella) == SHIPPED_IDCELLA else "layout.scarico.non_scaff",
|
||||
outcome="error",
|
||||
target=self.ubicazione,
|
||||
details={"error": str(ex)},
|
||||
)
|
||||
messagebox.showerror(
|
||||
loc_text("scarico.msg.title", catalog=self._locale_catalog, default="Scarica"),
|
||||
loc_text("scarico.msg.exec_error", catalog=self._locale_catalog, default="Scarico fallito:\n{error}").format(error=ex),
|
||||
parent=self,
|
||||
exception=ex,
|
||||
)
|
||||
|
||||
self._async.run(
|
||||
_job(),
|
||||
_ok,
|
||||
_err,
|
||||
busy=self._busy,
|
||||
message=busy_message,
|
||||
)
|
||||
|
||||
@_log_call()
|
||||
def _close(self):
|
||||
"""Release the modal grab and close the dialog safely."""
|
||||
try:
|
||||
self.grab_release()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@_log_call()
|
||||
def open_scarico_dialog(
|
||||
parent: tk.Misc,
|
||||
*,
|
||||
db_client,
|
||||
idcella: int,
|
||||
ubicazione: str,
|
||||
on_completed: Callable[[], None] | None = None,
|
||||
session: UserSession | None = None,
|
||||
) -> ScaricoDialog:
|
||||
"""Create and return the modal unload dialog for one multi-UDC cell."""
|
||||
return ScaricoDialog(
|
||||
parent,
|
||||
db_client=db_client,
|
||||
idcella=idcella,
|
||||
ubicazione=ubicazione,
|
||||
on_completed=on_completed,
|
||||
session=session,
|
||||
)
|
||||
269
inventario.py
Normal file
269
inventario.py
Normal file
@@ -0,0 +1,269 @@
|
||||
"""Dated inventory reconciliation window, using the shared desktop UI lifecycle."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import tkinter as tk
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
import error_dialog as messagebox
|
||||
from tkinter import filedialog, ttk
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from gestione_aree import AsyncRunner
|
||||
from inventory_service import (DETAIL_KEYS, LOT_KEYS, SUMMARY_KEYS, detail_values,
|
||||
export_inventory, inventory_cutoff, load_inventory, status_text)
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from runtime_support import log_exception
|
||||
from ui_tables import style_treeview, zebra_tag
|
||||
from ui_theme import theme_color, theme_font, theme_section, theme_value
|
||||
from version_info import module_version, versioned_title
|
||||
from window_placement import place_window_fullsize_below_parent_later
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
KEYS = SUMMARY_KEYS
|
||||
|
||||
|
||||
def display_number(value) -> str:
|
||||
"""Keep zeros visible and unknown values distinct from numeric stock."""
|
||||
if value is None:
|
||||
return "?"
|
||||
if isinstance(value, Decimal):
|
||||
return format(value, "f").rstrip("0").rstrip(".") if value.as_tuple().exponent < 0 else str(value)
|
||||
return str(value)
|
||||
|
||||
|
||||
class InventarioWindow(ctk.CTkToplevel):
|
||||
"""Read-only, single-instance launcher child; DB and XLSX work are asynchronous."""
|
||||
|
||||
def __init__(self, parent, db_client, session=None):
|
||||
super().__init__(parent)
|
||||
self.db_client = db_client
|
||||
self.session = session
|
||||
self._catalog = load_locale_catalog()
|
||||
self._theme = theme_section("inventory_window", theme_section("search_window", {}))
|
||||
self._async = AsyncRunner(self)
|
||||
self._busy = InlineBusyOverlay(self, self._theme)
|
||||
self._loading = False
|
||||
self._report = None
|
||||
self._sort_column = "Product"
|
||||
self._descending = False
|
||||
self._rows = []
|
||||
self.var_date = tk.StringVar(value=date.today().strftime("%d/%m/%Y"))
|
||||
self.var_status = tk.StringVar(value=self._t("inventory.ready"))
|
||||
self.title(versioned_title(self._t("inventory.title"), __name__))
|
||||
self.geometry(str(theme_value(self._theme, "window_geometry", "1200x720")))
|
||||
self.minsize(*theme_value(self._theme, "window_minsize", [900, 560]))
|
||||
self.configure(fg_color=theme_color(self._theme, "window_fg_color", ["#efefef", "#2f2f2f"]))
|
||||
self._build_ui()
|
||||
|
||||
def _t(self, key: str) -> str:
|
||||
return loc_text(key, catalog=self._catalog, default=key)
|
||||
|
||||
def _build_ui(self):
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
self.grid_rowconfigure(3, weight=3, minsize=120)
|
||||
self.grid_rowconfigure(5, weight=1, minsize=150)
|
||||
top = ctk.CTkFrame(self, fg_color=theme_color(self._theme, "toolbar_frame_fg_color", "#d7d7d7"))
|
||||
top.grid(row=0, column=0, sticky="ew", padx=8, pady=8)
|
||||
top.grid_columnconfigure(3, weight=1)
|
||||
font = theme_font(self._theme, "toolbar_button_font", ("Segoe UI", 11, "bold"))
|
||||
ctk.CTkLabel(top, text=self._t("inventory.date"), font=font).grid(row=0, column=0, padx=6)
|
||||
self.date_entry = ctk.CTkEntry(top, textvariable=self.var_date, width=130)
|
||||
self.date_entry.grid(row=0, column=1, padx=6)
|
||||
self.date_entry.bind("<Return>", lambda _: self._load())
|
||||
self.btn_load = ctk.CTkButton(top, text=self._t("inventory.load"), command=self._load, font=font)
|
||||
self.btn_load.grid(row=0, column=2, padx=6)
|
||||
self.btn_export = ctk.CTkButton(top, text=self._t("inventory.export"), command=self._export,
|
||||
font=font, state="disabled")
|
||||
self.btn_export.grid(row=0, column=4, padx=6)
|
||||
self._build_legend()
|
||||
ctk.CTkLabel(self, textvariable=self.var_status, anchor="w", justify="left",
|
||||
wraplength=1000).grid(row=2, column=0, sticky="ew", padx=10, pady=5)
|
||||
self.tree = self._make_tree(3, KEYS)
|
||||
self.tree.bind("<<TreeviewSelect>>", self._select)
|
||||
ctk.CTkLabel(self, text=self._t("inventory.detail"), anchor="w").grid(row=4, column=0, sticky="ew", padx=10)
|
||||
tabs = ttk.Notebook(self)
|
||||
tabs.grid(row=5, column=0, sticky="nsew", padx=8, pady=(0, 8))
|
||||
lot_page, detail_page = ttk.Frame(tabs), ttk.Frame(tabs)
|
||||
for page in (lot_page, detail_page):
|
||||
page.grid_rowconfigure(0, weight=1)
|
||||
page.grid_columnconfigure(0, weight=1)
|
||||
tabs.add(lot_page, text=self._t("inventory.lot_sheet"))
|
||||
tabs.add(detail_page, text=self._t("inventory.detail_sheet"))
|
||||
self.lot_tree = self._make_tree(0, LOT_KEYS, lot_page)
|
||||
self.detail_tree = self._make_tree(0, DETAIL_KEYS, detail_page)
|
||||
|
||||
def _build_legend(self):
|
||||
"""Keep component definitions visible independently of calculation status."""
|
||||
self.legend = ctk.CTkFrame(self, fg_color=theme_color(
|
||||
self._theme, "legend_fg_color", ["#f8fafb", "#262b30"]))
|
||||
self.legend.grid(row=1, column=0, sticky="ew", padx=8, pady=(0, 4))
|
||||
self.legend.grid_columnconfigure(1, weight=1)
|
||||
normal = theme_font(self._theme, "legend_font", ("Segoe UI", 13))
|
||||
bold = theme_font(self._theme, "legend_heading_font", ("Segoe UI", 13, "bold"))
|
||||
color = theme_color(self._theme, "legend_text_color", ["#202830", "#f1f3f5"])
|
||||
self.legend_labels = {}
|
||||
self.legend_descriptions = []
|
||||
for row, component in enumerate(("A", "B", "C", "X")):
|
||||
label = ctk.CTkLabel(self.legend, text=component + ":", font=bold,
|
||||
text_color=color, anchor="nw", height=20)
|
||||
label.grid(row=row, column=0, sticky="nw", padx=(10, 8), pady=1)
|
||||
self.legend_labels[component] = label
|
||||
description = ctk.CTkLabel(self.legend, text=self._t("inventory.legend." + component),
|
||||
font=normal, text_color=color, anchor="w", justify="left", wraplength=800, height=20)
|
||||
description.grid(row=row, column=1, sticky="ew", padx=(0, 10), pady=1)
|
||||
self.legend_descriptions.append(description)
|
||||
self.legend_notes = []
|
||||
for row, key in enumerate(("formula", "scope", "history_notice"), start=4):
|
||||
label = ctk.CTkLabel(self.legend, text=self._t("inventory." + key),
|
||||
font=bold if key == "formula" else normal, text_color=color,
|
||||
anchor="w", justify="left", wraplength=850, height=20)
|
||||
label.grid(row=row, column=0, columnspan=2, sticky="ew", padx=10, pady=1)
|
||||
self.legend_notes.append(label)
|
||||
self.legend.bind("<Configure>", self._resize_legend, add="+")
|
||||
|
||||
def _resize_legend(self, event):
|
||||
"""Wrap to the actual window width, including on smaller desktops."""
|
||||
for label in self.legend_descriptions:
|
||||
label.configure(wraplength=max(200, event.width - 65))
|
||||
for label in self.legend_notes:
|
||||
label.configure(wraplength=max(200, event.width - 24))
|
||||
|
||||
def _make_tree(self, row, keys, parent=None):
|
||||
wrap = ctk.CTkFrame(parent if parent is not None else self)
|
||||
wrap.grid(row=row, column=0, sticky="nsew", padx=8, pady=(0, 8))
|
||||
wrap.grid_columnconfigure(0, weight=1)
|
||||
wrap.grid_rowconfigure(0, weight=1)
|
||||
tree = ttk.Treeview(wrap, columns=keys, show="headings", selectmode="browse", height=5)
|
||||
style_treeview(tree, style_name="Inventory.Treeview", rowheight=24)
|
||||
tree.tag_configure("difference", foreground=theme_value(self._theme, "difference_color", "#9b3900"))
|
||||
tree.tag_configure("unknown", foreground=theme_value(self._theme, "unknown_color", "#aa0000"))
|
||||
for key in keys:
|
||||
tree.heading(key, text=self._t("inventory.col." + key))
|
||||
tree.column(key, width=250 if key in ("Description", "Status") else 120,
|
||||
anchor="e" if key in KEYS[3:-1] or key in ("Quantity", "SamQuantity") else "w")
|
||||
if keys == KEYS:
|
||||
tree.heading(key, command=lambda k=key: self._sort(k))
|
||||
sy = ttk.Scrollbar(wrap, orient="vertical", command=tree.yview)
|
||||
sx = ttk.Scrollbar(wrap, orient="horizontal", command=tree.xview)
|
||||
tree.configure(yscrollcommand=sy.set, xscrollcommand=sx.set)
|
||||
tree.grid(row=0, column=0, sticky="nsew")
|
||||
sy.grid(row=0, column=1, sticky="ns")
|
||||
sx.grid(row=1, column=0, sticky="ew")
|
||||
return tree
|
||||
|
||||
def _set_loading(self, value):
|
||||
self._loading = value
|
||||
state = "disabled" if value else "normal"
|
||||
self.btn_load.configure(state=state)
|
||||
self.date_entry.configure(state=state)
|
||||
self.btn_export.configure(state="normal" if not value and self._report and self._rows else "disabled")
|
||||
|
||||
def _load(self):
|
||||
if self._loading:
|
||||
return
|
||||
value = self.var_date.get()
|
||||
try:
|
||||
inventory_cutoff(value)
|
||||
except ValueError:
|
||||
messagebox.showerror(self._t("inventory.title"), self._t("inventory.bad_date"), parent=self)
|
||||
return
|
||||
self._report = None
|
||||
self._rows = []
|
||||
self.tree.delete(*self.tree.get_children())
|
||||
self.detail_tree.delete(*self.detail_tree.get_children())
|
||||
self.lot_tree.delete(*self.lot_tree.get_children())
|
||||
self.var_status.set(self._t("inventory.busy"))
|
||||
self._set_loading(True)
|
||||
self._async.run(load_inventory(self.db_client, value), self._loaded, self._error,
|
||||
busy=self._busy, message=self._t("inventory.busy"))
|
||||
|
||||
def _loaded(self, report):
|
||||
self._report = report
|
||||
self._rows = list(report.rows)
|
||||
self._set_loading(False)
|
||||
self._render()
|
||||
source = lambda key: str(report.metadata.get(key) or "?")[:10]
|
||||
self.var_status.set(self._t("inventory.loaded").format(
|
||||
date=report.selected_date.strftime("%d/%m/%Y"), count=len(report.rows),
|
||||
unknown=sum(bool(r["Issues"]) for r in report.rows),
|
||||
wms=source("WMS_MAX"), sam=source("SAM_MAX")))
|
||||
if report.selected_date == date.today():
|
||||
self.var_status.set(self.var_status.get() + "\n" + self._t("inventory.today"))
|
||||
|
||||
def _render(self):
|
||||
self.tree.delete(*self.tree.get_children())
|
||||
self.detail_tree.delete(*self.detail_tree.get_children())
|
||||
self.lot_tree.delete(*self.lot_tree.get_children())
|
||||
for index, row in enumerate(self._rows):
|
||||
tag = "unknown" if row["Issues"] else ("difference" if row["Difference"] else "")
|
||||
self.tree.insert("", "end", iid=str(index),
|
||||
values=[display_number(row[k]) for k in KEYS[:-1]] + [status_text(row, self._t)],
|
||||
tags=(zebra_tag(index), tag))
|
||||
|
||||
def _sort(self, key):
|
||||
if self._loading:
|
||||
return
|
||||
self._descending = not self._descending if self._sort_column == key else False
|
||||
self._sort_column = key
|
||||
def sort_value(row):
|
||||
value = status_text(row, self._t) if key == "Status" else row[key]
|
||||
return (value is None, value.casefold() if isinstance(value, str) else value if value is not None else ZERO_SORT)
|
||||
self._rows.sort(key=sort_value, reverse=self._descending)
|
||||
self._render()
|
||||
|
||||
def _select(self, _event=None):
|
||||
self.detail_tree.delete(*self.detail_tree.get_children())
|
||||
self.lot_tree.delete(*self.lot_tree.get_children())
|
||||
selected = self.tree.selection()
|
||||
if not selected or self._report is None:
|
||||
return
|
||||
product = self._rows[int(selected[0])]["Product"]
|
||||
for i, row in enumerate(r for r in self._report.lots if r["Product"] == product):
|
||||
self.lot_tree.insert("", "end",
|
||||
values=[display_number(row[k]) for k in LOT_KEYS[:-1]] + [status_text(row, self._t)],
|
||||
tags=(zebra_tag(i), "unknown" if row["Issues"] else "difference" if row["Difference"] else ""))
|
||||
details = [r for r in self._report.details if r["Product"] == product]
|
||||
for i, row in enumerate(details):
|
||||
self.detail_tree.insert("", "end", values=[display_number(v) for v in detail_values(row, self._t)],
|
||||
tags=(zebra_tag(i),))
|
||||
|
||||
def _error(self, error):
|
||||
self._set_loading(False)
|
||||
log_exception(__name__, error, context="inventory report/export")
|
||||
self.var_status.set(self._t("inventory.failed"))
|
||||
messagebox.showerror(self._t("inventory.title"), str(error), parent=self, exception=error)
|
||||
|
||||
def _export(self):
|
||||
if self._loading or not self._report or not self._rows:
|
||||
return
|
||||
report = self._report
|
||||
path = filedialog.asksaveasfilename(parent=self, defaultextension=".xlsx",
|
||||
filetypes=[("Excel", "*.xlsx")], initialfile=f"inventario_{report.selected_date:%Y%m%d}.xlsx")
|
||||
if not path:
|
||||
return
|
||||
self._set_loading(True)
|
||||
self._async.run(asyncio.to_thread(export_inventory, report, path,
|
||||
headers=[self._t("inventory.col." + k) for k in KEYS],
|
||||
detail_headers=[self._t("inventory.col." + k) for k in DETAIL_KEYS],
|
||||
translate=self._t, ordered_rows=list(self._rows)),
|
||||
lambda _: self._exported(path), self._error,
|
||||
busy=self._busy, message=self._t("inventory.export_busy"))
|
||||
|
||||
def _exported(self, path):
|
||||
self._set_loading(False)
|
||||
messagebox.showinfo(self._t("inventory.title"), self._t("inventory.exported").format(path=path), parent=self)
|
||||
|
||||
|
||||
ZERO_SORT = Decimal(0)
|
||||
|
||||
|
||||
def open_inventario_window(parent, db_client, session=None):
|
||||
"""Create the launcher-managed window with the same placement as other forms."""
|
||||
win = InventarioWindow(parent, db_client, session=session)
|
||||
place_window_fullsize_below_parent_later(parent, win)
|
||||
win.bind("<Escape>", lambda _: win.destroy())
|
||||
return win
|
||||
155
inventory_report.sql
Normal file
155
inventory_report.sql
Normal file
@@ -0,0 +1,155 @@
|
||||
-- Read-only runtime query: cutoff and sam_cutoff are exclusive next-day bounds.
|
||||
-- Writes only session-local temp tables; never alters SAM/WMS objects or stock.
|
||||
SET NOCOUNT ON;
|
||||
SET XACT_ABORT ON;
|
||||
SET LOCK_TIMEOUT 15000;
|
||||
DECLARE @cutoff datetime2 = :cutoff, @sam_cutoff float = :sam_cutoff;
|
||||
DECLARE @warehouse int;
|
||||
IF (SELECT COUNT(*) FROM SAMA1_Xwmstest.dbo.ANAMAG
|
||||
WHERE LTRIM(RTRIM(DESCR))='Magazzino Principale')<>1
|
||||
THROW 51200, 'Magazzino Principale SAM assente o ambiguo.', 1;
|
||||
SELECT @warehouse=ID FROM SAMA1_Xwmstest.dbo.ANAMAG
|
||||
WHERE LTRIM(RTRIM(DESCR))='Magazzino Principale';
|
||||
SELECT ID INTO #inv_slots FROM SAMA1_Xwmstest.dbo.ALLMAG WHERE IDANAMAG=@warehouse;
|
||||
CREATE UNIQUE CLUSTERED INDEX ix_slots ON #inv_slots(ID);
|
||||
|
||||
SELECT LTRIM(RTRIM(Attributo)) COLLATE DATABASE_DEFAULT AS Pallet, IDCella,
|
||||
SUM(CASE Tipo WHEN 'V' THEN CAST(PesoUnitario AS decimal(28,6))
|
||||
WHEN 'P' THEN -CAST(PesoUnitario AS decimal(28,6)) END) AS Balance
|
||||
INTO #inv_balance FROM dbo.MagazziniPallet
|
||||
WHERE DataMagazzino<@cutoff AND Tipo IN ('P','V')
|
||||
GROUP BY LTRIM(RTRIM(Attributo)),IDCella;
|
||||
CREATE INDEX ix_balance ON #inv_balance(Pallet);
|
||||
SELECT Pallet, COUNT(CASE WHEN Balance>0 THEN 1 END) AS Locations,
|
||||
COUNT(CASE WHEN Balance<0 THEN 1 END) AS NegativeBalances,
|
||||
MAX(CASE WHEN IDCella=9999 AND Balance>0 THEN 1 ELSE 0 END) AS Shipped
|
||||
INTO #inv_position FROM #inv_balance GROUP BY Pallet;
|
||||
CREATE UNIQUE CLUSTERED INDEX ix_position ON #inv_position(Pallet);
|
||||
SELECT b.*,CONCAT(RTRIM(c.Corsia),'.',RTRIM(c.Colonna),'.',RTRIM(c.Fila)) AS Location
|
||||
INTO #inv_stock FROM #inv_balance b
|
||||
JOIN dbo.Celle c ON c.ID=b.IDCella
|
||||
JOIN dbo.Aree a ON a.ID=c.IDArea
|
||||
JOIN dbo.Magazzini w ON w.ID=a.IDMagazzino
|
||||
WHERE b.Balance>0 AND (b.IDCella=1000 OR
|
||||
(b.IDCella<>9999 AND UPPER(RTRIM(w.Descrizione)) IN ('MDE5','MDE6')));
|
||||
CREATE INDEX ix_stock ON #inv_stock(Pallet);
|
||||
|
||||
-- First change AFTER cutoff supplies the OLD serial valid at cutoff.
|
||||
-- Same-timestamp ties have no ordering key: flag them instead of certifying them.
|
||||
SELECT IDLOTSER,MIN(AGGIORNAMENTO) AS FirstAfter
|
||||
INTO #inv_change_time FROM SAMA1_Xwmstest.dbo.EXTTACLOTSER
|
||||
WHERE AGGIORNAMENTO>=@cutoff GROUP BY IDLOTSER;
|
||||
CREATE UNIQUE CLUSTERED INDEX ix_time ON #inv_change_time(IDLOTSER);
|
||||
SELECT h.IDLOTSER,MIN(RTRIM(h.EXNUMSER)) COLLATE DATABASE_DEFAULT AS Serial,
|
||||
CASE WHEN COUNT(*)>1 THEN 1 ELSE 0 END AS AssignmentIssue
|
||||
INTO #inv_old FROM SAMA1_Xwmstest.dbo.EXTTACLOTSER h
|
||||
JOIN #inv_change_time t ON t.IDLOTSER=h.IDLOTSER AND t.FirstAfter=h.AGGIORNAMENTO
|
||||
GROUP BY h.IDLOTSER;
|
||||
CREATE UNIQUE CLUSTERED INDEX ix_old ON #inv_old(IDLOTSER);
|
||||
|
||||
SELECT ls.ID,ls.IDARTICO,RTRIM(ls.NUMLOT) COLLATE DATABASE_DEFAULT AS Lot,
|
||||
COALESCE(o.Serial,RTRIM(ls.NUMSER) COLLATE DATABASE_DEFAULT) AS Serial,
|
||||
ISNULL(o.AssignmentIssue,0) AS AssignmentIssue
|
||||
INTO #inv_wms_labels FROM SAMA1_Xwmstest.dbo.LOTSER ls
|
||||
LEFT JOIN #inv_old o ON o.IDLOTSER=ls.ID
|
||||
WHERE EXISTS(SELECT 1 FROM #inv_stock s WHERE s.Pallet=
|
||||
LEFT(COALESCE(o.Serial,RTRIM(ls.NUMSER) COLLATE DATABASE_DEFAULT),6));
|
||||
|
||||
-- Scope by PRODUCT + LOT in WMS, not all products and not a P% convention.
|
||||
SELECT DISTINCT IDARTICO,Lot INTO #inv_scope FROM #inv_wms_labels;
|
||||
CREATE UNIQUE CLUSTERED INDEX ix_scope ON #inv_scope(IDARTICO,Lot);
|
||||
SELECT ls.ID,ls.IDARTICO,RTRIM(ls.NUMLOT) COLLATE DATABASE_DEFAULT AS Lot,
|
||||
COALESCE(o.Serial,RTRIM(ls.NUMSER) COLLATE DATABASE_DEFAULT) AS Serial,
|
||||
ISNULL(o.AssignmentIssue,0) AS AssignmentIssue
|
||||
INTO #inv_labels FROM SAMA1_Xwmstest.dbo.LOTSER ls
|
||||
JOIN #inv_scope sc ON sc.IDARTICO=ls.IDARTICO
|
||||
AND sc.Lot=RTRIM(ls.NUMLOT) COLLATE DATABASE_DEFAULT
|
||||
LEFT JOIN #inv_old o ON o.IDLOTSER=ls.ID;
|
||||
CREATE UNIQUE CLUSTERED INDEX ix_labels ON #inv_labels(ID);
|
||||
|
||||
-- SAM balance per CONTAINER; B/C are never fabricated as SAM minus A.
|
||||
SELECT l.ID,SUM(CAST(g.QTTGIAI AS decimal(28,6))) AS Quantity
|
||||
INTO #inv_now FROM #inv_labels l
|
||||
JOIN SAMA1_Xwmstest.dbo.GIAMAG g ON g.IDARTICO=l.ID
|
||||
JOIN #inv_slots s ON s.ID=g.IDMAG GROUP BY l.ID;
|
||||
|
||||
SELECT m.IDARTICO AS ID,m.DATMOV,CAST(m.QTAINV AS decimal(28,6)) AS Quantity,
|
||||
RTRIM(c.CODICE) AS Cause,
|
||||
CASE WHEN sp.ID IS NOT NULL THEN
|
||||
CASE c.QTGIUP WHEN '+' THEN 1 WHEN '-' THEN -1 ELSE 0 END ELSE 0 END
|
||||
+ CASE WHEN sa.ID IS NOT NULL THEN
|
||||
CASE c.QTGIUA WHEN '+' THEN 1 WHEN '-' THEN -1 ELSE 0 END ELSE 0 END AS Sign,
|
||||
CASE WHEN sa.ID IS NOT NULL AND c.QTGIUA='+' THEN 1 ELSE 0 END AS Receipt,
|
||||
CASE WHEN c.ID IS NULL OR
|
||||
(sp.ID IS NOT NULL AND ISNULL(RTRIM(c.QTGIUP),'') NOT IN ('','+','-')) OR
|
||||
(sa.ID IS NOT NULL AND ISNULL(RTRIM(c.QTGIUA),'') NOT IN ('','+','-'))
|
||||
THEN 1 ELSE 0 END AS CauseIssue
|
||||
INTO #inv_moves FROM #inv_labels l
|
||||
JOIN SAMA1_Xwmstest.dbo.MOVMAG m ON m.IDARTICO=l.ID
|
||||
LEFT JOIN SAMA1_Xwmstest.dbo.CAUMOV c ON c.ID=m.IDCAUMOV
|
||||
LEFT JOIN #inv_slots sp ON sp.ID=m.IDMAGPAR
|
||||
LEFT JOIN #inv_slots sa ON sa.ID=m.IDMAGARR
|
||||
WHERE sp.ID IS NOT NULL OR sa.ID IS NOT NULL;
|
||||
CREATE INDEX ix_moves ON #inv_moves(ID);
|
||||
SELECT ID,
|
||||
SUM(CASE WHEN DATMOV>=@sam_cutoff THEN Quantity*Sign ELSE 0 END) AS AfterQuantity,
|
||||
SUM(CASE WHEN DATMOV<@sam_cutoff AND Cause='CP' THEN Quantity*Sign END) AS Nominal,
|
||||
SUM(CASE WHEN DATMOV IS NULL OR Quantity IS NULL OR CauseIssue=1 THEN 1 ELSE 0 END) AS MovementIssues,
|
||||
SUM(CASE WHEN DATMOV<@sam_cutoff AND Receipt=1 AND Cause<>'CP' THEN 1 ELSE 0 END) AS OtherReceipts
|
||||
INTO #inv_quantities FROM #inv_moves GROUP BY ID;
|
||||
|
||||
CREATE TABLE #inv_result (
|
||||
Kind varchar(8) NULL, Component varchar(8) NULL,
|
||||
Product nvarchar(255) NULL, Description nvarchar(1000) NULL, Unit nvarchar(32) NULL,
|
||||
ContainerId int NULL, Lot nvarchar(255) NULL, Serial nvarchar(255) NULL,
|
||||
Pallet nvarchar(64) NULL, Cell int NULL, Location nvarchar(255) NULL,
|
||||
Balance decimal(38,6) NULL, Quantity decimal(38,6) NULL, SamQuantity decimal(38,6) NULL,
|
||||
Locations int NULL, NegativeBalances int NULL, Shipped int NULL,
|
||||
AssignmentIssue int NULL, MovementIssues int NULL, OtherReceipts int NULL,
|
||||
SourceDate datetime2 NULL
|
||||
);
|
||||
INSERT INTO #inv_result
|
||||
SELECT CAST('ROW' AS varchar(8)) AS Kind,
|
||||
CAST(CASE WHEN s.Pallet IS NOT NULL THEN 'A'
|
||||
WHEN LEFT(l.Serial,6)='000000' THEN 'C'
|
||||
WHEN ISNULL(p.Locations,0)>0 OR ISNULL(p.NegativeBalances,0)>0 THEN 'X'
|
||||
WHEN LEN(l.Serial)<8 OR SUBSTRING(l.Serial,7,1)<>'/' THEN 'X'
|
||||
ELSE 'B' END AS varchar(8)) AS Component,
|
||||
RTRIM(a.CODICE) AS Product,RTRIM(a.DESCR) AS Description,RTRIM(a.UMI) AS Unit,
|
||||
l.ID AS ContainerId,l.Lot,l.Serial,
|
||||
LEFT(l.Serial,6) AS Pallet,s.IDCella AS Cell,s.Location,s.Balance,
|
||||
CASE WHEN s.Pallet IS NOT NULL THEN q.Nominal
|
||||
ELSE ISNULL(n.Quantity,0)-ISNULL(q.AfterQuantity,0) END AS Quantity,
|
||||
ISNULL(n.Quantity,0)-ISNULL(q.AfterQuantity,0) AS SamQuantity,
|
||||
ISNULL(p.Locations,0) AS Locations,ISNULL(p.NegativeBalances,0) AS NegativeBalances,
|
||||
ISNULL(p.Shipped,0) AS Shipped,l.AssignmentIssue,
|
||||
ISNULL(q.MovementIssues,0) AS MovementIssues,ISNULL(q.OtherReceipts,0) AS OtherReceipts,
|
||||
CAST(NULL AS datetime2) AS SourceDate
|
||||
FROM #inv_labels l
|
||||
LEFT JOIN SAMA1_Xwmstest.dbo.ARTICO a ON a.ID=l.IDARTICO
|
||||
LEFT JOIN #inv_now n ON n.ID=l.ID
|
||||
LEFT JOIN #inv_quantities q ON q.ID=l.ID
|
||||
LEFT JOIN #inv_position p ON p.Pallet=LEFT(l.Serial,6)
|
||||
LEFT JOIN #inv_stock s ON s.Pallet=LEFT(l.Serial,6)
|
||||
WHERE s.Pallet IS NOT NULL OR ISNULL(n.Quantity,0)-ISNULL(q.AfterQuantity,0)<>0
|
||||
OR ISNULL(q.MovementIssues,0)>0;
|
||||
|
||||
-- WMS presence with no recognizable label must remain visible.
|
||||
INSERT INTO #inv_result(Kind,Component,Pallet,Cell,Location,Balance,Locations,
|
||||
NegativeBalances,Shipped,AssignmentIssue,MovementIssues,OtherReceipts)
|
||||
SELECT 'ROW','A',s.Pallet,s.IDCella,s.Location,s.Balance,p.Locations,
|
||||
p.NegativeBalances,p.Shipped,0,0,0
|
||||
FROM #inv_stock s JOIN #inv_position p ON p.Pallet=s.Pallet
|
||||
WHERE NOT EXISTS(SELECT 1 FROM #inv_wms_labels l WHERE LEFT(l.Serial,6)=s.Pallet);
|
||||
|
||||
-- One result set, as required by the shared async SQL client.
|
||||
INSERT INTO #inv_result(Kind,Component,SourceDate)
|
||||
SELECT 'META','WMS_MAX',MAX(DataMagazzino) FROM dbo.MagazziniPallet;
|
||||
INSERT INTO #inv_result(Kind,Component,SourceDate)
|
||||
SELECT 'META','SAM_MAX',DATEADD(day,CAST(MAX(DATMOV) AS int),CAST('1899-12-30' AS datetime2))
|
||||
FROM SAMA1_Xwmstest.dbo.MOVMAG;
|
||||
INSERT INTO #inv_result(Kind,Component,SourceDate)
|
||||
SELECT 'META','HIST_MIN',MIN(AGGIORNAMENTO) FROM SAMA1_Xwmstest.dbo.EXTTACLOTSER;
|
||||
INSERT INTO #inv_result(Kind,Component,Quantity)
|
||||
SELECT 'META','UNDATED',COUNT(*) FROM dbo.MagazziniPallet WHERE DataMagazzino IS NULL;
|
||||
SELECT * FROM #inv_result;
|
||||
271
inventory_service.py
Normal file
271
inventory_service.py
Normal file
@@ -0,0 +1,271 @@
|
||||
"""Read-only WMS/SAM reconciliation by product and lot; see specifica_inventario.md."""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
SQL_PATH = Path(__file__).with_name("inventory_report.sql")
|
||||
ZERO = Decimal("0")
|
||||
SUMMARY_KEYS = ("Product", "Description", "Unit", "UDCs", "Shelved", "NonShelved",
|
||||
"WMS", "PackingUDCs", "Packing", "LooseContainers", "Loose",
|
||||
"Reconstructed", "SAM", "InitialDifference", "Difference", "Status")
|
||||
DETAIL_KEYS = ("Component", "Product", "Lot", "Pallet", "ContainerId", "Serial",
|
||||
"Location", "Quantity", "SamQuantity", "Status")
|
||||
LOT_KEYS = ("Product", "Lot") + SUMMARY_KEYS[2:]
|
||||
|
||||
|
||||
def inventory_cutoff(value: str, *, today: date | None = None) -> tuple[date, datetime, int]:
|
||||
"""Parse a day, not an instant; use the exclusive following midnight."""
|
||||
selected = datetime.strptime(value.strip(), "%d/%m/%Y").date()
|
||||
if selected > (today or date.today()) or selected < date(2010, 1, 1):
|
||||
raise ValueError("date_range")
|
||||
cutoff = datetime.combine(selected + timedelta(days=1), time.min)
|
||||
return selected, cutoff, (cutoff - datetime(1899, 12, 30)).days
|
||||
|
||||
|
||||
def number(value: Any) -> Decimal:
|
||||
"""Convert SQL decimals without introducing floating-point summation."""
|
||||
return Decimal(str(value)) if value is not None else ZERO
|
||||
|
||||
|
||||
@dataclass
|
||||
class InventoryReport:
|
||||
selected_date: date
|
||||
rows: list[dict[str, Any]]
|
||||
details: list[dict[str, Any]]
|
||||
metadata: dict[str, Any]
|
||||
lots: list[dict[str, Any]]
|
||||
|
||||
|
||||
def _bucket(product, description, unit, lot=""):
|
||||
return dict(Product=product, Description=description, Unit=unit, Lot=lot,
|
||||
UDCs=set(), PackingUDCs=set(), LooseContainers=set(),
|
||||
Shelved=ZERO, NonShelved=ZERO, Packing=ZERO, Loose=ZERO, SAM=ZERO,
|
||||
Issues=set(), Invalid=set())
|
||||
|
||||
|
||||
def build_report(selected_date: date, records: list[dict[str, Any]]) -> InventoryReport:
|
||||
"""Count each container once; retain anomalies instead of manufacturing balance.
|
||||
|
||||
A uses production receipt quantities, independently of current SAM balance.
|
||||
B/C use the dated container balance. X is unclassified/conflicting SAM stock;
|
||||
it contributes to SAM, never silently to B. Aggregation begins at product/lot.
|
||||
"""
|
||||
metadata = {r["Component"]: (r.get("Quantity") if r["Component"] == "UNDATED"
|
||||
else r.get("SourceDate"))
|
||||
for r in records if r["Kind"] == "META"}
|
||||
history_start = metadata.get("HIST_MIN")
|
||||
history_unknown = not history_start or selected_date < history_start.date()
|
||||
products, lots, details, seen = {}, {}, [], {}
|
||||
for record in records:
|
||||
if record["Kind"] == "META":
|
||||
continue
|
||||
r = dict(record)
|
||||
pallet = str(r.get("Pallet") or "").strip()
|
||||
product = str(r.get("Product") or "").strip() or f"? UDC {pallet}"
|
||||
lot = str(r.get("Lot") or "").strip()
|
||||
unit = str(r.get("Unit") or "").strip().upper()
|
||||
component = r["Component"]
|
||||
quantity = None if r.get("Quantity") is None else number(r["Quantity"])
|
||||
sam_quantity = None if r.get("SamQuantity") is None else number(r["SamQuantity"])
|
||||
issues, invalid = set(), set()
|
||||
if unit not in {"NR", "PZ", "PCS"}:
|
||||
issues.add("unit")
|
||||
invalid.update(("A", "B", "C", "SAM"))
|
||||
if r.get("AssignmentIssue") or history_unknown:
|
||||
issues.add("history")
|
||||
invalid.update(("A", "B", "C"))
|
||||
if metadata.get("UNDATED"):
|
||||
issues.add("undated")
|
||||
invalid.update(("A", "B", "C"))
|
||||
if r.get("MovementIssues") or sam_quantity is None:
|
||||
issues.add("movements")
|
||||
invalid.update(("A", "B", "C", "SAM"))
|
||||
if sam_quantity is not None and sam_quantity < 0:
|
||||
issues.add("negative")
|
||||
invalid.add("SAM")
|
||||
serial = str(r.get("Serial") or "").strip()
|
||||
if len(serial) < 8 or serial[6:7] != "/" or not serial[7:].strip():
|
||||
issues.add("serial")
|
||||
invalid.add(component)
|
||||
if component == "A":
|
||||
if quantity is None or quantity <= 0 or r.get("OtherReceipts"):
|
||||
issues.add("content")
|
||||
invalid.add("A")
|
||||
if r.get("Locations") != 1:
|
||||
issues.add("locations")
|
||||
invalid.add("A")
|
||||
if number(r.get("Balance")) != 1 or r.get("NegativeBalances"):
|
||||
issues.add("balance")
|
||||
invalid.add("A")
|
||||
if r.get("Shipped"):
|
||||
issues.add("shipped")
|
||||
invalid.add("A")
|
||||
elif component in ("B", "C"):
|
||||
if quantity is None or quantity <= 0:
|
||||
issues.add("content")
|
||||
invalid.add(component)
|
||||
if r.get("Shipped") or r.get("Locations") or r.get("NegativeBalances"):
|
||||
issues.add("shipped" if r.get("Shipped") else "outside")
|
||||
invalid.add(component)
|
||||
else:
|
||||
issues.add("shipped" if r.get("Shipped") else "outside")
|
||||
bucket = lots.setdefault((product, lot), _bucket(product, r.get("Description") or "", unit, lot))
|
||||
if bucket["Unit"] != unit:
|
||||
issues.add("unit")
|
||||
invalid.update(("A", "B", "C", "SAM"))
|
||||
bucket["Issues"].update(issues)
|
||||
bucket["Invalid"].update(invalid)
|
||||
if component == "A":
|
||||
bucket["UDCs"].add(pallet)
|
||||
elif component == "B":
|
||||
bucket["PackingUDCs"].add(pallet)
|
||||
elif component == "C":
|
||||
bucket["LooseContainers"].add(r.get("ContainerId"))
|
||||
# Anomaly details can have several locations, but SAM must not be doubled.
|
||||
identity = r.get("ContainerId") or ("missing", pallet)
|
||||
key = (product, lot, identity)
|
||||
fingerprint = (component, quantity, sam_quantity, pallet)
|
||||
if key not in seen:
|
||||
bucket["SAM"] += sam_quantity or ZERO
|
||||
field = ("NonShelved" if r.get("Cell") == 1000 else "Shelved") if component == "A" else {
|
||||
"B": "Packing", "C": "Loose"}.get(component)
|
||||
if field and quantity is not None:
|
||||
bucket[field] += quantity
|
||||
seen[key] = fingerprint
|
||||
elif seen[key] != fingerprint:
|
||||
bucket["Issues"].add("duplicate")
|
||||
bucket["Invalid"].update(("A", "B", "C", "SAM"))
|
||||
issues.add("duplicate")
|
||||
details.append(dict(Component=component, Product=product, Lot=lot,
|
||||
Pallet="" if pallet == "000000" else pallet,
|
||||
ContainerId=r.get("ContainerId"), Serial=serial,
|
||||
Cell=r.get("Cell"), Location=r.get("Location") or "",
|
||||
Quantity=None if component in invalid else quantity,
|
||||
SamQuantity=None if "SAM" in invalid else sam_quantity,
|
||||
Issues=tuple(sorted(issues))))
|
||||
# Aggregate lots without summing their distinct-UDC counts.
|
||||
for bucket in lots.values():
|
||||
total = products.setdefault(bucket["Product"], _bucket(
|
||||
bucket["Product"], bucket["Description"], bucket["Unit"]))
|
||||
if total["Unit"] != bucket["Unit"]:
|
||||
total["Issues"].add("unit")
|
||||
total["Invalid"].update(("A", "B", "C", "SAM"))
|
||||
for key in ("UDCs", "PackingUDCs", "LooseContainers", "Issues", "Invalid"):
|
||||
total[key].update(bucket[key])
|
||||
for key in ("Shelved", "NonShelved", "Packing", "Loose", "SAM"):
|
||||
total[key] += bucket[key]
|
||||
def finish(row):
|
||||
invalid = row.pop("Invalid")
|
||||
for key in ("UDCs", "PackingUDCs", "LooseContainers"):
|
||||
row[key] = len(row[key])
|
||||
if "A" in invalid:
|
||||
row["Shelved"] = row["NonShelved"] = None
|
||||
for component, field in (("B", "Packing"), ("C", "Loose"), ("SAM", "SAM")):
|
||||
if component in invalid:
|
||||
row[field] = None
|
||||
row["WMS"] = add_known(row["Shelved"], row["NonShelved"])
|
||||
row["Reconstructed"] = add_known(row["WMS"], row["Packing"], row["Loose"])
|
||||
row["InitialDifference"] = subtract_known(row["SAM"], row["WMS"])
|
||||
row["Difference"] = subtract_known(row["SAM"], row["Reconstructed"])
|
||||
row["Issues"] = tuple(sorted(row["Issues"]))
|
||||
return row
|
||||
lot_rows = [finish(lots[k]) for k in sorted(lots)]
|
||||
product_rows = [finish(products[k]) for k in sorted(products)]
|
||||
for row in product_rows:
|
||||
if row["Difference"] == 0 and any(
|
||||
lot["Product"] == row["Product"] and lot["Difference"] not in (None, ZERO)
|
||||
for lot in lot_rows):
|
||||
row["Issues"] = tuple(sorted(set(row["Issues"]) | {"lot_offsets"}))
|
||||
return InventoryReport(selected_date,
|
||||
product_rows,
|
||||
sorted(details, key=lambda r: (r["Product"], r["Lot"], r["Component"],
|
||||
r["Pallet"], r["Serial"], str(r["Cell"]))),
|
||||
metadata, lot_rows)
|
||||
|
||||
|
||||
def add_known(*values):
|
||||
return None if any(v is None for v in values) else sum(values, ZERO)
|
||||
|
||||
|
||||
def subtract_known(left, right):
|
||||
return None if left is None or right is None else left - right
|
||||
|
||||
|
||||
async def load_inventory(db_client, value: str) -> InventoryReport:
|
||||
"""Use the existing asynchronous DB client; no commit or stock mutation."""
|
||||
selected, cutoff, sam_cutoff = inventory_cutoff(value)
|
||||
result = await db_client.query_json(SQL_PATH.read_text(encoding="utf-8"),
|
||||
{"cutoff": cutoff, "sam_cutoff": sam_cutoff}, as_dict_rows=True)
|
||||
return build_report(selected, result["rows"])
|
||||
|
||||
|
||||
def status_text(row, translate):
|
||||
if row["Issues"]:
|
||||
return "; ".join(translate("inventory.issue." + issue) for issue in row["Issues"])
|
||||
return translate("inventory.match" if row["Difference"] == 0 else "inventory.mismatch")
|
||||
|
||||
|
||||
def detail_values(row, translate):
|
||||
"""Use identical localized labels in GUI and exported container details."""
|
||||
values = dict(row)
|
||||
values["Component"] = translate("inventory.component." + row["Component"])
|
||||
if not values["Location"] and row["Component"] in ("B", "C"):
|
||||
values["Location"] = translate("inventory.inferred_location")
|
||||
values["Status"] = "; ".join(translate("inventory.issue." + issue) for issue in row["Issues"])
|
||||
return [values[k] for k in DETAIL_KEYS]
|
||||
|
||||
|
||||
def export_inventory(report: InventoryReport, path: str, *, headers=None,
|
||||
detail_headers=None, translate, ordered_rows=None) -> None:
|
||||
"""Export product, lot and container views with typed cells and provenance."""
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Font, PatternFill
|
||||
from openpyxl.utils import get_column_letter
|
||||
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = translate("inventory.title")
|
||||
ws.append([translate("inventory.date"), report.selected_date])
|
||||
ws["B1"].number_format = "DD/MM/YYYY"
|
||||
ws.append([translate("inventory.notice")])
|
||||
ws.append([translate("inventory.scope")])
|
||||
ws.append([translate("inventory.sources"), str(report.metadata)])
|
||||
ws.append([translate("inventory.history_notice")])
|
||||
ws.append(headers or [translate("inventory.col." + k) for k in SUMMARY_KEYS])
|
||||
for row in ordered_rows if ordered_rows is not None else report.rows:
|
||||
ws.append([row[k] for k in SUMMARY_KEYS[:-1]] + [status_text(row, translate)])
|
||||
ls = wb.create_sheet(translate("inventory.lot_sheet"))
|
||||
ls.append([translate("inventory.col." + k) for k in LOT_KEYS])
|
||||
for row in report.lots:
|
||||
ls.append([row[k] for k in LOT_KEYS[:-1]] + [status_text(row, translate)])
|
||||
ds = wb.create_sheet(translate("inventory.detail_sheet"))
|
||||
ds.append(detail_headers or [translate("inventory.col." + k) for k in DETAIL_KEYS])
|
||||
for row in report.details:
|
||||
ds.append(detail_values(row, translate))
|
||||
for sheet, header_row in ((ws, 6), (ls, 1), (ds, 1)):
|
||||
sheet.freeze_panes = f"A{header_row + 1}"
|
||||
sheet.auto_filter.ref = f"A{header_row}:{get_column_letter(sheet.max_column)}{sheet.max_row}"
|
||||
for cell in sheet[header_row]:
|
||||
cell.font = Font(bold=True, color="000000")
|
||||
cell.fill = PatternFill("solid", fgColor="BFC4CA")
|
||||
for row in sheet.iter_rows():
|
||||
for cell in row:
|
||||
if isinstance(cell.value, str):
|
||||
cell.data_type = "s"
|
||||
elif isinstance(cell.value, (Decimal, float, int)):
|
||||
cell.number_format = '#,##0.######;[Red]-#,##0.######;0'
|
||||
if cell.row > header_row and cell.row % 2 == 0:
|
||||
cell.fill = PatternFill("solid", fgColor="F0F0F0")
|
||||
for col in range(1, sheet.max_column + 1):
|
||||
sheet.column_dimensions[get_column_letter(col)].width = 24
|
||||
try:
|
||||
wb.save(path)
|
||||
finally:
|
||||
wb.close()
|
||||
698
layout_window.py
698
layout_window.py
@@ -1,698 +0,0 @@
|
||||
"""Graphical aisle layout viewer for warehouse cells and pallet occupancy."""
|
||||
|
||||
from __future__ import annotations
|
||||
import tkinter as tk
|
||||
from tkinter import Menu, messagebox, filedialog
|
||||
import customtkinter as ctk
|
||||
from datetime import datetime
|
||||
|
||||
from gestione_aree_frame_async import BusyOverlay, AsyncRunner
|
||||
|
||||
# ---- Color palette ----
|
||||
COLOR_EMPTY = "#B0B0B0" # grigio (vuota)
|
||||
COLOR_FULL = "#FFA500" # arancione (una UDC)
|
||||
COLOR_DOUBLE = "#D62728" # rosso (>=2 UDC)
|
||||
FG_DARK = "#111111"
|
||||
FG_LIGHT = "#FFFFFF"
|
||||
|
||||
|
||||
def pct_text(p_full: float, p_double: float | None = None) -> str:
|
||||
"""Format occupancy percentages for the progress-bar labels."""
|
||||
p_full = max(0.0, min(1.0, p_full))
|
||||
pf = round(p_full * 100, 1)
|
||||
pe = round(100 - pf, 1)
|
||||
if p_double and p_double > 0:
|
||||
pd = round(p_double * 100, 1)
|
||||
return f"Pieno {pf}% · Vuoto {pe}% (di cui doppie {pd}%)"
|
||||
return f"Pieno {pf}% · Vuoto {pe}%"
|
||||
|
||||
|
||||
class LayoutWindow(ctk.CTkToplevel):
|
||||
"""
|
||||
Visualizzazione layout corsie con matrice di celle.
|
||||
- Ogni cella è un pulsante colorato (vuota/piena/doppia)
|
||||
- Etichetta su DUE righe:
|
||||
1) "Corsia.Colonna.Fila" (una sola riga, senza andare a capo)
|
||||
2) barcode UDC (primo, se presente)
|
||||
- Ricerca per barcode UDC con cambio automatico corsia + highlight cella
|
||||
- Statistiche: globale e corsia selezionata
|
||||
- Export XLSX
|
||||
"""
|
||||
def __init__(self, parent: tk.Widget, db_app):
|
||||
"""Create the window and initialize the state used by the matrix view."""
|
||||
super().__init__(parent)
|
||||
self.title("Warehouse · Layout corsie")
|
||||
self.geometry("1200x740")
|
||||
self.minsize(980, 560)
|
||||
self.resizable(True, True)
|
||||
|
||||
self.db = db_app
|
||||
self._busy = BusyOverlay(self)
|
||||
self._async = AsyncRunner(self)
|
||||
|
||||
# layout principale 5% / 80% / 15%
|
||||
self.grid_rowconfigure(0, weight=5)
|
||||
self.grid_rowconfigure(1, weight=80)
|
||||
self.grid_rowconfigure(2, weight=15)
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
|
||||
# stato runtime
|
||||
self.corsia_selezionata = tk.StringVar()
|
||||
self.buttons: list[list[ctk.CTkButton]] = []
|
||||
self.btn_frames: list[list[ctk.CTkFrame]] = []
|
||||
self.matrix_state: list[list[int]] = [] # <— rinominata: prima era self.state
|
||||
self.fila_txt: list[list[str]] = []
|
||||
self.col_txt: list[list[str]] = []
|
||||
self.desc: list[list[str]] = []
|
||||
self.udc1: list[list[str]] = [] # primo barcode UDC trovato (o "")
|
||||
|
||||
# ricerca → focus differito (corsia, col, fila, barcode)
|
||||
self._pending_focus: tuple[str, str, str, str] | None = None
|
||||
self._highlighted: tuple[int, int] | None = None
|
||||
|
||||
# anti-race: token per ignorare risposte vecchie
|
||||
self._req_counter = 0
|
||||
self._last_req = 0
|
||||
self._alive = True
|
||||
self._stats_after_id = None # se mai userai un refresh periodico, potremo cancellarlo qui
|
||||
|
||||
self._build_top()
|
||||
self._build_matrix_host()
|
||||
self._build_stats()
|
||||
|
||||
self._load_corsie()
|
||||
# disabilitato: il refresh ad ogni <Configure> generava molte query/lag
|
||||
# self.bind("<Configure>", lambda e: self.after_idle(self._refresh_stats))
|
||||
|
||||
# ---------------- TOP BAR ----------------
|
||||
def _build_top(self):
|
||||
"""Create the top toolbar with aisle selection and search controls."""
|
||||
top = ctk.CTkFrame(self)
|
||||
top.grid(row=0, column=0, sticky="nsew", padx=8, pady=6)
|
||||
for i in range(4):
|
||||
top.grid_columnconfigure(i, weight=0)
|
||||
top.grid_columnconfigure(1, weight=1)
|
||||
|
||||
# lista corsie
|
||||
lf = ctk.CTkFrame(top)
|
||||
lf.grid(row=0, column=0, sticky="nsw")
|
||||
lf.grid_columnconfigure(0, weight=1)
|
||||
ctk.CTkLabel(lf, text="Corsie", font=("", 12, "bold")).grid(row=0, column=0, sticky="w", padx=6, pady=(6, 2))
|
||||
self.lb = tk.Listbox(lf, height=6, exportselection=False)
|
||||
self.lb.grid(row=1, column=0, sticky="nsw", padx=6, pady=(0, 6))
|
||||
self.lb.bind("<<ListboxSelect>>", self._on_select)
|
||||
|
||||
# search by barcode
|
||||
srch = ctk.CTkFrame(top)
|
||||
srch.grid(row=0, column=1, sticky="nsew", padx=(10, 10))
|
||||
self.search_var = tk.StringVar()
|
||||
self.search_entry = ctk.CTkEntry(srch, textvariable=self.search_var, width=260)
|
||||
self.search_entry.grid(row=0, column=0, sticky="w")
|
||||
ctk.CTkButton(srch, text="Cerca per barcode UDC", command=self._search_udc).grid(row=0, column=1, padx=(8, 0))
|
||||
srch.grid_columnconfigure(0, weight=1)
|
||||
|
||||
# toolbar
|
||||
tb = ctk.CTkFrame(top)
|
||||
tb.grid(row=0, column=3, sticky="ne")
|
||||
ctk.CTkButton(tb, text="Aggiorna", command=self._refresh_current).grid(row=0, column=0, padx=4)
|
||||
ctk.CTkButton(tb, text="Export XLSX", command=self._export_xlsx).grid(row=0, column=1, padx=4)
|
||||
|
||||
# ---------------- MATRIX HOST ----------------
|
||||
def _build_matrix_host(self):
|
||||
"""Create the container that will host the dynamically rebuilt matrix."""
|
||||
center = ctk.CTkFrame(self)
|
||||
center.grid(row=1, column=0, sticky="nsew", padx=8, pady=(0, 6))
|
||||
center.grid_rowconfigure(0, weight=1)
|
||||
center.grid_columnconfigure(0, weight=1)
|
||||
self.host = ctk.CTkFrame(center)
|
||||
self.host.grid(row=0, column=0, sticky="nsew", padx=4, pady=4)
|
||||
|
||||
def _apply_cell_style(self, btn: ctk.CTkButton, state: int):
|
||||
"""Apply the visual state associated with a cell occupancy level."""
|
||||
if state == 0:
|
||||
btn.configure(
|
||||
fg_color=COLOR_EMPTY, hover_color="#9A9A9A",
|
||||
text_color=FG_DARK, border_width=0
|
||||
)
|
||||
elif state == 1:
|
||||
btn.configure(
|
||||
fg_color=COLOR_FULL, hover_color="#E69500",
|
||||
text_color=FG_DARK, border_width=0
|
||||
)
|
||||
else:
|
||||
btn.configure(
|
||||
fg_color=COLOR_DOUBLE, hover_color="#B22222",
|
||||
text_color=FG_LIGHT, border_width=0
|
||||
)
|
||||
|
||||
def _clear_highlight(self):
|
||||
"""Remove the temporary highlight from the previously focused cell."""
|
||||
if self._highlighted and self.buttons:
|
||||
r, c = self._highlighted
|
||||
try:
|
||||
if 0 <= r < len(self.buttons) and 0 <= c < len(self.buttons[r]):
|
||||
btn = self.buttons[r][c]
|
||||
if getattr(btn, "winfo_exists", None) and btn.winfo_exists():
|
||||
try:
|
||||
btn.configure(border_width=0)
|
||||
except Exception:
|
||||
pass
|
||||
# clear blue frame border
|
||||
try:
|
||||
fr = self.btn_frames[r][c]
|
||||
if fr and getattr(fr, "winfo_exists", None) and fr.winfo_exists():
|
||||
fr.configure(border_width=0)
|
||||
# in CTkFrame non esiste highlightthickness come in tk; border_* è corretto
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
self._highlighted = None
|
||||
|
||||
def _rebuild_matrix(self, rows: int, cols: int, state, fila_txt, col_txt, desc, udc1, corsia):
|
||||
"""Recreate the visible cell matrix from the latest query result."""
|
||||
# prima rimuovi highlight su vecchi bottoni
|
||||
self._clear_highlight()
|
||||
# ripulisci host
|
||||
for w in self.host.winfo_children():
|
||||
w.destroy()
|
||||
self.buttons.clear()
|
||||
self.btn_frames.clear()
|
||||
|
||||
# salva matrici
|
||||
self.matrix_state, self.fila_txt, self.col_txt, self.desc, self.udc1 = state, fila_txt, col_txt, desc, udc1
|
||||
|
||||
# ridistribuisci pesi griglia
|
||||
for r in range(rows):
|
||||
self.host.grid_rowconfigure(r, weight=1)
|
||||
for c in range(cols):
|
||||
self.host.grid_columnconfigure(c, weight=1)
|
||||
|
||||
# crea Frame+Button per cella (righe invertite: fila "a" in basso)
|
||||
for r in range(rows):
|
||||
row_btns = []
|
||||
row_frames = []
|
||||
for c in range(cols):
|
||||
st = state[r][c]
|
||||
code = f"{corsia}.{col_txt[r][c]}.{fila_txt[r][c]}" # PRIMA RIGA (in linea)
|
||||
udc = udc1[r][c] or "" # SECONDA RIGA: barcode UDC
|
||||
text = f"{code}\n{udc}"
|
||||
cell = ctk.CTkFrame(self.host, corner_radius=6, border_width=0)
|
||||
btn = ctk.CTkButton(
|
||||
cell,
|
||||
text=text,
|
||||
corner_radius=6)
|
||||
self._apply_cell_style(btn, st)
|
||||
|
||||
rr = (rows - 1) - r # capovolgi
|
||||
cell.grid(row=rr, column=c, padx=1, pady=1, sticky="nsew")
|
||||
btn.pack(fill="both", expand=True)
|
||||
btn.configure(command=lambda rr=r, cc=c: self._open_menu(None, rr, cc))
|
||||
btn.bind("<Button-3>", lambda e, rr=r, cc=c: self._open_menu(e, rr, cc))
|
||||
row_btns.append(btn)
|
||||
row_frames.append(cell)
|
||||
self.buttons.append(row_btns)
|
||||
self.btn_frames.append(row_frames)
|
||||
|
||||
# focus differito post-ricarica
|
||||
if getattr(self, '_alive', True) and self._pending_focus and self._pending_focus[0] == corsia:
|
||||
_, col, fila, _barcode = self._pending_focus
|
||||
self._pending_focus = None
|
||||
self._highlight_cell_by_labels(col, fila)
|
||||
|
||||
# ---------------- CONTEXT MENU ----------------
|
||||
def _open_menu(self, event, r, c):
|
||||
"""Open the context menu for a single matrix cell."""
|
||||
st = self.matrix_state[r][c]
|
||||
corsia = self.corsia_selezionata.get()
|
||||
label = f"{corsia}.{self.col_txt[r][c]}.{self.fila_txt[r][c]}"
|
||||
m = Menu(self, tearoff=0)
|
||||
m.add_command(label="Apri dettaglio", command=lambda: self._toast(f"Dettaglio {label}"))
|
||||
if st == 0:
|
||||
m.add_command(label="Segna pieno", command=lambda: self._set_cell(r, c, 1))
|
||||
m.add_command(label="Segna doppia", command=lambda: self._set_cell(r, c, 2))
|
||||
elif st == 1:
|
||||
m.add_command(label="Segna vuoto", command=lambda: self._set_cell(r, c, 0))
|
||||
m.add_command(label="Segna doppia", command=lambda: self._set_cell(r, c, 2))
|
||||
else:
|
||||
m.add_command(label="Segna vuoto", command=lambda: self._set_cell(r, c, 0))
|
||||
m.add_command(label="Segna pieno", command=lambda: self._set_cell(r, c, 1))
|
||||
m.add_separator()
|
||||
m.add_command(label="Copia ubicazione", command=lambda: self._copy(label))
|
||||
x = self.winfo_pointerx() if event is None else event.x_root
|
||||
y = self.winfo_pointery() if event is None else event.y_root
|
||||
m.tk_popup(x, y)
|
||||
|
||||
def _set_cell(self, r, c, val):
|
||||
"""Update a cell state in memory and refresh the local statistics."""
|
||||
self.matrix_state[r][c] = val
|
||||
btn = self.buttons[r][c]
|
||||
self._apply_cell_style(btn, val)
|
||||
self._refresh_stats()
|
||||
|
||||
# ---------------- STATS ----------------
|
||||
def _build_stats(self):
|
||||
"""Create progress bars, labels and legend for occupancy statistics."""
|
||||
bottom = ctk.CTkFrame(self)
|
||||
bottom.grid(row=2, column=0, sticky="nsew", padx=8, pady=6)
|
||||
bottom.grid_columnconfigure(0, weight=1)
|
||||
|
||||
ctk.CTkLabel(bottom, text="Riempimento globale", font=("", 10, "bold")).grid(row=0, column=0, sticky="w", pady=(0, 2))
|
||||
self.tot_canvas = tk.Canvas(bottom, height=22, highlightthickness=0)
|
||||
self.tot_canvas.grid(row=1, column=0, sticky="ew", padx=(0, 260))
|
||||
self.tot_text = ctk.CTkLabel(bottom, text=pct_text(0.0, 0.0))
|
||||
self.tot_text.grid(row=1, column=0, sticky="e")
|
||||
|
||||
ctk.CTkLabel(bottom, text="Riempimento corsia selezionata", font=("", 10, "bold")).grid(row=2, column=0, sticky="w", pady=(10, 2))
|
||||
self.sel_canvas = tk.Canvas(bottom, height=22, highlightthickness=0)
|
||||
self.sel_canvas.grid(row=3, column=0, sticky="ew", padx=(0, 260))
|
||||
self.sel_text = ctk.CTkLabel(bottom, text=pct_text(0.0, 0.0))
|
||||
self.sel_text.grid(row=3, column=0, sticky="e")
|
||||
|
||||
leg = ctk.CTkFrame(bottom)
|
||||
leg.grid(row=4, column=0, sticky="w", pady=(10, 0))
|
||||
ctk.CTkLabel(leg, text="Legenda celle:").grid(row=0, column=0, padx=(0, 8))
|
||||
self._legend(leg, 1, "Vuota", COLOR_EMPTY)
|
||||
self._legend(leg, 3, "Piena", COLOR_FULL)
|
||||
self._legend(leg, 5, "Doppia UDC", COLOR_DOUBLE)
|
||||
|
||||
def _legend(self, parent, col, text, color):
|
||||
"""Add a legend entry describing one matrix color."""
|
||||
box = tk.Canvas(parent, width=18, height=12, highlightthickness=0)
|
||||
box.create_rectangle(0, 0, 18, 12, fill=color, width=1, outline="#444")
|
||||
box.grid(row=0, column=col)
|
||||
ctk.CTkLabel(parent, text=text).grid(row=0, column=col + 1, padx=(4, 12))
|
||||
|
||||
# ---------------- DATA LOADING ----------------
|
||||
def _load_corsie(self):
|
||||
"""Load the list of aisles available for visualization."""
|
||||
sql = """
|
||||
WITH C AS (
|
||||
SELECT DISTINCT LTRIM(RTRIM(Corsia)) AS Corsia
|
||||
FROM dbo.Celle
|
||||
WHERE ID <> 9999 AND (DelDataOra IS NULL) AND LTRIM(RTRIM(Corsia)) <> '7G'
|
||||
)
|
||||
SELECT Corsia
|
||||
FROM C
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN LEFT(Corsia,3)='MAG' AND TRY_CONVERT(int, SUBSTRING(Corsia,4,50)) IS NOT NULL THEN 0
|
||||
WHEN TRY_CONVERT(int, Corsia) IS NOT NULL THEN 1
|
||||
ELSE 2
|
||||
END,
|
||||
CASE WHEN LEFT(Corsia,3)='MAG' THEN TRY_CONVERT(int, SUBSTRING(Corsia,4,50)) END,
|
||||
CASE WHEN TRY_CONVERT(int, Corsia) IS NOT NULL THEN TRY_CONVERT(int, Corsia) END,
|
||||
CASE WHEN TRY_CONVERT(int, Corsia) IS NOT NULL THEN SUBSTRING(Corsia, LEN(CAST(TRY_CONVERT(int, Corsia) AS varchar(20)))+1, 50) END,
|
||||
Corsia;
|
||||
"""
|
||||
def _ok(res):
|
||||
if not getattr(self, '_alive', True) or not self.winfo_exists():
|
||||
return
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
self.lb.delete(0, tk.END)
|
||||
corsie = [r[0] for r in rows]
|
||||
for c in corsie:
|
||||
self.lb.insert(tk.END, c)
|
||||
idx = corsie.index("1A") if "1A" in corsie else (0 if corsie else -1)
|
||||
if idx >= 0:
|
||||
self.lb.selection_clear(0, tk.END)
|
||||
self.lb.selection_set(idx)
|
||||
self.lb.see(idx)
|
||||
self._on_select(None)
|
||||
else:
|
||||
self._toast("Nessuna corsia trovata.")
|
||||
self._busy.hide()
|
||||
def _err(ex):
|
||||
if not getattr(self, '_alive', True) or not self.winfo_exists():
|
||||
return
|
||||
self._busy.hide()
|
||||
messagebox.showerror("Errore", f"Caricamento corsie fallito:\n{ex}")
|
||||
self._async.run(self.db.query_json(sql, {}), _ok, _err, busy=self._busy, message="Carico corsie…")
|
||||
|
||||
def _on_select(self, _):
|
||||
"""Load the selected aisle when the listbox selection changes."""
|
||||
sel = self.lb.curselection()
|
||||
if not sel:
|
||||
return
|
||||
corsia = self.lb.get(sel[0])
|
||||
self.corsia_selezionata.set(corsia)
|
||||
self._load_matrix(corsia)
|
||||
|
||||
def _select_corsia_in_listbox(self, corsia: str):
|
||||
"""Select a given aisle inside the listbox if it is present."""
|
||||
for i in range(self.lb.size()):
|
||||
if self.lb.get(i) == corsia:
|
||||
self.lb.selection_clear(0, tk.END)
|
||||
self.lb.selection_set(i)
|
||||
self.lb.see(i)
|
||||
break
|
||||
|
||||
def _load_matrix(self, corsia: str):
|
||||
"""Query and render the matrix for the selected aisle."""
|
||||
# nuovo token richiesta → evita che risposte vecchie spazzino la UI
|
||||
self._req_counter += 1
|
||||
req_id = self._req_counter
|
||||
self._last_req = req_id
|
||||
|
||||
sql = """
|
||||
WITH C AS (
|
||||
SELECT
|
||||
ID,
|
||||
LTRIM(RTRIM(Corsia)) AS Corsia,
|
||||
LTRIM(RTRIM(Fila)) AS Fila,
|
||||
LTRIM(RTRIM(Colonna)) AS Colonna,
|
||||
Descrizione
|
||||
FROM dbo.Celle
|
||||
WHERE ID <> 9999 AND (DelDataOra IS NULL)
|
||||
AND LTRIM(RTRIM(Corsia)) <> '7G' AND LTRIM(RTRIM(Corsia)) = :corsia
|
||||
),
|
||||
R AS (
|
||||
SELECT Fila,
|
||||
DENSE_RANK() OVER (
|
||||
ORDER BY CASE WHEN TRY_CONVERT(int, Fila) IS NULL THEN 1 ELSE 0 END,
|
||||
TRY_CONVERT(int, Fila), Fila
|
||||
) AS RowN
|
||||
FROM C GROUP BY Fila
|
||||
),
|
||||
K AS (
|
||||
SELECT Colonna,
|
||||
DENSE_RANK() OVER (
|
||||
ORDER BY CASE WHEN TRY_CONVERT(int, Colonna) IS NULL THEN 1 ELSE 0 END,
|
||||
TRY_CONVERT(int, Colonna), Colonna
|
||||
) AS ColN
|
||||
FROM C GROUP BY Colonna
|
||||
),
|
||||
S AS (
|
||||
SELECT c.ID, COUNT(DISTINCT g.BarcodePallet) AS n
|
||||
FROM C AS c
|
||||
LEFT JOIN dbo.XMag_GiacenzaPallet AS g ON g.IDCella = c.ID
|
||||
GROUP BY c.ID
|
||||
),
|
||||
U AS (
|
||||
SELECT c.ID, MIN(g.BarcodePallet) AS FirstUDC
|
||||
FROM C c
|
||||
LEFT JOIN dbo.XMag_GiacenzaPallet g ON g.IDCella = c.ID
|
||||
GROUP BY c.ID
|
||||
)
|
||||
SELECT
|
||||
r.RowN, k.ColN,
|
||||
CASE WHEN s.n IS NULL OR s.n = 0 THEN 0
|
||||
WHEN s.n = 1 THEN 1
|
||||
ELSE 2 END AS Stato,
|
||||
c.Descrizione,
|
||||
LTRIM(RTRIM(c.Fila)) AS FilaTxt,
|
||||
LTRIM(RTRIM(c.Colonna)) AS ColTxt,
|
||||
U.FirstUDC
|
||||
FROM C c
|
||||
JOIN R r ON r.Fila = c.Fila
|
||||
JOIN K k ON k.Colonna = c.Colonna
|
||||
LEFT JOIN S s ON s.ID = c.ID
|
||||
LEFT JOIN U ON U.ID = c.ID
|
||||
ORDER BY r.RowN, k.ColN;
|
||||
"""
|
||||
def _ok(res):
|
||||
if not getattr(self, '_alive', True) or not self.winfo_exists():
|
||||
return
|
||||
# ignora risposte superate
|
||||
if req_id < self._last_req:
|
||||
return
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
if not rows:
|
||||
# mostra matrice vuota senza rimuovere il frame (evita "schermo bianco")
|
||||
self._rebuild_matrix(0, 0, [], [], [], [], [], corsia)
|
||||
self._refresh_stats()
|
||||
self._busy.hide()
|
||||
return
|
||||
max_r = max_c = 0
|
||||
for row in rows:
|
||||
rown, coln = row[0], row[1]
|
||||
if rown and coln:
|
||||
max_r = max(max_r, int(rown))
|
||||
max_c = max(max_c, int(coln))
|
||||
mat = [[0] * max_c for _ in range(max_r)]
|
||||
fila = [[""] * max_c for _ in range(max_r)]
|
||||
col = [[""] * max_c for _ in range(max_r)]
|
||||
desc = [[""] * max_c for _ in range(max_r)]
|
||||
udc = [[""] * max_c for _ in range(max_r)]
|
||||
for row in rows:
|
||||
rown, coln, stato, descr, fila_txt, col_txt, first_udc = row
|
||||
r = int(rown) - 1
|
||||
c = int(coln) - 1
|
||||
mat[r][c] = int(stato)
|
||||
fila[r][c] = str(fila_txt or "")
|
||||
col[r][c] = str(col_txt or "")
|
||||
desc[r][c] = str(descr or f"{corsia}.{col_txt}.{fila_txt}")
|
||||
udc[r][c] = str(first_udc or "")
|
||||
self._rebuild_matrix(max_r, max_c, mat, fila, col, desc, udc, corsia)
|
||||
self._refresh_stats()
|
||||
self._busy.hide()
|
||||
def _err(ex):
|
||||
if not getattr(self, '_alive', True) or not self.winfo_exists():
|
||||
return
|
||||
if req_id < self._last_req:
|
||||
return
|
||||
self._busy.hide()
|
||||
messagebox.showerror("Errore", f"Caricamento matrice {corsia} fallito:\n{ex}")
|
||||
self._async.run(self.db.query_json(sql, {"corsia": corsia}), _ok, _err, busy=self._busy, message=f"Carico corsia {corsia}…")
|
||||
|
||||
# ---------------- SEARCH ----------------
|
||||
def _search_udc(self):
|
||||
"""Find a pallet barcode and navigate to the aisle and cell that contain it."""
|
||||
barcode = (self.search_var.get() or "").strip()
|
||||
if not barcode:
|
||||
self._toast("Inserisci un barcode UDC da cercare.")
|
||||
return
|
||||
|
||||
# bump token per impedire che una vecchia _load_matrix cancelli UI
|
||||
self._req_counter += 1
|
||||
search_req_id = self._req_counter
|
||||
self._last_req = search_req_id
|
||||
|
||||
sql = """
|
||||
SELECT TOP (1)
|
||||
RTRIM(c.Corsia) AS Corsia,
|
||||
RTRIM(c.Colonna) AS Colonna,
|
||||
RTRIM(c.Fila) AS Fila,
|
||||
c.ID AS IDCella
|
||||
FROM dbo.XMag_GiacenzaPallet g
|
||||
JOIN dbo.Celle c ON c.ID = g.IDCella
|
||||
WHERE g.BarcodePallet = :barcode
|
||||
AND c.ID <> 9999 AND RTRIM(c.Corsia) <> '7G'
|
||||
"""
|
||||
def _ok(res):
|
||||
if not getattr(self, '_alive', True) or not self.winfo_exists():
|
||||
return
|
||||
if search_req_id < self._last_req:
|
||||
return
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
if not rows:
|
||||
messagebox.showinfo("Ricerca", f"UDC {barcode} non trovata.", parent=self)
|
||||
return
|
||||
corsia, col, fila, _idc = rows[0]
|
||||
corsia = str(corsia).strip(); col = str(col).strip(); fila = str(fila).strip()
|
||||
self._pending_focus = (corsia, col, fila, barcode)
|
||||
|
||||
# sincronizza listbox e carica SEMPRE la corsia della UDC
|
||||
self._select_corsia_in_listbox(corsia)
|
||||
self.corsia_selezionata.set(corsia)
|
||||
self._load_matrix(corsia) # highlight avverrà in _rebuild_matrix
|
||||
def _err(ex):
|
||||
if not getattr(self, '_alive', True) or not self.winfo_exists():
|
||||
return
|
||||
if search_req_id < self._last_req:
|
||||
return
|
||||
messagebox.showerror("Ricerca", f"Errore ricerca UDC:\n{ex}", parent=self)
|
||||
|
||||
self._async.run(self.db.query_json(sql, {"barcode": barcode}), _ok, _err, busy=self._busy, message="Cerco UDC…")
|
||||
|
||||
def _try_highlight(self, col_txt: str, fila_txt: str) -> bool:
|
||||
"""Highlight a cell by its textual row and column labels."""
|
||||
for r in range(len(self.col_txt)):
|
||||
for c in range(len(self.col_txt[r])):
|
||||
if self.col_txt[r][c] == col_txt and self.fila_txt[r][c] == fila_txt:
|
||||
self._clear_highlight()
|
||||
btn = self.buttons[r][c]
|
||||
btn.configure(border_width=3, border_color="blue")
|
||||
try:
|
||||
fr = self.btn_frames[r][c]
|
||||
fr.configure(border_color="blue", border_width=2)
|
||||
except Exception:
|
||||
pass
|
||||
self._highlighted = (r, c)
|
||||
return True
|
||||
return False
|
||||
|
||||
def _highlight_cell_by_labels(self, col_txt: str, fila_txt: str):
|
||||
"""Show a toast when a searched cell cannot be highlighted."""
|
||||
if not self._try_highlight(col_txt, fila_txt):
|
||||
self._toast("Cella trovata ma non mappabile a pulsante.")
|
||||
|
||||
# ---------------- COMMANDS ----------------
|
||||
def _refresh_current(self):
|
||||
"""Reload the matrix of the currently selected aisle."""
|
||||
if self.corsia_selezionata.get():
|
||||
self._load_matrix(self.corsia_selezionata.get())
|
||||
|
||||
def _export_xlsx(self):
|
||||
"""Export both matrix metadata and the rendered grid to Excel."""
|
||||
if not self.matrix_state:
|
||||
messagebox.showinfo("Export", "Nessuna matrice da esportare.")
|
||||
return
|
||||
corsia = self.corsia_selezionata.get() or "NA"
|
||||
ts = datetime.now().strftime("%d_%m_%Y_%H-%M")
|
||||
default = f"layout_matrice_{corsia}_{ts}.xlsx"
|
||||
path = filedialog.asksaveasfilename(
|
||||
title="Esporta matrice",
|
||||
defaultextension=".xlsx",
|
||||
initialfile=default,
|
||||
filetypes=[("Excel", "*.xlsx")]
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
try:
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import PatternFill, Alignment, Font
|
||||
except Exception as ex:
|
||||
messagebox.showerror("Export", f"Manca openpyxl: {ex}\nInstalla con: pip install openpyxl")
|
||||
return
|
||||
rows = len(self.matrix_state)
|
||||
cols = len(self.matrix_state[0]) if self.matrix_state else 0
|
||||
wb = Workbook()
|
||||
ws1 = wb.active
|
||||
ws1.title = f"Dettaglio {corsia}"
|
||||
ws1.append(["Corsia", "FilaIdx", "ColIdx", "Stato", "Descrizione", "FilaTxt", "ColTxt", "UDC1"])
|
||||
for r in range(rows):
|
||||
for c in range(cols):
|
||||
st = self.matrix_state[r][c]
|
||||
stato_lbl = "Vuota" if st == 0 else ("Piena" if st == 1 else "Doppia")
|
||||
ws1.append([corsia, r + 1, c + 1, stato_lbl,
|
||||
self.desc[r][c], self.fila_txt[r][c], self.col_txt[r][c], self.udc1[r][c]])
|
||||
for cell in ws1[1]:
|
||||
cell.font = Font(bold=True)
|
||||
|
||||
ws2 = wb.create_sheet(f"Matrice {corsia}")
|
||||
fills = {
|
||||
0: PatternFill("solid", fgColor="B0B0B0"),
|
||||
1: PatternFill("solid", fgColor="FFA500"),
|
||||
2: PatternFill("solid", fgColor="D62728"),
|
||||
}
|
||||
center = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
||||
for r in range(rows):
|
||||
for c in range(cols):
|
||||
value = f"{corsia}.{self.col_txt[r][c]}.{self.fila_txt[r][c]}\n{self.udc1[r][c]}"
|
||||
cell = ws2.cell(row=(rows - r), column=c + 1, value=value) # capovolto per avere 'a' in basso
|
||||
cell.fill = fills.get(self.matrix_state[r][c], fills[0])
|
||||
cell.alignment = center
|
||||
try:
|
||||
wb.save(path)
|
||||
self._toast(f"Esportato: {path}")
|
||||
except Exception as ex:
|
||||
messagebox.showerror("Export", f"Salvataggio fallito:\n{ex}")
|
||||
|
||||
# ---------------- STATS ----------------
|
||||
def _refresh_stats(self):
|
||||
"""Refresh global and local occupancy statistics shown in the footer."""
|
||||
# globale dal DB
|
||||
sql_tot = """
|
||||
WITH C AS (
|
||||
SELECT ID
|
||||
FROM dbo.Celle
|
||||
WHERE ID <> 9999 AND (DelDataOra IS NULL)
|
||||
AND LTRIM(RTRIM(Corsia)) <> '7G'
|
||||
AND LTRIM(RTRIM(Fila)) IS NOT NULL
|
||||
AND LTRIM(RTRIM(Colonna)) IS NOT NULL
|
||||
),
|
||||
S AS (
|
||||
SELECT c.ID, COUNT(DISTINCT g.BarcodePallet) AS n
|
||||
FROM C AS c LEFT JOIN dbo.XMag_GiacenzaPallet AS g ON g.IDCella = c.ID
|
||||
GROUP BY c.ID
|
||||
)
|
||||
SELECT
|
||||
CAST(SUM(CASE WHEN s.n>0 THEN 1 ELSE 0 END) AS float)/NULLIF(COUNT(*),0) AS PercPieno,
|
||||
CAST(SUM(CASE WHEN s.n>1 THEN 1 ELSE 0 END) AS float)/NULLIF(COUNT(*),0) AS PercDoppie
|
||||
FROM C LEFT JOIN S s ON s.ID = C.ID;
|
||||
"""
|
||||
def _ok(res):
|
||||
if not getattr(self, '_alive', True) or not self.winfo_exists():
|
||||
return
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
p_full = float(rows[0][0] or 0.0) if rows else 0.0
|
||||
p_dbl = float(rows[0][1] or 0.0) if rows else 0.0
|
||||
self._draw_bar(self.tot_canvas, p_full)
|
||||
self.tot_text.configure(text=pct_text(p_full, p_dbl))
|
||||
self._async.run(self.db.query_json(sql_tot, {}), _ok, lambda e: None, busy=None, message=None)
|
||||
|
||||
# selezionata dalla matrice in memoria
|
||||
if self.matrix_state:
|
||||
tot = sum(len(r) for r in self.matrix_state)
|
||||
full = sum(1 for row in self.matrix_state for v in row if v in (1, 2))
|
||||
doubles = sum(1 for row in self.matrix_state for v in row if v == 2)
|
||||
p_full = (full / tot) if tot else 0.0
|
||||
p_dbl = (doubles / tot) if tot else 0.0
|
||||
else:
|
||||
p_full = p_dbl = 0.0
|
||||
self._draw_bar(self.sel_canvas, p_full)
|
||||
self.sel_text.configure(text=pct_text(p_full, p_dbl))
|
||||
|
||||
def _draw_bar(self, cv: tk.Canvas, p_full: float):
|
||||
"""Draw a horizontal occupancy bar on the given canvas."""
|
||||
cv.delete("all")
|
||||
w = max(300, cv.winfo_width() or 600)
|
||||
h = 18
|
||||
fw = int(w * max(0.0, min(1.0, p_full)))
|
||||
cv.create_rectangle(2, 2, 2 + fw, 2 + h, fill="#D62728", width=0)
|
||||
cv.create_rectangle(2 + fw, 2, 2 + w, 2 + h, fill="#2CA02C", width=0)
|
||||
cv.create_rectangle(2, 2, 2 + w, 2 + h, outline="#555", width=1)
|
||||
|
||||
# ---------------- UTIL ----------------
|
||||
def _toast(self, msg, ms=1400):
|
||||
"""Show a transient status message at the bottom of the window."""
|
||||
if not hasattr(self, "_status"):
|
||||
self._status = ctk.CTkLabel(self, anchor="w")
|
||||
self._status.grid(row=3, column=0, sticky="ew")
|
||||
self._status.configure(text=msg)
|
||||
self.after(ms, lambda: self._status.configure(text=""))
|
||||
|
||||
def _copy(self, txt: str):
|
||||
"""Copy a string to the clipboard and inform the user."""
|
||||
self.clipboard_clear()
|
||||
self.clipboard_append(txt)
|
||||
self._toast(f"Copiato: {txt}")
|
||||
|
||||
|
||||
|
||||
def destroy(self):
|
||||
"""Mark the window as closed and release dynamic widgets safely."""
|
||||
# evita nuovi refresh/async dopo destroy
|
||||
self._alive = False
|
||||
# cancella eventuali timer
|
||||
try:
|
||||
if self._stats_after_id is not None:
|
||||
self.after_cancel(self._stats_after_id)
|
||||
except Exception:
|
||||
pass
|
||||
# pulizia UI leggera
|
||||
try:
|
||||
for w in list(self.host.winfo_children()):
|
||||
w.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
super().destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def open_layout_window(parent, db_app):
|
||||
"""Open the layout window as a singleton-like child of ``parent``."""
|
||||
key = "_layout_window_singleton"
|
||||
ex = getattr(parent, key, None)
|
||||
if ex and ex.winfo_exists():
|
||||
try:
|
||||
ex.lift()
|
||||
ex.focus_force()
|
||||
return ex
|
||||
except Exception:
|
||||
pass
|
||||
w = LayoutWindow(parent, db_app)
|
||||
setattr(parent, key, w)
|
||||
return w
|
||||
491
locale.json
Normal file
491
locale.json
Normal file
@@ -0,0 +1,491 @@
|
||||
{
|
||||
"default_language": "IT",
|
||||
"IT": {
|
||||
"errors.title": "Dettaglio errore",
|
||||
"errors.copy": "Copia tutto",
|
||||
"errors.save": "Salva su file",
|
||||
"errors.close": "Chiudi",
|
||||
"errors.copied": "Testo copiato negli appunti.",
|
||||
"errors.copy_failed": "Copia non riuscita: {error}",
|
||||
"errors.saved": "Report salvato: {path}",
|
||||
"errors.save_failed": "Salvataggio non riuscito: {error}",
|
||||
"errors.text_file": "File di testo UTF-8",
|
||||
"errors.all_files": "Tutti i file",
|
||||
"inventory.title": "Inventario",
|
||||
"inventory.date": "Data (gg/mm/aaaa):",
|
||||
"inventory.load": "Calcola inventario",
|
||||
"inventory.export": "Esporta XLSX",
|
||||
"inventory.ready": "Scegli la data e premi Calcola inventario. Seleziona poi un prodotto per vedere lotti e contenitori.",
|
||||
"inventory.legend.A": "Pezzi nelle UDC presenti in WMS: scaffalate nelle aree 5/6 oppure non scaffalate.",
|
||||
"inventory.legend.B": "Pezzi in UDC assegnate ma fuori WMS: confezionamento dedotto, UDC piene o parziali.",
|
||||
"inventory.legend.C": "Pezzi in bag/vasche senza UDC: seriale 000000/..., con giacenza SAM positiva.",
|
||||
"inventory.legend.X": "Anomalie nel dettaglio: saldo SAM non classificabile in A/B/C; escluso dal totale ricostruito.",
|
||||
"inventory.formula": "Totale = A + B + C. Residuo = SAM - Totale. '?' = quantita' non determinabile, non zero.",
|
||||
"inventory.notice": "A: UDC WMS. B: UDC fuori WMS, confezionamento presunto. C: bag/vasche senza UDC. Residuo = SAM - (A+B+C). '?' indica dati non determinabili.",
|
||||
"inventory.scope": "Perimetro provvisorio: solo prodotti/lotti delle UDC in aree 5 e 6 o non scaffalate alla data. Non e' l'inventario completo SAM.",
|
||||
"inventory.history_notice": "Ricostruzione da movimenti e storico NUMSER disponibile, non inventario fisico certificato. Validare le etichette e la completezza dello storico.",
|
||||
"inventory.sources": "Ultimi movimenti nelle fonti (non data di aggiornamento del backup)",
|
||||
"inventory.detail": "Lotti e contenitori del prodotto selezionato",
|
||||
"inventory.detail_sheet": "Contenitori",
|
||||
"inventory.lot_sheet": "Lotti",
|
||||
"inventory.inferred_location": "Confezionamento (dedotto)",
|
||||
"inventory.component.A": "A - WMS",
|
||||
"inventory.component.B": "B - UDC fuori WMS",
|
||||
"inventory.component.C": "C - Senza UDC",
|
||||
"inventory.component.X": "X - Anomalia / fuori perimetro",
|
||||
"inventory.today": "Giornata corrente non ancora conclusa: il risultato comprende solo i movimenti gia' registrati.",
|
||||
"inventory.bad_date": "Inserisci una data valida gg/mm/aaaa, dal 01/01/2010 a oggi.",
|
||||
"inventory.busy": "Ricostruisco l'inventario alla data scelta...",
|
||||
"inventory.loaded": "Inventario al {date} (fine giornata) | Prodotti: {count} | Da verificare: {unknown}\nUltimo movimento WMS: {wms} | Ultimo movimento SAM: {sam}. Eseguire a movimentazioni ferme; verificare che i backup siano coerenti.",
|
||||
"inventory.failed": "Operazione non completata. Nessun dato del magazzino modificato.",
|
||||
"inventory.export_busy": "Esporto inventario...",
|
||||
"inventory.exported": "File creato:\n{path}",
|
||||
"inventory.match": "Saldo coerente (nominale)",
|
||||
"inventory.mismatch": "Differenza da verificare",
|
||||
"inventory.issue.content": "Contenuto UDC non determinabile",
|
||||
"inventory.issue.locations": "UDC in piu' locazioni",
|
||||
"inventory.issue.balance": "Saldo movimenti UDC anomalo",
|
||||
"inventory.issue.unit": "Unita' di misura da verificare",
|
||||
"inventory.issue.undated": "Movimenti WMS privi di data",
|
||||
"inventory.issue.history": "Assegnazione storica non determinabile",
|
||||
"inventory.issue.movements": "Movimenti o saldo SAM non determinabili",
|
||||
"inventory.issue.negative": "Giacenza SAM negativa",
|
||||
"inventory.issue.serial": "Seriale contenitore mancante o non valido",
|
||||
"inventory.issue.shipped": "Spedita WMS ma presenza residua da verificare",
|
||||
"inventory.issue.outside": "Presenza fuori perimetro / classificazione anomala",
|
||||
"inventory.issue.duplicate": "Contenitore duplicato con dati incompatibili",
|
||||
"inventory.issue.lot_offsets": "Differenze tra lotti si compensano: verificare il dettaglio",
|
||||
"inventory.col.Product": "Prodotto",
|
||||
"inventory.col.Description": "Descrizione",
|
||||
"inventory.col.Unit": "UM",
|
||||
"inventory.col.UDCs": "N. UDC WMS",
|
||||
"inventory.col.Shelved": "Pezzi scaffalati",
|
||||
"inventory.col.NonShelved": "Pezzi non scaffalati",
|
||||
"inventory.col.WMS": "Pezzi WMS",
|
||||
"inventory.col.SAM": "Pezzi SAM",
|
||||
"inventory.col.Difference": "Residuo SAM-(A+B+C)",
|
||||
"inventory.col.InitialDifference": "Differenza SAM-A",
|
||||
"inventory.col.PackingUDCs": "N. UDC fuori WMS",
|
||||
"inventory.col.Packing": "Pezzi B - UDC fuori WMS",
|
||||
"inventory.col.LooseContainers": "N. contenitori senza UDC",
|
||||
"inventory.col.Loose": "Pezzi C - Senza UDC",
|
||||
"inventory.col.Reconstructed": "Totale A+B+C",
|
||||
"inventory.col.Component": "Componente",
|
||||
"inventory.col.Lot": "Lotto",
|
||||
"inventory.col.ContainerId": "ID LOTSER",
|
||||
"inventory.col.Serial": "Seriale contenitore",
|
||||
"inventory.col.SamQuantity": "Giacenza SAM contenitore",
|
||||
"inventory.col.Status": "Esito / anomalie",
|
||||
"inventory.col.Pallet": "UDC",
|
||||
"inventory.col.Location": "Cella alla data",
|
||||
"inventory.col.Quantity": "Pezzi della componente",
|
||||
"launcher.window_title": "Warehouse 1.0.0",
|
||||
"launcher.operator": "Operatore: {display_name} ({login})",
|
||||
"launcher.reset_corsie": "Gestione Corsie",
|
||||
"launcher.layout": "Gestione Layout",
|
||||
"launcher.multi_udc": "UDC Fantasma",
|
||||
"launcher.search": "Ricerca UDC",
|
||||
"launcher.history_udc": "Storico movimenti UDC",
|
||||
"launcher.pickinglist": "Gestione Picking List",
|
||||
"launcher.history_pickinglist": "Storico Picking List",
|
||||
"launcher.diagnostics": "Diagnostica",
|
||||
"launcher.arrange": "Ridisponi finestre",
|
||||
"launcher.exit": "Esci",
|
||||
"launcher.already_running_title": "Warehouse",
|
||||
"launcher.already_running_message": "L'applicazione è già in esecuzione.",
|
||||
"login.title": "Login Warehouse",
|
||||
"login.heading": "Autenticazione operatore",
|
||||
"login.label.login": "Login",
|
||||
"login.label.password": "Password",
|
||||
"login.info": "Per ora tutti gli operatori autenticati possono usare tutte le funzioni.",
|
||||
"login.button.cancel": "Annulla",
|
||||
"login.button.submit": "Accedi",
|
||||
"login.status.checking": "Verifico credenziali...",
|
||||
"login.msg.title": "Login",
|
||||
"login.msg.missing": "Inserisci login e password.",
|
||||
"login.msg.invalid": "Credenziali non valide.",
|
||||
"login.msg.error": "Verifica credenziali fallita:\n{error}",
|
||||
"dbconfig.title": "Configurazione Database",
|
||||
"dbconfig.heading": "Configura la connessione al database del magazzino",
|
||||
"dbconfig.label.server": "Server",
|
||||
"dbconfig.label.database": "Database",
|
||||
"dbconfig.label.user": "Utente",
|
||||
"dbconfig.label.password": "Password",
|
||||
"dbconfig.label.driver": "Driver ODBC",
|
||||
"dbconfig.label.encrypt": "Encrypt",
|
||||
"dbconfig.label.trust_server_certificate": "Trust server certificate",
|
||||
"dbconfig.info": "Il file verra' salvato localmente e non verra' piu' richiesto ai prossimi avvii.",
|
||||
"dbconfig.button.cancel": "Annulla",
|
||||
"dbconfig.button.test": "Test connessione",
|
||||
"dbconfig.button.save": "Salva",
|
||||
"dbconfig.busy": "Verifico connessione...",
|
||||
"dbconfig.msg.title": "Configurazione Database",
|
||||
"dbconfig.msg.missing": "Compila almeno server, database, utente e password.",
|
||||
"dbconfig.msg.test_error": "Connessione fallita:\n{error}",
|
||||
"dbconfig.msg.test_ok": "Connessione riuscita.",
|
||||
"dbconfig.msg.save_error": "Salvataggio fallito:\n{error}",
|
||||
"search.title": "Ricerca UDC/Lotto/Codice",
|
||||
"search.label.udc": "UDC:",
|
||||
"search.label.lot": "Lotto:",
|
||||
"search.label.code": "Codice prodotto:",
|
||||
"search.button.search": "Cerca",
|
||||
"search.button.export": "Esporta XLSX",
|
||||
"search.msg.confirm_title": "Conferma",
|
||||
"search.msg.confirm_all": "Nessun filtro impostato. Vuoi cercare su TUTTO il magazzino?",
|
||||
"search.msg.export_title": "Esporta",
|
||||
"search.msg.export_empty": "Non ci sono righe da esportare.",
|
||||
"search.msg.export_dep": "Per l'esportazione serve 'openpyxl' (pip install openpyxl).",
|
||||
"search.msg.export_error": "Errore durante l'esportazione:{error}",
|
||||
"search.msg.no_results_title": "Nessun risultato",
|
||||
"search.msg.no_results": "Nessuna corrispondenza trovata con le chiavi di ricerca inserite.",
|
||||
"search.msg.error_title": "Errore ricerca",
|
||||
"search.busy": "Cerco...",
|
||||
"history.udc.title": "Storico movimenti UDC",
|
||||
"history.udc.button.search": "Cerca",
|
||||
"history.udc.busy": "Carico storico UDC...",
|
||||
"history.udc.msg.title": "Storico UDC",
|
||||
"history.udc.msg.empty": "Nessun movimento trovato.",
|
||||
"history.udc.msg.error": "Errore ricerca:\n{error}",
|
||||
"history.picking.title": "Storico Picking List",
|
||||
"history.picking.document": "Documento:",
|
||||
"history.picking.year": "Anno",
|
||||
"history.picking.udc_hint": "UDC vuota: anno corrente. Ricerca UDC: anno corrente e precedente. Se compilati, entrambi i filtri si applicano.",
|
||||
"history.picking.udc_invalid": "Inserire il codice UDC completo, numerico, di massimo 6 cifre.",
|
||||
"history.picking.button.reload": "Ricarica",
|
||||
"history.picking.detail_title": "Dettaglio contenuto",
|
||||
"history.picking.busy.master": "Carico storico picking list...",
|
||||
"history.picking.busy.detail": "Carico dettaglio picking list...",
|
||||
"history.picking.msg.title": "Storico Picking List",
|
||||
"history.picking.msg.load_error": "Errore caricamento:\n{error}",
|
||||
"history.picking.msg.detail_error": "Errore dettaglio:\n{error}",
|
||||
"diagnostics.title": "Diagnostica",
|
||||
"diagnostics.button.shipped_not_disassociated": "UDC spedite non disassociate",
|
||||
"diagnostics.button.multiple_udc_by_cell": "Celle con multiple UDC",
|
||||
"diagnostics.button.sam_udc_not_in_wms": "Ultime UDC SAM non in WMS",
|
||||
"diagnostics.button.export": "Esporta XLSX",
|
||||
"diagnostics.busy.shipped_not_disassociated": "Cerco UDC spedite ma ancora in cella...",
|
||||
"diagnostics.busy.multiple_udc_by_cell": "Cerco celle con multiple UDC...",
|
||||
"diagnostics.busy.sam_udc_not_in_wms": "Cerco le ultime UDC presenti in SAM ma non ancora in WMS...",
|
||||
"diagnostics.status.rows": "Righe trovate: {count}",
|
||||
"diagnostics.col.udc": "UDC",
|
||||
"diagnostics.col.cell": "CELLA",
|
||||
"diagnostics.col.lot": "Lotto",
|
||||
"diagnostics.col.product": "Prodotto",
|
||||
"diagnostics.col.description": "Descrizione",
|
||||
"diagnostics.col.shipped_not_disassociated": "Spedita ma non disassociata",
|
||||
"diagnostics.col.symbolic_cell": "Nome simbolico cella",
|
||||
"diagnostics.export.title": "Esporta",
|
||||
"diagnostics.export.empty": "Non ci sono righe da esportare.",
|
||||
"diagnostics.export.dep": "Per l'esportazione serve 'openpyxl' (pip install openpyxl).",
|
||||
"diagnostics.export.ok": "File creato:\n{path}",
|
||||
"diagnostics.export.error": "Errore durante l'esportazione:\n{error}",
|
||||
"reset.title": "Gestione Corsie - svuotamento celle per corsia",
|
||||
"reset.label.aisle": "Corsia:",
|
||||
"reset.button.refresh": "Carica",
|
||||
"reset.button.empty": "Svuota corsia...",
|
||||
"reset.summary": "Riepilogo",
|
||||
"reset.confirm": "Verranno movimentate {udc} UDC da {cells} celle della corsia {aisle}.\nUDC associate a documenti di spedizione definitivi (stato D): spedite in 9999 / 7G.1.1.\nTutte le altre: non scaffalate in 1000 (barcode 9001000).\nSaranno registrati prelievo e versamento, senza cancellazioni.\nLa verifica viene effettuata al momento di ogni movimento.\nDigitare il nome della corsia per confermare:",
|
||||
"reset.result": "Corsia {aisle}: movimentate {success} UDC su {total}.\nSpedite in 9999 / 7G.1.1: {shipped}.\nNon scaffalate in 1000: {non_shelved}.\nAggiornare lo storico picking list per ricalcolare i residui.",
|
||||
"layout.title": "Layout corsie",
|
||||
"layout.button.search": "Cerca per barcode UDC",
|
||||
"layout.button.refresh": "Aggiorna",
|
||||
"layout.button.export": "Export XLSX",
|
||||
"layout.fill.global": "Riempimento globale",
|
||||
"layout.fill.selected": "Riempimento corsia selezionata",
|
||||
"layout.legend": "Legenda celle:",
|
||||
"multi.title": "Celle con piu' pallet",
|
||||
"multi.button.refresh": "Aggiorna",
|
||||
"multi.button.expand": "Espandi tutto",
|
||||
"multi.button.collapse": "Comprimi tutto",
|
||||
"multi.button.preselect": "Preselezione fantasmi corsia",
|
||||
"multi.button.remove": "Rimuovi fantasmi corsia",
|
||||
"multi.button.export": "Esporta in XLSX",
|
||||
"multi.summary": "Riepilogo % celle multiple per corsia",
|
||||
"picking.title": "Gestione Picking List",
|
||||
"picking.button.reload": "Ricarica",
|
||||
"picking.button.prenota": "Prenota",
|
||||
"picking.button.sprenota": "S-prenota",
|
||||
"picking.button.sequence": "Sequenza di prelievo",
|
||||
"picking.button.export": "Esporta XLSX",
|
||||
"picking.label.days": "Giorni:",
|
||||
"picking.sequence.title": "Sequenza di prelievo",
|
||||
"picking.sequence.document": "Picking List {documento}",
|
||||
"picking.sequence.available": "Scaffali disponibili",
|
||||
"picking.sequence.selected": "Ordine personalizzato",
|
||||
"picking.sequence.hint": "Trascina gli scaffali a destra. Quelli non inseriti saranno accodati secondo l'ordine predefinito.",
|
||||
"picking.sequence.default_hint": "Default: prima Non scaff., poi gli scaffali secondo l'ordine WMS.",
|
||||
"picking.sequence.button.add": "Aggiungi >",
|
||||
"picking.sequence.button.remove": "< Rimuovi",
|
||||
"picking.sequence.button.up": "Su",
|
||||
"picking.sequence.button.down": "Giu'",
|
||||
"picking.sequence.button.save": "Salva",
|
||||
"picking.sequence.button.reset": "Ripristina default",
|
||||
"picking.sequence.button.close": "Chiudi",
|
||||
"picking.sequence.busy.load": "Carico gli scaffali...",
|
||||
"picking.sequence.busy.save": "Salvo la sequenza...",
|
||||
"picking.sequence.msg.select": "Seleziona una Picking List prima di definire la sequenza.",
|
||||
"picking.sequence.msg.denied": "Permesso negato.",
|
||||
"picking.sequence.msg.saved": "Sequenza salvata.",
|
||||
"picking.sequence.msg.reset": "Sequenza personalizzata rimossa. E' attivo l'ordine predefinito.",
|
||||
"picking.sequence.msg.load_error": "Errore durante il caricamento:\n{error}",
|
||||
"picking.sequence.msg.save_error": "Errore durante il salvataggio:\n{error}",
|
||||
"scarico.title": "Scarica {ubicazione}",
|
||||
"scarico.label.location": "Ubicazione: {ubicazione}",
|
||||
"scarico.label.select": "Seleziona le UDC da scaricare",
|
||||
"scarico.col.udc": "UDC",
|
||||
"scarico.col.last_insert": "Ultimo inserimento",
|
||||
"scarico.col.diagnostic": "Diagnostica",
|
||||
"scarico.button.submit": "Scarica",
|
||||
"scarico.button.shipped": "Scarico come spedita",
|
||||
"scarico.button.non_shelved": "Scarico come non scaff.",
|
||||
"scarico.button.close": "Chiudi",
|
||||
"scarico.msg.title": "Scarica",
|
||||
"scarico.msg.select_one": "Seleziona almeno una UDC da scaricare.",
|
||||
"scarico.msg.load_error": "Caricamento UDC fallito:\n{error}",
|
||||
"scarico.msg.exec_error": "Scarico fallito:\n{error}"
|
||||
},
|
||||
"ENG": {
|
||||
"errors.title": "Error details",
|
||||
"errors.copy": "Copy all",
|
||||
"errors.save": "Save to file",
|
||||
"errors.close": "Close",
|
||||
"errors.copied": "Text copied to clipboard.",
|
||||
"errors.copy_failed": "Copy failed: {error}",
|
||||
"errors.saved": "Report saved: {path}",
|
||||
"errors.save_failed": "Save failed: {error}",
|
||||
"errors.text_file": "UTF-8 text file",
|
||||
"errors.all_files": "All files",
|
||||
"inventory.title": "Inventory",
|
||||
"inventory.date": "Date (dd/mm/yyyy):",
|
||||
"inventory.load": "Calculate inventory",
|
||||
"inventory.export": "Export XLSX",
|
||||
"inventory.ready": "Choose a date and Calculate inventory. Then select a product to see lots and containers.",
|
||||
"inventory.legend.A": "Pieces in WMS UDCs: shelved in areas 5/6 or non-shelved.",
|
||||
"inventory.legend.B": "Pieces assigned to UDCs outside WMS: inferred packaging, full or partial UDCs.",
|
||||
"inventory.legend.C": "Pieces in bags/tubs without a UDC: serial 000000/..., with positive SAM stock.",
|
||||
"inventory.legend.X": "Detail anomalies: SAM stock not classifiable as A/B/C; excluded from the reconstructed total.",
|
||||
"inventory.formula": "Total = A + B + C. Residual = SAM - Total. '?' = undetermined quantity, not zero.",
|
||||
"inventory.notice": "A: WMS UDCs. B: UDCs outside WMS, inferred packaging location. C: bags/tubs without UDC. Residual = SAM - (A+B+C). '?' means undetermined data.",
|
||||
"inventory.scope": "Provisional scope: only products/lots of UDCs in areas 5/6 or non-shelved at date. Not the complete SAM inventory.",
|
||||
"inventory.history_notice": "Reconstruction from movements and available NUMSER history, not a certified physical inventory. Validate labels and history completeness.",
|
||||
"inventory.sources": "Latest source movements (not backup update dates)",
|
||||
"inventory.detail": "Lots and containers for the selected product",
|
||||
"inventory.detail_sheet": "Containers",
|
||||
"inventory.lot_sheet": "Lots",
|
||||
"inventory.inferred_location": "Packaging (inferred)",
|
||||
"inventory.component.A": "A - WMS",
|
||||
"inventory.component.B": "B - UDCs outside WMS",
|
||||
"inventory.component.C": "C - Without UDC",
|
||||
"inventory.component.X": "X - Conflict / out of scope",
|
||||
"inventory.today": "Today is still in progress: the result includes only movements already recorded.",
|
||||
"inventory.bad_date": "Enter a valid dd/mm/yyyy date between 01/01/2010 and today.",
|
||||
"inventory.busy": "Reconstructing inventory at the selected date...",
|
||||
"inventory.loaded": "Inventory at {date} (end of day) | Products: {count} | To verify: {unknown}\nLatest WMS movement: {wms} | Latest SAM movement: {sam}. Run while stock movements are stopped; verify backup consistency.",
|
||||
"inventory.failed": "Operation failed. No warehouse data was changed.",
|
||||
"inventory.export_busy": "Exporting inventory...",
|
||||
"inventory.exported": "File created:\n{path}",
|
||||
"inventory.match": "Matching balance (nominal)",
|
||||
"inventory.mismatch": "Difference to verify",
|
||||
"inventory.issue.content": "UDC content cannot be determined",
|
||||
"inventory.issue.locations": "UDC in multiple locations",
|
||||
"inventory.issue.balance": "Abnormal UDC movement balance",
|
||||
"inventory.issue.unit": "Unit of measure to verify",
|
||||
"inventory.issue.undated": "Undated WMS movements",
|
||||
"inventory.issue.history": "Historical assignment cannot be determined",
|
||||
"inventory.issue.movements": "SAM movements or balance cannot be determined",
|
||||
"inventory.issue.negative": "Negative SAM balance",
|
||||
"inventory.issue.serial": "Missing or invalid container serial",
|
||||
"inventory.issue.shipped": "WMS shipped with residual presence to verify",
|
||||
"inventory.issue.outside": "Out-of-scope presence / abnormal classification",
|
||||
"inventory.issue.duplicate": "Duplicate container with conflicting data",
|
||||
"inventory.issue.lot_offsets": "Lot differences offset each other: inspect lot details",
|
||||
"inventory.col.Product": "Product",
|
||||
"inventory.col.Description": "Description",
|
||||
"inventory.col.Unit": "UOM",
|
||||
"inventory.col.UDCs": "WMS UDC count",
|
||||
"inventory.col.Shelved": "Shelved pieces",
|
||||
"inventory.col.NonShelved": "Non-shelved pieces",
|
||||
"inventory.col.WMS": "WMS pieces",
|
||||
"inventory.col.SAM": "SAM pieces",
|
||||
"inventory.col.Difference": "Residual SAM-(A+B+C)",
|
||||
"inventory.col.InitialDifference": "SAM-A difference",
|
||||
"inventory.col.PackingUDCs": "UDCs outside WMS count",
|
||||
"inventory.col.Packing": "B pieces - UDCs outside WMS",
|
||||
"inventory.col.LooseContainers": "Unassigned container count",
|
||||
"inventory.col.Loose": "C pieces - Without UDC",
|
||||
"inventory.col.Reconstructed": "Total A+B+C",
|
||||
"inventory.col.Component": "Component",
|
||||
"inventory.col.Lot": "Lot",
|
||||
"inventory.col.ContainerId": "LOTSER ID",
|
||||
"inventory.col.Serial": "Container serial",
|
||||
"inventory.col.SamQuantity": "Container SAM balance",
|
||||
"inventory.col.Status": "Result / issues",
|
||||
"inventory.col.Pallet": "UDC",
|
||||
"inventory.col.Location": "Location at date",
|
||||
"inventory.col.Quantity": "Component pieces",
|
||||
"launcher.window_title": "Warehouse 1.0.0",
|
||||
"launcher.operator": "Operator: {display_name} ({login})",
|
||||
"launcher.reset_corsie": "Aisle Management",
|
||||
"launcher.layout": "Layout Management",
|
||||
"launcher.multi_udc": "Ghost UDC",
|
||||
"launcher.search": "UDC Search",
|
||||
"launcher.history_udc": "UDC Movement History",
|
||||
"launcher.pickinglist": "Picking List Management",
|
||||
"launcher.history_pickinglist": "Picking List History",
|
||||
"launcher.diagnostics": "Diagnostics",
|
||||
"launcher.arrange": "Arrange windows",
|
||||
"launcher.exit": "Exit",
|
||||
"launcher.already_running_title": "Warehouse",
|
||||
"launcher.already_running_message": "The application is already running.",
|
||||
"login.title": "Warehouse Login",
|
||||
"login.heading": "Operator authentication",
|
||||
"login.label.login": "Login",
|
||||
"login.label.password": "Password",
|
||||
"login.info": "For now, every authenticated operator can use every function.",
|
||||
"login.button.cancel": "Cancel",
|
||||
"login.button.submit": "Sign in",
|
||||
"login.status.checking": "Checking credentials...",
|
||||
"login.msg.title": "Login",
|
||||
"login.msg.missing": "Enter login and password.",
|
||||
"login.msg.invalid": "Invalid credentials.",
|
||||
"login.msg.error": "Credential check failed:\n{error}",
|
||||
"dbconfig.title": "Database Configuration",
|
||||
"dbconfig.heading": "Configure the warehouse database connection",
|
||||
"dbconfig.label.server": "Server",
|
||||
"dbconfig.label.database": "Database",
|
||||
"dbconfig.label.user": "User",
|
||||
"dbconfig.label.password": "Password",
|
||||
"dbconfig.label.driver": "ODBC Driver",
|
||||
"dbconfig.label.encrypt": "Encrypt",
|
||||
"dbconfig.label.trust_server_certificate": "Trust server certificate",
|
||||
"dbconfig.info": "The file will be saved locally and will not be requested again on the next startup.",
|
||||
"dbconfig.button.cancel": "Cancel",
|
||||
"dbconfig.button.test": "Test connection",
|
||||
"dbconfig.button.save": "Save",
|
||||
"dbconfig.busy": "Checking connection...",
|
||||
"dbconfig.msg.title": "Database Configuration",
|
||||
"dbconfig.msg.missing": "Fill in at least server, database, user and password.",
|
||||
"dbconfig.msg.test_error": "Connection failed:\n{error}",
|
||||
"dbconfig.msg.test_ok": "Connection successful.",
|
||||
"dbconfig.msg.save_error": "Save failed:\n{error}",
|
||||
"search.title": "Search UDC/Lot/Code",
|
||||
"search.label.udc": "UDC:",
|
||||
"search.label.lot": "Lot:",
|
||||
"search.label.code": "Product code:",
|
||||
"search.button.search": "Search",
|
||||
"search.button.export": "Export XLSX",
|
||||
"search.msg.confirm_title": "Confirm",
|
||||
"search.msg.confirm_all": "No filters set. Search the whole warehouse?",
|
||||
"search.msg.export_title": "Export",
|
||||
"search.msg.export_empty": "There are no rows to export.",
|
||||
"search.msg.export_dep": "Export requires 'openpyxl' (pip install openpyxl).",
|
||||
"search.msg.export_error": "Export failed:{error}",
|
||||
"search.msg.no_results_title": "No results",
|
||||
"search.msg.no_results": "No matches were found for the entered search keys.",
|
||||
"search.msg.error_title": "Search error",
|
||||
"search.busy": "Searching...",
|
||||
"history.udc.title": "UDC Movement History",
|
||||
"history.udc.button.search": "Search",
|
||||
"history.udc.busy": "Loading UDC history...",
|
||||
"history.udc.msg.title": "UDC History",
|
||||
"history.udc.msg.empty": "No movement found.",
|
||||
"history.udc.msg.error": "Search failed:\n{error}",
|
||||
"history.picking.title": "Picking List History",
|
||||
"history.picking.document": "Document:",
|
||||
"history.picking.year": "Year",
|
||||
"history.picking.udc_hint": "Empty UDC: current year. UDC search: current and previous year. Both filters apply when filled in.",
|
||||
"history.picking.udc_invalid": "Enter the complete numeric UDC code, up to 6 digits.",
|
||||
"history.picking.button.reload": "Reload",
|
||||
"history.picking.detail_title": "Content detail",
|
||||
"history.picking.busy.master": "Loading picking-list history...",
|
||||
"history.picking.busy.detail": "Loading picking-list detail...",
|
||||
"history.picking.msg.title": "Picking List History",
|
||||
"history.picking.msg.load_error": "Load failed:\n{error}",
|
||||
"history.picking.msg.detail_error": "Detail load failed:\n{error}",
|
||||
"diagnostics.title": "Diagnostics",
|
||||
"diagnostics.button.shipped_not_disassociated": "Shipped UDC not disassociated",
|
||||
"diagnostics.button.multiple_udc_by_cell": "Cells with multiple UDC",
|
||||
"diagnostics.button.sam_udc_not_in_wms": "Latest UDC in SAM not in WMS",
|
||||
"diagnostics.button.export": "Export XLSX",
|
||||
"diagnostics.busy.shipped_not_disassociated": "Searching shipped UDC still assigned to cells...",
|
||||
"diagnostics.busy.multiple_udc_by_cell": "Searching cells with multiple UDC...",
|
||||
"diagnostics.busy.sam_udc_not_in_wms": "Searching latest UDC present in SAM but not yet in WMS...",
|
||||
"diagnostics.status.rows": "Rows found: {count}",
|
||||
"diagnostics.col.udc": "UDC",
|
||||
"diagnostics.col.cell": "CELL",
|
||||
"diagnostics.col.lot": "Lot",
|
||||
"diagnostics.col.product": "Product",
|
||||
"diagnostics.col.description": "Description",
|
||||
"diagnostics.col.shipped_not_disassociated": "Shipped but not disassociated",
|
||||
"diagnostics.col.symbolic_cell": "Symbolic cell name",
|
||||
"diagnostics.export.title": "Export",
|
||||
"diagnostics.export.empty": "There are no rows to export.",
|
||||
"diagnostics.export.dep": "Export requires 'openpyxl' (pip install openpyxl).",
|
||||
"diagnostics.export.ok": "File created:\n{path}",
|
||||
"diagnostics.export.error": "Export failed:\n{error}",
|
||||
"reset.title": "Aisle Management - empty cells by aisle",
|
||||
"reset.label.aisle": "Aisle:",
|
||||
"reset.button.refresh": "Load",
|
||||
"reset.button.empty": "Empty aisle...",
|
||||
"reset.summary": "Summary",
|
||||
"reset.confirm": "{udc} UDCs will be moved from {cells} cells in aisle {aisle}.\nUDCs associated with definitive shipping documents (state D): shipped to 9999 / 7G.1.1.\nAll others: non-shelved in 1000 (barcode 9001000).\nPick and put-away movements will be recorded, without deletions.\nThe check is performed when each UDC is moved.\nType the aisle name to confirm:",
|
||||
"reset.result": "Aisle {aisle}: moved {success} out of {total} UDCs.\nShipped to 9999 / 7G.1.1: {shipped}.\nNon-shelved in 1000: {non_shelved}.\nRefresh picking-list history to recalculate residuals.",
|
||||
"layout.title": "Aisle layout",
|
||||
"layout.button.search": "Search by UDC barcode",
|
||||
"layout.button.refresh": "Refresh",
|
||||
"layout.button.export": "Export XLSX",
|
||||
"layout.fill.global": "Global occupancy",
|
||||
"layout.fill.selected": "Selected aisle occupancy",
|
||||
"layout.legend": "Cell legend:",
|
||||
"multi.title": "Cells with multiple pallets",
|
||||
"multi.button.refresh": "Refresh",
|
||||
"multi.button.expand": "Expand all",
|
||||
"multi.button.collapse": "Collapse all",
|
||||
"multi.button.preselect": "Preselect aisle ghosts",
|
||||
"multi.button.remove": "Remove aisle ghosts",
|
||||
"multi.button.export": "Export to XLSX",
|
||||
"multi.summary": "Summary % of multi-UDC cells by aisle",
|
||||
"picking.title": "Picking List Management",
|
||||
"picking.button.reload": "Reload",
|
||||
"picking.button.prenota": "Reserve",
|
||||
"picking.button.sprenota": "Unreserve",
|
||||
"picking.button.sequence": "Pickup sequence",
|
||||
"picking.button.export": "Export XLSX",
|
||||
"picking.label.days": "Days:",
|
||||
"picking.sequence.title": "Pickup sequence",
|
||||
"picking.sequence.document": "Picking List {documento}",
|
||||
"picking.sequence.available": "Available racks",
|
||||
"picking.sequence.selected": "Custom order",
|
||||
"picking.sequence.hint": "Drag racks to the right. Missing racks are appended using the default order.",
|
||||
"picking.sequence.default_hint": "Default: non-shelved first, then racks in WMS order.",
|
||||
"picking.sequence.button.add": "Add >",
|
||||
"picking.sequence.button.remove": "< Remove",
|
||||
"picking.sequence.button.up": "Up",
|
||||
"picking.sequence.button.down": "Down",
|
||||
"picking.sequence.button.save": "Save",
|
||||
"picking.sequence.button.reset": "Restore default",
|
||||
"picking.sequence.button.close": "Close",
|
||||
"picking.sequence.busy.load": "Loading racks...",
|
||||
"picking.sequence.busy.save": "Saving sequence...",
|
||||
"picking.sequence.msg.select": "Select a Picking List before defining its sequence.",
|
||||
"picking.sequence.msg.denied": "Permission denied.",
|
||||
"picking.sequence.msg.saved": "Sequence saved.",
|
||||
"picking.sequence.msg.reset": "Custom sequence removed. The default order is active.",
|
||||
"picking.sequence.msg.load_error": "Load failed:\n{error}",
|
||||
"picking.sequence.msg.save_error": "Save failed:\n{error}",
|
||||
"scarico.title": "Unload {ubicazione}",
|
||||
"scarico.label.location": "Location: {ubicazione}",
|
||||
"scarico.label.select": "Select the UDCs to unload",
|
||||
"scarico.col.udc": "UDC",
|
||||
"scarico.col.last_insert": "Last insert",
|
||||
"scarico.col.diagnostic": "Diagnostics",
|
||||
"scarico.button.submit": "Unload",
|
||||
"scarico.button.shipped": "Unload as shipped",
|
||||
"scarico.button.non_shelved": "Unload as non-shelved",
|
||||
"scarico.button.close": "Close",
|
||||
"scarico.msg.title": "Unload",
|
||||
"scarico.msg.select_one": "Select at least one UDC to unload.",
|
||||
"scarico.msg.load_error": "UDC load failed:\n{error}",
|
||||
"scarico.msg.exec_error": "Unload failed:\n{error}"
|
||||
}
|
||||
}
|
||||
44
locale_text.py
Normal file
44
locale_text.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Localized UI text loader for the warehouse desktop application."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
_LOCALE_FILE = Path(__file__).with_name("locale.json")
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def load_locale_catalog() -> dict:
|
||||
"""Load the locale catalog from JSON, returning a safe default on errors."""
|
||||
|
||||
try:
|
||||
return json.loads(_LOCALE_FILE.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
return {"default_language": "IT", "IT": {}, "ENG": {}}
|
||||
|
||||
|
||||
def reload_locale_catalog() -> dict:
|
||||
"""Clear the locale cache and reload the catalog from disk."""
|
||||
|
||||
load_locale_catalog.cache_clear()
|
||||
return load_locale_catalog()
|
||||
|
||||
|
||||
def text(key: str, *, language: str | None = None, catalog: dict | None = None, default: str = "") -> str:
|
||||
"""Return the localized UI text for ``key`` with Italian fallback."""
|
||||
|
||||
data = catalog or load_locale_catalog()
|
||||
lang = str(language or data.get("default_language") or "IT").upper()
|
||||
texts = data.get(lang, {}) or {}
|
||||
if key in texts:
|
||||
return str(texts[key])
|
||||
fallback = data.get("IT", {}) or {}
|
||||
if key in fallback:
|
||||
return str(fallback[key])
|
||||
return str(default)
|
||||
319
login_window.py
Normal file
319
login_window.py
Normal file
@@ -0,0 +1,319 @@
|
||||
"""Application login dialog backed by the ``Operatori`` table."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tkinter as tk
|
||||
import error_dialog as messagebox
|
||||
from tkinter import ttk
|
||||
from typing import Any
|
||||
|
||||
from audit_log import log_session_event
|
||||
from gestione_aree import AsyncRunner
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from ui_theme import theme_section, theme_value
|
||||
from user_session import UserSession, create_user_session
|
||||
from version_info import module_version, versioned_title
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
|
||||
SQL_LOGIN = """
|
||||
SELECT TOP (1)
|
||||
ID,
|
||||
Login,
|
||||
Nominativo,
|
||||
Privilegio,
|
||||
CodiceUnita
|
||||
FROM dbo.Operatori
|
||||
WHERE LTRIM(RTRIM(Login)) = :login
|
||||
AND LTRIM(RTRIM([Password])) = :password
|
||||
ORDER BY ID;
|
||||
"""
|
||||
|
||||
|
||||
def _rows_to_dicts(res: Any) -> list[dict[str, Any]]:
|
||||
"""Normalize DB responses into a list of row dictionaries."""
|
||||
|
||||
if res is None:
|
||||
return []
|
||||
if isinstance(res, list):
|
||||
return [row for row in res if isinstance(row, dict)]
|
||||
if isinstance(res, dict):
|
||||
rows = res.get("rows") or res.get("data") or res.get("records") or []
|
||||
if rows and isinstance(rows[0], dict):
|
||||
return rows
|
||||
cols = res.get("columns") or []
|
||||
out: list[dict[str, Any]] = []
|
||||
for row in rows:
|
||||
if isinstance(row, (list, tuple)) and cols:
|
||||
out.append({str(cols[i]): row[i] for i in range(min(len(cols), len(row)))})
|
||||
return out
|
||||
return []
|
||||
|
||||
|
||||
class LoginWindow(tk.Toplevel):
|
||||
"""Small modal dialog used to authenticate one warehouse operator."""
|
||||
|
||||
def __init__(self, parent: tk.Misc, db_client, *, compact: bool = False):
|
||||
super().__init__(parent)
|
||||
self.db_client = db_client
|
||||
self.compact = bool(compact)
|
||||
self.result_session: UserSession | None = None
|
||||
self._async = AsyncRunner(self)
|
||||
self._theme = theme_section("login_window", {})
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self._login_button: ttk.Button | None = None
|
||||
self._cancel_button: ttk.Button | None = None
|
||||
self._status_var = tk.StringVar(value="")
|
||||
self._show_ready_after_id: str | None = None
|
||||
self._clear_topmost_after_id: str | None = None
|
||||
|
||||
self.title(versioned_title(loc_text("login.msg.title", catalog=self._locale_catalog, default="Login"), __name__))
|
||||
self.geometry("170x148+0+0" if self.compact else str(theme_value(self._theme, "window_geometry", "165x170+0+0")))
|
||||
self.resizable(False, False)
|
||||
try:
|
||||
if parent is not None and parent.winfo_viewable():
|
||||
self.transient(parent)
|
||||
except Exception:
|
||||
pass
|
||||
self.protocol("WM_DELETE_WINDOW", self._on_cancel)
|
||||
|
||||
self.login_var = tk.StringVar()
|
||||
self.password_var = tk.StringVar()
|
||||
|
||||
self._build_ui()
|
||||
self.update_idletasks()
|
||||
self.grab_set()
|
||||
self.deiconify()
|
||||
self.lift()
|
||||
self.attributes("-topmost", True)
|
||||
self._show_ready_after_id = self.after(50, self._show_ready)
|
||||
|
||||
def _build_ui(self) -> None:
|
||||
"""Build the compact operator login form."""
|
||||
|
||||
body = ttk.Frame(self, padding=6 if self.compact else 8)
|
||||
body.pack(fill="both", expand=True)
|
||||
body.columnconfigure(1, weight=0)
|
||||
|
||||
row_offset = 0
|
||||
|
||||
ttk.Label(body, text="User:").grid(row=row_offset, column=0, sticky="w", padx=(0, 4), pady=(2, 3))
|
||||
self.login_entry = ttk.Entry(body, textvariable=self.login_var, width=10, font=("Segoe UI", 10 if self.compact else 9))
|
||||
self.login_entry.grid(row=row_offset, column=1, sticky="w", pady=(2, 3))
|
||||
|
||||
ttk.Label(body, text="Pwd:").grid(row=row_offset + 1, column=0, sticky="w", padx=(0, 4), pady=(2, 2))
|
||||
self.password_entry = ttk.Entry(body, textvariable=self.password_var, width=10, show="*", font=("Segoe UI", 10 if self.compact else 9))
|
||||
self.password_entry.grid(row=row_offset + 1, column=1, sticky="w", pady=(2, 2))
|
||||
|
||||
if self.compact:
|
||||
actions = ttk.Frame(body)
|
||||
actions.grid(row=row_offset + 2, column=0, columnspan=2, sticky="ew", pady=(3, 0))
|
||||
self._login_button = ttk.Button(
|
||||
actions,
|
||||
text="OK",
|
||||
command=self._on_login,
|
||||
)
|
||||
self._login_button.grid(row=0, column=0, sticky="ew")
|
||||
self._cancel_button = ttk.Button(
|
||||
actions,
|
||||
text="Annulla",
|
||||
command=self._on_cancel,
|
||||
)
|
||||
self._cancel_button.grid(row=1, column=0, sticky="ew", pady=(3, 0))
|
||||
else:
|
||||
self.status_label = ttk.Label(body, textvariable=self._status_var, foreground="#555555")
|
||||
self.status_label.grid(row=2, column=0, columnspan=2, sticky="w", pady=(1, 1))
|
||||
|
||||
actions = ttk.Frame(body)
|
||||
actions.grid(row=3, column=0, columnspan=2, sticky="w", pady=(3, 0))
|
||||
self._login_button = ttk.Button(
|
||||
actions,
|
||||
text=loc_text("login.button.submit", catalog=self._locale_catalog, default="OK"),
|
||||
command=self._on_login,
|
||||
)
|
||||
self._login_button.grid(row=0, column=0, sticky="ew")
|
||||
self._cancel_button = ttk.Button(
|
||||
actions,
|
||||
text=loc_text("login.button.cancel", catalog=self._locale_catalog, default="Annulla"),
|
||||
command=self._on_cancel,
|
||||
)
|
||||
self._cancel_button.grid(row=1, column=0, sticky="ew", pady=(3, 0))
|
||||
|
||||
for widget in (self.login_entry, self.password_entry, self._login_button, self._cancel_button):
|
||||
try:
|
||||
widget.configure(takefocus=True)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.bind("<Return>", lambda _e: self._on_login())
|
||||
self.bind("<Escape>", lambda _e: self._on_cancel())
|
||||
self.login_var.trace_add("write", lambda *_: self._limit_var(self.login_var, 10))
|
||||
self.password_var.trace_add("write", lambda *_: self._limit_var(self.password_var, 10))
|
||||
|
||||
def _limit_var(self, variable: tk.StringVar, max_len: int) -> None:
|
||||
value = str(variable.get() or "")
|
||||
if len(value) > max_len:
|
||||
variable.set(value[:max_len])
|
||||
|
||||
def _set_busy(self, busy: bool, message: str = "") -> None:
|
||||
"""Enable or disable user interaction during async authentication."""
|
||||
|
||||
state = "disabled" if busy else "normal"
|
||||
try:
|
||||
self.login_entry.configure(state=state)
|
||||
self.password_entry.configure(state=state)
|
||||
if self._login_button is not None:
|
||||
self._login_button.configure(state=state)
|
||||
if self._cancel_button is not None:
|
||||
self._cancel_button.configure(state=state)
|
||||
self.configure(cursor="watch" if busy else "")
|
||||
self._status_var.set(message)
|
||||
self.update_idletasks()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _focus_login(self) -> None:
|
||||
"""Focus the login entry as soon as the modal becomes visible."""
|
||||
|
||||
try:
|
||||
self.login_entry.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _show_ready(self) -> None:
|
||||
"""Make the login visible and ready even when the bootstrap root is hidden."""
|
||||
|
||||
try:
|
||||
self.attributes("-topmost", True)
|
||||
self.deiconify()
|
||||
self.lift()
|
||||
self.focus_force()
|
||||
self._focus_login()
|
||||
finally:
|
||||
try:
|
||||
self._clear_topmost_after_id = self.after(250, lambda: self.attributes("-topmost", False))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _on_login(self) -> None:
|
||||
"""Validate credentials against the Operatori table."""
|
||||
|
||||
login = str(self.login_var.get() or "").strip()
|
||||
password = str(self.password_var.get() or "").strip()
|
||||
if not login or not password:
|
||||
messagebox.showwarning(
|
||||
loc_text("login.msg.title", catalog=self._locale_catalog, default="Login"),
|
||||
loc_text("login.msg.missing", catalog=self._locale_catalog, default="Inserisci login e password."),
|
||||
parent=self,
|
||||
)
|
||||
return
|
||||
|
||||
params = {"login": login, "password": password}
|
||||
self._set_busy(True, loc_text("login.status.checking", catalog=self._locale_catalog, default="Verifico credenziali..."))
|
||||
|
||||
def _ok(res: Any) -> None:
|
||||
rows = _rows_to_dicts(res)
|
||||
self._set_busy(False, "")
|
||||
if not rows:
|
||||
log_session_event(
|
||||
None,
|
||||
action="login.failed",
|
||||
outcome="denied",
|
||||
details={"login": login},
|
||||
)
|
||||
messagebox.showerror(
|
||||
loc_text("login.msg.title", catalog=self._locale_catalog, default="Login"),
|
||||
loc_text("login.msg.invalid", catalog=self._locale_catalog, default="Credenziali non valide."),
|
||||
parent=self,
|
||||
)
|
||||
try:
|
||||
self.password_var.set("")
|
||||
self.password_entry.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
row = rows[0]
|
||||
self.result_session = create_user_session(
|
||||
operator_id=int(row.get("ID") or 0),
|
||||
login=str(row.get("Login") or login).strip(),
|
||||
nominativo=str(row.get("Nominativo") or "").strip(),
|
||||
privilegio=int(row["Privilegio"]) if row.get("Privilegio") is not None else None,
|
||||
codice_unita=str(row.get("CodiceUnita") or "").strip(),
|
||||
)
|
||||
log_session_event(
|
||||
self.result_session,
|
||||
action="login.success",
|
||||
outcome="ok",
|
||||
details={"display_name": self.result_session.display_name},
|
||||
)
|
||||
self._close()
|
||||
|
||||
def _err(ex: Exception) -> None:
|
||||
self._set_busy(False, "")
|
||||
log_session_event(
|
||||
None,
|
||||
action="login.error",
|
||||
outcome="error",
|
||||
details={"login": login, "error": str(ex)},
|
||||
)
|
||||
messagebox.showerror(
|
||||
loc_text("login.msg.title", catalog=self._locale_catalog, default="Login"),
|
||||
loc_text("login.msg.error", catalog=self._locale_catalog, default="Verifica credenziali fallita:\n{error}").format(error=ex),
|
||||
parent=self,
|
||||
exception=ex,
|
||||
)
|
||||
|
||||
self._async.run(
|
||||
self.db_client.query_json(SQL_LOGIN, params),
|
||||
_ok,
|
||||
_err,
|
||||
)
|
||||
|
||||
def _on_cancel(self) -> None:
|
||||
"""Abort the login flow and close the modal."""
|
||||
|
||||
log_session_event(None, action="login.cancel", outcome="cancelled")
|
||||
self.result_session = None
|
||||
self._close()
|
||||
|
||||
def _close(self) -> None:
|
||||
"""Release the modal grab and destroy the login window."""
|
||||
|
||||
if self._show_ready_after_id is not None:
|
||||
try:
|
||||
self.after_cancel(self._show_ready_after_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._show_ready_after_id = None
|
||||
if self._clear_topmost_after_id is not None:
|
||||
try:
|
||||
self.after_cancel(self._clear_topmost_after_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._clear_topmost_after_id = None
|
||||
try:
|
||||
self.grab_release()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def prompt_login(parent: tk.Misc, db_client) -> UserSession | None:
|
||||
"""Open the login modal and return the authenticated user session, if any."""
|
||||
|
||||
dialog = LoginWindow(parent, db_client)
|
||||
dialog.wait_window()
|
||||
return dialog.result_session
|
||||
|
||||
|
||||
def prompt_login_compact(parent: tk.Misc, db_client) -> UserSession | None:
|
||||
"""Open the barcode-oriented compact login modal."""
|
||||
|
||||
dialog = LoginWindow(parent, db_client, compact=True)
|
||||
dialog.wait_window()
|
||||
return dialog.result_session
|
||||
703
main.py
703
main.py
@@ -6,55 +6,60 @@ project.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import ctypes
|
||||
import sys
|
||||
import tkinter as tk
|
||||
import time
|
||||
|
||||
from runtime_support import ensure_stdio, run_with_fatal_log
|
||||
|
||||
ensure_stdio("warehouse_main")
|
||||
|
||||
import customtkinter as ctk
|
||||
from PIL import Image, ImageDraw
|
||||
import error_dialog as messagebox
|
||||
|
||||
from async_loop_singleton import get_global_loop
|
||||
from async_msssql_query import AsyncMSSQLClient, make_mssql_dsn
|
||||
from layout_window import open_layout_window
|
||||
from async_loop_singleton import get_global_loop, stop_global_loop
|
||||
from async_msssql_query import AsyncMSSQLClient
|
||||
from audit_log import log_session_event
|
||||
from db_config import build_dsn_from_config, ensure_db_config
|
||||
from diagnostica import open_diagnostica_window
|
||||
from inventario import open_inventario_window
|
||||
from gestione_layout import open_layout_window
|
||||
from gestione_pickinglist import open_pickinglist_window
|
||||
from login_window import prompt_login
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from reset_corsie import open_reset_corsie_window
|
||||
from search_pallets import open_search_window
|
||||
from view_celle_multiple import open_celle_multiple_window
|
||||
from storico_pickinglist import open_storico_pickinglist_window
|
||||
from storico_udc import open_storico_udc_window
|
||||
from tooltips import WidgetToolTip, load_tooltip_catalog, tooltip_text
|
||||
from udc_non_scaffalate import open_udc_non_scaffalate_window
|
||||
from ui_theme import theme_font, theme_section, theme_value
|
||||
from user_session import UserSession, create_user_session
|
||||
from version_info import module_version, versioned_title
|
||||
from view_celle_multi_udc import open_celle_multiple_window
|
||||
from window_placement import (
|
||||
cascade_children_below_parent,
|
||||
place_window_below_parent_later,
|
||||
place_window_fullsize_below_parent_later,
|
||||
)
|
||||
|
||||
# Try factory, else frame, else app (senza passare conn_str all'App)
|
||||
try:
|
||||
from gestione_pickinglist import create_frame as create_pickinglist_frame
|
||||
except Exception:
|
||||
try:
|
||||
from gestione_pickinglist import GestionePickingListFrame as _PLFrame
|
||||
# Development shortcut: skip the login dialog and boot directly as MAG1.
|
||||
# Set to False when you want to restore normal authentication.
|
||||
BYPASS_LOGIN = True
|
||||
__version__ = module_version(__name__)
|
||||
BYPASS_LOGIN_USER = {
|
||||
"operator_id": 4,
|
||||
"login": "MAG1",
|
||||
"nominativo": "MAG1",
|
||||
"privilegio": 3,
|
||||
"codice_unita": "U1",
|
||||
}
|
||||
|
||||
def create_pickinglist_frame(parent, db_client=None, conn_str=None):
|
||||
"""Build the picking list UI using the frame-based fallback."""
|
||||
ctk.set_appearance_mode("light")
|
||||
ctk.set_default_color_theme("green")
|
||||
return _PLFrame(parent, db_client=db_client, conn_str=conn_str)
|
||||
except Exception:
|
||||
from gestione_pickinglist import GestionePickingListApp as _PLApp
|
||||
|
||||
def create_pickinglist_frame(parent, db_client=None, conn_str=None):
|
||||
"""Fallback used only by legacy app-style picking list implementations."""
|
||||
app = _PLApp()
|
||||
app.mainloop()
|
||||
return tk.Frame(parent)
|
||||
|
||||
|
||||
# ---- Config ----
|
||||
SERVER = r"mde3\gesterp"
|
||||
DBNAME = "Mediseawall"
|
||||
USER = "sa"
|
||||
PASSWORD = "1Password1"
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
try:
|
||||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Create one global loop and make it the default everywhere.
|
||||
# Create one global loop for database work. Tk must keep the main thread clean;
|
||||
# callers schedule async jobs on this loop explicitly.
|
||||
_loop = get_global_loop()
|
||||
asyncio.set_event_loop(_loop)
|
||||
|
||||
|
||||
def _noop(*args, **kwargs):
|
||||
@@ -67,114 +72,574 @@ if not hasattr(tk.Toplevel, "block_update_dimensions_event"):
|
||||
if not hasattr(tk.Toplevel, "unblock_update_dimensions_event"):
|
||||
tk.Toplevel.unblock_update_dimensions_event = _noop # type: ignore[attr-defined]
|
||||
|
||||
dsn_app = make_mssql_dsn(server=SERVER, database=DBNAME, user=USER, password=PASSWORD)
|
||||
db_app = AsyncMSSQLClient(dsn_app)
|
||||
db_app: AsyncMSSQLClient | None = None
|
||||
_APP_MUTEX = None
|
||||
_APP_MUTEX_NAME = "Local\\WarehousePythonAppSingleton"
|
||||
|
||||
|
||||
def open_pickinglist_window(parent: tk.Misc, db_client: AsyncMSSQLClient):
|
||||
"""Open the picking list window while minimizing initial flicker."""
|
||||
win = ctk.CTkToplevel(parent)
|
||||
win.title("Gestione Picking List")
|
||||
win.geometry("1200x700+0+100")
|
||||
win.minsize(1000, 560)
|
||||
def _dispose_db_client() -> None:
|
||||
"""Best-effort disposal of the shared DB client."""
|
||||
|
||||
# Keep the toplevel hidden while its content is being created.
|
||||
global db_app
|
||||
if db_app is None:
|
||||
return
|
||||
try:
|
||||
win.withdraw()
|
||||
win.attributes("-alpha", 0.0)
|
||||
fut = asyncio.run_coroutine_threadsafe(db_app.dispose(), _loop)
|
||||
try:
|
||||
fut.result(timeout=2)
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
db_app = None
|
||||
|
||||
|
||||
def _destroy_tk_root(root: tk.Misc | None) -> None:
|
||||
"""Destroy a hidden bootstrap root without leaking a Tk interpreter."""
|
||||
|
||||
if root is None:
|
||||
return
|
||||
try:
|
||||
root.quit()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
root.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
frame = create_pickinglist_frame(win, db_client=db_client)
|
||||
try:
|
||||
frame.pack(fill="both", expand=True)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Show the window only when the layout is ready.
|
||||
try:
|
||||
win.update_idletasks()
|
||||
try:
|
||||
win.transient(parent)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
win.deiconify()
|
||||
except Exception:
|
||||
pass
|
||||
win.lift()
|
||||
try:
|
||||
win.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
win.attributes("-alpha", 1.0)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
def _shutdown_runtime(*, bootstrap: tk.Misc | None = None, dispose_db: bool = True) -> None:
|
||||
"""Release temporary Tk resources, DB client and background loop."""
|
||||
|
||||
win.bind("<Escape>", lambda e: win.destroy())
|
||||
win.protocol("WM_DELETE_WINDOW", win.destroy)
|
||||
return win
|
||||
try:
|
||||
_destroy_tk_root(bootstrap)
|
||||
finally:
|
||||
if dispose_db:
|
||||
_dispose_db_client()
|
||||
try:
|
||||
stop_global_loop()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _acquire_single_instance_mutex() -> bool:
|
||||
"""Return ``True`` only for the first running instance of the application."""
|
||||
|
||||
global _APP_MUTEX
|
||||
if not sys.platform.startswith("win"):
|
||||
return True
|
||||
|
||||
kernel32 = ctypes.windll.kernel32
|
||||
mutex = kernel32.CreateMutexW(None, False, _APP_MUTEX_NAME)
|
||||
if not mutex:
|
||||
return True
|
||||
|
||||
last_error = kernel32.GetLastError()
|
||||
_APP_MUTEX = mutex
|
||||
ERROR_ALREADY_EXISTS = 183
|
||||
return last_error != ERROR_ALREADY_EXISTS
|
||||
|
||||
|
||||
def _build_bypass_session() -> UserSession:
|
||||
"""Create the development session used when authentication is bypassed."""
|
||||
|
||||
return create_user_session(
|
||||
operator_id=int(BYPASS_LOGIN_USER["operator_id"]),
|
||||
login=str(BYPASS_LOGIN_USER["login"]),
|
||||
nominativo=str(BYPASS_LOGIN_USER["nominativo"]),
|
||||
privilegio=int(BYPASS_LOGIN_USER["privilegio"]),
|
||||
codice_unita=str(BYPASS_LOGIN_USER["codice_unita"]),
|
||||
)
|
||||
|
||||
|
||||
class Launcher(ctk.CTk):
|
||||
"""Main launcher window that exposes the available warehouse tools."""
|
||||
|
||||
def __init__(self):
|
||||
_WINDOW_ORDER = [
|
||||
"reset_corsie",
|
||||
"layout",
|
||||
"multi_udc",
|
||||
"non_shelved",
|
||||
"search",
|
||||
"storico_udc",
|
||||
"pickinglist",
|
||||
"storico_pickinglist",
|
||||
"diagnostica",
|
||||
"inventario",
|
||||
]
|
||||
|
||||
def __init__(self, session: UserSession, db_client: AsyncMSSQLClient):
|
||||
"""Create the launcher toolbar and wire every button to a feature window."""
|
||||
super().__init__()
|
||||
self.title("Warehouse 1.0.0")
|
||||
self.geometry("1200x70+0+0")
|
||||
self.session: UserSession = session
|
||||
self.db_client = db_client
|
||||
self._theme = theme_section("launcher", {})
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self._tooltip_catalog = load_tooltip_catalog()
|
||||
self._child_windows: list[tk.Misc] = []
|
||||
self._child_windows_by_key: dict[str, tk.Misc] = {}
|
||||
self._is_cascading = False
|
||||
self._focus_restore_pending: set[str] = set()
|
||||
self._restore_suppressed_until = 0.0
|
||||
self._exit_icon = self._make_exit_icon(
|
||||
color=str(theme_value(self._theme, "exit_icon_color", "#ca3d3d"))
|
||||
)
|
||||
self.title(
|
||||
f"{versioned_title(loc_text('launcher.window_title', catalog=self._locale_catalog, default='Warehouse'), __name__)} - {self.session.display_name}"
|
||||
)
|
||||
self._apply_dynamic_geometry()
|
||||
|
||||
outer_pady = int(theme_value(self._theme, "outer_pady", 10))
|
||||
outer_padx = int(theme_value(self._theme, "outer_padx", 0))
|
||||
info_padx = int(theme_value(self._theme, "info_padx", 6))
|
||||
info_pady = theme_value(self._theme, "info_pady", [4, 2])
|
||||
button_padx = int(theme_value(self._theme, "button_padx", 6))
|
||||
button_pady = int(theme_value(self._theme, "button_pady", 6))
|
||||
max_buttons_per_row = max(1, int(theme_value(self._theme, "max_buttons_per_row", 7)))
|
||||
|
||||
wrap = ctk.CTkFrame(self)
|
||||
wrap.pack(pady=10, fill="x")
|
||||
wrap.pack(padx=outer_padx, pady=outer_pady, fill="x")
|
||||
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Gestione Corsie",
|
||||
command=lambda: open_reset_corsie_window(self, db_app),
|
||||
).grid(row=0, column=0, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Gestione Layout",
|
||||
command=lambda: open_layout_window(self, db_app),
|
||||
).grid(row=0, column=1, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="UDC Fantasma",
|
||||
command=lambda: open_celle_multiple_window(self, db_app),
|
||||
).grid(row=0, column=2, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Ricerca UDC",
|
||||
command=lambda: open_search_window(self, db_app),
|
||||
).grid(row=0, column=3, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Gestione Picking List",
|
||||
command=lambda: open_pickinglist_window(self, db_app),
|
||||
).grid(row=0, column=4, padx=6, pady=6, sticky="ew")
|
||||
actions = [
|
||||
(
|
||||
"reset_corsie",
|
||||
loc_text("launcher.reset_corsie", catalog=self._locale_catalog, default="Gestione Corsie"),
|
||||
"launcher.open_reset_corsie",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"reset_corsie",
|
||||
lambda: open_reset_corsie_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"layout",
|
||||
loc_text("launcher.layout", catalog=self._locale_catalog, default="Gestione Layout"),
|
||||
"launcher.open_layout",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"layout",
|
||||
lambda: open_layout_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"multi_udc",
|
||||
loc_text("launcher.multi_udc", catalog=self._locale_catalog, default="UDC Fantasma"),
|
||||
"launcher.open_multi_udc",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"multi_udc",
|
||||
lambda: open_celle_multiple_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"non_shelved",
|
||||
loc_text("launcher.non_shelved", catalog=self._locale_catalog, default="UDC non scaffalate"),
|
||||
"launcher.open_non_shelved",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"non_shelved",
|
||||
lambda: open_udc_non_scaffalate_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"search",
|
||||
loc_text("launcher.search", catalog=self._locale_catalog, default="Ricerca UDC"),
|
||||
"launcher.open_search",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"search",
|
||||
lambda: open_search_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"storico_udc",
|
||||
loc_text("launcher.history_udc", catalog=self._locale_catalog, default="Storico movimenti UDC"),
|
||||
"launcher.open_history_udc",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"storico_udc",
|
||||
lambda: open_storico_udc_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"pickinglist",
|
||||
loc_text("launcher.pickinglist", catalog=self._locale_catalog, default="Gestione Picking List"),
|
||||
"launcher.open_pickinglist",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"pickinglist",
|
||||
lambda: open_pickinglist_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"storico_pickinglist",
|
||||
loc_text("launcher.history_pickinglist", catalog=self._locale_catalog, default="Storico Picking List"),
|
||||
"launcher.open_history_pickinglist",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"storico_pickinglist",
|
||||
lambda: open_storico_pickinglist_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"diagnostica",
|
||||
loc_text("launcher.diagnostics", catalog=self._locale_catalog, default="Diagnostica"),
|
||||
"launcher.open_diagnostics",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"diagnostica",
|
||||
lambda: open_diagnostica_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"inventario",
|
||||
loc_text("inventory.title", catalog=self._locale_catalog, default="Inventario"),
|
||||
"launcher.open_inventory",
|
||||
lambda: self._open_or_focus_child_window(
|
||||
"inventario",
|
||||
lambda: open_inventario_window(self, self.db_client, session=self.session),
|
||||
),
|
||||
),
|
||||
(
|
||||
"arrange",
|
||||
loc_text("launcher.arrange", catalog=self._locale_catalog, default="Ridisponi finestre"),
|
||||
"launcher.arrange_windows",
|
||||
self._cascade_open_windows,
|
||||
),
|
||||
(
|
||||
"exit",
|
||||
loc_text("launcher.exit", catalog=self._locale_catalog, default="Esci"),
|
||||
"launcher.exit",
|
||||
self._shutdown,
|
||||
),
|
||||
]
|
||||
|
||||
for i in range(5):
|
||||
used_columns = max(1, min(len(actions), max_buttons_per_row))
|
||||
|
||||
info = ctk.CTkLabel(
|
||||
wrap,
|
||||
text=loc_text(
|
||||
"launcher.operator",
|
||||
catalog=self._locale_catalog,
|
||||
default="Operatore: {display_name} ({login})",
|
||||
).format(display_name=self.session.display_name, login=self.session.login),
|
||||
anchor="w",
|
||||
font=theme_font(self._theme, "info_font", default=("Segoe UI", 12, "bold")),
|
||||
)
|
||||
info.grid(row=0, column=0, columnspan=used_columns, padx=info_padx, pady=tuple(info_pady), sticky="ew")
|
||||
|
||||
for idx, (_key, label, permission, callback) in enumerate(actions):
|
||||
row = 1 + (idx // max_buttons_per_row)
|
||||
column = idx % max_buttons_per_row
|
||||
text = label
|
||||
button_options = {}
|
||||
if _key == "exit":
|
||||
row = 2
|
||||
column = max_buttons_per_row - 1
|
||||
text = label
|
||||
button_options = {
|
||||
"image": self._exit_icon,
|
||||
"compound": "left",
|
||||
}
|
||||
button = ctk.CTkButton(
|
||||
wrap,
|
||||
text=text,
|
||||
font=theme_font(self._theme, "button_font", default=("Segoe UI", 11, "bold")),
|
||||
state="normal" if self.session.can(permission) else "disabled",
|
||||
command=callback,
|
||||
**button_options,
|
||||
)
|
||||
button.grid(row=row, column=column, padx=button_padx, pady=button_pady, sticky="ew")
|
||||
tip = tooltip_text(permission, catalog=self._tooltip_catalog)
|
||||
if tip:
|
||||
WidgetToolTip(button, tip)
|
||||
|
||||
for i in range(max_buttons_per_row):
|
||||
wrap.grid_columnconfigure(i, weight=1)
|
||||
|
||||
def _on_close():
|
||||
"""Dispose shared resources before closing the launcher."""
|
||||
self.update_idletasks()
|
||||
self._apply_dynamic_geometry()
|
||||
|
||||
self.protocol("WM_DELETE_WINDOW", self._shutdown)
|
||||
try:
|
||||
self.lift()
|
||||
self.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _make_exit_icon(self, *, color: str) -> ctk.CTkImage:
|
||||
"""Create a transparent X with extra resolution for HighDPI scaling."""
|
||||
|
||||
size = 14
|
||||
scale = 3
|
||||
image = Image.new("RGBA", (size * scale, size * scale), (0, 0, 0, 0))
|
||||
draw = ImageDraw.Draw(image)
|
||||
draw.line((3 * scale, 3 * scale, 10 * scale, 10 * scale),
|
||||
fill=color, width=2 * scale)
|
||||
draw.line((3 * scale, 10 * scale, 10 * scale, 3 * scale),
|
||||
fill=color, width=2 * scale)
|
||||
return ctk.CTkImage(light_image=image, dark_image=image, size=(size, size))
|
||||
|
||||
def _apply_dynamic_geometry(self) -> None:
|
||||
"""Size the launcher around its current content and keep it docked at the top."""
|
||||
|
||||
top_x = int(theme_value(self._theme, "window_top_x", 0))
|
||||
top_y = int(theme_value(self._theme, "window_top_y", 0))
|
||||
min_width = int(theme_value(self._theme, "window_min_width", 960))
|
||||
target_width = int(theme_value(self._theme, "window_width", 1280))
|
||||
|
||||
requested_width = max(min_width, self.winfo_reqwidth())
|
||||
width = max(min_width, target_width, requested_width)
|
||||
height = max(80, self.winfo_reqheight())
|
||||
self.geometry(f"{width}x{height}+{top_x}+{top_y}")
|
||||
|
||||
def _open_child_window(self, key: str, window: tk.Misc | None) -> None:
|
||||
"""Track child windows opened from the launcher."""
|
||||
|
||||
if window is None:
|
||||
return
|
||||
self._child_windows = [w for w in self._child_windows if getattr(w, "winfo_exists", lambda: False)()]
|
||||
if window not in self._child_windows:
|
||||
self._child_windows.append(window)
|
||||
self._child_windows_by_key = {
|
||||
child_key: child
|
||||
for child_key, child in self._child_windows_by_key.items()
|
||||
if getattr(child, "winfo_exists", lambda: False)()
|
||||
}
|
||||
self._child_windows_by_key[key] = window
|
||||
try:
|
||||
window.bind(
|
||||
"<Destroy>",
|
||||
lambda event, win=window, win_key=key: self._forget_child_window(win_key, win, event.widget),
|
||||
add="+",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
window.bind(
|
||||
"<Activate>",
|
||||
lambda event, win=window, win_key=key: self._on_child_activate(win_key, win, event.widget),
|
||||
add="+",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
window.bind(
|
||||
"<FocusIn>",
|
||||
lambda event, win=window, win_key=key: self._on_child_activate(win_key, win, event.widget),
|
||||
add="+",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _open_or_focus_child_window(self, key: str, factory) -> None:
|
||||
"""Open one child per launcher key, or focus the existing window."""
|
||||
|
||||
self._child_windows_by_key = {
|
||||
child_key: child
|
||||
for child_key, child in self._child_windows_by_key.items()
|
||||
if getattr(child, "winfo_exists", lambda: False)()
|
||||
}
|
||||
existing = self._child_windows_by_key.get(key)
|
||||
if existing is not None and getattr(existing, "winfo_exists", lambda: False)():
|
||||
try:
|
||||
fut = asyncio.run_coroutine_threadsafe(db_app.dispose(), _loop)
|
||||
if hasattr(existing, "state") and existing.state() == "iconic":
|
||||
existing.deiconify()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
existing.lift()
|
||||
existing.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
place_window_below_parent_later(self, existing)
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
self._open_child_window(key, factory())
|
||||
|
||||
def _forget_child_window(self, key: str, window: tk.Misc, event_widget: tk.Misc | None = None) -> None:
|
||||
"""Remove stale references to child windows that have been closed."""
|
||||
|
||||
if event_widget is not None and event_widget is not window:
|
||||
return
|
||||
try:
|
||||
tracked = self._child_windows_by_key.get(key)
|
||||
if tracked is window:
|
||||
self._child_windows_by_key.pop(key, None)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self._child_windows = [w for w in self._child_windows if w is not window and getattr(w, "winfo_exists", lambda: False)()]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _widget_belongs_to_window(self, window: tk.Misc, widget: tk.Misc | None) -> bool:
|
||||
"""Return True when an event widget is the toplevel itself or one of its descendants."""
|
||||
|
||||
if widget is None:
|
||||
return True
|
||||
if widget is window:
|
||||
return True
|
||||
try:
|
||||
current = widget
|
||||
while current is not None:
|
||||
if current is window:
|
||||
return True
|
||||
parent_name = current.winfo_parent()
|
||||
if not parent_name:
|
||||
break
|
||||
current = current.nametowidget(parent_name)
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
|
||||
def _on_child_activate(self, key: str, window: tk.Misc, event_widget: tk.Misc | None = None) -> None:
|
||||
"""Restore an activated child to the primary slot below the launcher."""
|
||||
|
||||
if self._is_cascading:
|
||||
return
|
||||
if time.monotonic() < self._restore_suppressed_until:
|
||||
return
|
||||
if event_widget is not None and event_widget is not window:
|
||||
return
|
||||
tracked = self._child_windows_by_key.get(key)
|
||||
if tracked is not window or not getattr(window, "winfo_exists", lambda: False)():
|
||||
return
|
||||
if key in self._focus_restore_pending:
|
||||
return
|
||||
self._focus_restore_pending.add(key)
|
||||
|
||||
def _restore() -> None:
|
||||
try:
|
||||
tracked_now = self._child_windows_by_key.get(key)
|
||||
if tracked_now is window and getattr(window, "winfo_exists", lambda: False)():
|
||||
place_window_below_parent_later(self, window)
|
||||
try:
|
||||
window.lift()
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
try:
|
||||
self.after(250, lambda: self._focus_restore_pending.discard(key))
|
||||
except Exception:
|
||||
self._focus_restore_pending.discard(key)
|
||||
|
||||
try:
|
||||
self.after(0, _restore)
|
||||
except Exception:
|
||||
self._focus_restore_pending.discard(key)
|
||||
|
||||
def _cascade_open_windows(self) -> None:
|
||||
"""Cascade all open child windows following launcher button order."""
|
||||
|
||||
self._child_windows = [w for w in self._child_windows if getattr(w, "winfo_exists", lambda: False)()]
|
||||
self._child_windows_by_key = {
|
||||
key: window
|
||||
for key, window in self._child_windows_by_key.items()
|
||||
if getattr(window, "winfo_exists", lambda: False)()
|
||||
}
|
||||
ordered_windows = [
|
||||
self._child_windows_by_key[key]
|
||||
for key in self._WINDOW_ORDER
|
||||
if key in self._child_windows_by_key
|
||||
]
|
||||
self._is_cascading = True
|
||||
self._focus_restore_pending.clear()
|
||||
self._restore_suppressed_until = time.monotonic() + 1.2
|
||||
cascade_children_below_parent(
|
||||
self,
|
||||
ordered_windows,
|
||||
x_offset_step=int(theme_value(self._theme, "cascade_x_offset", 28)),
|
||||
y_offset_step=int(theme_value(self._theme, "cascade_y_offset", 28)),
|
||||
margin_left=int(theme_value(self._theme, "cascade_margin_left", 0)),
|
||||
margin_top=int(theme_value(self._theme, "cascade_margin_top", 0)),
|
||||
)
|
||||
def _finish_cascade() -> None:
|
||||
self._is_cascading = False
|
||||
self._restore_suppressed_until = 0.0
|
||||
try:
|
||||
self.lift()
|
||||
self.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.after(250, _finish_cascade)
|
||||
except Exception:
|
||||
self._is_cascading = False
|
||||
|
||||
def _shutdown(self) -> None:
|
||||
"""Dispose session and shared DB resources before closing the launcher."""
|
||||
|
||||
try:
|
||||
if self.session is not None:
|
||||
log_session_event(self.session, action="logout", outcome="ok")
|
||||
if self.db_client is not None:
|
||||
fut = asyncio.run_coroutine_threadsafe(self.db_client.dispose(), _loop)
|
||||
try:
|
||||
fut.result(timeout=2)
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
self.destroy()
|
||||
finally:
|
||||
self.destroy()
|
||||
|
||||
self.protocol("WM_DELETE_WINDOW", _on_close)
|
||||
|
||||
def run_app() -> int:
|
||||
"""Run the backoffice application entry point."""
|
||||
|
||||
ctk.set_appearance_mode("light")
|
||||
ctk.set_default_color_theme("green")
|
||||
if not _acquire_single_instance_mutex():
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
messagebox.showwarning(
|
||||
loc_text("launcher.already_running_title", default="Warehouse"),
|
||||
loc_text(
|
||||
"launcher.already_running_message",
|
||||
default="L'applicazione e' gia' in esecuzione.\nChiudi l'istanza aperta prima di avviarne un'altra.",
|
||||
),
|
||||
parent=root,
|
||||
)
|
||||
_destroy_tk_root(root)
|
||||
try:
|
||||
stop_global_loop()
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
db_cfg = ensure_db_config(_loop)
|
||||
if db_cfg is None:
|
||||
try:
|
||||
stop_global_loop()
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
db_app = AsyncMSSQLClient(build_dsn_from_config(db_cfg))
|
||||
|
||||
if BYPASS_LOGIN:
|
||||
session = _build_bypass_session()
|
||||
log_session_event(
|
||||
session,
|
||||
action="login.bypass",
|
||||
outcome="ok",
|
||||
details={"login": session.login},
|
||||
)
|
||||
bootstrap = None
|
||||
else:
|
||||
bootstrap = tk.Tk()
|
||||
bootstrap.geometry("1x1+0+0")
|
||||
bootstrap.overrideredirect(True)
|
||||
bootstrap.attributes("-alpha", 0.0)
|
||||
bootstrap.deiconify()
|
||||
bootstrap.update_idletasks()
|
||||
session = prompt_login(bootstrap, db_app)
|
||||
|
||||
if session is None:
|
||||
_shutdown_runtime(bootstrap=bootstrap, dispose_db=True)
|
||||
return 0
|
||||
|
||||
_destroy_tk_root(bootstrap)
|
||||
|
||||
try:
|
||||
Launcher(session, db_app).mainloop()
|
||||
finally:
|
||||
_shutdown_runtime(bootstrap=None, dispose_db=True)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ctk.set_appearance_mode("light")
|
||||
ctk.set_default_color_theme("green")
|
||||
Launcher().mainloop()
|
||||
raise SystemExit(run_with_fatal_log("Warehouse Backoffice", run_app))
|
||||
|
||||
414
ordinamento.md
Normal file
414
ordinamento.md
Normal file
@@ -0,0 +1,414 @@
|
||||
# Ordinamento di prelievo delle celle
|
||||
|
||||
## 1. Scopo del documento
|
||||
|
||||
Questo documento descrive il significato e l'origine del campo
|
||||
`dbo.Celle.Ordinamento`, il modo in cui viene utilizzato per proporre le UDC al
|
||||
barcode e le differenze riscontrate tra i due magazzini storici:
|
||||
|
||||
- Area 5, identificata nel database legacy come magazzino `MDE5`;
|
||||
- Area 6, identificata nel database legacy come magazzino `MDE6`.
|
||||
|
||||
Nel linguaggio operativo si parla di Area 5 e Area 6. Nel modello legacy,
|
||||
tuttavia, la tabella `Magazzini` contiene `MDE5` e `MDE6`, mentre la tabella
|
||||
`Aree` contiene le singole corsie o scaffali. Gli ID della tabella `Aree` non
|
||||
devono quindi essere confusi con i nomi operativi Area 5 e Area 6.
|
||||
|
||||
Le conclusioni riportate derivano da:
|
||||
|
||||
- struttura e dati correnti della tabella `dbo.Celle`;
|
||||
- stored procedure legacy contenute in `script.sql`;
|
||||
- viste usate dalle picking list;
|
||||
- codice Python del barcode e della gestione picking list;
|
||||
- confronto tra `ID`, ubicazione e `Ordinamento` delle celle reali.
|
||||
|
||||
## 2. Significato di `Celle.Ordinamento`
|
||||
|
||||
`Celle.Ordinamento` e' una priorita' numerica associata all'anagrafica della
|
||||
cella. Rappresenta la posizione della cella nel percorso predefinito di
|
||||
prelievo.
|
||||
|
||||
Il campo non indica:
|
||||
|
||||
- la quantita' di UDC presenti;
|
||||
- la priorita' della picking list;
|
||||
- lo stato libero o occupato della cella;
|
||||
- l'ordine cronologico di inserimento delle UDC;
|
||||
- l'ID della UDC;
|
||||
- la distanza calcolata dinamicamente dal barcode.
|
||||
|
||||
Il valore non viene ricalcolato durante un versamento o un prelievo. E' un dato
|
||||
statico dell'anagrafica della cella, salvo interventi amministrativi o
|
||||
procedure specifiche di rinumerazione.
|
||||
|
||||
Il tipo SQL storico e' `float`, ma nei dati analizzati viene usato come numero
|
||||
intero progressivo. Nella futura riprogettazione sarebbe preferibile un tipo
|
||||
intero o una struttura esplicita di percorso.
|
||||
|
||||
## 3. Dove viene assegnato
|
||||
|
||||
La stored procedure legacy `dbo.spt_SaveCelle` riceve il parametro
|
||||
`@Ordinamento` e lo salva direttamente:
|
||||
|
||||
```sql
|
||||
UPDATE Celle
|
||||
SET Ordinamento = @Ordinamento
|
||||
WHERE ID = @ID;
|
||||
```
|
||||
|
||||
Se la cella non esiste, la stessa stored procedure esegue una `INSERT` e
|
||||
inserisce il valore ricevuto. La procedura non contiene una formula per
|
||||
calcolarlo: chi crea o modifica la cella deve decidere il valore e passarlo.
|
||||
|
||||
Nel database non risultano trigger sulla tabella `Celle` che aggiornino
|
||||
automaticamente `Ordinamento`.
|
||||
|
||||
Sono state individuate anche procedure legacy di supporto:
|
||||
|
||||
- `CreaNuoveCelle`;
|
||||
- `CreaNuoveCelleMDE6`;
|
||||
- `CreaNuoveCelleMDE6_BIS`;
|
||||
- `sp_OrdinaCelle`;
|
||||
- `spt_SaveCelle`.
|
||||
|
||||
Le procedure di creazione MDE6 impostano normalmente:
|
||||
|
||||
```sql
|
||||
SET @Ordinamento = @ID;
|
||||
```
|
||||
|
||||
La procedura `sp_OrdinaCelle` dimostra invece che il campo puo' essere
|
||||
rinumerato in un secondo momento per rappresentare un percorso differente
|
||||
dall'ID della cella.
|
||||
|
||||
## 4. Uso durante una picking list
|
||||
|
||||
Le viste operative associano ogni UDC alla cella corrente e recuperano
|
||||
`Celle.Ordinamento`. Il barcode richiede la prima riga residua secondo l'ordine
|
||||
effettivo.
|
||||
|
||||
Prima dell'introduzione della sequenza personalizzata, il criterio principale
|
||||
era sostanzialmente:
|
||||
|
||||
```sql
|
||||
ORDER BY Ordinamento;
|
||||
```
|
||||
|
||||
Questo significa che il barcode non percorre tutte le celle del magazzino. La
|
||||
vista contiene soltanto le UDC ancora presenti nella picking list: le celle che
|
||||
non contengono una UDC richiesta vengono saltate automaticamente.
|
||||
|
||||
Esempio: se il percorso contiene le celle con ordine `1001`, `1002`, `1003` e
|
||||
`1004`, ma la picking list contiene UDC soltanto nelle celle `1001` e `1004`, il
|
||||
barcode propone direttamente la UDC di `1001` e poi quella di `1004`.
|
||||
|
||||
## 5. Ordinamento dell'Area 5 / MDE5
|
||||
|
||||
### 5.1 Caratteristica generale
|
||||
|
||||
Nell'Area 5 `Ordinamento` non coincide normalmente con l'ID della cella. Dai
|
||||
dati emerge un percorso fisico costruito intenzionalmente, verosimilmente
|
||||
hardcoded o rinumerato durante la configurazione iniziale del magazzino.
|
||||
|
||||
Le corsie principali coinvolte sono:
|
||||
|
||||
- `1A`;
|
||||
- `2B`;
|
||||
- `3C`;
|
||||
- `4D`.
|
||||
|
||||
Il percorso iniziale delle corsie `1A` e `2B` e' a serpentina. Le due corsie
|
||||
vengono trattate come lati o scaffali adiacenti di uno stesso tragitto fisico.
|
||||
|
||||
### 5.2 Esempio reale dell'inizio del percorso
|
||||
|
||||
```text
|
||||
Ordine Ubicazione ID cella
|
||||
1001 1A.1.e 1005
|
||||
1002 1A.1.d 1004
|
||||
1003 1A.1.c 1003
|
||||
1004 1A.1.b 1002
|
||||
1005 1A.1.a 1001
|
||||
|
||||
1007 2B.1.e 2005
|
||||
1008 2B.1.d 2004
|
||||
1009 2B.1.c 2003
|
||||
1010 2B.1.b 2002
|
||||
1011 2B.1.a 2001
|
||||
|
||||
1013 2B.2.e 2011
|
||||
1014 2B.2.d 2010
|
||||
1015 2B.2.c 2009
|
||||
1016 2B.2.b 2008
|
||||
1017 2B.2.a 2007
|
||||
|
||||
1019 1A.2.e 1011
|
||||
1020 1A.2.d 1010
|
||||
1021 1A.2.c 1009
|
||||
1022 1A.2.b 1008
|
||||
1023 1A.2.a 1007
|
||||
```
|
||||
|
||||
La sequenza prosegue con lo stesso principio:
|
||||
|
||||
```text
|
||||
1A campata 1
|
||||
2B campata 1
|
||||
2B campata 2
|
||||
1A campata 2
|
||||
1A campata 3
|
||||
2B campata 3
|
||||
2B campata 4
|
||||
1A campata 4
|
||||
...
|
||||
```
|
||||
|
||||
### 5.3 Movimento verticale nella campata
|
||||
|
||||
All'interno di ciascuna campata l'ordine verificato e':
|
||||
|
||||
```text
|
||||
e -> d -> c -> b -> a
|
||||
```
|
||||
|
||||
Il percorso procede quindi dal livello identificato con `e` verso il livello
|
||||
`a`. Non viene prelevata una sola UDC per campata per poi ricominciare il giro.
|
||||
Vengono considerate, in sequenza, tutte le celle richieste della campata
|
||||
corrente prima di passare alla campata successiva.
|
||||
|
||||
Se una campata contiene piu' UDC richieste in livelli diversi, il barcode le
|
||||
propone secondo `e, d, c, b, a`. Se alcuni livelli non contengono UDC della
|
||||
picking list, vengono semplicemente saltati.
|
||||
|
||||
### 5.4 Alternanza tra 1A e 2B
|
||||
|
||||
Il sistema non esaurisce tutto `1A` prima di iniziare `2B`. Alterna blocchi di
|
||||
campate tra le due corsie per seguire un tragitto a serpentina ed evitare
|
||||
ritorni inutili.
|
||||
|
||||
Il comportamento predefinito storico e' quindi:
|
||||
|
||||
- completare le UDC richieste nella campata corrente;
|
||||
- passare alla campata fisicamente successiva del percorso;
|
||||
- alternare `1A` e `2B` secondo la serpentina configurata;
|
||||
- non tornare all'inizio dopo ogni singola UDC.
|
||||
|
||||
### 5.5 Passaggio a 3C e 4D
|
||||
|
||||
Le corsie `3C` e `4D` hanno valori di ordinamento molto piu' alti. Nei dati
|
||||
analizzati:
|
||||
|
||||
```text
|
||||
1A: minimo 1001, massimo 1275
|
||||
2B: minimo 1007, massimo 1251
|
||||
3C: minimo 10019, massimo 10227
|
||||
4D: valori nell'intervallo 10055 - 10233 circa
|
||||
```
|
||||
|
||||
Di conseguenza il percorso storico esaurisce normalmente il blocco `1A/2B`
|
||||
prima di passare al blocco `3C/4D`.
|
||||
|
||||
La presenza di famiglie numeriche differenti indica che l'ordinamento
|
||||
dell'Area 5 e' stato costruito o modificato in piu' fasi storiche.
|
||||
|
||||
### 5.6 Significato dei numeri mancanti
|
||||
|
||||
La progressione contiene intervalli non utilizzati, per esempio `1005` seguito
|
||||
da `1007`. Il numero mancante non indica necessariamente una cella eliminata o
|
||||
un errore. Puo' essere stato lasciato come separatore tra campate o derivare
|
||||
dalla procedura di rinumerazione.
|
||||
|
||||
Il software deve usare il confronto numerico e non deve presumere che tutti i
|
||||
valori siano consecutivi.
|
||||
|
||||
## 6. Ordinamento dell'Area 6 / MDE6
|
||||
|
||||
### 6.1 Caratteristica generale
|
||||
|
||||
Nell'Area 6 il modello e' piu' semplice. La maggior parte delle celle e' stata
|
||||
generata con `Ordinamento` uguale all'ID della cella.
|
||||
|
||||
Le famiglie principali sono:
|
||||
|
||||
```text
|
||||
1M -> celle e ordinamenti 5001, 5002, 5003, ...
|
||||
2N -> celle e ordinamenti 6001, 6002, 6003, ...
|
||||
3O -> celle e ordinamenti 7001, 7002, 7003, ...
|
||||
4P -> celle e ordinamenti 8001, 8002, 8003, ...
|
||||
```
|
||||
|
||||
Le procedure `CreaNuoveCelleMDE6` e `CreaNuoveCelleMDE6_BIS` creano le celle
|
||||
con cicli annidati e assegnano esplicitamente:
|
||||
|
||||
```sql
|
||||
SET @Ordinamento = @ID;
|
||||
```
|
||||
|
||||
### 6.2 Ordine degli scaffali
|
||||
|
||||
Poiche' le famiglie numeriche sono separate, l'ordine globale predefinito e':
|
||||
|
||||
```text
|
||||
1M -> 2N -> 3O -> 4P
|
||||
```
|
||||
|
||||
Senza una sequenza personalizzata vengono quindi considerate prima tutte le
|
||||
UDC richieste in `1M`, poi quelle in `2N`, successivamente `3O` e infine `4P`.
|
||||
|
||||
### 6.3 Ordine interno dello scaffale
|
||||
|
||||
Durante la generazione delle celle, i cicli legacy incrementano prima la
|
||||
campata e, all'interno della campata, il piano. L'ordine risultante e':
|
||||
|
||||
```text
|
||||
1M.1.a -> 1M.1.b -> 1M.1.c -> 1M.1.d -> 1M.1.e
|
||||
1M.2.a -> 1M.2.b -> 1M.2.c -> 1M.2.d -> 1M.2.e
|
||||
...
|
||||
2N.1.a -> 2N.1.b -> ...
|
||||
```
|
||||
|
||||
Quindi l'Area 6 differisce dall'Area 5 in due aspetti principali:
|
||||
|
||||
- non presenta l'alternanza a serpentina tra due corsie adiacenti;
|
||||
- dentro la campata procede da `a` verso `e`, mentre nell'Area 5 verificata
|
||||
procede da `e` verso `a`.
|
||||
|
||||
### 6.4 Limiti della ricostruzione
|
||||
|
||||
Il comportamento descritto deriva dalla procedura di generazione e dai valori
|
||||
correnti. Eventuali celle aggiunte manualmente in tempi successivi possono
|
||||
avere eccezioni. L'applicazione deve sempre leggere il valore effettivo dal
|
||||
database e non ricostruirlo aritmeticamente dall'ubicazione.
|
||||
|
||||
## 7. Celle virtuali
|
||||
|
||||
Nel sistema legacy esistono due ubicazioni convenzionali:
|
||||
|
||||
```text
|
||||
ID 1000 -> 5E.1.1 -> Non scaff. -> Ordinamento 99999
|
||||
ID 9999 -> 7G.1.1 -> Spedita -> Ordinamento 0
|
||||
```
|
||||
|
||||
Questi valori non rappresentano un percorso fisico:
|
||||
|
||||
- `5E.1.1` identifica UDC presenti nel magazzino ma non allocate in uno
|
||||
scaffale fisico;
|
||||
- `7G.1.1` identifica UDC spedite.
|
||||
|
||||
Storicamente `Non scaff.` aveva ordinamento `99999`, quindi finiva in fondo
|
||||
alla picking list. Il nuovo requisito operativo stabilisce invece che le UDC
|
||||
non scaffalate devono essere proposte per prime.
|
||||
|
||||
La nuova vista Python non modifica `Celle.Ordinamento`: assegna a `Non scaff.`
|
||||
una precedenza logica di gruppo pari a zero. La cella `Spedita` non entra nella
|
||||
vista residuale e quindi non viene proposta dal barcode.
|
||||
|
||||
## 8. Nuovo ordinamento predefinito Python
|
||||
|
||||
In assenza di una configurazione specifica per il documento, il nuovo ordine
|
||||
effettivo e':
|
||||
|
||||
1. tutte le UDC `Non scaff.` ancora appartenenti alla picking list;
|
||||
2. tutte le UDC nelle celle fisiche secondo `Celle.Ordinamento`;
|
||||
3. codice pallet come criterio stabile in caso di parita'.
|
||||
|
||||
In forma semplificata:
|
||||
|
||||
```sql
|
||||
ORDER BY
|
||||
OrdinePrelievoGruppo,
|
||||
Ordinamento,
|
||||
Pallet;
|
||||
```
|
||||
|
||||
Per le celle fisiche, se non esiste una personalizzazione,
|
||||
`OrdinePrelievoGruppo` conserva la progressione storica. Il percorso dell'Area
|
||||
5 rimane quindi a serpentina e quello dell'Area 6 rimane progressivo.
|
||||
|
||||
## 9. Effetto della sequenza personalizzata
|
||||
|
||||
La sequenza personalizzata opera a livello di gruppo o scaffale, non a livello
|
||||
di singola cella.
|
||||
|
||||
Esempio di configurazione:
|
||||
|
||||
```text
|
||||
1. Non scaff.
|
||||
2. 3C
|
||||
3. 1A
|
||||
4. 2B
|
||||
5. 4D
|
||||
```
|
||||
|
||||
In questo caso il sistema esaurisce prima il gruppo `Non scaff.`, poi tutte le
|
||||
UDC di `3C`, quindi tutte quelle di `1A` e cosi' via.
|
||||
|
||||
All'interno di ciascun gruppo continua a usare `Celle.Ordinamento`. Per
|
||||
esempio, se `1A` viene posizionata prima di `2B`, non viene piu' conservata
|
||||
l'alternanza storica tra `1A` e `2B`: vengono esaurite prima tutte le UDC di
|
||||
`1A`, nel loro ordine interno, e successivamente quelle di `2B`.
|
||||
|
||||
Questa differenza e' intenzionale:
|
||||
|
||||
- ordine predefinito: conserva il percorso storico globale;
|
||||
- ordine personalizzato: impone la precedenza degli scaffali scelta
|
||||
dall'operatore e conserva l'ordine storico soltanto dentro ogni scaffale.
|
||||
|
||||
Se la sequenza personalizzata non include tutti i gruppi, quelli mancanti
|
||||
vengono accodati secondo il percorso predefinito. Nessuna UDC viene esclusa.
|
||||
|
||||
## 10. UDC multiple, lotti e parita' di ordine
|
||||
|
||||
Piu' righe della vista possono riferirsi alla stessa UDC quando contiene piu'
|
||||
lotti o articoli. Questo non significa che il magazziniere debba movimentare
|
||||
fisicamente la stessa UDC piu' volte: l'unita' di movimentazione rimane il
|
||||
pallet/UDC.
|
||||
|
||||
Piu' UDC possono inoltre risultare associate alla stessa cella nel modello
|
||||
legacy. In quel caso condividono lo stesso `Ordinamento`. Il nuovo codice usa
|
||||
anche `Pallet` come criterio finale per rendere stabile la sequenza, ma il
|
||||
percorso fisico resta quello della cella.
|
||||
|
||||
## 11. Considerazioni per la futura riprogettazione
|
||||
|
||||
Nel futuro FlyWMS Core e' consigliabile separare esplicitamente:
|
||||
|
||||
- ordine fisico della cella dentro lo scaffale;
|
||||
- ordine predefinito degli scaffali;
|
||||
- percorso o strategia di visita del magazzino;
|
||||
- ordine personalizzato per documento;
|
||||
- priorita' operativa della picking list;
|
||||
- eventuale ottimizzazione dinamica del percorso.
|
||||
|
||||
Il campo legacy `Celle.Ordinamento` incorpora piu' significati e dipende da
|
||||
decisioni storiche non completamente documentate. Non dovrebbe essere copiato
|
||||
alla lettera nel nuovo modello dati senza scomporne la semantica.
|
||||
|
||||
Una possibile struttura futura potrebbe prevedere:
|
||||
|
||||
- `Location.SequenceWithinRack` per l'ordine interno;
|
||||
- `Rack.DefaultSequence` per l'ordine tra scaffali;
|
||||
- `Route` e `RouteStep` per percorsi configurabili;
|
||||
- `PickingDocumentRoute` per la personalizzazione della singola lista.
|
||||
|
||||
## 12. Riferimenti tecnici nel progetto
|
||||
|
||||
- `script.sql`: definizioni di `spt_SaveCelle`, `CreaNuoveCelleMDE6`,
|
||||
`CreaNuoveCelleMDE6_BIS` e `sp_OrdinaCelle`;
|
||||
- `barcode_repository.py`: interrogazione della prossima UDC;
|
||||
- `gestione_pickinglist.py`: visualizzazione del dettaglio ordinato;
|
||||
- `pickinglist_sequence.py`: gestione della sequenza per documento;
|
||||
- `apply_pickinglist_sequence_patch.sql`: tabella e vista Python dedicate;
|
||||
- `specifica_sequenza_prelievo.md`: specifica funzionale della nuova
|
||||
configurazione.
|
||||
|
||||
## 13. Conclusione
|
||||
|
||||
L'Area 5 utilizza un percorso storico a serpentina, costruito per alternare
|
||||
corsie e campate secondo la disposizione fisica. L'Area 6 utilizza invece una
|
||||
progressione piu' semplice, sostanzialmente coincidente con gli ID creati in
|
||||
sequenza.
|
||||
|
||||
Il nuovo software conserva entrambi i comportamenti come default, anticipa le
|
||||
UDC non scaffalate e permette di sostituire l'ordine globale degli scaffali per
|
||||
una singola picking list senza modificare l'anagrafica delle celle.
|
||||
346
patch_sp_xExePackingListPallet.sql
Normal file
346
patch_sp_xExePackingListPallet.sql
Normal file
@@ -0,0 +1,346 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/* ============================================================
|
||||
Patch prenotazione Picking List a livello documento
|
||||
|
||||
Obiettivo:
|
||||
- rendere esclusiva la prenotazione di una sola picking list
|
||||
- mantenere la stored con lo stesso nome:
|
||||
dbo.sp_xExePackingListPallet
|
||||
- introdurre una sorgente di verità per documento prenotato:
|
||||
dbo.PickingListReservation
|
||||
- far leggere XMag_ViewPackingList.IDStato da tale stato
|
||||
e non più soltanto da Celle.IDStato
|
||||
============================================================ */
|
||||
|
||||
IF OBJECT_ID(N'dbo.PickingListReservation', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [dbo].[PickingListReservation](
|
||||
[ID] [tinyint] NOT NULL,
|
||||
[Documento] [varchar](8) NULL,
|
||||
[IDOperatore] [int] NULL,
|
||||
[ModUtente] [varchar](50) NULL,
|
||||
[ModDataOra] [datetime] NULL,
|
||||
CONSTRAINT [PK_PickingListReservation] PRIMARY KEY CLUSTERED ([ID] ASC),
|
||||
CONSTRAINT [CK_PickingListReservation_Singleton] CHECK ([ID] = 1)
|
||||
) ON [PRIMARY];
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[sp_xExePackingListPallet]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@Azione char(1) = 'P', -- 'P' = Prenota, 'S' = S-prenota
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
DECLARE @DocumentoAttivo varchar(8) = NULL;
|
||||
DECLARE @Description varchar(255) = '';
|
||||
DECLARE @Message varchar(255) = '';
|
||||
DECLARE @IDResult int = 0;
|
||||
DECLARE @ID int = 0;
|
||||
|
||||
SELECT @Nominativo = [Login]
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
IF @Azione NOT IN ('P', 'S')
|
||||
BEGIN
|
||||
SET @RC = -10;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
SET @RC = -20;
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM dbo.PickingListReservation WHERE ID = 1)
|
||||
BEGIN
|
||||
INSERT INTO dbo.PickingListReservation (ID, Documento, IDOperatore, ModUtente, ModDataOra)
|
||||
VALUES (1, NULL, NULL, NULL, GETDATE());
|
||||
END;
|
||||
|
||||
SELECT @DocumentoAttivo = NULLIF(LTRIM(RTRIM(Documento)), '')
|
||||
FROM dbo.PickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
DECLARE @TargetCelle TABLE (
|
||||
IDCella int PRIMARY KEY
|
||||
);
|
||||
|
||||
INSERT INTO @TargetCelle (IDCella)
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL;
|
||||
|
||||
IF @Azione = 'P'
|
||||
BEGIN
|
||||
IF @DocumentoAttivo = @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE ISNULL(c.IDStato, 0) <> 0;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PickingListReservation
|
||||
SET Documento = @Documento,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
SELECT TOP 1 @Description = NAZIONE
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento;
|
||||
|
||||
EXEC dbo.sp_LogPackingList
|
||||
@ID = @ID,
|
||||
@Code = @Documento,
|
||||
@Description = @Description,
|
||||
@Message = @Message OUTPUT,
|
||||
@IDResult = @IDResult OUTPUT;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF @Azione = 'S'
|
||||
BEGIN
|
||||
IF ISNULL(@DocumentoAttivo, '') <> @Documento
|
||||
RETURN;
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 0,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
INNER JOIN @TargetCelle t ON t.IDCella = c.ID;
|
||||
|
||||
UPDATE dbo.PickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[XMag_ViewPackingList]
|
||||
AS
|
||||
WITH Base AS (
|
||||
SELECT
|
||||
dbo.vPreparaPackingList.UDC AS Pallet,
|
||||
dbo.vPreparaPackingList.NUMLOT AS Lotto,
|
||||
dbo.vPreparaPackingList.CODICE AS Articolo,
|
||||
dbo.vPreparaPackingList.DESCR AS Descrizione,
|
||||
dbo.vPreparaPackingList.Qta,
|
||||
dbo.vPreparaPackingList.NUMDOC AS Documento,
|
||||
dbo.vPreparaPackingList.Expr1 AS CodNazione,
|
||||
dbo.vPreparaPackingList.NAZIONE,
|
||||
CASE
|
||||
WHEN Expr1 = 'DE' THEN 10
|
||||
WHEN Expr1 = 'TH' THEN CASE WHEN SUBSTRING(dbo.vPreparaPackingList.DESCRDEST, 1, 2) = 'NA' THEN 11 ELSE 13 END
|
||||
WHEN Expr1 = 'MEX' THEN 12
|
||||
ELSE 4
|
||||
END AS Stato,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.NumeroPallet, 0) AS PalletCella,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.IDMagazzino, 1) AS Magazzino,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.IDArea, 5) AS Area,
|
||||
ISNULL(dbo.XMag_GiacenzaPallet.IDCella, 1000) AS Cella,
|
||||
ISNULL(dbo.Celle.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(dbo.Celle.Corsia + ' - ' + dbo.Celle.Colonna + ' - ' + dbo.Celle.Fila, 'Non scaff.') AS Ubicazione,
|
||||
SUBSTRING(dbo.vPreparaPackingList.DESCRDEST, 1, 2) AS DEST
|
||||
FROM dbo.Celle
|
||||
INNER JOIN dbo.XMag_GiacenzaPallet
|
||||
ON dbo.Celle.ID = dbo.XMag_GiacenzaPallet.IDCella
|
||||
RIGHT OUTER JOIN dbo.vPreparaPackingList
|
||||
ON dbo.XMag_GiacenzaPallet.BarcodePallet COLLATE SQL_Latin1_General_CP1_CI_AS = dbo.vPreparaPackingList.UDC
|
||||
GROUP BY
|
||||
dbo.vPreparaPackingList.Expr1,
|
||||
dbo.vPreparaPackingList.NAZIONE,
|
||||
dbo.vPreparaPackingList.UDC,
|
||||
dbo.vPreparaPackingList.NUMDOC,
|
||||
dbo.vPreparaPackingList.NUMLOT,
|
||||
dbo.vPreparaPackingList.CODICE,
|
||||
dbo.vPreparaPackingList.DESCR,
|
||||
dbo.vPreparaPackingList.Qta,
|
||||
dbo.XMag_GiacenzaPallet.NumeroPallet,
|
||||
dbo.XMag_GiacenzaPallet.IDMagazzino,
|
||||
dbo.XMag_GiacenzaPallet.IDArea,
|
||||
dbo.XMag_GiacenzaPallet.IDCella,
|
||||
dbo.Celle.Ordinamento,
|
||||
dbo.Celle.Corsia,
|
||||
dbo.Celle.Colonna,
|
||||
dbo.Celle.Fila,
|
||||
dbo.vPreparaPackingList.DESCRDEST
|
||||
)
|
||||
SELECT TOP 10000
|
||||
Base.Pallet,
|
||||
Base.Lotto,
|
||||
Base.Articolo,
|
||||
Base.Descrizione,
|
||||
Base.Qta,
|
||||
Base.Documento,
|
||||
Base.CodNazione,
|
||||
Base.NAZIONE,
|
||||
Base.Stato,
|
||||
Base.PalletCella,
|
||||
Base.Magazzino,
|
||||
Base.Area,
|
||||
Base.Cella,
|
||||
Base.Ordinamento,
|
||||
Base.Ubicazione,
|
||||
Base.DEST,
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM Base
|
||||
LEFT JOIN dbo.PickingListReservation pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(Base.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
Base.Documento,
|
||||
Base.Ordinamento;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[sp_xExePackingListPalletPrenota]
|
||||
@IDOperatore int,
|
||||
@Documento varchar(8),
|
||||
@RC int OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SET @RC = 0;
|
||||
|
||||
DECLARE @Nominativo varchar(50) = '';
|
||||
|
||||
SELECT @Nominativo = LOGIN
|
||||
FROM dbo.Operatori
|
||||
WHERE ID = @IDOperatore;
|
||||
|
||||
IF @Nominativo IS NULL
|
||||
SET @Nominativo = 'SYSTEM';
|
||||
|
||||
UPDATE c
|
||||
SET c.IDStato = 1,
|
||||
c.ModUtente = @Nominativo,
|
||||
c.ModDataOra = GETDATE()
|
||||
FROM dbo.Celle c
|
||||
WHERE c.ID IN (
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
AND Cella IS NOT NULL
|
||||
);
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[sp_ControllaPrenotazionePackingListPalletNew]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @Documento varchar(8) = NULL;
|
||||
DECLARE @IDOperatore int = 0;
|
||||
DECLARE @Nominativo varchar(50) = 'SYSTEM';
|
||||
DECLARE @RC int = 0;
|
||||
|
||||
SELECT
|
||||
@Documento = NULLIF(LTRIM(RTRIM(Documento)), ''),
|
||||
@IDOperatore = ISNULL(IDOperatore, 0),
|
||||
@Nominativo = ISNULL(NULLIF(LTRIM(RTRIM(ModUtente)), ''), 'SYSTEM')
|
||||
FROM dbo.PickingListReservation
|
||||
WHERE ID = 1;
|
||||
|
||||
IF ISNULL(@Documento, '') = ''
|
||||
RETURN;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.ViewPackingListRestante
|
||||
WHERE CAST(Documento AS varchar(8)) = @Documento
|
||||
)
|
||||
BEGIN
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
UPDATE dbo.PickingListReservation
|
||||
SET Documento = NULL,
|
||||
IDOperatore = @IDOperatore,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = 1;
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
UPDATE dbo.Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = @Nominativo,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ISNULL(IDStato, 0) <> 0;
|
||||
|
||||
IF @IDOperatore <= 0
|
||||
BEGIN
|
||||
SELECT TOP 1 @IDOperatore = ID
|
||||
FROM dbo.Operatori
|
||||
WHERE LOGIN = @Nominativo;
|
||||
END;
|
||||
|
||||
EXEC dbo.sp_xExePackingListPalletPrenota
|
||||
@IDOperatore = @IDOperatore,
|
||||
@Documento = @Documento,
|
||||
@RC = @RC OUTPUT;
|
||||
END;
|
||||
GO
|
||||
@@ -1,3 +1,6 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SELECT * FROM vViewMappaturaDescrizioneCorsia WHERE ( Area > 0) ORDER BY Area Desc
|
||||
|
||||
SELECT * FROM Celle WHERE ( ID > 0) ORDER BY ID Desc
|
||||
@@ -26,16 +29,16 @@ USE master;
|
||||
GO
|
||||
|
||||
-- (facoltativo) terminare connessioni attive
|
||||
ALTER DATABASE SAMA1 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
|
||||
ALTER DATABASE SAMA1_Xwmstest SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
|
||||
GO
|
||||
|
||||
-- Ripristino dal tuo snapshot
|
||||
RESTORE DATABASE SAMA1
|
||||
RESTORE DATABASE SAMA1_Xwmstest
|
||||
FROM DATABASE_SNAPSHOT = 'SAMA1_SNAP_20251014_112623';
|
||||
GO
|
||||
|
||||
-- Riporta il DB in multi-user
|
||||
ALTER DATABASE SAMA1 SET MULTI_USER;
|
||||
ALTER DATABASE SAMA1_Xwmstest SET MULTI_USER;
|
||||
GO
|
||||
|
||||
|
||||
|
||||
100
pickinglist_history_search.py
Normal file
100
pickinglist_history_search.py
Normal file
@@ -0,0 +1,100 @@
|
||||
"""Read-only UDC lookup across the current and previous ERP document years.
|
||||
|
||||
Unlike the default history view this query retains BAMTES.ID, so documents with
|
||||
the same display number in different years cannot share details or movements.
|
||||
The UDC selects documents, not detail rows: counts always describe whole lists.
|
||||
"""
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
_BASE = """
|
||||
DECLARE @UDC varchar(32) = :pallet;
|
||||
DECLARE @Document varchar(32) = :documento;
|
||||
DECLARE @DocumentID int = :id_documento;
|
||||
WITH documents AS (
|
||||
SELECT bt.*
|
||||
FROM SAMA1_Xwmstest.dbo.BAMTES bt
|
||||
WHERE bt.ANNDOC BETWEEN YEAR(GETDATE()) - 1 AND YEAR(GETDATE())
|
||||
AND bt.STATO IN ('P', 'D')
|
||||
AND (@DocumentID IS NULL OR bt.ID = @DocumentID)
|
||||
AND (@Document IS NULL OR CAST(bt.NUMDOC AS varchar(32)) LIKE '%' + @Document + '%')
|
||||
AND (@UDC IS NULL OR EXISTS (
|
||||
SELECT 1 FROM SAMA1_Xwmstest.dbo.FATRIG fr
|
||||
JOIN SAMA1_Xwmstest.dbo.LOTTIBF lb ON lb.IDFATRIG = fr.ID
|
||||
JOIN SAMA1_Xwmstest.dbo.LOTSER ls ON ls.ID = lb.IDLOTSER
|
||||
WHERE fr.IDBAM = bt.ID
|
||||
AND ls.NUMLOT NOT IN ('', '00000000000')
|
||||
AND LEFT(ls.NUMSER, 6) COLLATE Latin1_General_CI_AS = @UDC COLLATE Latin1_General_CI_AS
|
||||
))
|
||||
), prep AS (
|
||||
SELECT bt.ID AS IDDocumento, bt.ANNDOC AS AnnoDocumento,
|
||||
bt.NUMDOC AS Documento, bt.DATDOC AS DataDocumento, bt.STATO AS StatoDocumento,
|
||||
LEFT(ls.NUMSER, 6) AS Pallet, ls.NUMLOT AS Lotto, a.CODICE AS Articolo,
|
||||
fr.DESCR AS Descrizione, SUM(ls.QTTGIAI) AS Qta,
|
||||
n.CODICE AS CodNazione, mt.CODICE + ' ' + n.DESCR AS NAZIONE
|
||||
FROM documents bt
|
||||
JOIN SAMA1_Xwmstest.dbo.FATRIG fr ON fr.IDBAM = bt.ID
|
||||
JOIN SAMA1_Xwmstest.dbo.LOTTIBF lb ON lb.IDFATRIG = fr.ID
|
||||
JOIN SAMA1_Xwmstest.dbo.LOTSER ls ON ls.ID = lb.IDLOTSER
|
||||
LEFT JOIN SAMA1_Xwmstest.dbo.ARTICO a ON a.ID = ls.IDARTICO
|
||||
LEFT JOIN SAMA1_Xwmstest.dbo.NAZIONI n ON n.ID = bt.IDNAZDEST
|
||||
LEFT JOIN SAMA1_Xwmstest.dbo.MTRASP mt ON mt.ID = bt.IDMTRASP
|
||||
WHERE ls.NUMLOT NOT IN ('', '00000000000')
|
||||
GROUP BY bt.ID, bt.ANNDOC, bt.NUMDOC, bt.DATDOC, bt.STATO,
|
||||
LEFT(ls.NUMSER, 6), ls.NUMLOT, a.CODICE, fr.DESCR, n.CODICE, mt.CODICE, n.DESCR
|
||||
), locations AS (
|
||||
SELECT g.BarcodePallet, g.IDCella, c.Ordinamento,
|
||||
c.Corsia + ' - ' + c.Colonna + ' - ' + c.Fila AS Ubicazione
|
||||
FROM dbo.XMag_GiacenzaPallet g JOIN dbo.Celle c ON c.ID = g.IDCella
|
||||
), base AS (
|
||||
SELECT prep.*, ISNULL(g.IDCella, 1000) AS Cella,
|
||||
ISNULL(g.Ordinamento, 99999) AS Ordinamento,
|
||||
ISNULL(g.Ubicazione, 'Non scaff.') AS Ubicazione,
|
||||
CASE WHEN prep.AnnoDocumento = YEAR(GETDATE()) AND EXISTS (
|
||||
SELECT 1 FROM dbo.PyPickingListReservation pr
|
||||
WHERE pr.ID = 1 AND pr.Documento = CAST(prep.Documento AS varchar(8))
|
||||
) THEN 1 ELSE 0 END AS IDStato
|
||||
FROM prep LEFT JOIN locations g
|
||||
ON g.BarcodePallet COLLATE Latin1_General_CI_AS = prep.Pallet COLLATE Latin1_General_CI_AS
|
||||
)
|
||||
"""
|
||||
|
||||
SQL_UDC_HISTORY_DETAILS = _BASE + """
|
||||
SELECT * FROM base ORDER BY Ordinamento, Pallet, Lotto;
|
||||
"""
|
||||
|
||||
SQL_UDC_HISTORY = _BASE + """
|
||||
, pallets AS (
|
||||
SELECT IDDocumento, Pallet,
|
||||
MAX(CASE WHEN Cella <> 9999 THEN 1 ELSE 0 END) AS HasResiduo
|
||||
FROM base WHERE NULLIF(LTRIM(RTRIM(Pallet)), '') IS NOT NULL
|
||||
GROUP BY IDDocumento, Pallet
|
||||
), totals AS (
|
||||
SELECT IDDocumento, COUNT(*) AS TotUDC, SUM(HasResiduo) AS RigheResidue,
|
||||
SUM(1 - HasResiduo) AS RigheSpedite
|
||||
FROM pallets GROUP BY IDDocumento
|
||||
), meta AS (
|
||||
SELECT IDDocumento, MAX(AnnoDocumento) AS AnnoDocumento,
|
||||
MAX(Documento) AS Documento, MAX(DataDocumento) AS DataDocumento,
|
||||
MAX(StatoDocumento) AS StatoDocumento, MAX(NAZIONE) AS NAZIONE,
|
||||
MAX(CodNazione) AS CodNazione, MAX(IDStato) AS IDStato
|
||||
FROM base GROUP BY IDDocumento
|
||||
)
|
||||
SELECT m.*, ISNULL(t.TotUDC, 0) AS TotUDC, ISNULL(t.RigheResidue, 0) AS RigheResidue,
|
||||
ISNULL(t.RigheSpedite, 0) AS RigheSpedite,
|
||||
CASE WHEN m.StatoDocumento = 'D' AND ISNULL(t.RigheResidue, 0) > 0 THEN 'Chiusa ERP con residui'
|
||||
WHEN m.StatoDocumento = 'D' THEN 'Chiusa'
|
||||
WHEN ISNULL(t.RigheResidue, 0) = 0 THEN 'Esaurita'
|
||||
WHEN ISNULL(t.RigheSpedite, 0) > 0 THEN 'In corso'
|
||||
ELSE 'Da lavorare' END AS StatoOperativo
|
||||
FROM meta m LEFT JOIN totals t ON t.IDDocumento = m.IDDocumento
|
||||
ORDER BY m.DataDocumento DESC, m.Documento DESC, m.IDDocumento DESC;
|
||||
"""
|
||||
|
||||
|
||||
def detail_request(documento: str, document_id: int | None, default_sql: str):
|
||||
"""Return a bound detail query; never use a cross-year display number alone."""
|
||||
if document_id is not None:
|
||||
return SQL_UDC_HISTORY_DETAILS, {"pallet": None, "documento": None, "id_documento": document_id}
|
||||
return default_sql, {"documento": documento}
|
||||
586
pickinglist_sequence.py
Normal file
586
pickinglist_sequence.py
Normal file
@@ -0,0 +1,586 @@
|
||||
"""Editor for the per-document picking-list pickup sequence.
|
||||
|
||||
The barcode client remains unaware of the editor: it reads the effective order
|
||||
from ``dbo.py_ViewPackingListPrelievo``. This module only manages the Python-
|
||||
specific configuration rows used by that view.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable
|
||||
import tkinter as tk
|
||||
import error_dialog as messagebox
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from gestione_aree import AsyncRunner
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from ui_theme import theme_color, theme_font, theme_section
|
||||
from user_session import UserSession
|
||||
from version_info import module_version, versioned_title
|
||||
from tooltips import WidgetToolTip, load_tooltip_catalog, tooltip_text
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
|
||||
SQL_LOAD_GROUPS = """
|
||||
SELECT
|
||||
GruppoPrelievoChiave,
|
||||
MAX(GruppoPrelievo) AS GruppoPrelievo,
|
||||
MIN(OrdineGruppoDefault) AS OrdineGruppoDefault,
|
||||
MIN(OrdineGruppoConfigurato) AS OrdineGruppoConfigurato
|
||||
FROM dbo.py_ViewPackingListPrelievo
|
||||
WHERE CAST(Documento AS varchar(50)) = :documento
|
||||
AND Cella <> 9999
|
||||
GROUP BY GruppoPrelievoChiave
|
||||
ORDER BY
|
||||
CASE WHEN MIN(OrdineGruppoConfigurato) IS NULL THEN 1 ELSE 0 END,
|
||||
MIN(OrdineGruppoConfigurato),
|
||||
MIN(OrdineGruppoDefault),
|
||||
MAX(GruppoPrelievo);
|
||||
"""
|
||||
|
||||
|
||||
SQL_RESET_SEQUENCE = """
|
||||
SET NOCOUNT ON;
|
||||
SET XACT_ABORT ON;
|
||||
UPDATE dbo.py_PickingListPrelievoSequenza
|
||||
SET DelUtente = :utente,
|
||||
DelDataOra = SYSDATETIME(),
|
||||
ModUtente = :utente,
|
||||
ModDataOra = SYSDATETIME()
|
||||
WHERE Documento = :documento
|
||||
AND DelDataOra IS NULL;
|
||||
SELECT CAST(0 AS int) AS ElementiSalvati;
|
||||
"""
|
||||
|
||||
|
||||
def _rows_to_dicts(result: dict[str, Any] | None) -> list[dict[str, Any]]:
|
||||
"""Convert the shared database payload to dictionaries."""
|
||||
|
||||
if not isinstance(result, dict):
|
||||
return []
|
||||
rows = result.get("rows") or []
|
||||
columns = result.get("columns") or []
|
||||
if rows and isinstance(rows[0], dict):
|
||||
return [dict(row) for row in rows]
|
||||
return [
|
||||
{str(columns[index]): row[index] for index in range(min(len(columns), len(row)))}
|
||||
for row in rows
|
||||
if isinstance(row, (list, tuple))
|
||||
]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PickupGroup:
|
||||
"""One rack group, or the conventional non-shelved group."""
|
||||
|
||||
key: str
|
||||
label: str
|
||||
default_order: int
|
||||
|
||||
|
||||
class PickingListSequenceWindow(ctk.CTkToplevel):
|
||||
"""Drag-and-drop editor for one picking-list pickup sequence."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent: tk.Misc,
|
||||
db_client,
|
||||
*,
|
||||
documento: str,
|
||||
session: UserSession | None,
|
||||
on_saved: Callable[[], None] | None = None,
|
||||
):
|
||||
super().__init__(parent)
|
||||
self.db_client = db_client
|
||||
self.documento = str(documento or "").strip()
|
||||
self.session = session
|
||||
self.on_saved = on_saved
|
||||
self._catalog = load_locale_catalog()
|
||||
self._tooltip_catalog = load_tooltip_catalog()
|
||||
self._theme = theme_section("picking_sequence_window", {})
|
||||
self.runner = AsyncRunner(self)
|
||||
self.busy = InlineBusyOverlay(self, self._theme)
|
||||
self.available: list[PickupGroup] = []
|
||||
self.selected: list[PickupGroup] = []
|
||||
self._selected_key: str | None = None
|
||||
self._selected_side: str | None = None
|
||||
self._drag_group: PickupGroup | None = None
|
||||
self._drag_side: str | None = None
|
||||
|
||||
self.title(versioned_title(self._t("picking.sequence.title", "Sequenza di prelievo"), __name__))
|
||||
self.geometry("780x560")
|
||||
self.minsize(680, 480)
|
||||
self.transient(parent)
|
||||
self.configure(fg_color=theme_color(self._theme, "window_fg_color", ("#efefef", "#2f2f2f")))
|
||||
self.protocol("WM_DELETE_WINDOW", self.destroy)
|
||||
self.bind("<Escape>", lambda _event: self.destroy())
|
||||
|
||||
self._build_layout()
|
||||
self.withdraw()
|
||||
self.after_idle(self._show_and_load)
|
||||
|
||||
def _t(self, key: str, default: str, **values: Any) -> str:
|
||||
"""Return one localized and formatted label."""
|
||||
|
||||
value = loc_text(key, catalog=self._catalog, default=default)
|
||||
try:
|
||||
return value.format(**values)
|
||||
except Exception:
|
||||
return value
|
||||
|
||||
def _build_layout(self) -> None:
|
||||
"""Build the two lists and the explicit keyboard-friendly controls."""
|
||||
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
self.grid_columnconfigure(2, weight=1)
|
||||
self.grid_rowconfigure(2, weight=1)
|
||||
|
||||
ctk.CTkLabel(
|
||||
self,
|
||||
text=self._t("picking.sequence.document", "Picking List {documento}", documento=self.documento),
|
||||
font=theme_font(self._theme, "title_font", ("Segoe UI", 16, "bold")),
|
||||
).grid(row=0, column=0, columnspan=3, padx=16, pady=(14, 4), sticky="w")
|
||||
|
||||
ctk.CTkLabel(
|
||||
self,
|
||||
text=self._t(
|
||||
"picking.sequence.hint",
|
||||
"Trascina gli scaffali a destra. Quelli non inseriti saranno accodati secondo l'ordine predefinito.",
|
||||
),
|
||||
anchor="w",
|
||||
justify="left",
|
||||
wraplength=720,
|
||||
).grid(row=1, column=0, columnspan=3, padx=16, pady=(0, 10), sticky="ew")
|
||||
|
||||
self.available_panel, self.available_list = self._build_list_panel(
|
||||
0, self._t("picking.sequence.available", "Scaffali disponibili")
|
||||
)
|
||||
controls = ctk.CTkFrame(self, fg_color="transparent")
|
||||
controls.grid(row=2, column=1, padx=10, pady=4)
|
||||
for label, command in (
|
||||
(self._t("picking.sequence.button.add", "Aggiungi >"), self._add_selected),
|
||||
(self._t("picking.sequence.button.remove", "< Rimuovi"), self._remove_selected),
|
||||
(self._t("picking.sequence.button.up", "Su"), lambda: self._move_selected(-1)),
|
||||
(self._t("picking.sequence.button.down", "Giu'"), lambda: self._move_selected(1)),
|
||||
):
|
||||
button = ctk.CTkButton(controls, text=label, width=120, command=command)
|
||||
button.pack(pady=5)
|
||||
tooltip_key = {
|
||||
self._t("picking.sequence.button.add", "Aggiungi >"): "picking.sequence.add",
|
||||
self._t("picking.sequence.button.remove", "< Rimuovi"): "picking.sequence.remove",
|
||||
self._t("picking.sequence.button.up", "Su"): "picking.sequence.up",
|
||||
self._t("picking.sequence.button.down", "Giu'"): "picking.sequence.down",
|
||||
}.get(label, "")
|
||||
self._attach_tooltip(button, tooltip_key)
|
||||
|
||||
self.selected_panel, self.selected_list = self._build_list_panel(
|
||||
2, self._t("picking.sequence.selected", "Ordine personalizzato")
|
||||
)
|
||||
|
||||
ctk.CTkLabel(
|
||||
self,
|
||||
text=self._t(
|
||||
"picking.sequence.default_hint",
|
||||
"Default: prima Non scaff., poi gli scaffali secondo l'ordine WMS.",
|
||||
),
|
||||
anchor="w",
|
||||
text_color=theme_color(self._theme, "secondary_text_color", "#4b5563"),
|
||||
).grid(row=3, column=0, columnspan=3, padx=16, pady=(8, 4), sticky="ew")
|
||||
|
||||
bottom = ctk.CTkFrame(self)
|
||||
bottom.grid(row=4, column=0, columnspan=3, padx=16, pady=(6, 14), sticky="ew")
|
||||
bottom.grid_columnconfigure(0, weight=1)
|
||||
reset_button = ctk.CTkButton(
|
||||
bottom,
|
||||
text=self._t("picking.sequence.button.reset", "Ripristina default"),
|
||||
command=self._reset_default,
|
||||
fg_color=theme_color(self._theme, "reset_button_fg_color", "#6b7280"),
|
||||
)
|
||||
reset_button.grid(row=0, column=1, padx=5, pady=8)
|
||||
self._attach_tooltip(reset_button, "picking.sequence.reset")
|
||||
save_button = ctk.CTkButton(
|
||||
bottom,
|
||||
text=self._t("picking.sequence.button.save", "Salva"),
|
||||
command=self._save,
|
||||
)
|
||||
save_button.grid(row=0, column=2, padx=5, pady=8)
|
||||
self._attach_tooltip(save_button, "picking.sequence.save")
|
||||
close_button = ctk.CTkButton(
|
||||
bottom,
|
||||
text=self._t("picking.sequence.button.close", "Chiudi"),
|
||||
command=self.destroy,
|
||||
)
|
||||
close_button.grid(row=0, column=3, padx=5, pady=8)
|
||||
self._attach_tooltip(close_button, "picking.sequence.close")
|
||||
|
||||
def _attach_tooltip(self, widget: tk.Misc, key: str) -> None:
|
||||
"""Attach a localized tooltip when the catalog contains one."""
|
||||
|
||||
value = tooltip_text(key, catalog=self._tooltip_catalog) if key else ""
|
||||
if value:
|
||||
WidgetToolTip(widget, value)
|
||||
|
||||
def _build_list_panel(self, column: int, title: str):
|
||||
"""Create one titled, scrollable group list."""
|
||||
|
||||
panel = ctk.CTkFrame(self)
|
||||
panel.grid(row=2, column=column, padx=(16 if column == 0 else 0, 16 if column == 2 else 0), pady=4, sticky="nsew")
|
||||
panel.grid_columnconfigure(0, weight=1)
|
||||
panel.grid_rowconfigure(1, weight=1)
|
||||
ctk.CTkLabel(panel, text=title, font=("Segoe UI", 12, "bold")).grid(
|
||||
row=0, column=0, padx=10, pady=(10, 6), sticky="w"
|
||||
)
|
||||
content = ctk.CTkScrollableFrame(panel, fg_color=theme_color(self._theme, "list_fg_color", "#f8fafc"))
|
||||
content.grid(row=1, column=0, padx=8, pady=(0, 8), sticky="nsew")
|
||||
content.grid_columnconfigure(0, weight=1)
|
||||
return panel, content
|
||||
|
||||
def _show_and_load(self) -> None:
|
||||
"""Center the ready window and start its asynchronous load."""
|
||||
|
||||
try:
|
||||
self.update_idletasks()
|
||||
parent = self.master
|
||||
x = max(0, parent.winfo_rootx() + (parent.winfo_width() - self.winfo_width()) // 2)
|
||||
y = max(0, parent.winfo_rooty() + (parent.winfo_height() - self.winfo_height()) // 2)
|
||||
self.geometry(f"+{x}+{y}")
|
||||
except Exception:
|
||||
pass
|
||||
self.deiconify()
|
||||
self.lift()
|
||||
self.focus_force()
|
||||
self._load()
|
||||
|
||||
def _load(self) -> None:
|
||||
"""Load available groups and the optional saved sequence."""
|
||||
|
||||
async def _job():
|
||||
return await self.db_client.query_json(SQL_LOAD_GROUPS, {"documento": self.documento})
|
||||
|
||||
def _ok(result):
|
||||
rows = _rows_to_dicts(result)
|
||||
configured: list[tuple[int, PickupGroup]] = []
|
||||
available: list[PickupGroup] = []
|
||||
for row in rows:
|
||||
group = PickupGroup(
|
||||
key=str(row.get("GruppoPrelievoChiave") or "").strip(),
|
||||
label=str(row.get("GruppoPrelievo") or "").strip(),
|
||||
default_order=int(row.get("OrdineGruppoDefault") or 0),
|
||||
)
|
||||
configured_order = row.get("OrdineGruppoConfigurato")
|
||||
if configured_order is None:
|
||||
available.append(group)
|
||||
else:
|
||||
configured.append((int(configured_order), group))
|
||||
self.available = sorted(available, key=lambda item: (item.default_order, item.label))
|
||||
self.selected = [item for _order, item in sorted(configured, key=lambda pair: pair[0])]
|
||||
self._render_lists()
|
||||
|
||||
def _error(exc):
|
||||
messagebox.showerror(
|
||||
self._t("picking.sequence.title", "Sequenza di prelievo"),
|
||||
self._t("picking.sequence.msg.load_error", "Errore durante il caricamento:\n{error}", error=exc),
|
||||
parent=self,
|
||||
exception=exc,
|
||||
)
|
||||
|
||||
self.runner.run(
|
||||
_job(),
|
||||
on_success=_ok,
|
||||
on_error=_error,
|
||||
busy=self.busy,
|
||||
message=self._t("picking.sequence.busy.load", "Carico gli scaffali..."),
|
||||
)
|
||||
|
||||
def _render_lists(self) -> None:
|
||||
"""Redraw list buttons after a move or a database load."""
|
||||
|
||||
for host in (self.available_list, self.selected_list):
|
||||
for child in host.winfo_children():
|
||||
child.destroy()
|
||||
for row, group in enumerate(self.available):
|
||||
self._render_group_button(self.available_list, group, "available", row)
|
||||
for row, group in enumerate(self.selected):
|
||||
self._render_group_button(self.selected_list, group, "selected", row)
|
||||
|
||||
def _render_group_button(self, host, group: PickupGroup, side: str, row: int) -> None:
|
||||
"""Render one selectable and draggable group button."""
|
||||
|
||||
is_selected = self._selected_key == group.key and self._selected_side == side
|
||||
prefix = f"{row + 1}. " if side == "selected" else ""
|
||||
button = ctk.CTkButton(
|
||||
host,
|
||||
text=f"{prefix}{group.label}",
|
||||
anchor="w",
|
||||
height=34,
|
||||
fg_color="#1976d2" if is_selected else theme_color(self._theme, "item_fg_color", "#2ebf74"),
|
||||
command=lambda g=group, s=side: self._select(g, s),
|
||||
)
|
||||
button.grid(row=row, column=0, padx=4, pady=4, sticky="ew")
|
||||
button.bind("<Double-Button-1>", lambda _event, g=group, s=side: self._toggle_group(g, s), add="+")
|
||||
drag_widgets = [button]
|
||||
for attr in ("_canvas", "_text_label", "_image_label"):
|
||||
widget = getattr(button, attr, None)
|
||||
if widget is not None:
|
||||
drag_widgets.append(widget)
|
||||
for widget in drag_widgets:
|
||||
widget.bind("<ButtonPress-1>", lambda _event, g=group, s=side: self._start_drag(g, s), add="+")
|
||||
widget.bind("<ButtonRelease-1>", self._finish_drag, add="+")
|
||||
self._attach_tooltip(button, "picking.sequence.item")
|
||||
|
||||
def _select(self, group: PickupGroup, side: str) -> None:
|
||||
"""Select one group for the explicit move controls."""
|
||||
|
||||
self._selected_key = group.key
|
||||
self._selected_side = side
|
||||
self._render_lists()
|
||||
|
||||
def _toggle_group(self, group: PickupGroup, side: str) -> None:
|
||||
"""Move a double-clicked group to the opposite side."""
|
||||
|
||||
self._selected_key = group.key
|
||||
self._selected_side = side
|
||||
self._add_selected() if side == "available" else self._remove_selected()
|
||||
|
||||
def _selected_group(self) -> PickupGroup | None:
|
||||
"""Return the group selected in the active side."""
|
||||
|
||||
source = self.available if self._selected_side == "available" else self.selected
|
||||
return next((item for item in source if item.key == self._selected_key), None)
|
||||
|
||||
def _add_selected(self) -> None:
|
||||
"""Append the selected available group to the custom sequence."""
|
||||
|
||||
if self._selected_side != "available":
|
||||
return
|
||||
group = self._selected_group()
|
||||
if group is None:
|
||||
return
|
||||
self.available = [item for item in self.available if item.key != group.key]
|
||||
self.selected.append(group)
|
||||
self._selected_side = "selected"
|
||||
self._render_lists()
|
||||
|
||||
def _remove_selected(self) -> None:
|
||||
"""Return the selected configured group to the available list."""
|
||||
|
||||
if self._selected_side != "selected":
|
||||
return
|
||||
group = self._selected_group()
|
||||
if group is None:
|
||||
return
|
||||
self.selected = [item for item in self.selected if item.key != group.key]
|
||||
self.available.append(group)
|
||||
self.available.sort(key=lambda item: (item.default_order, item.label))
|
||||
self._selected_side = "available"
|
||||
self._render_lists()
|
||||
|
||||
def _move_selected(self, offset: int) -> None:
|
||||
"""Move one configured group up or down."""
|
||||
|
||||
if self._selected_side != "selected":
|
||||
return
|
||||
index = next((i for i, item in enumerate(self.selected) if item.key == self._selected_key), -1)
|
||||
target = index + int(offset)
|
||||
if index < 0 or target < 0 or target >= len(self.selected):
|
||||
return
|
||||
self.selected[index], self.selected[target] = self.selected[target], self.selected[index]
|
||||
self._render_lists()
|
||||
|
||||
def _start_drag(self, group: PickupGroup, side: str) -> None:
|
||||
"""Remember the item being dragged."""
|
||||
|
||||
self._drag_group = group
|
||||
self._drag_side = side
|
||||
|
||||
@staticmethod
|
||||
def _is_descendant(widget: tk.Misc | None, ancestor: tk.Misc) -> bool:
|
||||
"""Return whether a widget belongs to one list panel."""
|
||||
|
||||
current = widget
|
||||
while current is not None:
|
||||
if current == ancestor:
|
||||
return True
|
||||
current = getattr(current, "master", None)
|
||||
return False
|
||||
|
||||
def _finish_drag(self, event) -> None:
|
||||
"""Drop the dragged group into a list and place it near the pointer."""
|
||||
|
||||
group = self._drag_group
|
||||
if group is None:
|
||||
return
|
||||
self._drag_group = None
|
||||
try:
|
||||
target_widget = self.winfo_containing(event.x_root, event.y_root)
|
||||
except Exception:
|
||||
return
|
||||
if self._is_descendant(target_widget, self.selected_panel):
|
||||
self.available = [item for item in self.available if item.key != group.key]
|
||||
self.selected = [item for item in self.selected if item.key != group.key]
|
||||
target_y = event.y_root - self.selected_list.winfo_rooty()
|
||||
row_height = 42
|
||||
target_index = max(0, min(len(self.selected), target_y // row_height))
|
||||
self.selected.insert(target_index, group)
|
||||
self._selected_side = "selected"
|
||||
elif self._is_descendant(target_widget, self.available_panel):
|
||||
self.selected = [item for item in self.selected if item.key != group.key]
|
||||
if not any(item.key == group.key for item in self.available):
|
||||
self.available.append(group)
|
||||
self.available.sort(key=lambda item: (item.default_order, item.label))
|
||||
self._selected_side = "available"
|
||||
else:
|
||||
return
|
||||
self._selected_key = group.key
|
||||
self._render_lists()
|
||||
|
||||
def _save_sql(self) -> tuple[str, dict[str, Any]]:
|
||||
"""Build one atomic soft-delete/insert batch using bound parameters."""
|
||||
|
||||
params: dict[str, Any] = {
|
||||
"documento": self.documento,
|
||||
"utente": self.session.login if self.session else "SYSTEM",
|
||||
}
|
||||
values: list[str] = []
|
||||
for index, group in enumerate(self.selected):
|
||||
params[f"key_{index}"] = group.key
|
||||
params[f"label_{index}"] = group.label
|
||||
params[f"order_{index}"] = index
|
||||
values.append(
|
||||
f"(:documento, :key_{index}, :label_{index}, :order_{index}, :utente, SYSDATETIME(), :utente, SYSDATETIME())"
|
||||
)
|
||||
insert = ""
|
||||
if values:
|
||||
insert = """
|
||||
INSERT INTO dbo.py_PickingListPrelievoSequenza (
|
||||
Documento, GruppoChiave, GruppoEtichetta, Ordine,
|
||||
InsUtente, InsDataOra, ModUtente, ModDataOra
|
||||
)
|
||||
VALUES
|
||||
""" + ",\n".join(values) + ";"
|
||||
sql = f"""
|
||||
SET NOCOUNT ON;
|
||||
SET XACT_ABORT ON;
|
||||
UPDATE dbo.py_PickingListPrelievoSequenza
|
||||
SET DelUtente = :utente,
|
||||
DelDataOra = SYSDATETIME(),
|
||||
ModUtente = :utente,
|
||||
ModDataOra = SYSDATETIME()
|
||||
WHERE Documento = :documento
|
||||
AND DelDataOra IS NULL;
|
||||
{insert}
|
||||
SELECT CAST({len(values)} AS int) AS ElementiSalvati;
|
||||
"""
|
||||
return sql, params
|
||||
|
||||
def _save(self) -> None:
|
||||
"""Persist the configured prefix atomically."""
|
||||
|
||||
sql, params = self._save_sql()
|
||||
|
||||
async def _job():
|
||||
return await self.db_client.query_json(sql, params, commit=True)
|
||||
|
||||
self.runner.run(
|
||||
_job(),
|
||||
on_success=lambda _result: self._save_completed("saved"),
|
||||
on_error=self._save_error,
|
||||
busy=self.busy,
|
||||
message=self._t("picking.sequence.busy.save", "Salvo la sequenza..."),
|
||||
)
|
||||
|
||||
def _reset_default(self) -> None:
|
||||
"""Delete the custom sequence so the shared default becomes active."""
|
||||
|
||||
async def _job():
|
||||
return await self.db_client.query_json(
|
||||
SQL_RESET_SEQUENCE,
|
||||
{
|
||||
"documento": self.documento,
|
||||
"utente": self.session.login if self.session else "SYSTEM",
|
||||
},
|
||||
commit=True,
|
||||
)
|
||||
|
||||
self.runner.run(
|
||||
_job(),
|
||||
on_success=lambda _result: self._save_completed("reset"),
|
||||
on_error=self._save_error,
|
||||
busy=self.busy,
|
||||
message=self._t("picking.sequence.busy.save", "Salvo la sequenza..."),
|
||||
)
|
||||
|
||||
def _save_completed(self, mode: str) -> None:
|
||||
"""Refresh the editor and notify the parent after a successful save."""
|
||||
|
||||
message_key = "picking.sequence.msg.reset" if mode == "reset" else "picking.sequence.msg.saved"
|
||||
default = (
|
||||
"Sequenza personalizzata rimossa. E' attivo l'ordine predefinito."
|
||||
if mode == "reset"
|
||||
else "Sequenza salvata."
|
||||
)
|
||||
messagebox.showinfo(self._t("picking.sequence.title", "Sequenza di prelievo"), self._t(message_key, default), parent=self)
|
||||
if self.on_saved:
|
||||
self.on_saved()
|
||||
self._selected_key = None
|
||||
self._selected_side = None
|
||||
self._load()
|
||||
|
||||
def _save_error(self, exc: BaseException) -> None:
|
||||
"""Show a localized save error."""
|
||||
|
||||
messagebox.showerror(
|
||||
self._t("picking.sequence.title", "Sequenza di prelievo"),
|
||||
self._t("picking.sequence.msg.save_error", "Errore durante il salvataggio:\n{error}", error=exc),
|
||||
parent=self,
|
||||
exception=exc,
|
||||
)
|
||||
|
||||
|
||||
def open_pickinglist_sequence_window(
|
||||
parent: tk.Misc,
|
||||
db_client,
|
||||
*,
|
||||
documento: str,
|
||||
session: UserSession | None,
|
||||
on_saved: Callable[[], None] | None = None,
|
||||
) -> PickingListSequenceWindow:
|
||||
"""Open at most one sequence editor for the picking-list window."""
|
||||
|
||||
key = "_pickinglist_sequence_window_singleton"
|
||||
existing = getattr(parent, key, None)
|
||||
if existing is not None:
|
||||
try:
|
||||
if existing.winfo_exists() and existing.documento == str(documento).strip():
|
||||
existing.on_saved = on_saved
|
||||
existing.deiconify()
|
||||
existing.lift()
|
||||
existing.focus_force()
|
||||
return existing
|
||||
if existing.winfo_exists():
|
||||
existing.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
window = PickingListSequenceWindow(
|
||||
parent,
|
||||
db_client,
|
||||
documento=documento,
|
||||
session=session,
|
||||
on_saved=on_saved,
|
||||
)
|
||||
setattr(parent, key, window)
|
||||
|
||||
def _clear_reference() -> None:
|
||||
try:
|
||||
if getattr(parent, key, None) is window:
|
||||
setattr(parent, key, None)
|
||||
finally:
|
||||
window.destroy()
|
||||
|
||||
window.protocol("WM_DELETE_WINDOW", _clear_reference)
|
||||
return window
|
||||
35
prenota-sprenota.csv
Normal file
35
prenota-sprenota.csv
Normal file
@@ -0,0 +1,35 @@
|
||||
NULL;0xFFFE900209004D006900630072006F0073006F00660074002000530051004C00200053006500720076006500720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E00A60C000000006D006400650033005C00670065007300740065007200700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FAFBEDFB00FCFF100E00010009000A000B0006000C000E00FCFF180F000B00060009000A000C000D000E000F00100011001200FCFF101100010009000A000B0006000C000E00FCFF1A0A00090002000A0006000B000C000D000E000F00100011001200FCFF1A0C00010009000B0006000A000C000D000E000F00100011001200FCFF100D00010009000B0006000A000C000E00FCFB1C1B0001000A0006000B001200100011000D0009000C000E000F000200;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65528;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;2025-10-09 10:22:49.633;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65534;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;68;NULL;2025-10-09 10:22:36.277;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:36.920;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3908;.Net SqlClient Data Provider;MAG2;99;NULL;2025-10-09 10:22:42.777;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3908;.Net SqlClient Data Provider;MAG2;110;NULL;2025-10-09 10:22:42.077;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;18233000;2025-10-09 10:22:36.920;2025-10-09 10:22:55.153;381449;1;688;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;103;2025-10-09 10:22:55.153;2025-10-09 10:22:55.153;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:55.153;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xExePackingListPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074007800000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D00650030000000730070005F0078004500780065005000610063006B0069006E0067004C00690073007400500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;1496;2025-10-09 10:22:55.153;2025-10-09 10:22:55.153;47;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;3000;2025-10-09 10:22:55.153;2025-10-09 10:22:55.157;381496;1;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;61;2025-10-09 10:22:55.157;2025-10-09 10:22:55.157;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:55.153;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM [Mediseawall].[dbo].Operatori WHERE login = 'magazzino';NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:55.157;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM [Mediseawall].[dbo].Operatori WHERE login = 'magazzino';NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;195;2025-10-09 10:22:55.157;2025-10-09 10:22:55.157;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;3000;2025-10-09 10:22:55.153;2025-10-09 10:22:55.157;381500;1;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;49;2025-10-09 10:22:55.157;2025-10-09 10:22:55.157;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:55.153;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p3 int set @p3=0 exec sp_xExePackingListPallet @IDOperatore=6,@Documento='241',@RC=@p3 output select @p3;0x00000000040000003000730070005F0078004500780065005000610063006B0069006E0067004C00690073007400500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500060000003B00000081001400A73076006100720063006800610072002800380029001400400044006F00630075006D0065006E0074006F00030000003234311C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;1335697;2025-10-09 10:22:55.157;2025-10-09 10:22:56.493;74756;0;1328;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;1330000;2025-10-09 10:22:55.153;2025-10-09 10:22:56.483;456256;1;1328;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;25;2025-10-09 10:22:56.483;2025-10-09 10:22:56.483;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:56.497;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT COUNT(DISTINCT Pallet) AS Pallet, COUNT(DISTINCT Lotto) AS Lotto, COUNT(DISTINCT Articolo) AS Articolo, COUNT(DISTINCT Descrizione) AS Descrizione, SUM(Qta) AS Qta, Documento, CodNazione, NAZIONE, Stato, MAX(PalletCella) AS PalletCella, MAX(Magazzino) AS Magazzino, MAX(Area) AS Area, MAX(Cella) AS Cella, MIN(Ordinamento) AS Ordinamento, MAX(IDStato) AS IDStato FROM dbo.XMag_ViewPackingList GROUP BY Documento, CodNazione, NAZIONE, Stato ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:56.487;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
" SELECT COUNT(DISTINCT Pallet) AS Pallet, COUNT(DISTINCT Lotto) AS Lotto, COUNT(DISTINCT Articolo) AS Articolo, COUNT(DISTINCT Descrizione) AS Descrizione, SUM(Qta) AS Qta, Documento, CodNazione, NAZIONE, Stato, MAX(PalletCella) AS PalletCella, MAX(Magazzino) AS Magazzino, MAX(Area) AS Area, MAX(Cella) AS Cella, MIN(Ordinamento) AS Ordinamento, MAX(IDStato) AS IDStato FROM dbo.XMag_ViewPackingList GROUP BY Documento, CodNazione, NAZIONE, Stato ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;703451;2025-10-09 10:22:56.487;2025-10-09 10:22:57.190;37506;0;703;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;68;20914000;2025-10-09 10:22:36.277;2025-10-09 10:22:57.190;266027;7;640;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;68;91;2025-10-09 10:22:57.190;2025-10-09 10:22:57.190;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;68;NULL;2025-10-09 10:22:57.200;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 237 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;68;NULL;2025-10-09 10:22:57.190;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 237 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;68;646262;2025-10-09 10:22:57.190;2025-10-09 10:22:57.837;37056;0;641;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;1344000;2025-10-09 10:22:56.497;2025-10-09 10:22:57.840;493762;1;703;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;38;2025-10-09 10:22:57.840;2025-10-09 10:22:57.840;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:57.840;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 241 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;NULL;2025-10-09 10:22:57.840;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT * FROM vViewPackingListRestante WHERE Documento = 241 ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;3432;.Net SqlClient Data Provider;magazzino;97;652370;2025-10-09 10:22:57.840;2025-10-09 10:22:58.493;37056;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;2025-10-09 10:23:20.287;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65533;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
|
@@ -2,9 +2,154 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from functools import wraps
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
try:
|
||||
from loguru import logger
|
||||
except Exception: # pragma: no cover - safety fallback if dependency is missing locally
|
||||
class _FallbackLogger:
|
||||
"""Minimal adapter used only when Loguru is not installed yet."""
|
||||
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger(MODULE_LOG_NAME if "MODULE_LOG_NAME" in globals() else __name__)
|
||||
self._logger.setLevel(logging.DEBUG)
|
||||
self._logger.propagate = False
|
||||
|
||||
def bind(self, **_kwargs):
|
||||
return self
|
||||
|
||||
def add(self, sink, level="INFO", format=None, encoding="utf-8", **_kwargs):
|
||||
handler: logging.Handler
|
||||
if hasattr(sink, "write"):
|
||||
handler = logging.StreamHandler(sink)
|
||||
else:
|
||||
handler = logging.FileHandler(str(sink), encoding=encoding)
|
||||
handler.setLevel(getattr(logging, str(level).upper(), logging.INFO))
|
||||
handler.setFormatter(
|
||||
logging.Formatter("%(asctime)s | %(levelname)-8s | %(name)s | %(message)s")
|
||||
)
|
||||
self._logger.addHandler(handler)
|
||||
return 0
|
||||
|
||||
def log(self, level, message):
|
||||
getattr(self._logger, str(level).lower(), self._logger.info)(message)
|
||||
|
||||
def debug(self, message):
|
||||
self._logger.debug(message)
|
||||
|
||||
def info(self, message):
|
||||
self._logger.info(message)
|
||||
|
||||
def exception(self, message):
|
||||
self._logger.exception(message)
|
||||
|
||||
logger = _FallbackLogger()
|
||||
|
||||
|
||||
PACKINGLIST_SP_LOG_MODE = "INFO" # "OFF" | "INFO" | "DEBUG"
|
||||
MODULE_LOG_NAME = Path(__file__).stem
|
||||
MODULE_LOG_PATH = Path(__file__).with_suffix(".log")
|
||||
_MODULE_LOG_ENABLED = PACKINGLIST_SP_LOG_MODE.upper() != "OFF"
|
||||
_MODULE_LOG_LEVEL = "DEBUG" if PACKINGLIST_SP_LOG_MODE.upper() == "DEBUG" else "INFO"
|
||||
_MODULE_LOGGER = logger.bind(warehouse_module=MODULE_LOG_NAME)
|
||||
_MODULE_LOGGING_CONFIGURED = False
|
||||
|
||||
|
||||
def _configure_module_logger():
|
||||
"""Configure console and file logging for this module."""
|
||||
global _MODULE_LOGGING_CONFIGURED
|
||||
if _MODULE_LOGGING_CONFIGURED:
|
||||
return
|
||||
if not _MODULE_LOG_ENABLED:
|
||||
_MODULE_LOGGING_CONFIGURED = True
|
||||
return
|
||||
|
||||
record_filter = lambda record: record["extra"].get("warehouse_module") == MODULE_LOG_NAME
|
||||
|
||||
logger.add(
|
||||
sys.stderr,
|
||||
level=_MODULE_LOG_LEVEL,
|
||||
colorize=True,
|
||||
filter=record_filter,
|
||||
format=(
|
||||
"<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
|
||||
"<level>{level: <8}</level> | "
|
||||
"<cyan>" + MODULE_LOG_NAME + "</cyan> | "
|
||||
"<level>{message}</level>"
|
||||
),
|
||||
)
|
||||
logger.add(
|
||||
MODULE_LOG_PATH,
|
||||
level=_MODULE_LOG_LEVEL,
|
||||
colorize=False,
|
||||
encoding="utf-8",
|
||||
filter=record_filter,
|
||||
format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | " + MODULE_LOG_NAME + " | {message}",
|
||||
)
|
||||
_MODULE_LOGGING_CONFIGURED = True
|
||||
|
||||
|
||||
def _format_payload(payload: Any) -> str:
|
||||
"""Serialize payloads for human-readable logging."""
|
||||
try:
|
||||
return json.dumps(payload, ensure_ascii=False, indent=2, default=str)
|
||||
except Exception:
|
||||
return repr(payload)
|
||||
|
||||
|
||||
def _log_call(level: Optional[str] = None):
|
||||
"""Trace entry, exit and failure of selected procedure helpers."""
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
async def wrapper(*args, **kwargs):
|
||||
effective_level = level or _MODULE_LOG_LEVEL
|
||||
_MODULE_LOGGER.log(
|
||||
effective_level,
|
||||
f"CALL {func.__qualname__} args={_format_payload(args[1:] if len(args) > 1 else ())} kwargs={_format_payload(kwargs)}",
|
||||
)
|
||||
try:
|
||||
result = await func(*args, **kwargs)
|
||||
except Exception:
|
||||
_MODULE_LOGGER.exception(f"FAIL {func.__qualname__}")
|
||||
raise
|
||||
_MODULE_LOGGER.log(effective_level, f"RETURN {func.__qualname__}")
|
||||
return result
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
|
||||
def _log_sql(query_name: str, sql: str, params: Dict[str, Any]):
|
||||
"""Log one SQL statement and its parameters."""
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"SQL {query_name} params={_format_payload(params)}")
|
||||
_MODULE_LOGGER.debug(f"SQL {query_name} text:\n{sql.strip()}")
|
||||
|
||||
|
||||
def _log_dataset(query_name: str, rows: Any):
|
||||
"""Log query results at summary or full-debug level depending on the mode."""
|
||||
if isinstance(rows, list):
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"SQL {query_name} returned {len(rows)} rows")
|
||||
if PACKINGLIST_SP_LOG_MODE.upper() == "DEBUG":
|
||||
_MODULE_LOGGER.debug(f"SQL {query_name} dataset:\n{_format_payload(rows)}")
|
||||
else:
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"SQL {query_name} scalar={_format_payload(rows)}")
|
||||
|
||||
|
||||
_configure_module_logger()
|
||||
if _MODULE_LOG_ENABLED:
|
||||
_MODULE_LOGGER.info(
|
||||
f"Logging inizializzato su {MODULE_LOG_PATH.name} livello={_MODULE_LOG_LEVEL} mode={PACKINGLIST_SP_LOG_MODE.upper()}"
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SPResult:
|
||||
@@ -15,14 +160,18 @@ class SPResult:
|
||||
id_result: Optional[int] = None
|
||||
|
||||
|
||||
@_log_call("DEBUG")
|
||||
async def _query_one_value(db, sql: str, params: Dict[str, Any]) -> Optional[Any]:
|
||||
"""Return the first column of the first row from a query result."""
|
||||
_log_sql("_query_one_value", sql, params)
|
||||
if hasattr(db, "query_json"):
|
||||
res = await db.query_json(sql, params)
|
||||
if isinstance(res, list) and res:
|
||||
row0 = res[0]
|
||||
if isinstance(row0, dict):
|
||||
return next(iter(row0.values()), None)
|
||||
value = next(iter(row0.values()), None)
|
||||
_log_dataset("_query_one_value", value)
|
||||
return value
|
||||
elif isinstance(res, dict):
|
||||
rows = None
|
||||
for key in ("rows", "data", "result", "records"):
|
||||
@@ -32,139 +181,147 @@ async def _query_one_value(db, sql: str, params: Dict[str, Any]) -> Optional[Any
|
||||
if rows:
|
||||
row0 = rows[0]
|
||||
if isinstance(row0, dict):
|
||||
return next(iter(row0.values()), None)
|
||||
value = next(iter(row0.values()), None)
|
||||
_log_dataset("_query_one_value", value)
|
||||
return value
|
||||
if isinstance(row0, (list, tuple)) and row0:
|
||||
return row0[0]
|
||||
value = row0[0]
|
||||
_log_dataset("_query_one_value", value)
|
||||
return value
|
||||
_log_dataset("_query_one_value", None)
|
||||
return None
|
||||
|
||||
if hasattr(db, "query_value"):
|
||||
return await db.query_value(sql, params)
|
||||
value = await db.query_value(sql, params)
|
||||
_log_dataset("_query_one_value", value)
|
||||
return value
|
||||
if hasattr(db, "scalar"):
|
||||
return await db.scalar(sql, params)
|
||||
value = await db.scalar(sql, params)
|
||||
_log_dataset("_query_one_value", value)
|
||||
return value
|
||||
raise RuntimeError("Il client DB non espone query_json/query_value/scalar")
|
||||
|
||||
|
||||
@_log_call("DEBUG")
|
||||
async def _query_all(db, sql: str, params: Dict[str, Any]) -> List[Dict[str, Any]]:
|
||||
"""Return all rows as dictionaries, normalizing different DB client APIs."""
|
||||
_log_sql("_query_all", sql, params)
|
||||
if hasattr(db, "query_json"):
|
||||
res = await db.query_json(sql, params)
|
||||
if res is None:
|
||||
_log_dataset("_query_all", [])
|
||||
return []
|
||||
if isinstance(res, list):
|
||||
return res if res and isinstance(res[0], dict) else []
|
||||
rows = res if res and isinstance(res[0], dict) else []
|
||||
_log_dataset("_query_all", rows)
|
||||
return rows
|
||||
if isinstance(res, dict):
|
||||
for key in ("rows", "data", "result", "records"):
|
||||
if key in res and isinstance(res[key], list):
|
||||
rows = res[key]
|
||||
if rows and isinstance(rows[0], dict):
|
||||
_log_dataset("_query_all", rows)
|
||||
return rows
|
||||
cols = res.get("columns") or res.get("cols") or []
|
||||
out = []
|
||||
for row in rows:
|
||||
if isinstance(row, (list, tuple)) and cols:
|
||||
out.append({(cols[i] if i < len(cols) else f"c{i}"): row[i] for i in range(min(len(cols), len(row)))})
|
||||
_log_dataset("_query_all", out)
|
||||
return out
|
||||
_log_dataset("_query_all", [])
|
||||
return []
|
||||
if hasattr(db, "fetch_all"):
|
||||
return await db.fetch_all(sql, params)
|
||||
rows = await db.fetch_all(sql, params)
|
||||
_log_dataset("_query_all", rows)
|
||||
return rows
|
||||
raise RuntimeError("Il client DB non espone query_json/fetch_all")
|
||||
|
||||
|
||||
@_log_call("DEBUG")
|
||||
async def _execute(db, sql: str, params: Dict[str, Any]) -> int:
|
||||
"""Execute a DML statement using the best method exposed by the DB client."""
|
||||
_log_sql("_execute", sql, params)
|
||||
for name in ("execute", "exec", "execute_non_query"):
|
||||
if hasattr(db, name):
|
||||
rc = await getattr(db, name)(sql, params)
|
||||
if isinstance(rc, int):
|
||||
_log_dataset("_execute", rc)
|
||||
return rc
|
||||
_log_dataset("_execute", 0)
|
||||
return 0
|
||||
if hasattr(db, "query_json"):
|
||||
await db.query_json(sql, params)
|
||||
_log_dataset("_execute", 0)
|
||||
return 0
|
||||
raise RuntimeError("Il client DB non espone metodi di esecuzione DML noti")
|
||||
|
||||
|
||||
async def sp_xExePackingListPallet_async(db, IDOperatore: int, Documento: str) -> SPResult:
|
||||
"""Toggle the reservation state of all cells belonging to a packing list.
|
||||
|
||||
The implementation mirrors the original SQL stored procedure while using
|
||||
the shared async DB client already managed by the application.
|
||||
"""
|
||||
@_log_call()
|
||||
async def sp_xExePackingListPallet_async(db, IDOperatore: int, Documento: str, Azione: str = "P") -> SPResult:
|
||||
"""Execute the Python-specific picking-list reservation stored procedure."""
|
||||
try:
|
||||
nominativo = await _query_one_value(
|
||||
db,
|
||||
"SELECT LOGIN FROM Operatori WHERE id = :IDOperatore",
|
||||
{"IDOperatore": IDOperatore},
|
||||
) or ""
|
||||
|
||||
celle = await _query_all(
|
||||
db,
|
||||
"""
|
||||
SELECT DISTINCT Cella
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE Documento = :Documento
|
||||
""",
|
||||
{"Documento": Documento},
|
||||
azione = str(Azione or "P").strip().upper()
|
||||
# The toolbar uses two explicit commands rather than a toggle:
|
||||
# P = reserve the selected document, S = release it if it is active.
|
||||
if azione not in ("P", "S"):
|
||||
return SPResult(rc=-10, message=f"Azione non valida: {Azione}", id_result=None)
|
||||
_MODULE_LOGGER.log(
|
||||
_MODULE_LOG_LEVEL,
|
||||
f"Procedura packing list via stored procedure documento={Documento} azione={azione} id_operatore={IDOperatore}",
|
||||
)
|
||||
id_celle = [row.get("Cella") for row in celle if "Cella" in row]
|
||||
sql = """
|
||||
SET NOCOUNT ON;
|
||||
DECLARE @RC int = 0;
|
||||
|
||||
# Each cell is toggled individually because the original procedure also
|
||||
# updates metadata such as operator and timestamp per row.
|
||||
for id_cella in id_celle:
|
||||
if id_cella is None:
|
||||
continue
|
||||
stato = await _query_one_value(
|
||||
db,
|
||||
"SELECT IDStato FROM Celle WHERE ID = :IDC",
|
||||
{"IDC": id_cella},
|
||||
)
|
||||
if stato == 0:
|
||||
await _execute(
|
||||
db,
|
||||
"""
|
||||
UPDATE Celle
|
||||
SET IDStato = 1,
|
||||
ModUtente = :N,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = :IDC
|
||||
""",
|
||||
{"N": nominativo, "IDC": id_cella},
|
||||
)
|
||||
EXEC dbo.py_sp_xExePackingListPallet
|
||||
@IDOperatore = :IDOperatore,
|
||||
@Documento = :Documento,
|
||||
@Azione = :Azione,
|
||||
@RC = @RC OUTPUT;
|
||||
|
||||
SELECT CAST(@RC AS int) AS RC;
|
||||
"""
|
||||
_log_sql("py_sp_xExePackingListPallet", sql, {"IDOperatore": IDOperatore, "Documento": Documento, "Azione": azione})
|
||||
if not hasattr(db, "query_json"):
|
||||
raise RuntimeError("Il client DB non espone query_json necessario per eseguire la stored procedure.")
|
||||
# commit=True is required because the stored procedure updates
|
||||
# PyPickingListReservation and Celle.IDStato.
|
||||
res = await db.query_json(
|
||||
sql,
|
||||
{"IDOperatore": IDOperatore, "Documento": Documento, "Azione": azione},
|
||||
as_dict_rows=True,
|
||||
commit=True,
|
||||
)
|
||||
rows = []
|
||||
if isinstance(res, dict):
|
||||
rows = res.get("rows", []) or []
|
||||
_log_dataset("py_sp_xExePackingListPallet", rows)
|
||||
rc = 0
|
||||
if rows and isinstance(rows[0], dict):
|
||||
try:
|
||||
rc = int(rows[0].get("RC") or 0)
|
||||
except Exception:
|
||||
rc = 0
|
||||
if rc == 0 and azione == "P":
|
||||
resolve_sql = """
|
||||
UPDATE dbo.py_BarcodePickingListSkip
|
||||
SET Risolto = 1
|
||||
WHERE Documento COLLATE Latin1_General_CI_AS =
|
||||
CAST(:Documento AS varchar(50)) COLLATE Latin1_General_CI_AS
|
||||
AND Risolto = 0;
|
||||
"""
|
||||
_log_sql("resolve_skipped_pallets_on_prenota", resolve_sql, {"Documento": Documento})
|
||||
if hasattr(db, "exec"):
|
||||
await db.exec(resolve_sql, {"Documento": Documento}, commit=True)
|
||||
else:
|
||||
await _execute(
|
||||
db,
|
||||
"""
|
||||
UPDATE Celle
|
||||
SET IDStato = 0,
|
||||
ModUtente = :N,
|
||||
ModDataOra = GETDATE()
|
||||
WHERE ID = :IDC
|
||||
""",
|
||||
{"N": nominativo, "IDC": id_cella},
|
||||
await db.query_json(
|
||||
resolve_sql + "\nSELECT 0 AS RC;",
|
||||
{"Documento": Documento},
|
||||
commit=True,
|
||||
)
|
||||
|
||||
description = await _query_one_value(
|
||||
db,
|
||||
"""
|
||||
SELECT TOP 1 NAZIONE
|
||||
FROM dbo.XMag_ViewPackingList
|
||||
WHERE Documento = :Documento
|
||||
GROUP BY Documento, NAZIONE
|
||||
ORDER BY NAZIONE
|
||||
""",
|
||||
{"Documento": Documento},
|
||||
)
|
||||
|
||||
await _execute(
|
||||
db,
|
||||
"""
|
||||
INSERT INTO dbo.LogPackingList (Code, Description, IDInsUser, InsDateTime)
|
||||
VALUES (:Code, :Descr, :IDInsUser, GETDATE());
|
||||
""",
|
||||
{"Code": Documento, "Descr": description, "IDInsUser": IDOperatore},
|
||||
)
|
||||
|
||||
new_id = await _query_one_value(db, "SELECT SCOPE_IDENTITY() AS ID", {})
|
||||
return SPResult(rc=0, message="", id_result=int(new_id) if new_id is not None else None)
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"Stored procedure completata documento={Documento} azione={azione} rc={rc}")
|
||||
return SPResult(rc=rc, message="", id_result=None)
|
||||
except Exception as exc:
|
||||
_MODULE_LOGGER.exception(f"Procedura fallita documento={Documento} azione={Azione}: {exc}")
|
||||
return SPResult(rc=-1, message=str(exc), id_result=None)
|
||||
|
||||
@@ -5,6 +5,8 @@ requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"sqlalchemy[asyncio]>=2.0",
|
||||
"aioodbc>=0.3.3",
|
||||
"loguru>=0.7",
|
||||
"tksheet>=7.5",
|
||||
# "orjson>=3.9" # opzionale: il tuo codice fa fallback su json puro
|
||||
]
|
||||
|
||||
|
||||
9
requirements.txt
Normal file
9
requirements.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
aioodbc==0.5.0
|
||||
customtkinter==5.2.2
|
||||
loguru
|
||||
openpyxl==3.1.5
|
||||
orjson
|
||||
Pillow
|
||||
pyodbc==5.3.0
|
||||
SQLAlchemy==2.0.49
|
||||
tksheet==7.6.0
|
||||
572
reset_corsie.py
572
reset_corsie.py
@@ -1,22 +1,178 @@
|
||||
"""Window used to inspect and empty an entire warehouse aisle.
|
||||
"""Window used to inspect and logically empty an entire warehouse aisle.
|
||||
|
||||
The module exposes a destructive maintenance tool: it summarizes the occupancy
|
||||
state of a selected aisle and, after explicit confirmation, deletes matching
|
||||
rows from ``MagazziniPallet``.
|
||||
The tool summarizes the current occupancy of one aisle and, after explicit
|
||||
confirmation, unloads every active UDC through the same logical movement
|
||||
semantics used by the rest of the WMS.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox, simpledialog, ttk
|
||||
from functools import wraps
|
||||
from pathlib import Path
|
||||
import error_dialog as messagebox
|
||||
from tkinter import simpledialog, ttk
|
||||
from typing import Any
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
from gestione_aree_frame_async import AsyncRunner, BusyOverlay
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from gestione_aree import AsyncRunner
|
||||
from reset_corsie_service import reset_pallet_async
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from tooltips import WidgetToolTip, load_tooltip_catalog, tooltip_text
|
||||
from ui_theme import theme_color, theme_font, theme_section, theme_value
|
||||
from ui_tables import style_treeview, zebra_tag
|
||||
from version_info import module_version, versioned_title
|
||||
from window_placement import place_window_fullsize_below_parent_later
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
try:
|
||||
from loguru import logger
|
||||
except Exception: # pragma: no cover - fallback used only when Loguru is not available
|
||||
class _FallbackLogger:
|
||||
"""Minimal adapter used only when Loguru is not installed yet."""
|
||||
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger(MODULE_LOG_NAME if "MODULE_LOG_NAME" in globals() else __name__)
|
||||
self._logger.setLevel(logging.DEBUG)
|
||||
self._logger.propagate = False
|
||||
|
||||
def bind(self, **_kwargs):
|
||||
return self
|
||||
|
||||
def add(self, sink, level="INFO", format=None, encoding="utf-8", **_kwargs):
|
||||
handler: logging.Handler
|
||||
if hasattr(sink, "write"):
|
||||
handler = logging.StreamHandler(sink)
|
||||
else:
|
||||
handler = logging.FileHandler(str(sink), encoding=encoding)
|
||||
handler.setLevel(getattr(logging, str(level).upper(), logging.INFO))
|
||||
handler.setFormatter(
|
||||
logging.Formatter("%(asctime)s | %(levelname)-8s | %(name)s | %(message)s")
|
||||
)
|
||||
self._logger.addHandler(handler)
|
||||
return 0
|
||||
|
||||
def log(self, level, message):
|
||||
getattr(self._logger, str(level).lower(), self._logger.info)(message)
|
||||
|
||||
def debug(self, message):
|
||||
self._logger.debug(message)
|
||||
|
||||
def info(self, message):
|
||||
self._logger.info(message)
|
||||
|
||||
def exception(self, message):
|
||||
self._logger.exception(message)
|
||||
|
||||
logger = _FallbackLogger()
|
||||
|
||||
|
||||
RESET_CORSIE_LOG_MODE = "INFO" # "OFF" | "INFO" | "DEBUG"
|
||||
MODULE_LOG_NAME = Path(__file__).stem
|
||||
MODULE_LOG_PATH = Path(__file__).with_suffix(".log")
|
||||
_MODULE_LOG_ENABLED = RESET_CORSIE_LOG_MODE.upper() != "OFF"
|
||||
_MODULE_LOG_LEVEL = "DEBUG" if RESET_CORSIE_LOG_MODE.upper() == "DEBUG" else "INFO"
|
||||
_MODULE_LOGGER = logger.bind(warehouse_module=MODULE_LOG_NAME)
|
||||
_MODULE_LOGGING_CONFIGURED = False
|
||||
|
||||
|
||||
def _configure_module_logger():
|
||||
"""Configure console and file logging for this module."""
|
||||
global _MODULE_LOGGING_CONFIGURED
|
||||
if _MODULE_LOGGING_CONFIGURED:
|
||||
return
|
||||
if not _MODULE_LOG_ENABLED:
|
||||
_MODULE_LOGGING_CONFIGURED = True
|
||||
return
|
||||
|
||||
record_filter = lambda record: record["extra"].get("warehouse_module") == MODULE_LOG_NAME
|
||||
|
||||
logger.add(
|
||||
sys.stderr,
|
||||
level=_MODULE_LOG_LEVEL,
|
||||
colorize=True,
|
||||
filter=record_filter,
|
||||
format=(
|
||||
"<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
|
||||
"<level>{level: <8}</level> | "
|
||||
"<cyan>" + MODULE_LOG_NAME + "</cyan> | "
|
||||
"<level>{message}</level>"
|
||||
),
|
||||
)
|
||||
logger.add(
|
||||
MODULE_LOG_PATH,
|
||||
level=_MODULE_LOG_LEVEL,
|
||||
colorize=False,
|
||||
encoding="utf-8",
|
||||
filter=record_filter,
|
||||
format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | " + MODULE_LOG_NAME + " | {message}",
|
||||
)
|
||||
_MODULE_LOGGING_CONFIGURED = True
|
||||
|
||||
|
||||
def _format_payload(payload: Any) -> str:
|
||||
"""Serialize payloads for human-readable logging."""
|
||||
try:
|
||||
return json.dumps(payload, ensure_ascii=False, indent=2, default=str)
|
||||
except Exception:
|
||||
return repr(payload)
|
||||
|
||||
|
||||
def _log_call(level: str | None = None):
|
||||
"""Trace entry, exit and failure of selected high-level functions."""
|
||||
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
effective_level = level or _MODULE_LOG_LEVEL
|
||||
_MODULE_LOGGER.log(
|
||||
effective_level,
|
||||
f"CALL {func.__qualname__} args={_format_payload(args[1:] if args else ())} kwargs={_format_payload(kwargs)}",
|
||||
)
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
except Exception:
|
||||
_MODULE_LOGGER.exception(f"FAIL {func.__qualname__}")
|
||||
raise
|
||||
_MODULE_LOGGER.log(effective_level, f"RETURN {func.__qualname__}")
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
def _log_sql(query_name: str, sql: str, params: dict[str, Any] | None = None):
|
||||
"""Log one SQL statement and its parameters."""
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"SQL {query_name} params={_format_payload(params or {})}")
|
||||
_MODULE_LOGGER.debug(f"SQL {query_name} text:\n{sql.strip()}")
|
||||
|
||||
|
||||
def _log_dataset(query_name: str, rows: list[Any]):
|
||||
"""Log query results at summary or full-debug level depending on the flag."""
|
||||
_MODULE_LOGGER.log(_MODULE_LOG_LEVEL, f"SQL {query_name} returned {len(rows)} rows")
|
||||
if RESET_CORSIE_LOG_MODE.upper() == "DEBUG":
|
||||
_MODULE_LOGGER.debug(f"SQL {query_name} dataset:\n{_format_payload(rows)}")
|
||||
|
||||
|
||||
_configure_module_logger()
|
||||
if _MODULE_LOG_ENABLED:
|
||||
_MODULE_LOGGER.info(
|
||||
f"Logging inizializzato su {MODULE_LOG_PATH.name} livello={_MODULE_LOG_LEVEL} mode={RESET_CORSIE_LOG_MODE.upper()}"
|
||||
)
|
||||
|
||||
|
||||
SQL_CORSIE = """
|
||||
WITH C AS (
|
||||
SELECT DISTINCT LTRIM(RTRIM(Corsia)) AS Corsia
|
||||
FROM dbo.Celle
|
||||
WHERE ID <> 9999 AND (DelDataOra IS NULL) AND LTRIM(RTRIM(Corsia)) <> '7G'
|
||||
WHERE ID NOT IN (1000, 9999) AND (DelDataOra IS NULL) AND LTRIM(RTRIM(Corsia)) <> '7G'
|
||||
)
|
||||
SELECT Corsia
|
||||
FROM C
|
||||
@@ -38,7 +194,7 @@ WITH C AS (
|
||||
LTRIM(RTRIM(Colonna)) AS Colonna,
|
||||
LTRIM(RTRIM(Fila)) AS Fila
|
||||
FROM dbo.Celle
|
||||
WHERE ID <> 9999 AND (DelDataOra IS NULL)
|
||||
WHERE ID NOT IN (1000, 9999) AND (DelDataOra IS NULL)
|
||||
AND LTRIM(RTRIM(Corsia)) = :corsia
|
||||
),
|
||||
S AS (
|
||||
@@ -60,7 +216,7 @@ WITH C AS (
|
||||
LTRIM(RTRIM(Colonna)) AS Colonna,
|
||||
LTRIM(RTRIM(Fila)) AS Fila
|
||||
FROM dbo.Celle
|
||||
WHERE ID <> 9999 AND (DelDataOra IS NULL)
|
||||
WHERE ID NOT IN (1000, 9999) AND (DelDataOra IS NULL)
|
||||
AND LTRIM(RTRIM(Corsia)) = :corsia
|
||||
),
|
||||
S AS (
|
||||
@@ -76,59 +232,168 @@ WHERE COALESCE(s.n,0) > 0
|
||||
ORDER BY TRY_CONVERT(int,c.Colonna), c.Colonna, TRY_CONVERT(int,c.Fila), c.Fila;
|
||||
"""
|
||||
|
||||
SQL_COUNT_DELETE = """
|
||||
SELECT COUNT(*) AS RowsToDelete
|
||||
FROM dbo.MagazziniPallet mp
|
||||
JOIN dbo.Celle c ON c.ID = mp.IDCella
|
||||
WHERE c.ID <> 9999 AND LTRIM(RTRIM(c.Corsia)) = :corsia;
|
||||
SQL_COUNT_RESET = """
|
||||
SELECT
|
||||
COUNT(DISTINCT g.BarcodePallet) AS TotUDC,
|
||||
COUNT(DISTINCT g.IDCella) AS TotCelle
|
||||
FROM dbo.XMag_GiacenzaPallet g
|
||||
JOIN dbo.Celle c ON c.ID = g.IDCella
|
||||
WHERE c.ID NOT IN (1000, 9999)
|
||||
AND LTRIM(RTRIM(c.Corsia)) = :corsia;
|
||||
"""
|
||||
|
||||
SQL_DELETE = """
|
||||
DELETE mp
|
||||
FROM dbo.MagazziniPallet mp
|
||||
JOIN dbo.Celle c ON c.ID = mp.IDCella
|
||||
WHERE c.ID <> 9999 AND LTRIM(RTRIM(c.Corsia)) = :corsia;
|
||||
SQL_UDC_RESET = """
|
||||
WITH U AS (
|
||||
SELECT DISTINCT
|
||||
g.BarcodePallet AS BarcodePallet,
|
||||
g.IDCella AS IDCella,
|
||||
CONCAT(LTRIM(RTRIM(c.Corsia)), '.', LTRIM(RTRIM(c.Colonna)), '.', LTRIM(RTRIM(c.Fila))) AS Ubicazione,
|
||||
TRY_CONVERT(int, c.Colonna) AS SortColNum,
|
||||
LTRIM(RTRIM(c.Colonna)) AS SortColTxt,
|
||||
TRY_CONVERT(int, c.Fila) AS SortFilaNum,
|
||||
LTRIM(RTRIM(c.Fila)) AS SortFilaTxt
|
||||
FROM dbo.XMag_GiacenzaPallet g
|
||||
JOIN dbo.Celle c ON c.ID = g.IDCella
|
||||
WHERE c.ID NOT IN (1000, 9999)
|
||||
AND LTRIM(RTRIM(c.Corsia)) = :corsia
|
||||
)
|
||||
SELECT
|
||||
BarcodePallet,
|
||||
IDCella,
|
||||
Ubicazione
|
||||
FROM U
|
||||
ORDER BY
|
||||
SortColNum,
|
||||
SortColTxt,
|
||||
SortFilaNum,
|
||||
SortFilaTxt,
|
||||
BarcodePallet;
|
||||
"""
|
||||
|
||||
|
||||
class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
"""Toplevel used to inspect and clear the pallets assigned to an aisle."""
|
||||
|
||||
def __init__(self, parent, db_client):
|
||||
@_log_call()
|
||||
def __init__(self, parent, db_client, session=None):
|
||||
"""Create the window and immediately load the list of aisles."""
|
||||
super().__init__(parent)
|
||||
self.title("Reset Corsie - svuotamento celle per corsia")
|
||||
self.geometry("1000x680")
|
||||
self.minsize(880, 560)
|
||||
self._theme = theme_section("reset_corsie", {})
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self.title(versioned_title(loc_text("reset.title", catalog=self._locale_catalog, default="Gestione Corsie - svuotamento celle per corsia"), __name__))
|
||||
self.geometry(str(theme_value(self._theme, "window_geometry", "1000x680")))
|
||||
minsize = theme_value(self._theme, "window_minsize", [880, 560])
|
||||
self.minsize(int(minsize[0]), int(minsize[1]))
|
||||
self.resizable(True, True)
|
||||
try:
|
||||
self.configure(fg_color=theme_color(self._theme, "window_fg_color", ("#efefef", "#2f2f2f")))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.db = db_client
|
||||
self._busy = BusyOverlay(self)
|
||||
self.session = session
|
||||
self._busy = InlineBusyOverlay(self, self._theme)
|
||||
self._async = AsyncRunner(self)
|
||||
self._refresh_token = 0
|
||||
self._tooltip_catalog = load_tooltip_catalog()
|
||||
|
||||
self._build_ui()
|
||||
self._load_corsie()
|
||||
|
||||
def _setup_tree_style(self):
|
||||
"""Apply a denser, spreadsheet-like style to the main result grid."""
|
||||
|
||||
@_log_call()
|
||||
def _build_ui(self):
|
||||
"""Create selectors, summary widgets and the occupied-cell grid."""
|
||||
self._setup_tree_style()
|
||||
top = ctk.CTkFrame(self)
|
||||
top.pack(fill="x", padx=8, pady=8)
|
||||
ctk.CTkLabel(top, text="Corsia:").pack(side="left")
|
||||
self.cmb = ctk.CTkComboBox(top, width=140, values=[])
|
||||
top.pack(
|
||||
fill="x",
|
||||
padx=int(theme_value(self._theme, "frame_padx", 8)),
|
||||
pady=int(theme_value(self._theme, "frame_pady", 8)),
|
||||
)
|
||||
try:
|
||||
top.configure(fg_color=theme_color(self._theme, "top_frame_fg_color", ("#d7d7d7", "#3b3b3b")))
|
||||
except Exception:
|
||||
pass
|
||||
ctk.CTkLabel(
|
||||
top,
|
||||
text=loc_text("reset.label.aisle", catalog=self._locale_catalog, default="Corsia:"),
|
||||
font=theme_font(self._theme, "toolbar_label_font", ("Segoe UI", 10)),
|
||||
).pack(side="left")
|
||||
self.cmb = ctk.CTkComboBox(
|
||||
top,
|
||||
width=int(theme_value(self._theme, "combobox_width", 140)),
|
||||
height=int(theme_value(self._theme, "combobox_height", 28)),
|
||||
values=[],
|
||||
font=theme_font(self._theme, "combobox_font", ("Segoe UI", 10)),
|
||||
dropdown_font=theme_font(self._theme, "combobox_font", ("Segoe UI", 10)),
|
||||
)
|
||||
self.cmb.pack(side="left", padx=(6, 10))
|
||||
ctk.CTkButton(top, text="Carica", command=self.refresh).pack(side="left")
|
||||
ctk.CTkButton(top, text="Svuota corsia...", command=self._ask_reset).pack(side="right")
|
||||
btn_refresh = ctk.CTkButton(
|
||||
top,
|
||||
text=loc_text("reset.button.refresh", catalog=self._locale_catalog, default="Carica"),
|
||||
command=self.refresh,
|
||||
width=int(theme_value(self._theme, "toolbar_button_width", 140)),
|
||||
height=int(theme_value(self._theme, "toolbar_button_height", 28)),
|
||||
corner_radius=int(theme_value(self._theme, "toolbar_button_corner_radius", 6)),
|
||||
font=theme_font(self._theme, "toolbar_button_font", ("Segoe UI", 10, "bold")),
|
||||
)
|
||||
btn_refresh.pack(side="left")
|
||||
btn_reset = ctk.CTkButton(
|
||||
top,
|
||||
text=loc_text("reset.button.empty", catalog=self._locale_catalog, default="Svuota corsia..."),
|
||||
command=self._ask_reset,
|
||||
width=int(theme_value(self._theme, "toolbar_button_width", 140)),
|
||||
height=int(theme_value(self._theme, "toolbar_button_height", 28)),
|
||||
corner_radius=int(theme_value(self._theme, "toolbar_button_corner_radius", 6)),
|
||||
font=theme_font(self._theme, "toolbar_button_font", ("Segoe UI", 10, "bold")),
|
||||
)
|
||||
btn_reset.pack(side="right")
|
||||
WidgetToolTip(btn_refresh, tooltip_text("reset_corsie.refresh", catalog=self._tooltip_catalog))
|
||||
WidgetToolTip(btn_reset, tooltip_text("reset_corsie.empty_aisle", catalog=self._tooltip_catalog))
|
||||
|
||||
mid = ctk.CTkFrame(self)
|
||||
mid.pack(fill="both", expand=True, padx=8, pady=(0, 8))
|
||||
mid.pack(
|
||||
fill="both",
|
||||
expand=True,
|
||||
padx=int(theme_value(self._theme, "frame_padx", 8)),
|
||||
pady=(0, int(theme_value(self._theme, "frame_pady", 8))),
|
||||
)
|
||||
try:
|
||||
mid.configure(fg_color=theme_color(self._theme, "mid_frame_fg_color", ("#e5e5e5", "#383838")))
|
||||
except Exception:
|
||||
pass
|
||||
mid.grid_columnconfigure(0, weight=1)
|
||||
mid.grid_rowconfigure(0, weight=1)
|
||||
|
||||
self.tree = ttk.Treeview(mid, columns=("Ubicazione", "NumUDC"), show="headings", selectmode="browse")
|
||||
self.tree = ttk.Treeview(
|
||||
mid,
|
||||
columns=("Ubicazione", "NumUDC"),
|
||||
show="headings",
|
||||
selectmode="browse",
|
||||
style="ResetCorsie.Treeview",
|
||||
)
|
||||
self.tree.heading("Ubicazione", text="Ubicazione")
|
||||
self.tree.heading("NumUDC", text="UDC in cella")
|
||||
self.tree.column("Ubicazione", width=240, anchor="w")
|
||||
self.tree.column("NumUDC", width=120, anchor="e")
|
||||
self.tree.column(
|
||||
"Ubicazione",
|
||||
width=int(theme_value(self._theme, "tree_col_ubicazione_width", 340)),
|
||||
anchor=str(theme_value(self._theme, "tree_col_ubicazione_anchor", "center")),
|
||||
)
|
||||
self.tree.column(
|
||||
"NumUDC",
|
||||
width=int(theme_value(self._theme, "tree_col_num_udc_width", 160)),
|
||||
anchor=str(theme_value(self._theme, "tree_col_num_udc_anchor", "center")),
|
||||
)
|
||||
style_treeview(
|
||||
self.tree,
|
||||
style_name="ResetCorsie.Treeview",
|
||||
rowheight=int(theme_value(self._theme, "tree_row_height", 30)),
|
||||
font=theme_font(self._theme, "tree_body_font", ("Segoe UI", 10)),
|
||||
heading_font=theme_font(self._theme, "tree_heading_font", ("Segoe UI", 10, "bold")),
|
||||
)
|
||||
|
||||
sy = ttk.Scrollbar(mid, orient="vertical", command=self.tree.yview)
|
||||
sx = ttk.Scrollbar(mid, orient="horizontal", command=self.tree.xview)
|
||||
@@ -138,11 +403,27 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
sx.grid(row=1, column=0, sticky="ew")
|
||||
|
||||
bottom = ctk.CTkFrame(self)
|
||||
bottom.pack(fill="x", padx=8, pady=(0, 8))
|
||||
ctk.CTkLabel(bottom, text="Riepilogo", font=("Segoe UI", 12, "bold")).pack(anchor="w", padx=8, pady=(8, 0))
|
||||
bottom.pack(
|
||||
fill="x",
|
||||
padx=int(theme_value(self._theme, "frame_padx", 8)),
|
||||
pady=(0, int(theme_value(self._theme, "frame_pady", 8))),
|
||||
)
|
||||
try:
|
||||
bottom.configure(fg_color=theme_color(self._theme, "bottom_frame_fg_color", ("#dcdcdc", "#363636")))
|
||||
except Exception:
|
||||
pass
|
||||
ctk.CTkLabel(
|
||||
bottom,
|
||||
text=loc_text("reset.summary", catalog=self._locale_catalog, default="Riepilogo"),
|
||||
font=theme_font(self._theme, "summary_title_font", ("Segoe UI", 12, "bold")),
|
||||
).pack(anchor="w", padx=8, pady=(8, 0))
|
||||
|
||||
g = ctk.CTkFrame(bottom)
|
||||
g.pack(fill="x", padx=8, pady=8)
|
||||
try:
|
||||
g.configure(fg_color=theme_color(self._theme, "inner_summary_frame_fg_color", ("#d4d4d4", "#404040")))
|
||||
except Exception:
|
||||
pass
|
||||
self.var_tot_celle = tk.StringVar(value="0")
|
||||
self.var_occ = tk.StringVar(value="0")
|
||||
self.var_dbl = tk.StringVar(value="0")
|
||||
@@ -150,8 +431,16 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
|
||||
def _kv(parent_widget, label, var, col):
|
||||
"""Build a compact summary label/value pair."""
|
||||
ctk.CTkLabel(parent_widget, text=label, font=("Segoe UI", 9, "bold")).grid(row=0, column=col * 2, sticky="w", padx=(0, 6))
|
||||
ctk.CTkLabel(parent_widget, textvariable=var).grid(row=0, column=col * 2 + 1, sticky="w", padx=(0, 18))
|
||||
ctk.CTkLabel(
|
||||
parent_widget,
|
||||
text=label,
|
||||
font=theme_font(self._theme, "summary_label_font", ("Segoe UI", 9, "bold")),
|
||||
).grid(row=0, column=col * 2, sticky="w", padx=(0, 6))
|
||||
ctk.CTkLabel(
|
||||
parent_widget,
|
||||
textvariable=var,
|
||||
font=theme_font(self._theme, "summary_value_font", ("Segoe UI", 9)),
|
||||
).grid(row=0, column=col * 2 + 1, sticky="w", padx=(0, 18))
|
||||
|
||||
g.grid_columnconfigure(7, weight=1)
|
||||
_kv(g, "Tot. celle:", self.var_tot_celle, 0)
|
||||
@@ -159,10 +448,14 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
_kv(g, "Celle doppie:", self.var_dbl, 2)
|
||||
_kv(g, "Tot. pallet:", self.var_pallet, 3)
|
||||
|
||||
@_log_call()
|
||||
def _load_corsie(self):
|
||||
"""Load available aisles and preselect ``1A`` when present."""
|
||||
_log_sql("reset_corsie_corsie", SQL_CORSIE, {})
|
||||
|
||||
def _ok(res):
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
_log_dataset("reset_corsie_corsie", rows)
|
||||
items = [r[0] for r in rows]
|
||||
self.cmb.configure(values=items)
|
||||
if items:
|
||||
@@ -173,92 +466,203 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
messagebox.showinfo("Info", "Nessuna corsia trovata.", parent=self)
|
||||
|
||||
def _err(ex):
|
||||
messagebox.showerror("Errore", f"Caricamento corsie fallito:\n{ex}", parent=self)
|
||||
_MODULE_LOGGER.exception(f"Errore caricamento corsie reset corsie: {ex}")
|
||||
messagebox.showerror("Errore", f"Caricamento corsie fallito:\n{ex}", parent=self, exception=ex)
|
||||
|
||||
self._async.run(self.db.query_json(SQL_CORSIE, {}), _ok, _err, busy=self._busy, message="Carico corsie...")
|
||||
|
||||
@_log_call()
|
||||
def refresh(self):
|
||||
"""Refresh both the summary counters and the occupied-cell list."""
|
||||
corsia = self.cmb.get().strip()
|
||||
if not corsia:
|
||||
return
|
||||
_log_sql("reset_corsie_riepilogo", SQL_RIEPILOGO, {"corsia": corsia})
|
||||
_log_sql("reset_corsie_dettaglio", SQL_DETTAGLIO, {"corsia": corsia})
|
||||
|
||||
def _ok_sum(res):
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
if rows:
|
||||
tot, occ, dbl, pallet = rows[0]
|
||||
self.var_tot_celle.set(str(tot or 0))
|
||||
self.var_occ.set(str(occ or 0))
|
||||
self.var_dbl.set(str(dbl or 0))
|
||||
self.var_pallet.set(str(pallet or 0))
|
||||
else:
|
||||
self.var_tot_celle.set("0")
|
||||
self.var_occ.set("0")
|
||||
self.var_dbl.set("0")
|
||||
self.var_pallet.set("0")
|
||||
async def _q():
|
||||
riepilogo = await self.db.query_json(SQL_RIEPILOGO, {"corsia": corsia})
|
||||
dettaglio = await self.db.query_json(SQL_DETTAGLIO, {"corsia": corsia})
|
||||
return {"riepilogo": riepilogo, "dettaglio": dettaglio}
|
||||
|
||||
def _err_sum(ex):
|
||||
messagebox.showerror("Errore", f"Riepilogo fallito:\n{ex}", parent=self)
|
||||
def _ok(payload):
|
||||
try:
|
||||
riepilogo = payload.get("riepilogo", {}) if isinstance(payload, dict) else {}
|
||||
dettaglio = payload.get("dettaglio", {}) if isinstance(payload, dict) else {}
|
||||
|
||||
self._async.run(self.db.query_json(SQL_RIEPILOGO, {"corsia": corsia}), _ok_sum, _err_sum, busy=self._busy, message=f"Riepilogo {corsia}...")
|
||||
sum_rows = riepilogo.get("rows", []) if isinstance(riepilogo, dict) else []
|
||||
det_rows = dettaglio.get("rows", []) if isinstance(dettaglio, dict) else []
|
||||
_log_dataset("reset_corsie_riepilogo", sum_rows)
|
||||
_log_dataset("reset_corsie_dettaglio", det_rows)
|
||||
|
||||
def _ok_det(res):
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
for item in self.tree.get_children():
|
||||
self.tree.delete(item)
|
||||
for _idc, ubi, n in rows:
|
||||
self.tree.insert("", "end", values=(ubi, n))
|
||||
if sum_rows:
|
||||
tot, occ, dbl, pallet = sum_rows[0]
|
||||
self.var_tot_celle.set(str(tot or 0))
|
||||
self.var_occ.set(str(occ or 0))
|
||||
self.var_dbl.set(str(dbl or 0))
|
||||
self.var_pallet.set(str(pallet or 0))
|
||||
else:
|
||||
self.var_tot_celle.set("0")
|
||||
self.var_occ.set("0")
|
||||
self.var_dbl.set("0")
|
||||
self.var_pallet.set("0")
|
||||
|
||||
def _err_det(ex):
|
||||
messagebox.showerror("Errore", f"Dettaglio fallito:\n{ex}", parent=self)
|
||||
for item in self.tree.get_children():
|
||||
self.tree.delete(item)
|
||||
for idx, (_idc, ubi, n) in enumerate(det_rows):
|
||||
tag = zebra_tag(idx)
|
||||
self.tree.insert("", "end", values=(ubi, n), tags=(tag,))
|
||||
except Exception as ex:
|
||||
_MODULE_LOGGER.exception(f"Errore UI refresh reset corsie corsia={corsia}: {ex}")
|
||||
messagebox.showerror("Errore", f"Aggiornamento interfaccia fallito:\n{ex}", parent=self, exception=ex)
|
||||
|
||||
self._async.run(self.db.query_json(SQL_DETTAGLIO, {"corsia": corsia}), _ok_det, _err_det, busy=None, message=None)
|
||||
def _err(ex):
|
||||
_MODULE_LOGGER.exception(f"Errore refresh reset corsie corsia={corsia}: {ex}")
|
||||
messagebox.showerror("Errore", f"Refresh fallito:\n{ex}", parent=self, exception=ex)
|
||||
|
||||
self._async.run(_q(), _ok, _err, busy=self._busy, message=f"Riepilogo {corsia}...")
|
||||
|
||||
@_log_call()
|
||||
def _ask_reset(self):
|
||||
"""Ask for confirmation and start the delete flow for the selected aisle."""
|
||||
"""Ask for confirmation and start the logical unload flow for the selected aisle."""
|
||||
corsia = self.cmb.get().strip()
|
||||
if not corsia:
|
||||
return
|
||||
_log_sql("reset_corsie_count_reset", SQL_COUNT_RESET, {"corsia": corsia})
|
||||
|
||||
def _ok_count(res):
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
n = int(rows[0][0]) if rows else 0
|
||||
if n <= 0:
|
||||
messagebox.showinfo("Svuota corsia", f"Nessun pallet da rimuovere per la corsia {corsia}.", parent=self)
|
||||
_log_dataset("reset_corsie_count_reset", rows)
|
||||
tot_udc = int(rows[0][0] or 0) if rows else 0
|
||||
tot_celle = int(rows[0][1] or 0) if rows else 0
|
||||
if tot_udc <= 0:
|
||||
messagebox.showinfo("Svuota corsia", f"Nessuna UDC attiva da scaricare per la corsia {corsia}.", parent=self)
|
||||
return
|
||||
msg = (
|
||||
f"Verranno cancellati {n} record da MagazziniPallet per la corsia {corsia}.",
|
||||
"Questa operazione e' irreversibile.",
|
||||
"Digitare il nome della corsia per confermare:",
|
||||
)
|
||||
confirm = simpledialog.askstring("Conferma", "\n".join(msg), parent=self)
|
||||
msg = loc_text("reset.confirm", catalog=self._locale_catalog).format(
|
||||
udc=tot_udc, cells=tot_celle, aisle=corsia)
|
||||
confirm = simpledialog.askstring("Conferma", msg, parent=self)
|
||||
if confirm is None:
|
||||
_MODULE_LOGGER.info(f"Reset corsia {corsia}: conferma annullata dall'utente")
|
||||
return
|
||||
if confirm.strip().upper() != corsia.upper():
|
||||
_MODULE_LOGGER.info(f"Reset corsia {corsia}: testo conferma non corrispondente ({confirm!r})")
|
||||
messagebox.showwarning("Annullato", "Testo di conferma non corrispondente.", parent=self)
|
||||
return
|
||||
self._do_reset(corsia)
|
||||
|
||||
def _err_count(ex):
|
||||
messagebox.showerror("Errore", f"Conteggio righe da cancellare fallito:\n{ex}", parent=self)
|
||||
_MODULE_LOGGER.exception(f"Errore conteggio reset corsie corsia={corsia}: {ex}")
|
||||
messagebox.showerror("Errore", f"Conteggio UDC da scaricare fallito:\n{ex}", parent=self, exception=ex)
|
||||
|
||||
self._async.run(self.db.query_json(SQL_COUNT_DELETE, {"corsia": corsia}), _ok_count, _err_count, busy=self._busy, message="Verifico...")
|
||||
self._async.run(self.db.query_json(SQL_COUNT_RESET, {"corsia": corsia}), _ok_count, _err_count, busy=self._busy, message="Verifico...")
|
||||
|
||||
@_log_call()
|
||||
def _do_reset(self, corsia: str):
|
||||
"""Execute the actual delete and refresh the window afterwards."""
|
||||
def _ok_del(_):
|
||||
messagebox.showinfo("Completato", f"Corsia {corsia}: svuotamento completato.", parent=self)
|
||||
"""Execute the logical unload of every active UDC in the selected aisle."""
|
||||
_log_sql("reset_corsie_udc_reset", SQL_UDC_RESET, {"corsia": corsia})
|
||||
|
||||
async def _q():
|
||||
payload = await self.db.query_json(SQL_UDC_RESET, {"corsia": corsia})
|
||||
rows = payload.get("rows", []) if isinstance(payload, dict) else []
|
||||
_log_dataset("reset_corsie_udc_reset", rows)
|
||||
|
||||
success = 0
|
||||
shipped = 0
|
||||
non_shelved = 0
|
||||
failed: list[dict[str, Any]] = []
|
||||
utente = str(getattr(self.session, "login", "") or "warehouse_ui").strip()
|
||||
|
||||
for barcode_pallet, idcella, ubicazione in rows:
|
||||
try:
|
||||
target = await reset_pallet_async(
|
||||
self.db,
|
||||
barcode_pallet=str(barcode_pallet or "").strip(),
|
||||
source_idcella=int(idcella),
|
||||
utente=utente,
|
||||
)
|
||||
success += 1
|
||||
shipped += int(target == 9999)
|
||||
non_shelved += int(target == 1000)
|
||||
_MODULE_LOGGER.info(
|
||||
f"RESET MOVE corsia={corsia} pallet={barcode_pallet} "
|
||||
f"source={idcella} target={target} utente={utente}"
|
||||
)
|
||||
except Exception as ex:
|
||||
_MODULE_LOGGER.exception(
|
||||
f"RESET FAILED corsia={corsia} pallet={barcode_pallet} source={idcella}: {ex}"
|
||||
)
|
||||
failed.append(
|
||||
{
|
||||
"barcode_pallet": str(barcode_pallet or ""),
|
||||
"idcella": int(idcella or 0),
|
||||
"ubicazione": str(ubicazione or ""),
|
||||
"error": str(ex),
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
"total": len(rows),
|
||||
"success": success,
|
||||
"shipped": shipped,
|
||||
"non_shelved": non_shelved,
|
||||
"failed": failed,
|
||||
}
|
||||
|
||||
def _ok_del(result):
|
||||
total = int((result or {}).get("total", 0))
|
||||
success = int((result or {}).get("success", 0))
|
||||
failed = list((result or {}).get("failed", []))
|
||||
summary = loc_text("reset.result", catalog=self._locale_catalog).format(
|
||||
aisle=corsia, success=success, total=total,
|
||||
shipped=result.get("shipped", 0), non_shelved=result.get("non_shelved", 0))
|
||||
_MODULE_LOGGER.info(
|
||||
f"Reset corsia {corsia}: scarico logico completato success={success} total={total} failed={len(failed)}"
|
||||
)
|
||||
if failed:
|
||||
messagebox.showwarning(
|
||||
"Completato con errori",
|
||||
(
|
||||
summary + "\n" +
|
||||
f"Errori su {len(failed)} UDC. Controllare {MODULE_LOG_PATH.name}."
|
||||
),
|
||||
parent=self,
|
||||
)
|
||||
else:
|
||||
messagebox.showinfo(
|
||||
"Completato",
|
||||
summary,
|
||||
parent=self,
|
||||
)
|
||||
self.refresh()
|
||||
|
||||
def _err_del(ex):
|
||||
messagebox.showerror("Errore", f"Svuotamento fallito:\n{ex}", parent=self)
|
||||
_MODULE_LOGGER.exception(f"Errore reset logico corsie corsia={corsia}: {ex}")
|
||||
messagebox.showerror("Errore", f"Svuotamento fallito:\n{ex}", parent=self, exception=ex)
|
||||
|
||||
self._async.run(self.db.query_json(SQL_DELETE, {"corsia": corsia}), _ok_del, _err_del, busy=self._busy, message=f"Svuoto {corsia}...")
|
||||
self._async.run(_q(), _ok_del, _err_del, busy=self._busy, message=f"Svuoto {corsia}...")
|
||||
|
||||
|
||||
def open_reset_corsie_window(parent, db_app):
|
||||
def open_reset_corsie_window(parent, db_app, session=None):
|
||||
"""Create, focus and return the aisle reset window."""
|
||||
win = ResetCorsieWindow(parent, db_app)
|
||||
win.lift()
|
||||
win.focus_set()
|
||||
key = "_reset_corsie_window_singleton"
|
||||
ex = getattr(parent, key, None)
|
||||
if ex and ex.winfo_exists():
|
||||
try:
|
||||
ex.deiconify()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
ex.lift()
|
||||
ex.focus_force()
|
||||
return ex
|
||||
except Exception:
|
||||
pass
|
||||
win = ResetCorsieWindow(parent, db_app, session=session)
|
||||
setattr(parent, key, win)
|
||||
place_window_fullsize_below_parent_later(parent, win)
|
||||
try:
|
||||
win.lift()
|
||||
win.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
return win
|
||||
|
||||
121
reset_corsie_service.py
Normal file
121
reset_corsie_service.py
Normal file
@@ -0,0 +1,121 @@
|
||||
"""Classify and move aisle-reset UDCs without changing barcode workflows.
|
||||
|
||||
Each call is one transaction: recheck the source, read the ERP document state,
|
||||
record P/V movements, refresh reservations and verify the resulting location.
|
||||
The caller must use query_json(commit=True), never execute this batch piecemeal.
|
||||
"""
|
||||
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
SQL_RESET_PALLET = """
|
||||
SET NOCOUNT ON;
|
||||
SET XACT_ABORT ON;
|
||||
DECLARE @Pallet varchar(32) = :barcode_pallet;
|
||||
DECLARE @ExpectedCell int = :source_idcella;
|
||||
DECLARE @User varchar(128) = :utente;
|
||||
DECLARE @Now datetime = GETDATE();
|
||||
DECLARE @LockedRows int;
|
||||
DECLARE @TargetCell int = 1000;
|
||||
DECLARE @SourceID int;
|
||||
|
||||
-- Keep other ledger writers away until this UDC transaction completes.
|
||||
SELECT @LockedRows = COUNT(*)
|
||||
FROM dbo.MagazziniPallet WITH (UPDLOCK, HOLDLOCK)
|
||||
WHERE Attributo = @Pallet;
|
||||
|
||||
IF @ExpectedCell IN (1000, 9999)
|
||||
THROW 51001, 'Reset: la sorgente deve essere una cella fisica.', 1;
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM dbo.XMag_GiacenzaPallet
|
||||
WHERE BarcodePallet = @Pallet AND IDCella = @ExpectedCell
|
||||
) OR EXISTS (
|
||||
SELECT 1 FROM dbo.XMag_GiacenzaPallet
|
||||
WHERE BarcodePallet = @Pallet AND (IDCella <> @ExpectedCell OR IDCella IS NULL)
|
||||
)
|
||||
THROW 51002, 'Reset: UDC spostata o presente in piu celle. Ricaricare e verificare.', 1;
|
||||
|
||||
-- Read the ERP association directly: history UI date filters must not decide
|
||||
-- whether an old, already shipped UDC is put back into available stock.
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM SAMA1_Xwmstest.dbo.LOTSER AS ls
|
||||
JOIN SAMA1_Xwmstest.dbo.LOTTIBF AS lb ON lb.IDLOTSER = ls.ID
|
||||
JOIN SAMA1_Xwmstest.dbo.FATRIG AS fr ON fr.ID = lb.IDFATRIG
|
||||
JOIN SAMA1_Xwmstest.dbo.BAMTES AS bt ON bt.ID = fr.IDBAM
|
||||
WHERE bt.STATO = 'D'
|
||||
AND LEFT(ls.NUMSER, 6) COLLATE Latin1_General_CI_AS =
|
||||
@Pallet COLLATE Latin1_General_CI_AS
|
||||
)
|
||||
SET @TargetCell = 9999;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM dbo.Celle c JOIN dbo.Aree a ON a.ID = c.IDArea
|
||||
WHERE c.ID = @TargetCell AND c.DelDataOra IS NULL
|
||||
)
|
||||
THROW 51003, 'Reset: cella virtuale di destinazione non disponibile.', 1;
|
||||
|
||||
SELECT TOP (1) @SourceID = ID
|
||||
FROM dbo.MagazziniPallet
|
||||
WHERE Attributo = @Pallet AND IDCella = @ExpectedCell
|
||||
AND Tipo = 'V' AND PesoUnitario > 0
|
||||
ORDER BY ID DESC;
|
||||
IF @SourceID IS NULL
|
||||
THROW 51004, 'Reset: movimento sorgente non trovato.', 1;
|
||||
|
||||
UPDATE dbo.MagazziniPallet
|
||||
SET ModUtente = @User, ModDataOra = @Now
|
||||
WHERE ID = @SourceID;
|
||||
|
||||
INSERT INTO dbo.MagazziniPallet (
|
||||
Tipo, IDRiferimento, NumeroPallet, Attributo, IDMagazzino, IDArea,
|
||||
IDCella, DataMagazzino, PesoUnitario, Tara, InsUtente, InsDataOra
|
||||
)
|
||||
SELECT 'P', src.ID, ISNULL(src.NumeroPallet, 0), src.Attributo,
|
||||
src.IDMagazzino, src.IDArea, src.IDCella, @Now,
|
||||
src.PesoUnitario, ISNULL(src.Tara, 0), @User, @Now
|
||||
FROM dbo.MagazziniPallet src WHERE src.ID = @SourceID;
|
||||
|
||||
UPDATE dbo.Celle SET IDStato = 0, ModUtente = @User, ModDataOra = @Now
|
||||
WHERE ID = @ExpectedCell;
|
||||
|
||||
INSERT INTO dbo.MagazziniPallet (
|
||||
Tipo, IDRiferimento, NumeroPallet, Attributo, IDMagazzino, IDArea,
|
||||
IDCella, DataMagazzino, PesoUnitario, Tara, InsUtente, InsDataOra
|
||||
)
|
||||
SELECT 'V', src.ID, ISNULL(src.NumeroPallet, 0), src.Attributo,
|
||||
a.IDMagazzino, c.IDArea, c.ID, @Now,
|
||||
src.PesoUnitario, ISNULL(src.Tara, 0), @User, @Now
|
||||
FROM dbo.MagazziniPallet src
|
||||
JOIN dbo.Celle c ON c.ID = @TargetCell
|
||||
JOIN dbo.Aree a ON a.ID = c.IDArea
|
||||
WHERE src.ID = @SourceID;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM dbo.XMag_GiacenzaPallet
|
||||
WHERE BarcodePallet = @Pallet AND IDCella = @TargetCell
|
||||
) OR EXISTS (
|
||||
SELECT 1 FROM dbo.XMag_GiacenzaPallet
|
||||
WHERE BarcodePallet = @Pallet AND (IDCella <> @TargetCell OR IDCella IS NULL)
|
||||
)
|
||||
THROW 51005, 'Reset: ubicazione finale incoerente. Movimento annullato.', 1;
|
||||
|
||||
EXEC dbo.py_sp_ControllaPrenotazionePackingListPalletNew;
|
||||
SELECT @TargetCell AS TargetIDCella;
|
||||
"""
|
||||
|
||||
|
||||
async def reset_pallet_async(db_client, *, barcode_pallet: str,
|
||||
source_idcella: int, utente: str) -> int:
|
||||
"""Move one UDC, returning 9999 (definitive document) or 1000 (otherwise).
|
||||
|
||||
source_idcella is the location shown in the reset selection, not a new
|
||||
destination. Any SQL failure rolls back this UDC through the DB client.
|
||||
"""
|
||||
result = await db_client.query_json(SQL_RESET_PALLET, {
|
||||
"barcode_pallet": str(barcode_pallet or "").strip(),
|
||||
"source_idcella": int(source_idcella),
|
||||
"utente": str(utente or "warehouse_ui").strip(),
|
||||
}, commit=True)
|
||||
return int(result["rows"][0][0])
|
||||
12
rollback_barcode_picking_skip_patch.sql
Normal file
12
rollback_barcode_picking_skip_patch.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SET XACT_ABORT ON;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U') IS NOT NULL
|
||||
BEGIN
|
||||
DROP TABLE dbo.py_BarcodePickingListSkip;
|
||||
END;
|
||||
|
||||
COMMIT TRANSACTION;
|
||||
27
rollback_online_history_forms_patch.sql
Normal file
27
rollback_online_history_forms_patch.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Rollback online - form storiche Python
|
||||
|
||||
Rimuove solo le viste Python-only usate dalla form "Storico Picking List".
|
||||
Non tocca oggetti C# legacy e non tocca dati.
|
||||
|
||||
Nota:
|
||||
- la form "Storico movimenti UDC" non ha oggetti dedicati da rimuovere.
|
||||
*/
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_XMag_ViewPackingListStorico', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_XMag_ViewPackingListStorico;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_vPreparaPackingList', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_vPreparaPackingList;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_vPreparaPackingListSAMA1', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_vPreparaPackingListSAMA1;
|
||||
GO
|
||||
|
||||
PRINT 'Rollback form storiche Python completato.';
|
||||
GO
|
||||
79
rollback_pickinglist_days_filter_patch.sql
Normal file
79
rollback_pickinglist_days_filter_patch.sql
Normal file
@@ -0,0 +1,79 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Rollback: intervallo giorni selezionabile in Gestione Picking List Python
|
||||
|
||||
Effetto:
|
||||
- ripristina le viste Python precedenti, appoggiate a dbo.XMag_ViewPackingList;
|
||||
- il filtro effettivo torna quindi a quello legacy fisso a 10 giorni.
|
||||
*/
|
||||
|
||||
SET ANSI_NULLS ON;
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_XMag_ViewPackingList]
|
||||
AS
|
||||
SELECT TOP 10000
|
||||
legacy.Pallet,
|
||||
legacy.Lotto,
|
||||
legacy.Articolo,
|
||||
legacy.Descrizione,
|
||||
legacy.Qta,
|
||||
legacy.Documento,
|
||||
legacy.CodNazione,
|
||||
legacy.NAZIONE,
|
||||
legacy.Stato,
|
||||
legacy.PalletCella,
|
||||
legacy.Magazzino,
|
||||
legacy.Area,
|
||||
legacy.Cella,
|
||||
legacy.Ordinamento,
|
||||
legacy.Ubicazione,
|
||||
legacy.DEST,
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(legacy.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS IDStato
|
||||
FROM dbo.XMag_ViewPackingList AS legacy
|
||||
LEFT JOIN dbo.PyPickingListReservation AS pr
|
||||
ON pr.ID = 1
|
||||
AND NULLIF(LTRIM(RTRIM(pr.Documento)), '') IS NOT NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN pr.Documento IS NOT NULL
|
||||
AND pr.Documento = CAST(legacy.Documento AS varchar(8))
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
legacy.Documento,
|
||||
legacy.Ordinamento;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[py_ViewPackingListRestante]
|
||||
AS
|
||||
SELECT
|
||||
Pallet,
|
||||
Lotto,
|
||||
Articolo,
|
||||
Descrizione,
|
||||
Qta,
|
||||
Documento,
|
||||
CodNazione,
|
||||
NAZIONE,
|
||||
Stato,
|
||||
PalletCella,
|
||||
Magazzino,
|
||||
Area,
|
||||
Cella,
|
||||
Ordinamento,
|
||||
Ubicazione,
|
||||
DEST,
|
||||
IDStato
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
WHERE Cella <> 9999;
|
||||
GO
|
||||
22
rollback_pickinglist_sequence_patch.sql
Normal file
22
rollback_pickinglist_sequence_patch.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Rollback della sequenza personalizzata per picking list.
|
||||
|
||||
Attenzione:
|
||||
- elimina le configurazioni di sequenza salvate nel ramo Python;
|
||||
- non modifica gli oggetti legacy C#;
|
||||
- dopo il rollback occorre usare una versione Python precedente alla feature.
|
||||
*/
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_ViewPackingListPrelievo', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_ViewPackingListPrelievo;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_PickingListPrelievoSequenza', N'U') IS NOT NULL
|
||||
DROP TABLE dbo.py_PickingListPrelievoSequenza;
|
||||
GO
|
||||
|
||||
PRINT 'Rollback sequenza prelievo Python completato.';
|
||||
GO
|
||||
72
rollback_plist_reservation_patch.sql
Normal file
72
rollback_plist_reservation_patch.sql
Normal file
@@ -0,0 +1,72 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
Rollback della patch prenotazione plist.
|
||||
|
||||
Ripristina dal backup salvato da:
|
||||
- apply_plist_reservation_patch.sql
|
||||
|
||||
Oggetti ripristinati:
|
||||
- dbo.XMag_ViewPackingList
|
||||
- dbo.sp_xExePackingListPallet
|
||||
- dbo.sp_xExePackingListPalletPrenota
|
||||
- dbo.sp_ControllaPrenotazionePackingListPalletNew
|
||||
|
||||
La tabella dbo.PickingListReservation NON viene rimossa:
|
||||
- può restare nel DB
|
||||
- il codice legacy non la usa
|
||||
*/
|
||||
|
||||
DECLARE @BackupTag varchar(64) = 'plist_reservation_fix_alpha2';
|
||||
DECLARE @Sql nvarchar(max);
|
||||
|
||||
IF OBJECT_ID(N'dbo.WarehouseObjectBackup', N'U') IS NULL
|
||||
BEGIN
|
||||
RAISERROR('dbo.WarehouseObjectBackup non esiste. Impossibile fare rollback.', 16, 1);
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.WarehouseObjectBackup
|
||||
WHERE BackupTag = @BackupTag
|
||||
)
|
||||
BEGIN
|
||||
RAISERROR('Backup tag %s non trovato. Impossibile fare rollback.', 16, 1, @BackupTag);
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
SELECT @Sql = Definition
|
||||
FROM dbo.WarehouseObjectBackup
|
||||
WHERE BackupTag = @BackupTag
|
||||
AND ObjectName = N'dbo.XMag_ViewPackingList';
|
||||
|
||||
IF @Sql IS NOT NULL EXEC(@Sql);
|
||||
|
||||
SELECT @Sql = Definition
|
||||
FROM dbo.WarehouseObjectBackup
|
||||
WHERE BackupTag = @BackupTag
|
||||
AND ObjectName = N'dbo.sp_xExePackingListPallet';
|
||||
|
||||
IF @Sql IS NOT NULL EXEC(@Sql);
|
||||
|
||||
SELECT @Sql = Definition
|
||||
FROM dbo.WarehouseObjectBackup
|
||||
WHERE BackupTag = @BackupTag
|
||||
AND ObjectName = N'dbo.sp_xExePackingListPalletPrenota';
|
||||
|
||||
IF @Sql IS NOT NULL EXEC(@Sql);
|
||||
|
||||
SELECT @Sql = Definition
|
||||
FROM dbo.WarehouseObjectBackup
|
||||
WHERE BackupTag = @BackupTag
|
||||
AND ObjectName = N'dbo.sp_ControllaPrenotazionePackingListPalletNew';
|
||||
|
||||
IF @Sql IS NOT NULL EXEC(@Sql);
|
||||
|
||||
38
rollback_python_parallel_pickinglist_patch.sql
Normal file
38
rollback_python_parallel_pickinglist_patch.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
Rollback della patch parallela Python.
|
||||
|
||||
Non ripristina oggetti legacy, perche' la patch parallela non li modifica.
|
||||
Rimuove solo gli oggetti dbo.py_* e la tabella di prenotazione Python.
|
||||
*/
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_sp_ControllaPrenotazionePackingListPalletNew', N'P') IS NOT NULL
|
||||
DROP PROCEDURE dbo.py_sp_ControllaPrenotazionePackingListPalletNew;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_sp_xExePackingListPalletPrenota', N'P') IS NOT NULL
|
||||
DROP PROCEDURE dbo.py_sp_xExePackingListPalletPrenota;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_sp_xExePackingListPallet', N'P') IS NOT NULL
|
||||
DROP PROCEDURE dbo.py_sp_xExePackingListPallet;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_ViewPackingListRestante', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_ViewPackingListRestante;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_XMag_ViewPackingList', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_XMag_ViewPackingList;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.PyPickingListReservation', N'U') IS NOT NULL
|
||||
DROP TABLE dbo.PyPickingListReservation;
|
||||
GO
|
||||
23
rollback_python_pickinglist_history_views.sql
Normal file
23
rollback_python_pickinglist_history_views.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- XWMS LOCAL TEST ONLY. Never run against the stable databases.
|
||||
USE [Xwmsdb];
|
||||
GO
|
||||
/*
|
||||
Rollback SQL - rimozione viste storiche picking list Python.
|
||||
|
||||
Non tocca oggetti C# legacy.
|
||||
*/
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_XMag_ViewPackingListStorico', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_XMag_ViewPackingListStorico;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_vPreparaPackingList', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_vPreparaPackingList;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_vPreparaPackingListSAMA1', N'V') IS NOT NULL
|
||||
DROP VIEW dbo.py_vPreparaPackingListSAMA1;
|
||||
GO
|
||||
|
||||
PRINT 'Viste storiche Python rimosse.';
|
||||
GO
|
||||
188
runtime_support.py
Normal file
188
runtime_support.py
Normal file
@@ -0,0 +1,188 @@
|
||||
"""Runtime helpers for console-less Windows launches."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
from typing import Callable, TypeVar
|
||||
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
FATAL_LOG = BASE_DIR / "warehouse_fatal.log"
|
||||
TEMP_DIR = Path(tempfile.gettempdir())
|
||||
_STDIO_HANDLES = []
|
||||
_EXCEPTION_LOGGING_CONFIGURED: set[str] = set()
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def _open_log_file(path: Path):
|
||||
"""Open a log path, falling back to the user temp directory when needed."""
|
||||
|
||||
try:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
return path.open("a", encoding="utf-8", buffering=1)
|
||||
except Exception:
|
||||
fallback = TEMP_DIR / path.name
|
||||
fallback.parent.mkdir(parents=True, exist_ok=True)
|
||||
return fallback.open("a", encoding="utf-8", buffering=1)
|
||||
|
||||
|
||||
def ensure_stdio(app_name: str) -> None:
|
||||
"""Give ``pythonw`` a real stdout/stderr target before loggers are imported."""
|
||||
|
||||
stamp = datetime.now().strftime("%Y%m%d")
|
||||
if sys.stdout is None:
|
||||
handle = _open_log_file(BASE_DIR / f"{app_name}_stdout_{stamp}.log")
|
||||
_STDIO_HANDLES.append(handle)
|
||||
sys.stdout = handle
|
||||
if sys.stderr is None:
|
||||
handle = _open_log_file(BASE_DIR / f"{app_name}_stderr_{stamp}.log")
|
||||
_STDIO_HANDLES.append(handle)
|
||||
sys.stderr = handle
|
||||
|
||||
|
||||
def log_fatal(app_name: str, exc: BaseException) -> None:
|
||||
"""Write one startup/runtime crash to a persistent log file."""
|
||||
|
||||
with _open_log_file(FATAL_LOG) as handle:
|
||||
handle.write("\n" + "=" * 80 + "\n")
|
||||
handle.write(f"{datetime.now():%Y-%m-%d %H:%M:%S} | {app_name}\n")
|
||||
handle.write("".join(traceback.format_exception(type(exc), exc, exc.__traceback__)))
|
||||
|
||||
|
||||
def log_exception(app_name: str, exc: BaseException, *, context: str = "") -> None:
|
||||
"""Write a handled or callback exception to the persistent fatal log."""
|
||||
|
||||
with _open_log_file(FATAL_LOG) as handle:
|
||||
handle.write("\n" + "=" * 80 + "\n")
|
||||
handle.write(f"{datetime.now():%Y-%m-%d %H:%M:%S} | {app_name}")
|
||||
if context:
|
||||
handle.write(f" | {context}")
|
||||
handle.write("\n")
|
||||
handle.write("".join(traceback.format_exception(type(exc), exc, exc.__traceback__)))
|
||||
|
||||
|
||||
def configure_exception_logging(app_name: str, root=None, loop=None) -> None:
|
||||
"""Install process, Tk and asyncio exception hooks for console-less apps."""
|
||||
|
||||
if app_name in _EXCEPTION_LOGGING_CONFIGURED:
|
||||
return
|
||||
_EXCEPTION_LOGGING_CONFIGURED.add(app_name)
|
||||
|
||||
previous_excepthook = sys.excepthook
|
||||
|
||||
def _sys_excepthook(exc_type, exc, tb):
|
||||
log_exception(app_name, exc, context="sys.excepthook")
|
||||
if previous_excepthook:
|
||||
previous_excepthook(exc_type, exc, tb)
|
||||
|
||||
sys.excepthook = _sys_excepthook
|
||||
|
||||
if hasattr(threading, "excepthook"):
|
||||
previous_threading_excepthook = threading.excepthook
|
||||
|
||||
def _threading_excepthook(args):
|
||||
log_exception(app_name, args.exc_value, context=f"thread={getattr(args.thread, 'name', '')}")
|
||||
previous_threading_excepthook(args)
|
||||
|
||||
threading.excepthook = _threading_excepthook
|
||||
|
||||
if root is not None:
|
||||
def _tk_exception(exc_type, exc, tb):
|
||||
log_exception(app_name, exc, context="tkinter callback")
|
||||
try:
|
||||
import error_dialog as messagebox
|
||||
|
||||
messagebox.showerror(
|
||||
app_name,
|
||||
"Errore applicativo registrato nei log.\n\n"
|
||||
"Se l'operazione era in corso, ripeterla o avvisare il responsabile.",
|
||||
parent=root,
|
||||
exception=exc,
|
||||
context="tkinter callback",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
root.report_callback_exception = _tk_exception
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if loop is not None:
|
||||
previous_loop_handler = None
|
||||
try:
|
||||
previous_loop_handler = loop.get_exception_handler()
|
||||
except Exception:
|
||||
previous_loop_handler = None
|
||||
|
||||
def _loop_exception_handler(active_loop, context):
|
||||
exc = context.get("exception")
|
||||
if exc is not None:
|
||||
log_exception(app_name, exc, context=f"asyncio: {context.get('message', '')}")
|
||||
else:
|
||||
log_runtime_event(app_name, f"ASYNCIO {context!r}")
|
||||
if previous_loop_handler is not None:
|
||||
previous_loop_handler(active_loop, context)
|
||||
|
||||
try:
|
||||
loop.set_exception_handler(_loop_exception_handler)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def log_runtime_event(app_name: str, message: str) -> None:
|
||||
"""Write a lightweight launch/shutdown trace for console-less starts."""
|
||||
|
||||
safe_name = "".join(ch if ch.isalnum() or ch in ("_", "-") else "_" for ch in app_name.lower())
|
||||
path = BASE_DIR / f"{safe_name}_launch.log"
|
||||
with _open_log_file(path) as handle:
|
||||
handle.write(f"{datetime.now():%Y-%m-%d %H:%M:%S} | {message}\n")
|
||||
|
||||
|
||||
def show_fatal_message(app_name: str, exc: BaseException) -> None:
|
||||
"""Show a best-effort message box for console-less launches."""
|
||||
|
||||
try:
|
||||
import tkinter as tk
|
||||
import error_dialog as messagebox
|
||||
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
messagebox.showerror(
|
||||
app_name,
|
||||
"Avvio non riuscito.\n\n"
|
||||
f"Controlla i log in:\n{BASE_DIR}\n\n"
|
||||
f"Se non ci sono, controlla anche:\n{TEMP_DIR}\n\n"
|
||||
f"{exc}",
|
||||
parent=root,
|
||||
exception=exc,
|
||||
)
|
||||
root.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def run_with_fatal_log(app_name: str, func: Callable[[], T]) -> T:
|
||||
"""Run an app entry point and persist otherwise invisible ``pythonw`` crashes."""
|
||||
|
||||
try:
|
||||
log_runtime_event(
|
||||
app_name,
|
||||
f"START exe={sys.executable!r} version={sys.version.split()[0]} cwd={Path.cwd()} base={BASE_DIR} argv={sys.argv!r}",
|
||||
)
|
||||
result = func()
|
||||
log_runtime_event(app_name, f"RETURN result={result!r}")
|
||||
return result
|
||||
except BaseException as exc:
|
||||
log_runtime_event(app_name, f"EXCEPTION type={type(exc).__name__} value={exc!r}")
|
||||
log_fatal(app_name, exc)
|
||||
show_fatal_message(app_name, exc)
|
||||
raise
|
||||
66
scarico-plist.csv
Normal file
66
scarico-plist.csv
Normal file
@@ -0,0 +1,66 @@
|
||||
NULL;0xFFFE900209004D006900630072006F0073006F00660074002000530051004C00200053006500720076006500720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E00A60C000000006D006400650033005C00670065007300740065007200700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FAFBEDFB00FCFF100E00010009000A000B0006000C000E00FCFF180F000B00060009000A000C000D000E000F00100011001200FCFF101100010009000A000B0006000C000E00FCFF1A0A00090002000A0006000B000C000D000E000F00100011001200FCFF1A0C00010009000B0006000A000C000D000E000F00100011001200FCFF100D00010009000B0006000A000C000E00FCFB1C1B0001000A0006000B001200100011000D0009000C000E000F000200;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65528;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;2025-10-09 14:44:32.410;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;65534;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:38:36.847;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;NULL;2025-10-09 14:38:36.847;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;106;NULL;2025-10-09 14:38:36.923;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;113;NULL;2025-10-09 14:40:15.317;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;NULL;2025-10-09 14:40:15.960;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;17;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;114;280806000;2025-10-09 14:40:15.960;2025-10-09 14:44:56.767;149;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;113;281450000;2025-10-09 14:40:15.317;2025-10-09 14:44:56.767;666877;3;625;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;401464000;2025-10-09 14:38:36.847;2025-10-09 14:45:18.310;2;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;40;2025-10-09 14:45:18.310;2025-10-09 14:45:18.310;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:18.317;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:18.310;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;255;2025-10-09 14:45:18.310;2025-10-09 14:45:18.310;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;4000;2025-10-09 14:45:18.317;2025-10-09 14:45:18.320;6;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;67;2025-10-09 14:45:18.320;2025-10-09 14:45:18.320;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:18.330;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;1522;2025-10-09 14:45:18.320;2025-10-09 14:45:18.320;64;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;-7000;2025-10-09 14:45:18.330;2025-10-09 14:45:18.323;70;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;54;2025-10-09 14:45:18.323;2025-10-09 14:45:18.323;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:18.330;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9005106',@BarcodePallet='504521',@NumeroCella=9005106,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030353130364800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343532312E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100326889001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;2661665;2025-10-09 14:45:18.323;2025-10-09 14:45:20.983;83819;0;2016;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;2656000;2025-10-09 14:45:18.330;2025-10-09 14:45:20.987;83889;0;2016;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;19;2025-10-09 14:45:20.987;2025-10-09 14:45:20.987;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:21.003;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504521' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:20.987;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504521' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;755056;2025-10-09 14:45:20.987;2025-10-09 14:45:21.743;30639;0;703;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;740000;2025-10-09 14:45:21.003;2025-10-09 14:45:21.743;114528;0;703;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;19;2025-10-09 14:45:21.743;2025-10-09 14:45:21.743;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:21.753;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504521';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:21.743;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504521';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;1153373;2025-10-09 14:45:21.743;2025-10-09 14:45:22.897;17928;0;719;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;406054000;2025-10-09 14:38:36.847;2025-10-09 14:45:22.900;2;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;17;2025-10-09 14:45:22.900;2025-10-09 14:45:22.900;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;NULL;2025-10-09 14:45:22.910;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9005106 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;NULL;2025-10-09 14:45:22.900;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9005106 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;6319;2025-10-09 14:45:22.900;2025-10-09 14:45:22.907;40;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;4903000;2025-10-09 14:45:21.753;2025-10-09 14:45:26.657;132456;0;719;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;40;2025-10-09 14:45:26.657;2025-10-09 14:45:26.657;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:26.660;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:26.657;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT ID, Privilegio, Nominativo FROM Operatori WHERE login = 'MAG2';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;182;2025-10-09 14:45:26.657;2025-10-09 14:45:26.657;4;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;-4000;2025-10-09 14:45:26.660;2025-10-09 14:45:26.657;132460;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;39;2025-10-09 14:45:26.657;2025-10-09 14:45:26.657;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:26.660;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
exec sp_procedure_params_rowset @procedure_name=N'sp_xMagGestioneMagazziniPallet';0x00000000020000003400730070005F00700072006F006300650064007500720065005F0070006100720061006D0073005F0072006F0077007300650074008400000082001A00E7306E007600610072006300680061007200280032003500350029001E004000700072006F006300650064007500720065005F006E0061006D0065003C000000730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;1460;2025-10-09 14:45:26.657;2025-10-09 14:45:26.657;64;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;0;2025-10-09 14:45:26.660;2025-10-09 14:45:26.660;132524;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;38;2025-10-09 14:45:26.660;2025-10-09 14:45:26.660;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:26.660;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
declare @p5 int set @p5=0 exec sp_xMagGestioneMagazziniPallet @IDOperatore=5,@BarcodeCella='9005107',@BarcodePallet='504512',@NumeroCella=9005107,@RC=@p5 output select @p5;0x00000000060000003C00730070005F0078004D0061006700470065007300740069006F006E0065004D006100670061007A007A0069006E006900500061006C006C00650074002E00000003000600381069006E00740018004000490044004F00700065007200610074006F0072006500050000004500000081001400A73076006100720063006800610072002800380029001A00400042006100720063006F0064006500430065006C006C00610007000000393030353130374800000081001600A730760061007200630068006100720028003100360029001C00400042006100720063006F0064006500500061006C006C0065007400060000003530343531322E00000003000600381069006E007400180040004E0075006D00650072006F00430065006C006C006100336889001C00000003000600381169006E0074000600400052004300000000001400000003000600380469006E00740000000000;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;2132203;2025-10-09 14:45:26.660;2025-10-09 14:45:28.793;83818;0;1969;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;2123000;2025-10-09 14:45:26.660;2025-10-09 14:45:28.783;216342;0;1969;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;24;2025-10-09 14:45:28.783;2025-10-09 14:45:28.783;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:28.783;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504512' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:28.783;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT TOP 1 * FROM XMag_ViewPackingList WHERE Pallet = '504512' ORDER BY Ordinamento ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;942565;2025-10-09 14:45:28.783;2025-10-09 14:45:29.727;30639;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;950000;2025-10-09 14:45:28.783;2025-10-09 14:45:29.733;246981;0;656;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;61;2025-10-09 14:45:29.733;2025-10-09 14:45:29.733;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:29.737;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504512';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;NULL;2025-10-09 14:45:29.733;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
SELECT TOP 1 * FROM vXTracciaProdotti WHERE Pallet = '504512';NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;65;761464;2025-10-09 14:45:29.733;2025-10-09 14:45:30.493;17926;0;766;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;7590000;2025-10-09 14:45:22.910;2025-10-09 14:45:30.500;42;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"exec sp_reset_connection ";0x00000000000000002600730070005F00720065007300650074005F0063006F006E006E0065006300740069006F006E00;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;31;2025-10-09 14:45:30.500;2025-10-09 14:45:30.500;0;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;10;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"-- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language Italiano set dateformat dmy set datefirst 1 set transaction isolation level read committed ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;NULL;2025-10-09 14:45:30.503;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;14;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9005107 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;NULL;2025-10-09 14:45:30.500;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;13;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
"SELECT Ubicazione FROM Celle WHERE ID = 9005107 ";NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;71;6501;2025-10-09 14:45:30.500;2025-10-09 14:45:30.507;40;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;12;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;5204;.Net SqlClient Data Provider;MAG2;106;569860000;2025-10-09 14:38:36.923;2025-10-09 14:48:06.783;19;0;0;NULL;NULL;NULL;NULL;NULL;NULL;NULL;mde3\gesterp;15;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user