Compare commits
1 Commits
alpha11-sa
...
alpha12-sc
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dd7139b19 |
@@ -681,27 +681,7 @@ class LayoutWindow(ctk.CTkToplevel):
|
|||||||
if stato <= 0:
|
if stato <= 0:
|
||||||
self._toast("La cella selezionata non contiene alcuna UDC da scaricare.")
|
self._toast("La cella selezionata non contiene alcuna UDC da scaricare.")
|
||||||
return
|
return
|
||||||
if stato >= 2:
|
self._open_scarico_dialog(r, c)
|
||||||
self._open_scarico_dialog(r, c)
|
|
||||||
return
|
|
||||||
|
|
||||||
barcode = str(self.udc1[r][c] or "").strip()
|
|
||||||
if not barcode:
|
|
||||||
self._toast("UDC non disponibile per lo scarico.")
|
|
||||||
return
|
|
||||||
if not messagebox.askyesno(
|
|
||||||
"Scarico",
|
|
||||||
f"Scaricare l'UDC {barcode} da {self._cell_label(r, c)}?",
|
|
||||||
parent=self,
|
|
||||||
):
|
|
||||||
return
|
|
||||||
self._run_pallet_move(
|
|
||||||
barcode_pallet=barcode,
|
|
||||||
target_idcella=9999,
|
|
||||||
target_barcode_cella="9000000",
|
|
||||||
success_message=f"Scarico completato per {barcode}.",
|
|
||||||
busy_message=f"Scarico {barcode}...",
|
|
||||||
)
|
|
||||||
|
|
||||||
@_log_call()
|
@_log_call()
|
||||||
def _run_pallet_move(
|
def _run_pallet_move(
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ _MODULE_LOG_LEVEL = "DEBUG" if SCARICO_LOG_MODE.upper() == "DEBUG" else "INFO"
|
|||||||
_MODULE_LOGGER = logger.bind(warehouse_module=MODULE_LOG_NAME)
|
_MODULE_LOGGER = logger.bind(warehouse_module=MODULE_LOG_NAME)
|
||||||
_MODULE_LOGGING_CONFIGURED = False
|
_MODULE_LOGGING_CONFIGURED = False
|
||||||
DEFAULT_SCARICO_USER = "warehouse_ui"
|
DEFAULT_SCARICO_USER = "warehouse_ui"
|
||||||
|
SHIPPED_IDCELLA = 9999
|
||||||
|
SHIPPED_BARCODE = "9000000"
|
||||||
|
SHIPPED_LABEL = "7G.1.1"
|
||||||
|
NON_SCAFF_IDCELLA = 1000
|
||||||
|
NON_SCAFF_BARCODE = "9001000"
|
||||||
|
NON_SCAFF_LABEL = "5E1.1"
|
||||||
|
|
||||||
|
|
||||||
def _session_login(session: UserSession | None, fallback: str | None = None) -> str:
|
def _session_login(session: UserSession | None, fallback: str | None = None) -> str:
|
||||||
@@ -231,6 +237,7 @@ SELECT
|
|||||||
cp.BarcodePallet AS UDC,
|
cp.BarcodePallet AS UDC,
|
||||||
lm.ID AS SourceID,
|
lm.ID AS SourceID,
|
||||||
lm.DataMagazzino AS LastEventAt,
|
lm.DataMagazzino AS LastEventAt,
|
||||||
|
ISNULL(la.IDCella, :idcella) AS CurrentIDCella,
|
||||||
CASE
|
CASE
|
||||||
WHEN shipped.BarcodePallet IS NOT NULL THEN CAST(1 AS int)
|
WHEN shipped.BarcodePallet IS NOT NULL THEN CAST(1 AS int)
|
||||||
ELSE CAST(0 AS int)
|
ELSE CAST(0 AS int)
|
||||||
@@ -413,6 +420,7 @@ class ScaricoRow:
|
|||||||
udc: str
|
udc: str
|
||||||
source_id: int | None
|
source_id: int | None
|
||||||
last_event_at: str
|
last_event_at: str
|
||||||
|
current_idcella: int
|
||||||
diagnostic_note: str
|
diagnostic_note: str
|
||||||
selected: tk.BooleanVar
|
selected: tk.BooleanVar
|
||||||
|
|
||||||
@@ -546,19 +554,27 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
actions.grid_columnconfigure(0, weight=1)
|
actions.grid_columnconfigure(0, weight=1)
|
||||||
ctk.CTkButton(
|
ctk.CTkButton(
|
||||||
actions,
|
actions,
|
||||||
text=loc_text("scarico.button.submit", catalog=self._locale_catalog, default="Scarica"),
|
text=loc_text("scarico.button.shipped", catalog=self._locale_catalog, default="Scarico come spedita"),
|
||||||
command=self._on_scarica,
|
command=self._on_scarica_spedita,
|
||||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||||
).grid(
|
).grid(
|
||||||
row=0, column=1, padx=(8, 0), pady=8
|
row=0, column=1, padx=(8, 0), pady=8
|
||||||
)
|
)
|
||||||
|
ctk.CTkButton(
|
||||||
|
actions,
|
||||||
|
text=loc_text("scarico.button.non_shelved", catalog=self._locale_catalog, default="Scarico come non scaff."),
|
||||||
|
command=self._on_scarica_non_scaff,
|
||||||
|
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||||
|
).grid(
|
||||||
|
row=0, column=2, padx=(8, 0), pady=8
|
||||||
|
)
|
||||||
ctk.CTkButton(
|
ctk.CTkButton(
|
||||||
actions,
|
actions,
|
||||||
text=loc_text("scarico.button.close", catalog=self._locale_catalog, default="Chiudi"),
|
text=loc_text("scarico.button.close", catalog=self._locale_catalog, default="Chiudi"),
|
||||||
command=self._close,
|
command=self._close,
|
||||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||||
).grid(
|
).grid(
|
||||||
row=0, column=2, padx=(8, 8), pady=8
|
row=0, column=3, padx=(8, 8), pady=8
|
||||||
)
|
)
|
||||||
|
|
||||||
def _render_rows(self):
|
def _render_rows(self):
|
||||||
@@ -617,7 +633,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||||
_log_dataset("scarico_load_rows", rows)
|
_log_dataset("scarico_load_rows", rows)
|
||||||
self.rows = []
|
self.rows = []
|
||||||
for udc, source_id, last_event_at, is_shipped, is_moved in rows:
|
for udc, source_id, last_event_at, current_idcella, is_shipped, is_moved in rows:
|
||||||
if isinstance(last_event_at, datetime):
|
if isinstance(last_event_at, datetime):
|
||||||
last_event = last_event_at.strftime("%d/%m/%Y %H:%M:%S")
|
last_event = last_event_at.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
else:
|
else:
|
||||||
@@ -627,6 +643,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
udc=str(udc or ""),
|
udc=str(udc or ""),
|
||||||
source_id=int(source_id) if source_id is not None else None,
|
source_id=int(source_id) if source_id is not None else None,
|
||||||
last_event_at=last_event,
|
last_event_at=last_event,
|
||||||
|
current_idcella=int(current_idcella or 0),
|
||||||
diagnostic_note=_build_diagnostic_note(is_shipped, is_moved),
|
diagnostic_note=_build_diagnostic_note(is_shipped, is_moved),
|
||||||
selected=tk.BooleanVar(value=False),
|
selected=tk.BooleanVar(value=False),
|
||||||
)
|
)
|
||||||
@@ -653,8 +670,9 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@_log_call()
|
@_log_call()
|
||||||
def _on_scarica(self):
|
def _selected_rows_or_warn(self) -> list[ScaricoRow] | None:
|
||||||
"""Unload the UDCs selected by the user from the current cell."""
|
"""Return selected rows or show the standard selection warning."""
|
||||||
|
|
||||||
selected = [row for row in self.rows if row.selected.get()]
|
selected = [row for row in self.rows if row.selected.get()]
|
||||||
if not selected:
|
if not selected:
|
||||||
messagebox.showinfo(
|
messagebox.showinfo(
|
||||||
@@ -662,23 +680,88 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
loc_text("scarico.msg.select_one", catalog=self._locale_catalog, default="Seleziona almeno una UDC da scaricare."),
|
loc_text("scarico.msg.select_one", catalog=self._locale_catalog, default="Seleziona almeno una UDC da scaricare."),
|
||||||
parent=self,
|
parent=self,
|
||||||
)
|
)
|
||||||
|
return selected
|
||||||
|
|
||||||
|
@_log_call()
|
||||||
|
def _on_scarica_spedita(self):
|
||||||
|
"""Unload selected UDCs to the shipped conventional location."""
|
||||||
|
|
||||||
|
self._scarica_selected_to_target(
|
||||||
|
target_idcella=SHIPPED_IDCELLA,
|
||||||
|
target_barcode_cella=SHIPPED_BARCODE,
|
||||||
|
target_label=SHIPPED_LABEL,
|
||||||
|
title="Scarico come spedita",
|
||||||
|
confirm_text="Scaricare come spedite {count} UDC da {ubicazione}?",
|
||||||
|
busy_message="Scarico UDC come spedite...",
|
||||||
|
block_shipped_for_non_scaff=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
@_log_call()
|
||||||
|
def _on_scarica_non_scaff(self):
|
||||||
|
"""Unload selected UDCs to the non-shelved conventional location."""
|
||||||
|
|
||||||
|
self._scarica_selected_to_target(
|
||||||
|
target_idcella=NON_SCAFF_IDCELLA,
|
||||||
|
target_barcode_cella=NON_SCAFF_BARCODE,
|
||||||
|
target_label=NON_SCAFF_LABEL,
|
||||||
|
title="Scarico come non scaff.",
|
||||||
|
confirm_text="Scaricare come non scaffalate {count} UDC da {ubicazione}?",
|
||||||
|
busy_message="Scarico UDC come non scaffalate...",
|
||||||
|
block_shipped_for_non_scaff=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _scarica_selected_to_target(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
target_idcella: int,
|
||||||
|
target_barcode_cella: str,
|
||||||
|
target_label: str,
|
||||||
|
title: str,
|
||||||
|
confirm_text: str,
|
||||||
|
busy_message: str,
|
||||||
|
block_shipped_for_non_scaff: bool,
|
||||||
|
):
|
||||||
|
"""Move selected UDCs to one conventional unload location."""
|
||||||
|
|
||||||
|
selected = self._selected_rows_or_warn()
|
||||||
|
if not selected:
|
||||||
|
return
|
||||||
|
|
||||||
|
shipped_rows: list[ScaricoRow] = []
|
||||||
|
movable_rows = list(selected)
|
||||||
|
if block_shipped_for_non_scaff:
|
||||||
|
shipped_rows = [
|
||||||
|
row for row in selected
|
||||||
|
if int(row.current_idcella or 0) == SHIPPED_IDCELLA
|
||||||
|
or "spedita" in str(row.diagnostic_note or "").lower()
|
||||||
|
]
|
||||||
|
shipped_udcs = {row.udc for row in shipped_rows}
|
||||||
|
movable_rows = [row for row in selected if row.udc not in shipped_udcs]
|
||||||
|
|
||||||
|
if shipped_rows and not movable_rows:
|
||||||
|
messagebox.showwarning(
|
||||||
|
title,
|
||||||
|
"Nessuna UDC movimentata.\n"
|
||||||
|
f"UDC in {SHIPPED_LABEL}: " + ", ".join(row.udc for row in shipped_rows),
|
||||||
|
parent=self,
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not messagebox.askyesno(
|
if not messagebox.askyesno(
|
||||||
"Conferma scarico",
|
title,
|
||||||
f"Scaricare {len(selected)} UDC da {self.ubicazione}?",
|
confirm_text.format(count=len(movable_rows), ubicazione=self.ubicazione),
|
||||||
parent=self,
|
parent=self,
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
async def _job():
|
async def _job():
|
||||||
results: list[dict[str, Any]] = []
|
results: list[dict[str, Any]] = []
|
||||||
for row in selected:
|
for row in movable_rows:
|
||||||
result = await move_pallet_async(
|
result = await move_pallet_async(
|
||||||
self.db_client,
|
self.db_client,
|
||||||
barcode_pallet=row.udc,
|
barcode_pallet=row.udc,
|
||||||
target_idcella=9999,
|
target_idcella=target_idcella,
|
||||||
target_barcode_cella="9000000",
|
target_barcode_cella=target_barcode_cella,
|
||||||
utente=_session_login(self.session),
|
utente=_session_login(self.session),
|
||||||
)
|
)
|
||||||
results.append({"udc": row.udc, "affected": int(result.get("ok") or 0)})
|
results.append({"udc": row.udc, "affected": int(result.get("ok") or 0)})
|
||||||
@@ -690,33 +773,51 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
skipped = [item["udc"] for item in results if int(item.get("affected") or 0) <= 0]
|
skipped = [item["udc"] for item in results if int(item.get("affected") or 0) <= 0]
|
||||||
if not done:
|
if not done:
|
||||||
messagebox.showwarning(
|
messagebox.showwarning(
|
||||||
"Scarica",
|
title,
|
||||||
"Nessuna UDC e' stata scaricata. Verifica che le unita' siano ancora presenti in cella.",
|
"Nessuna UDC e' stata scaricata. Verifica che le unita' siano ancora presenti in cella.",
|
||||||
parent=self,
|
parent=self,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if skipped:
|
if skipped:
|
||||||
|
shipped_note = (
|
||||||
|
f"\nGia' in {SHIPPED_LABEL} non toccate: " + ", ".join(row.udc for row in shipped_rows)
|
||||||
|
if shipped_rows
|
||||||
|
else ""
|
||||||
|
)
|
||||||
|
target_note = (
|
||||||
|
f"\nUDC in {target_label}: " + ", ".join(done)
|
||||||
|
if done
|
||||||
|
else ""
|
||||||
|
)
|
||||||
messagebox.showwarning(
|
messagebox.showwarning(
|
||||||
"Scarica",
|
title,
|
||||||
"Scarico parziale.\nCompletate: "
|
"Scarico parziale.\nCompletate: "
|
||||||
+ ", ".join(done)
|
+ ", ".join(done)
|
||||||
+ "\nNon scaricate: "
|
+ "\nNon scaricate: "
|
||||||
+ ", ".join(skipped),
|
+ ", ".join(skipped)
|
||||||
|
+ shipped_note
|
||||||
|
+ target_note,
|
||||||
parent=self,
|
parent=self,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
messagebox.showinfo(
|
msg = f"Scarico completato verso {target_label} per:\n" + "\n".join(done)
|
||||||
"Scarica",
|
if shipped_rows:
|
||||||
"Scarico completato per:\n" + "\n".join(done),
|
msg += f"\n\nUDC gia' in {SHIPPED_LABEL} non toccate:\n" + "\n".join(row.udc for row in shipped_rows)
|
||||||
parent=self,
|
msg += f"\n\nUDC in {target_label}: " + ", ".join(done)
|
||||||
)
|
messagebox.showinfo(title, msg, parent=self)
|
||||||
log_user_action(
|
log_user_action(
|
||||||
self.session,
|
self.session,
|
||||||
module=MODULE_LOG_NAME,
|
module=MODULE_LOG_NAME,
|
||||||
action="layout.scarico",
|
action="layout.scarico.spedita" if int(target_idcella) == SHIPPED_IDCELLA else "layout.scarico.non_scaff",
|
||||||
outcome="ok",
|
outcome="ok",
|
||||||
target=self.ubicazione,
|
target=self.ubicazione,
|
||||||
details={"scaricate": done, "saltate": skipped},
|
details={
|
||||||
|
"scaricate": done,
|
||||||
|
"saltate": skipped,
|
||||||
|
"target_idcella": target_idcella,
|
||||||
|
"target_barcode_cella": target_barcode_cella,
|
||||||
|
"gia_spedite": [row.udc for row in shipped_rows],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
if self.on_completed:
|
if self.on_completed:
|
||||||
self.on_completed()
|
self.on_completed()
|
||||||
@@ -727,7 +828,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
log_user_action(
|
log_user_action(
|
||||||
self.session,
|
self.session,
|
||||||
module=MODULE_LOG_NAME,
|
module=MODULE_LOG_NAME,
|
||||||
action="layout.scarico",
|
action="layout.scarico.spedita" if int(target_idcella) == SHIPPED_IDCELLA else "layout.scarico.non_scaff",
|
||||||
outcome="error",
|
outcome="error",
|
||||||
target=self.ubicazione,
|
target=self.ubicazione,
|
||||||
details={"error": str(ex)},
|
details={"error": str(ex)},
|
||||||
@@ -743,7 +844,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
|||||||
_ok,
|
_ok,
|
||||||
_err,
|
_err,
|
||||||
busy=self._busy,
|
busy=self._busy,
|
||||||
message="Scarico UDC...",
|
message=busy_message,
|
||||||
)
|
)
|
||||||
|
|
||||||
@_log_call()
|
@_log_call()
|
||||||
|
|||||||
@@ -107,6 +107,8 @@
|
|||||||
"scarico.col.last_insert": "Ultimo inserimento",
|
"scarico.col.last_insert": "Ultimo inserimento",
|
||||||
"scarico.col.diagnostic": "Diagnostica",
|
"scarico.col.diagnostic": "Diagnostica",
|
||||||
"scarico.button.submit": "Scarica",
|
"scarico.button.submit": "Scarica",
|
||||||
|
"scarico.button.shipped": "Scarico come spedita",
|
||||||
|
"scarico.button.non_shelved": "Scarico come non scaff.",
|
||||||
"scarico.button.close": "Chiudi",
|
"scarico.button.close": "Chiudi",
|
||||||
"scarico.msg.title": "Scarica",
|
"scarico.msg.title": "Scarica",
|
||||||
"scarico.msg.select_one": "Seleziona almeno una UDC da scaricare.",
|
"scarico.msg.select_one": "Seleziona almeno una UDC da scaricare.",
|
||||||
@@ -220,6 +222,8 @@
|
|||||||
"scarico.col.last_insert": "Last insert",
|
"scarico.col.last_insert": "Last insert",
|
||||||
"scarico.col.diagnostic": "Diagnostics",
|
"scarico.col.diagnostic": "Diagnostics",
|
||||||
"scarico.button.submit": "Unload",
|
"scarico.button.submit": "Unload",
|
||||||
|
"scarico.button.shipped": "Unload as shipped",
|
||||||
|
"scarico.button.non_shelved": "Unload as non-shelved",
|
||||||
"scarico.button.close": "Close",
|
"scarico.button.close": "Close",
|
||||||
"scarico.msg.title": "Unload",
|
"scarico.msg.title": "Unload",
|
||||||
"scarico.msg.select_one": "Select at least one UDC to unload.",
|
"scarico.msg.select_one": "Select at least one UDC to unload.",
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ MODULE_VERSIONS: dict[str, str] = {
|
|||||||
"busy_overlay": "1.0.0",
|
"busy_overlay": "1.0.0",
|
||||||
"db_config": "1.0.0",
|
"db_config": "1.0.0",
|
||||||
"gestione_aree": "1.0.1",
|
"gestione_aree": "1.0.1",
|
||||||
"gestione_layout": "1.0.0",
|
"gestione_layout": "1.0.1",
|
||||||
"gestione_pickinglist": "1.0.2",
|
"gestione_pickinglist": "1.0.2",
|
||||||
"gestione_scarico": "1.0.0",
|
"gestione_scarico": "1.0.1",
|
||||||
"locale_text": "1.0.0",
|
"locale_text": "1.0.0",
|
||||||
"login_window": "1.0.0",
|
"login_window": "1.0.0",
|
||||||
"prenota_sprenota_sql": "1.0.0",
|
"prenota_sprenota_sql": "1.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user