Rendi operativa diagnostica UDC SAM recenti

This commit is contained in:
2026-07-06 18:37:00 +02:00
parent 7dc068b1b0
commit 0ae052e55b
2 changed files with 30 additions and 18 deletions

View File

@@ -70,19 +70,31 @@ ORDER BY CELLA, UDC;
""" """
SQL_SAM_UDC_NOT_IN_WMS = """ 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 SELECT
LTRIM(RTRIM(Pallet)) AS UDC, LTRIM(RTRIM(r.UDC)) AS UDC,
MIN(Lotto) AS Lotto, MIN(r.Lotto) AS Lotto,
MIN(Prodotto) AS Prodotto, MIN(a.CODICE) AS Prodotto,
MIN(Descrizione) AS Descrizione MIN(a.DESCR) AS Descrizione,
FROM dbo.vXTracciaProdotti MAX(r.ID) AS UltimoIDLotSer
WHERE NULLIF(LTRIM(RTRIM(Pallet)), '') IS NOT NULL FROM recent_lotser AS r
AND TRY_CONVERT(int, LTRIM(RTRIM(Pallet))) > 0 INNER JOIN SAMA1.dbo.ARTICO AS a
AND Lotto LIKE CONCAT('P', RIGHT(CONVERT(varchar(4), YEAR(GETDATE())), 2), '%') ON a.ID = r.IDARTICO
GROUP BY LTRIM(RTRIM(Pallet)) GROUP BY LTRIM(RTRIM(r.UDC))
) )
SELECT SELECT TOP (100)
s.UDC, s.UDC,
s.Lotto, s.Lotto,
s.Prodotto, s.Prodotto,
@@ -94,7 +106,7 @@ WHERE NOT EXISTS (
WHERE LTRIM(RTRIM(mp.Attributo)) COLLATE Latin1_General_CI_AS = WHERE LTRIM(RTRIM(mp.Attributo)) COLLATE Latin1_General_CI_AS =
s.UDC 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 = ( SHIPPED_NOT_DISASSOCIATED_COLUMNS = (
@@ -221,7 +233,7 @@ class DiagnosticaWindow(ctk.CTkToplevel):
text=loc_text( text=loc_text(
"diagnostics.button.sam_udc_not_in_wms", "diagnostics.button.sam_udc_not_in_wms",
catalog=self._locale_catalog, 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, command=self._load_sam_udc_not_in_wms,
font=button_font, font=button_font,
@@ -311,7 +323,7 @@ class DiagnosticaWindow(ctk.CTkToplevel):
busy_text=loc_text( busy_text=loc_text(
"diagnostics.busy.sam_udc_not_in_wms", "diagnostics.busy.sam_udc_not_in_wms",
catalog=self._locale_catalog, 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...",
), ),
) )

View File

@@ -79,11 +79,11 @@
"diagnostics.title": "Diagnostica", "diagnostics.title": "Diagnostica",
"diagnostics.button.shipped_not_disassociated": "UDC spedite non disassociate", "diagnostics.button.shipped_not_disassociated": "UDC spedite non disassociate",
"diagnostics.button.multiple_udc_by_cell": "Celle con multiple UDC", "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.button.export": "Esporta XLSX",
"diagnostics.busy.shipped_not_disassociated": "Cerco UDC spedite ma ancora in cella...", "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.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.status.rows": "Righe trovate: {count}",
"diagnostics.col.udc": "UDC", "diagnostics.col.udc": "UDC",
"diagnostics.col.cell": "CELLA", "diagnostics.col.cell": "CELLA",
@@ -216,11 +216,11 @@
"diagnostics.title": "Diagnostics", "diagnostics.title": "Diagnostics",
"diagnostics.button.shipped_not_disassociated": "Shipped UDC not disassociated", "diagnostics.button.shipped_not_disassociated": "Shipped UDC not disassociated",
"diagnostics.button.multiple_udc_by_cell": "Cells with multiple UDC", "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.button.export": "Export XLSX",
"diagnostics.busy.shipped_not_disassociated": "Searching shipped UDC still assigned to cells...", "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.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.status.rows": "Rows found: {count}",
"diagnostics.col.udc": "UDC", "diagnostics.col.udc": "UDC",
"diagnostics.col.cell": "CELL", "diagnostics.col.cell": "CELL",