Aggiungi diagnostica UDC SAM non entrate in WMS
This commit is contained in:
@@ -69,6 +69,34 @@ INNER JOIN dbo.Celle AS c
|
||||
ORDER BY CELLA, UDC;
|
||||
"""
|
||||
|
||||
SQL_SAM_UDC_NOT_IN_WMS = """
|
||||
WITH 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))
|
||||
)
|
||||
SELECT
|
||||
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.UDC;
|
||||
"""
|
||||
|
||||
SHIPPED_NOT_DISASSOCIATED_COLUMNS = (
|
||||
("UDC", "diagnostics.col.udc", "UDC", 130, "w"),
|
||||
(
|
||||
@@ -86,6 +114,13 @@ MULTIPLE_UDC_COLUMNS = (
|
||||
("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):
|
||||
@@ -156,7 +191,7 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
||||
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(2, weight=1)
|
||||
top.grid_columnconfigure(3, weight=1)
|
||||
|
||||
button_font = theme_font(self._theme, "toolbar_button_font", ("Segoe UI", 10, "bold"))
|
||||
ctk.CTkButton(
|
||||
@@ -181,6 +216,17 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
||||
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="UDC in 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"),
|
||||
@@ -188,7 +234,7 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
||||
font=button_font,
|
||||
state="disabled",
|
||||
)
|
||||
self.btn_export.grid(row=0, column=3, sticky="e")
|
||||
self.btn_export.grid(row=0, column=4, sticky="e")
|
||||
|
||||
ctk.CTkLabel(
|
||||
self,
|
||||
@@ -257,6 +303,18 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
||||
),
|
||||
)
|
||||
|
||||
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 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
|
||||
|
||||
Reference in New Issue
Block a user