Aggiungi diagnostica celle con multiple UDC
This commit is contained in:
127
diagnostica.py
127
diagnostica.py
@@ -43,6 +43,49 @@ WHERE chiuse.StatoDocumento = 'D'
|
|||||||
ORDER BY NomeSimbolicoCella, UDC;
|
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;
|
||||||
|
"""
|
||||||
|
|
||||||
|
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"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _rows_to_dicts(res: dict[str, Any] | None) -> list[dict[str, Any]]:
|
def _rows_to_dicts(res: dict[str, Any] | None) -> list[dict[str, Any]]:
|
||||||
if not isinstance(res, dict):
|
if not isinstance(res, dict):
|
||||||
@@ -74,6 +117,7 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
self._current_check = ""
|
self._current_check = ""
|
||||||
self.var_status = tk.StringVar(value="")
|
self.var_status = tk.StringVar(value="")
|
||||||
self._last_export_slug = "diagnostica"
|
self._last_export_slug = "diagnostica"
|
||||||
|
self._current_columns = SHIPPED_NOT_DISASSOCIATED_COLUMNS
|
||||||
|
|
||||||
self.title(
|
self.title(
|
||||||
versioned_title(
|
versioned_title(
|
||||||
@@ -112,7 +156,7 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
fg_color=theme_color(self._theme, "toolbar_frame_fg_color", ("#d7d7d7", "#3b3b3b")),
|
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(row=0, column=0, sticky="ew", padx=8, pady=8)
|
||||||
top.grid_columnconfigure(1, weight=1)
|
top.grid_columnconfigure(2, weight=1)
|
||||||
|
|
||||||
button_font = theme_font(self._theme, "toolbar_button_font", ("Segoe UI", 10, "bold"))
|
button_font = theme_font(self._theme, "toolbar_button_font", ("Segoe UI", 10, "bold"))
|
||||||
ctk.CTkButton(
|
ctk.CTkButton(
|
||||||
@@ -126,6 +170,17 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
font=button_font,
|
font=button_font,
|
||||||
).grid(row=0, column=0, sticky="w", padx=(0, 8))
|
).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))
|
||||||
|
|
||||||
self.btn_export = ctk.CTkButton(
|
self.btn_export = ctk.CTkButton(
|
||||||
top,
|
top,
|
||||||
text=loc_text("diagnostics.button.export", catalog=self._locale_catalog, default="Esporta XLSX"),
|
text=loc_text("diagnostics.button.export", catalog=self._locale_catalog, default="Esporta XLSX"),
|
||||||
@@ -133,7 +188,7 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
font=button_font,
|
font=button_font,
|
||||||
state="disabled",
|
state="disabled",
|
||||||
)
|
)
|
||||||
self.btn_export.grid(row=0, column=2, sticky="e")
|
self.btn_export.grid(row=0, column=3, sticky="e")
|
||||||
|
|
||||||
ctk.CTkLabel(
|
ctk.CTkLabel(
|
||||||
self,
|
self,
|
||||||
@@ -147,37 +202,8 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
wrap.grid_rowconfigure(0, weight=1)
|
wrap.grid_rowconfigure(0, weight=1)
|
||||||
wrap.grid_columnconfigure(0, weight=1)
|
wrap.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
cols = ("UDC", "Diagnostica", "NomeSimbolicoCella")
|
self.tree = ttk.Treeview(wrap, show="headings")
|
||||||
self.tree = ttk.Treeview(wrap, columns=cols, show="headings")
|
self._configure_tree_columns(self._current_columns)
|
||||||
headings = {
|
|
||||||
"UDC": (
|
|
||||||
loc_text("diagnostics.col.udc", catalog=self._locale_catalog, default="UDC"),
|
|
||||||
130,
|
|
||||||
"w",
|
|
||||||
),
|
|
||||||
"Diagnostica": (
|
|
||||||
loc_text(
|
|
||||||
"diagnostics.col.shipped_not_disassociated",
|
|
||||||
catalog=self._locale_catalog,
|
|
||||||
default="Spedita ma non disassociata",
|
|
||||||
),
|
|
||||||
280,
|
|
||||||
"w",
|
|
||||||
),
|
|
||||||
"NomeSimbolicoCella": (
|
|
||||||
loc_text(
|
|
||||||
"diagnostics.col.symbolic_cell",
|
|
||||||
catalog=self._locale_catalog,
|
|
||||||
default="Nome simbolico cella",
|
|
||||||
),
|
|
||||||
240,
|
|
||||||
"w",
|
|
||||||
),
|
|
||||||
}
|
|
||||||
for col in cols:
|
|
||||||
text, width, anchor = headings[col]
|
|
||||||
self.tree.heading(col, text=text)
|
|
||||||
self.tree.column(col, width=width, anchor=anchor, stretch=True)
|
|
||||||
style_treeview(
|
style_treeview(
|
||||||
self.tree,
|
self.tree,
|
||||||
style_name="Diagnostics.Treeview",
|
style_name="Diagnostics.Treeview",
|
||||||
@@ -196,10 +222,22 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
def _set_status(self, text: str) -> None:
|
def _set_status(self, text: str) -> None:
|
||||||
self.var_status.set(text)
|
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")
|
||||||
|
for key, locale_key, default, width, anchor in columns:
|
||||||
|
self.tree.heading(
|
||||||
|
key,
|
||||||
|
text=loc_text(str(locale_key), catalog=self._locale_catalog, default=str(default)),
|
||||||
|
)
|
||||||
|
self.tree.column(key, width=int(width), anchor=str(anchor), stretch=True)
|
||||||
|
|
||||||
def _load_shipped_not_disassociated(self) -> None:
|
def _load_shipped_not_disassociated(self) -> None:
|
||||||
self._run_check(
|
self._run_check(
|
||||||
key="shipped_not_disassociated",
|
key="shipped_not_disassociated",
|
||||||
sql=SQL_SHIPPED_NOT_DISASSOCIATED,
|
sql=SQL_SHIPPED_NOT_DISASSOCIATED,
|
||||||
|
columns=SHIPPED_NOT_DISASSOCIATED_COLUMNS,
|
||||||
busy_text=loc_text(
|
busy_text=loc_text(
|
||||||
"diagnostics.busy.shipped_not_disassociated",
|
"diagnostics.busy.shipped_not_disassociated",
|
||||||
catalog=self._locale_catalog,
|
catalog=self._locale_catalog,
|
||||||
@@ -207,7 +245,19 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _run_check(self, *, key: str, sql: str, busy_text: str) -> None:
|
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 _run_check(self, *, key: str, sql: str, columns, busy_text: str) -> None:
|
||||||
if self._load_in_progress or not self._is_alive():
|
if self._load_in_progress or not self._is_alive():
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -217,6 +267,8 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
self._load_in_progress = True
|
self._load_in_progress = True
|
||||||
self._current_check = key
|
self._current_check = key
|
||||||
self._last_export_slug = key
|
self._last_export_slug = key
|
||||||
|
self._current_columns = columns
|
||||||
|
self._configure_tree_columns(columns)
|
||||||
try:
|
try:
|
||||||
self.btn_export.configure(state="disabled")
|
self.btn_export.configure(state="disabled")
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -242,15 +294,12 @@ class DiagnosticaWindow(ctk.CTkToplevel):
|
|||||||
try:
|
try:
|
||||||
rows = _rows_to_dicts(res)
|
rows = _rows_to_dicts(res)
|
||||||
self.tree.delete(*self.tree.get_children(""))
|
self.tree.delete(*self.tree.get_children(""))
|
||||||
|
keys = [str(col[0]) for col in self._current_columns]
|
||||||
for index, row in enumerate(rows):
|
for index, row in enumerate(rows):
|
||||||
self.tree.insert(
|
self.tree.insert(
|
||||||
"",
|
"",
|
||||||
"end",
|
"end",
|
||||||
values=(
|
values=tuple(row.get(key) or "" for key in keys),
|
||||||
row.get("UDC") or "",
|
|
||||||
row.get("Diagnostica") or "",
|
|
||||||
row.get("NomeSimbolicoCella") or "",
|
|
||||||
),
|
|
||||||
tags=(zebra_tag(index),),
|
tags=(zebra_tag(index),),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -78,10 +78,13 @@
|
|||||||
"history.picking.msg.detail_error": "Errore dettaglio:\n{error}",
|
"history.picking.msg.detail_error": "Errore dettaglio:\n{error}",
|
||||||
"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.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.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.shipped_not_disassociated": "Spedita ma non disassociata",
|
"diagnostics.col.shipped_not_disassociated": "Spedita ma non disassociata",
|
||||||
"diagnostics.col.symbolic_cell": "Nome simbolico cella",
|
"diagnostics.col.symbolic_cell": "Nome simbolico cella",
|
||||||
"diagnostics.export.title": "Esporta",
|
"diagnostics.export.title": "Esporta",
|
||||||
@@ -207,10 +210,13 @@
|
|||||||
"history.picking.msg.detail_error": "Detail load failed:\n{error}",
|
"history.picking.msg.detail_error": "Detail load failed:\n{error}",
|
||||||
"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.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.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.shipped_not_disassociated": "Shipped but not disassociated",
|
"diagnostics.col.shipped_not_disassociated": "Shipped but not disassociated",
|
||||||
"diagnostics.col.symbolic_cell": "Symbolic cell name",
|
"diagnostics.col.symbolic_cell": "Symbolic cell name",
|
||||||
"diagnostics.export.title": "Export",
|
"diagnostics.export.title": "Export",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ MODULE_VERSIONS: dict[str, str] = {
|
|||||||
"barcode_service": "1.0.24",
|
"barcode_service": "1.0.24",
|
||||||
"busy_overlay": "1.0.0",
|
"busy_overlay": "1.0.0",
|
||||||
"db_config": "1.0.0",
|
"db_config": "1.0.0",
|
||||||
"diagnostica": "1.0.1",
|
"diagnostica": "1.0.2",
|
||||||
"gestione_aree": "1.0.1",
|
"gestione_aree": "1.0.1",
|
||||||
"gestione_layout": "1.0.2",
|
"gestione_layout": "1.0.2",
|
||||||
"gestione_pickinglist": "1.0.4",
|
"gestione_pickinglist": "1.0.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user