From 0ae052e55b3560cc5dba01664b90a1336563f3e1 Mon Sep 17 00:00:00 2001 From: allebonvi Date: Mon, 6 Jul 2026 18:37:00 +0200 Subject: [PATCH] Rendi operativa diagnostica UDC SAM recenti --- diagnostica.py | 40 ++++++++++++++++++++++++++-------------- locale.json | 8 ++++---- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/diagnostica.py b/diagnostica.py index 23f25af..24a213b 100644 --- a/diagnostica.py +++ b/diagnostica.py @@ -70,19 +70,31 @@ ORDER BY CELLA, UDC; """ SQL_SAM_UDC_NOT_IN_WMS = """ -WITH sam_udc AS ( +WITH recent_lotser AS ( + SELECT TOP (5000) + ls.ID, + LEFT(ls.NUMSER, 6) AS UDC, + ls.NUMLOT AS Lotto, + ls.IDARTICO + FROM SAMA1.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(Pallet)) AS UDC, - MIN(Lotto) AS Lotto, - MIN(Prodotto) AS Prodotto, - MIN(Descrizione) AS Descrizione - FROM dbo.vXTracciaProdotti - WHERE NULLIF(LTRIM(RTRIM(Pallet)), '') IS NOT NULL - AND TRY_CONVERT(int, LTRIM(RTRIM(Pallet))) > 0 - AND Lotto LIKE CONCAT('P', RIGHT(CONVERT(varchar(4), YEAR(GETDATE())), 2), '%') - GROUP BY LTRIM(RTRIM(Pallet)) + 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.dbo.ARTICO AS a + ON a.ID = r.IDARTICO + GROUP BY LTRIM(RTRIM(r.UDC)) ) -SELECT +SELECT TOP (100) s.UDC, s.Lotto, s.Prodotto, @@ -94,7 +106,7 @@ WHERE NOT EXISTS ( WHERE LTRIM(RTRIM(mp.Attributo)) COLLATE Latin1_General_CI_AS = s.UDC COLLATE Latin1_General_CI_AS ) -ORDER BY s.UDC; +ORDER BY s.UltimoIDLotSer DESC; """ SHIPPED_NOT_DISASSOCIATED_COLUMNS = ( @@ -221,7 +233,7 @@ class DiagnosticaWindow(ctk.CTkToplevel): text=loc_text( "diagnostics.button.sam_udc_not_in_wms", catalog=self._locale_catalog, - default="UDC in SAM non in WMS", + default="Ultime UDC SAM non in WMS", ), command=self._load_sam_udc_not_in_wms, font=button_font, @@ -311,7 +323,7 @@ class DiagnosticaWindow(ctk.CTkToplevel): busy_text=loc_text( "diagnostics.busy.sam_udc_not_in_wms", catalog=self._locale_catalog, - default="Cerco UDC presenti in SAM ma non ancora in WMS...", + default="Cerco le ultime UDC presenti in SAM ma non ancora in WMS...", ), ) diff --git a/locale.json b/locale.json index 804d61a..3198a3f 100644 --- a/locale.json +++ b/locale.json @@ -79,11 +79,11 @@ "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": "UDC anno in SAM non in WMS", + "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 UDC dell'anno presenti in SAM ma non ancora in WMS...", + "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", @@ -216,11 +216,11 @@ "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": "Current-year UDC in SAM not in WMS", + "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 current-year UDC present in SAM but not yet in WMS...", + "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",