Monolista: svuotamento corsie per stato ERP e ricerca UDC nello storico biennale
This commit is contained in:
@@ -20,7 +20,7 @@ import customtkinter as ctk
|
||||
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from gestione_aree import AsyncRunner
|
||||
from gestione_scarico import move_pallet_async
|
||||
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
|
||||
@@ -171,7 +171,7 @@ 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
|
||||
@@ -193,7 +193,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 (
|
||||
@@ -215,7 +215,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 (
|
||||
@@ -237,7 +237,7 @@ SELECT
|
||||
COUNT(DISTINCT g.IDCella) AS TotCelle
|
||||
FROM dbo.XMag_GiacenzaPallet g
|
||||
JOIN dbo.Celle c ON c.ID = g.IDCella
|
||||
WHERE c.ID <> 9999
|
||||
WHERE c.ID NOT IN (1000, 9999)
|
||||
AND LTRIM(RTRIM(c.Corsia)) = :corsia;
|
||||
"""
|
||||
|
||||
@@ -253,7 +253,7 @@ WITH U AS (
|
||||
LTRIM(RTRIM(c.Fila)) AS SortFilaTxt
|
||||
FROM dbo.XMag_GiacenzaPallet g
|
||||
JOIN dbo.Celle c ON c.ID = g.IDCella
|
||||
WHERE c.ID <> 9999
|
||||
WHERE c.ID NOT IN (1000, 9999)
|
||||
AND LTRIM(RTRIM(c.Corsia)) = :corsia
|
||||
)
|
||||
SELECT
|
||||
@@ -537,12 +537,9 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
if tot_udc <= 0:
|
||||
messagebox.showinfo("Svuota corsia", f"Nessuna UDC attiva da scaricare per la corsia {corsia}.", parent=self)
|
||||
return
|
||||
msg = (
|
||||
f"Verranno scaricate logicamente {tot_udc} UDC attive distribuite su {tot_celle} celle della corsia {corsia}.",
|
||||
"L'operazione verra' eseguita come scarico verso 9000000 / 9999, senza cancellazioni fisiche dirette.",
|
||||
"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
|
||||
@@ -569,20 +566,30 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
_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:
|
||||
await move_pallet_async(
|
||||
target = await reset_pallet_async(
|
||||
self.db,
|
||||
barcode_pallet=str(barcode_pallet or "").strip(),
|
||||
target_idcella=9999,
|
||||
target_barcode_cella="9000000",
|
||||
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 ""),
|
||||
@@ -595,6 +602,8 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
return {
|
||||
"total": len(rows),
|
||||
"success": success,
|
||||
"shipped": shipped,
|
||||
"non_shelved": non_shelved,
|
||||
"failed": failed,
|
||||
}
|
||||
|
||||
@@ -602,6 +611,9 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
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)}"
|
||||
)
|
||||
@@ -609,7 +621,7 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
messagebox.showwarning(
|
||||
"Completato con errori",
|
||||
(
|
||||
f"Corsia {corsia}: scaricate {success} UDC su {total}.\n"
|
||||
summary + "\n" +
|
||||
f"Errori su {len(failed)} UDC. Controllare {MODULE_LOG_PATH.name}."
|
||||
),
|
||||
parent=self,
|
||||
@@ -617,7 +629,7 @@ class ResetCorsieWindow(ctk.CTkToplevel):
|
||||
else:
|
||||
messagebox.showinfo(
|
||||
"Completato",
|
||||
f"Corsia {corsia}: svuotamento logico completato su {success} UDC.",
|
||||
summary,
|
||||
parent=self,
|
||||
)
|
||||
self.refresh()
|
||||
|
||||
Reference in New Issue
Block a user