Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dd7139b19 | |||
| d4cfe0be54 | |||
| f4e73bd5b9 | |||
| e575c748cc | |||
| 7ecc906d59 | |||
| 29687c8094 | |||
| bd844ce056 |
43
apply_barcode_picking_skip_patch.sql
Normal file
43
apply_barcode_picking_skip_patch.sql
Normal file
@@ -0,0 +1,43 @@
|
||||
SET XACT_ABORT ON;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.py_BarcodePickingListSkip (
|
||||
ID int IDENTITY(1,1) NOT NULL CONSTRAINT PK_py_BarcodePickingListSkip PRIMARY KEY,
|
||||
Documento varchar(50) NOT NULL,
|
||||
Pallet varchar(50) NOT NULL,
|
||||
IDStato int NOT NULL,
|
||||
IDOperatore int NOT NULL,
|
||||
DataOra datetime2(0) NOT NULL CONSTRAINT DF_py_BarcodePickingListSkip_DataOra DEFAULT SYSDATETIME(),
|
||||
Motivo nvarchar(200) NULL,
|
||||
Risolto bit NOT NULL CONSTRAINT DF_py_BarcodePickingListSkip_Risolto DEFAULT 0,
|
||||
RisoltoDa int NULL,
|
||||
RisoltoDataOra datetime2(0) NULL
|
||||
);
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = N'UX_py_BarcodePickingListSkip_Open'
|
||||
AND object_id = OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U')
|
||||
)
|
||||
BEGIN
|
||||
CREATE UNIQUE INDEX UX_py_BarcodePickingListSkip_Open
|
||||
ON dbo.py_BarcodePickingListSkip (Documento, Pallet, IDStato)
|
||||
WHERE Risolto = 0;
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = N'IX_py_BarcodePickingListSkip_Queue'
|
||||
AND object_id = OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U')
|
||||
)
|
||||
BEGIN
|
||||
CREATE INDEX IX_py_BarcodePickingListSkip_Queue
|
||||
ON dbo.py_BarcodePickingListSkip (IDStato, Documento, Pallet, Risolto);
|
||||
END;
|
||||
|
||||
COMMIT TRANSACTION;
|
||||
@@ -48,6 +48,7 @@ def _build_bypass_session():
|
||||
class BarcodeClientApp:
|
||||
"""Single-window Tk barcode client modeled after the C# legacy form."""
|
||||
|
||||
PALLET_BARCODE_LENGTH = 6
|
||||
NON_SCAFFALATA_BARCODE = "9001000"
|
||||
SHIPPED_BARCODE = "9000000"
|
||||
BARCODE_MAX_WIDTH = 320
|
||||
@@ -65,6 +66,8 @@ class BarcodeClientApp:
|
||||
self.service = BarcodeService(self.repository, session.operator_id)
|
||||
self._pending: Future | None = None
|
||||
self._auto_advance_id: str | None = None
|
||||
self._pallet_auto_focus_id: str | None = None
|
||||
self._paused_queue_id: int | None = None
|
||||
self._status_colors = {
|
||||
"red": "#f4cccc",
|
||||
"green": "#d9ead3",
|
||||
@@ -196,7 +199,7 @@ class BarcodeClientApp:
|
||||
|
||||
self.btn_f1 = ttk.Button(buttons, text="[F1] H Priority", command=lambda: self._start_queue(1))
|
||||
self.btn_f1.grid(row=0, column=0, padx=(0, 4), pady=(0, button_pad_y), sticky="ew")
|
||||
self.btn_submit = ttk.Button(buttons, text="[Ent] Carica", command=self._submit)
|
||||
self.btn_submit = ttk.Button(buttons, text="[F3] Carica", command=self._on_f3)
|
||||
self.btn_submit.grid(row=0, column=1, padx=(4, 0), pady=(0, button_pad_y), sticky="ew")
|
||||
self.btn_f2 = ttk.Button(buttons, text="[F2] L Priority", command=lambda: self._start_queue(0))
|
||||
self.btn_f2.grid(row=1, column=0, padx=(0, 4), sticky="ew")
|
||||
@@ -234,7 +237,7 @@ class BarcodeClientApp:
|
||||
parent.columnconfigure(1, weight=1)
|
||||
if scanned:
|
||||
self.pallet_entry = entry
|
||||
self.scanned_var.trace_add("write", lambda *_: self._limit_var(self.scanned_var, 8))
|
||||
self.scanned_var.trace_add("write", lambda *_: self._on_scanned_var_changed())
|
||||
else:
|
||||
self.destination_entry = entry
|
||||
self.destination_var.trace_add("write", lambda *_: self._limit_var(self.destination_var, 8))
|
||||
@@ -244,6 +247,32 @@ class BarcodeClientApp:
|
||||
if len(value) > max_len:
|
||||
variable.set(value[:max_len])
|
||||
|
||||
def _on_scanned_var_changed(self) -> None:
|
||||
self._limit_var(self.scanned_var, 8)
|
||||
if self._pallet_auto_focus_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._pallet_auto_focus_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._pallet_auto_focus_id = None
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
if len(pallet) < self.PALLET_BARCODE_LENGTH:
|
||||
return
|
||||
self._pallet_auto_focus_id = self.root.after(80, self._auto_focus_destination_after_scan)
|
||||
|
||||
def _auto_focus_destination_after_scan(self) -> None:
|
||||
self._pallet_auto_focus_id = None
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
if not pallet:
|
||||
return
|
||||
if self._pending is not None and not self._pending.done():
|
||||
return
|
||||
if getattr(self.service.state, "mode", "") == "confirm":
|
||||
return
|
||||
if bool(getattr(self.service.state, "destination_readonly", False)):
|
||||
return
|
||||
self._focus_destination_input()
|
||||
|
||||
def _apply_responsive_geometry(self) -> None:
|
||||
"""Adapt the window size to barcode-sized or desktop-sized screens."""
|
||||
|
||||
@@ -296,7 +325,9 @@ class BarcodeClientApp:
|
||||
def _bind_keys(self) -> None:
|
||||
self.root.bind("<F1>", lambda _e: self._start_queue(1))
|
||||
self.root.bind("<F2>", lambda _e: self._start_queue(0))
|
||||
self.root.bind("<F3>", self._on_f3_key)
|
||||
self.root.bind("<F4>", self._on_unload_key)
|
||||
self.root.bind("<Escape>", self._on_escape_key)
|
||||
self.pallet_entry.bind("<Return>", self._on_pallet_enter)
|
||||
self.destination_entry.bind("<Return>", self._on_destination_enter)
|
||||
|
||||
@@ -324,6 +355,9 @@ class BarcodeClientApp:
|
||||
self.busy_bar.stop()
|
||||
self.busy_cover.place_forget()
|
||||
|
||||
def _is_priority_pause(self) -> bool:
|
||||
return str(self.queue_var.get() or "") == "Pausa PL"
|
||||
|
||||
def _apply_state(self, state: BarcodeViewState) -> None:
|
||||
if self._auto_advance_id is not None:
|
||||
try:
|
||||
@@ -331,15 +365,39 @@ class BarcodeClientApp:
|
||||
except Exception:
|
||||
pass
|
||||
self._auto_advance_id = None
|
||||
if self._pallet_auto_focus_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._pallet_auto_focus_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._pallet_auto_focus_id = None
|
||||
self.queue_var.set(state.queue_label)
|
||||
self.destination_var.set(state.destination_barcode)
|
||||
self.scanned_var.set(state.scanned_pallet)
|
||||
self.info1_var.set(state.status_text)
|
||||
self.info1_var.set(self._status_text_with_wait_hint(state))
|
||||
self.info2_var.set(state.document)
|
||||
self.info3_var.set(state.customer)
|
||||
self.info4_var.set(state.expected_pallet)
|
||||
self.status_band.configure(bg=state.status_color or self._status_colors["red"])
|
||||
|
||||
try:
|
||||
if str(state.queue_label or "") != "Pausa PL":
|
||||
self._paused_queue_id = None
|
||||
resumable_queue = self._resumable_queue_from_state(state)
|
||||
if state.mode in ("priority_high", "priority_low") or resumable_queue is not None:
|
||||
self.btn_submit.configure(text="[F3] Pausa PL")
|
||||
else:
|
||||
self.btn_submit.configure(text="[F3] Carica")
|
||||
if state.mode in ("priority_high", "priority_low"):
|
||||
self.btn_unload.configure(text="[F4] Salta UDC")
|
||||
else:
|
||||
self.btn_unload.configure(text="[F4] Scarica")
|
||||
queue_buttons_state = "disabled" if str(state.queue_label or "") == "Pausa PL" else "normal"
|
||||
self.btn_f1.configure(state=queue_buttons_state)
|
||||
self.btn_f2.configure(state=queue_buttons_state)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
destination_readonly = bool(getattr(state, "destination_readonly", False))
|
||||
try:
|
||||
self.destination_entry.configure(state="normal")
|
||||
@@ -348,19 +406,17 @@ class BarcodeClientApp:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
is_completed_move = (
|
||||
str(state.status_text or "").startswith("Ok Scarico")
|
||||
or str(state.status_text or "").startswith("Ok Carico")
|
||||
)
|
||||
if state.mode == "confirm" and is_completed_move:
|
||||
next_queue = self._queue_id_from_label(state.queue_label)
|
||||
delay_ms = int(getattr(state, "auto_advance_delay_ms", 0) or 0)
|
||||
if next_queue is not None and delay_ms > 0:
|
||||
if state.mode == "confirm":
|
||||
next_queue = self._resumable_queue_from_state(state)
|
||||
if next_queue is not None:
|
||||
self._auto_advance_id = self.root.after(
|
||||
delay_ms,
|
||||
int(getattr(state, "auto_advance_delay_ms", 0) or 0),
|
||||
lambda q=next_queue: self._start_queue(q),
|
||||
)
|
||||
|
||||
if bool(getattr(state, "focus_destination", False)):
|
||||
self.root.after(20, self._focus_destination_input)
|
||||
else:
|
||||
self.root.after(20, self._focus_primary_input)
|
||||
|
||||
def _focus_primary_input(self) -> None:
|
||||
@@ -370,6 +426,17 @@ class BarcodeClientApp:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _status_text_with_wait_hint(self, state: BarcodeViewState) -> str:
|
||||
text = str(getattr(state, "status_text", "") or "")
|
||||
delay_ms = int(getattr(state, "auto_advance_delay_ms", 0) or 0)
|
||||
if delay_ms <= 0:
|
||||
return text
|
||||
seconds = max(1, round(delay_ms / 1000))
|
||||
hint = f"Attendi {seconds} secondi..."
|
||||
if hint.lower() in text.lower():
|
||||
return text
|
||||
return f"{text} - {hint}" if text else hint
|
||||
|
||||
def _focus_destination_input(self) -> None:
|
||||
try:
|
||||
self.destination_entry.configure(state="normal")
|
||||
@@ -409,23 +476,52 @@ class BarcodeClientApp:
|
||||
self._begin_manual_unload()
|
||||
return "break"
|
||||
|
||||
def _on_escape_key(self, _event=None) -> str:
|
||||
if self._is_priority_pause() and self._paused_queue_id is not None:
|
||||
self._start_queue(self._paused_queue_id, allow_during_pause=True)
|
||||
return "break"
|
||||
|
||||
def _on_f3_key(self, _event=None) -> str:
|
||||
self._on_f3()
|
||||
return "break"
|
||||
|
||||
def _on_f3(self) -> None:
|
||||
mode = getattr(self.service.state, "mode", "")
|
||||
if mode == "priority_high":
|
||||
self._paused_queue_id = 1
|
||||
self._apply_state(self.service.begin_priority_pause(1))
|
||||
return
|
||||
if mode == "priority_low":
|
||||
self._paused_queue_id = 0
|
||||
self._apply_state(self.service.begin_priority_pause(0))
|
||||
return
|
||||
resumable_queue = self._resumable_queue_from_state(self.service.state)
|
||||
if resumable_queue is not None:
|
||||
self._paused_queue_id = resumable_queue
|
||||
self._apply_state(self.service.begin_priority_pause(resumable_queue))
|
||||
return
|
||||
self._submit()
|
||||
|
||||
def _begin_manual_unload(self) -> None:
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
destination = str(self.destination_var.get() or "").strip()
|
||||
if pallet and destination in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE):
|
||||
# Legacy barcode flow: F4/Scarica confirms the prepared unload destination.
|
||||
self._submit()
|
||||
mode = getattr(self.service.state, "mode", "")
|
||||
if mode in ("priority_high", "priority_low"):
|
||||
self._skip_current_picking_pallet()
|
||||
return
|
||||
if pallet and not destination:
|
||||
self.destination_var.set(self.NON_SCAFFALATA_BARCODE)
|
||||
self._submit()
|
||||
if pallet:
|
||||
self._submit_unload_with_source_check()
|
||||
return
|
||||
if self._is_priority_pause():
|
||||
return
|
||||
self._apply_state(self.service.begin_manual_unload())
|
||||
|
||||
def _start_queue(self, id_stato: int) -> None:
|
||||
def _start_queue(self, id_stato: int, *, allow_during_pause: bool = False) -> None:
|
||||
if self._is_priority_pause() and not allow_during_pause:
|
||||
return
|
||||
self._run_async(
|
||||
lambda: self.service.start_priority_queue(id_stato),
|
||||
busy_message="Carico la coda selezionata...",
|
||||
busy_message="In preparazione...",
|
||||
)
|
||||
|
||||
def _submit(self) -> None:
|
||||
@@ -434,7 +530,22 @@ class BarcodeClientApp:
|
||||
scanned_pallet=self.scanned_var.get(),
|
||||
destination_barcode=self.destination_var.get(),
|
||||
),
|
||||
busy_message="Eseguo il movimento...",
|
||||
busy_message="In esecuzione...",
|
||||
)
|
||||
|
||||
def _submit_unload_with_source_check(self) -> None:
|
||||
self._run_async(
|
||||
lambda: self.service.submit_unload_with_source_check(
|
||||
scanned_pallet=self.scanned_var.get(),
|
||||
source_barcode=self.destination_var.get(),
|
||||
),
|
||||
busy_message="In esecuzione...",
|
||||
)
|
||||
|
||||
def _skip_current_picking_pallet(self) -> None:
|
||||
self._run_async(
|
||||
lambda: self.service.skip_current_picking_pallet(),
|
||||
busy_message="Registro salto UDC...",
|
||||
)
|
||||
|
||||
def _run_async(self, coro_factory: Callable[[], object], busy_message: str) -> None:
|
||||
@@ -458,6 +569,12 @@ class BarcodeClientApp:
|
||||
return 0
|
||||
return None
|
||||
|
||||
def _resumable_queue_from_state(self, state: BarcodeViewState) -> int | None:
|
||||
delay_ms = int(getattr(state, "auto_advance_delay_ms", 0) or 0)
|
||||
if delay_ms <= 0:
|
||||
return None
|
||||
return self._queue_id_from_label(str(getattr(state, "queue_label", "") or ""))
|
||||
|
||||
def _poll_future(self) -> None:
|
||||
if self._pending is None:
|
||||
self._set_busy(False)
|
||||
@@ -473,10 +590,25 @@ class BarcodeClientApp:
|
||||
result = future.result()
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context="barcode async operation")
|
||||
current = self.service.state
|
||||
current.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
current.status_color = "#f4cccc"
|
||||
self._apply_state(current)
|
||||
self._set_busy(True, "Verifico esito...")
|
||||
self._pending = asyncio.run_coroutine_threadsafe(
|
||||
self.service.reconcile_after_submit_exception(
|
||||
scanned_pallet=self.scanned_var.get(),
|
||||
destination_barcode=self.destination_var.get(),
|
||||
),
|
||||
self.loop,
|
||||
)
|
||||
self.root.after(40, lambda err=exc: self._poll_recovery_future(err))
|
||||
return
|
||||
|
||||
if isinstance(result, BarcodeActionResult):
|
||||
self._apply_state(result.state)
|
||||
if result.message and not result.ok:
|
||||
self.root.bell()
|
||||
elif isinstance(result, BarcodeViewState):
|
||||
self._apply_state(result)
|
||||
|
||||
def _show_transaction_error(self) -> None:
|
||||
messagebox.showerror(
|
||||
"Barcode WMS",
|
||||
"Operazione non completata.\n\n"
|
||||
@@ -484,12 +616,35 @@ class BarcodeClientApp:
|
||||
"Il dettaglio tecnico e' stato scritto nel log.",
|
||||
parent=self.root,
|
||||
)
|
||||
|
||||
def _poll_recovery_future(self, original_exception: Exception) -> None:
|
||||
if self._pending is None:
|
||||
self._set_busy(False)
|
||||
self._show_transaction_error()
|
||||
return
|
||||
if not self._pending.done():
|
||||
self.root.after(40, lambda err=original_exception: self._poll_recovery_future(err))
|
||||
return
|
||||
|
||||
future = self._pending
|
||||
self._pending = None
|
||||
self._set_busy(False)
|
||||
try:
|
||||
result = future.result()
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context=f"barcode recovery after {original_exception!r}")
|
||||
current = self.service.state
|
||||
current.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
current.status_color = "#f4cccc"
|
||||
self._apply_state(current)
|
||||
self._show_transaction_error()
|
||||
return
|
||||
|
||||
if isinstance(result, BarcodeActionResult):
|
||||
self._apply_state(result.state)
|
||||
if result.message and not result.ok:
|
||||
if not result.ok:
|
||||
self.root.bell()
|
||||
self._show_transaction_error()
|
||||
elif isinstance(result, BarcodeViewState):
|
||||
self._apply_state(result)
|
||||
|
||||
|
||||
@@ -26,9 +26,17 @@ SELECT TOP (1)
|
||||
Ubicazione,
|
||||
Ordinamento,
|
||||
IDStato
|
||||
FROM dbo.py_XMag_ViewPackingList
|
||||
FROM dbo.py_XMag_ViewPackingList AS pl
|
||||
WHERE Ordinamento > 0
|
||||
AND IDStato = :id_stato
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_BarcodePickingListSkip AS s
|
||||
WHERE s.Documento = CAST(pl.Documento AS varchar(50))
|
||||
AND s.Pallet = CAST(pl.Pallet AS varchar(50))
|
||||
AND s.IDStato = pl.IDStato
|
||||
AND s.Risolto = 0
|
||||
)
|
||||
ORDER BY Ordinamento;
|
||||
"""
|
||||
|
||||
@@ -72,6 +80,29 @@ LEFT JOIN dbo.Celle AS c
|
||||
WHERE g.BarcodePallet = :pallet;
|
||||
"""
|
||||
|
||||
SQL_OPEN_LOCATIONS_BY_PALLET = """
|
||||
SELECT
|
||||
g.BarcodePallet,
|
||||
g.IDCella,
|
||||
RTRIM(c.Corsia) AS Corsia,
|
||||
RTRIM(CAST(c.Colonna AS varchar(32))) AS Colonna,
|
||||
RTRIM(CAST(c.Fila AS varchar(32))) AS Fila
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
LEFT JOIN dbo.Celle AS c
|
||||
ON c.ID = g.IDCella
|
||||
WHERE g.BarcodePallet = :pallet
|
||||
ORDER BY g.IDCella;
|
||||
"""
|
||||
|
||||
SQL_OPEN_PALLETS_BY_CELL = """
|
||||
SELECT
|
||||
g.BarcodePallet,
|
||||
g.IDCella
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
WHERE g.IDCella = :id_cella
|
||||
ORDER BY g.BarcodePallet;
|
||||
"""
|
||||
|
||||
SQL_RESOLVE_PHYSICAL_CELL = """
|
||||
DECLARE @raw int = TRY_CONVERT(int, :destination);
|
||||
DECLARE @cell_id int =
|
||||
@@ -113,6 +144,44 @@ SELECT
|
||||
:numero_cella AS NumeroCella;
|
||||
"""
|
||||
|
||||
SQL_SKIP_PICKING_PALLET = """
|
||||
SET NOCOUNT ON;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_BarcodePickingListSkip
|
||||
WHERE Documento = :documento
|
||||
AND Pallet = :pallet
|
||||
AND IDStato = :id_stato
|
||||
AND Risolto = 0
|
||||
)
|
||||
BEGIN
|
||||
INSERT INTO dbo.py_BarcodePickingListSkip (
|
||||
Documento,
|
||||
Pallet,
|
||||
IDStato,
|
||||
IDOperatore,
|
||||
DataOra,
|
||||
Motivo,
|
||||
Risolto
|
||||
)
|
||||
VALUES (
|
||||
:documento,
|
||||
:pallet,
|
||||
:id_stato,
|
||||
:id_operatore,
|
||||
SYSDATETIME(),
|
||||
:motivo,
|
||||
0
|
||||
);
|
||||
END;
|
||||
|
||||
SELECT
|
||||
:documento AS Documento,
|
||||
:pallet AS Pallet,
|
||||
:id_stato AS IDStato;
|
||||
"""
|
||||
|
||||
|
||||
def _rows_to_dicts(res: dict[str, Any] | None) -> list[dict[str, Any]]:
|
||||
"""Convert ``query_json`` payloads to a list of row dictionaries."""
|
||||
@@ -184,6 +253,57 @@ class BarcodeRepository:
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def fetch_open_locations_by_pallet(self, pallet: str) -> list[dict[str, Any]]:
|
||||
"""Return all positive stock locations currently open for a pallet."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_OPEN_LOCATIONS_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
||||
return _rows_to_dicts(res)
|
||||
|
||||
async def fetch_open_pallets_by_cell(self, id_cella: int) -> list[dict[str, Any]]:
|
||||
"""Return pallets currently present in a physical cell."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_OPEN_PALLETS_BY_CELL, {"id_cella": int(id_cella)})
|
||||
return _rows_to_dicts(res)
|
||||
|
||||
async def skip_picking_pallet(
|
||||
self,
|
||||
*,
|
||||
documento: str,
|
||||
pallet: str,
|
||||
id_stato: int,
|
||||
operator_id: int,
|
||||
motivo: str = "UDC non trovata dal magazziniere",
|
||||
) -> None:
|
||||
"""Persist one skipped picking-list pallet so the queue can advance."""
|
||||
|
||||
params = {
|
||||
"documento": str(documento or "").strip(),
|
||||
"pallet": str(pallet or "").strip(),
|
||||
"id_stato": int(id_stato),
|
||||
"id_operatore": int(operator_id),
|
||||
"motivo": str(motivo or "").strip(),
|
||||
}
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"PICKING SKIP START "
|
||||
f"documento={params['documento']} "
|
||||
f"pallet={params['pallet']} "
|
||||
f"id_stato={params['id_stato']} "
|
||||
f"operator={params['id_operatore']}"
|
||||
),
|
||||
)
|
||||
await self.db_client.query_json(SQL_SKIP_PICKING_PALLET, params, commit=True)
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"PICKING SKIP OK "
|
||||
f"documento={params['documento']} "
|
||||
f"pallet={params['pallet']} "
|
||||
f"id_stato={params['id_stato']}"
|
||||
),
|
||||
)
|
||||
|
||||
async def resolve_physical_cell(self, destination: str) -> DestinationCell | None:
|
||||
"""Accept either an internal cell ID or the scanned legacy cell barcode."""
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from dataclasses import dataclass
|
||||
from typing import Literal
|
||||
|
||||
from barcode_repository import BarcodeRepository, LegacyMoveResult
|
||||
from runtime_support import log_exception
|
||||
from runtime_support import log_exception, log_runtime_event
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
@@ -30,6 +30,7 @@ class BarcodeViewState:
|
||||
scanned_pallet: str = ""
|
||||
auto_advance_delay_ms: int = 0
|
||||
destination_readonly: bool = False
|
||||
focus_destination: bool = False
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -58,7 +59,7 @@ class BarcodeService:
|
||||
def __init__(self, repository: BarcodeRepository, operator_id: int):
|
||||
self.repository = repository
|
||||
self.operator_id = int(operator_id)
|
||||
self._current_priority_state = 0
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState()
|
||||
|
||||
@property
|
||||
@@ -70,14 +71,14 @@ class BarcodeService:
|
||||
def reset(self) -> BarcodeViewState:
|
||||
"""Return the client to its neutral state."""
|
||||
|
||||
self._current_priority_state = 0
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState()
|
||||
return self._state
|
||||
|
||||
def begin_manual_load(self) -> BarcodeViewState:
|
||||
"""Prepare a real versamento into a physical warehouse cell."""
|
||||
|
||||
self._current_priority_state = 0
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_load",
|
||||
queue_label="Versamento",
|
||||
@@ -89,7 +90,7 @@ class BarcodeService:
|
||||
def begin_manual_unload(self) -> BarcodeViewState:
|
||||
"""Prepare a direct unload toward the conventional non-shelved cell."""
|
||||
|
||||
self._current_priority_state = 0
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_unload",
|
||||
queue_label="Prelievo diretto",
|
||||
@@ -100,6 +101,58 @@ class BarcodeService:
|
||||
)
|
||||
return self._state
|
||||
|
||||
def begin_priority_pause(self, id_stato: int) -> BarcodeViewState:
|
||||
"""Pause the active picking queue locally for exactly one free movement."""
|
||||
|
||||
self._current_priority_state = int(id_stato)
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_unload",
|
||||
queue_label="Pausa PL",
|
||||
status_text="Premi ESC per uscire dalla pausa",
|
||||
status_color=self.GRAY,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
destination_readonly=False,
|
||||
)
|
||||
return self._state
|
||||
|
||||
async def skip_current_picking_pallet(self) -> BarcodeActionResult:
|
||||
"""Mark the currently proposed picking pallet as skipped and advance."""
|
||||
|
||||
mode = str(self._state.mode or "")
|
||||
if mode not in ("priority_high", "priority_low"):
|
||||
return BarcodeActionResult(False, self._state, "Nessuna picking list attiva.")
|
||||
|
||||
id_stato = 1 if mode == "priority_high" else 0
|
||||
documento = str(self._state.document or "").strip()
|
||||
pallet = str(self._state.expected_pallet or "").strip()
|
||||
if not documento or not pallet:
|
||||
self._state.status_text = "Nessuna UDC da saltare."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
await self.repository.skip_picking_pallet(
|
||||
documento=documento,
|
||||
pallet=pallet,
|
||||
id_stato=id_stato,
|
||||
operator_id=self.operator_id,
|
||||
)
|
||||
queue_label = "Alta priorita' (F1)" if id_stato == 1 else "Bassa priorita' (F2)"
|
||||
self._current_priority_state = id_stato
|
||||
self._state = BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label=queue_label,
|
||||
status_text="UDC saltata - chiusura manuale richiesta",
|
||||
status_color=self.RED,
|
||||
source_location=self._state.source_location,
|
||||
document=documento,
|
||||
customer="UDC non trovata",
|
||||
expected_pallet=pallet,
|
||||
destination_barcode=self.SHIPPED_BARCODE,
|
||||
auto_advance_delay_ms=1500,
|
||||
destination_readonly=True,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def start_priority_queue(self, id_stato: int) -> BarcodeActionResult:
|
||||
"""Load the next item of the selected legacy priority queue."""
|
||||
|
||||
@@ -107,6 +160,7 @@ class BarcodeService:
|
||||
self._current_priority_state = int(id_stato)
|
||||
queue_label = "Alta priorita' (F1)" if int(id_stato) == 1 else "Bassa priorita' (F2)"
|
||||
if not row:
|
||||
self._current_priority_state = -1
|
||||
self._state = BarcodeViewState(
|
||||
mode="manual_unload",
|
||||
queue_label=queue_label,
|
||||
@@ -161,24 +215,111 @@ class BarcodeService:
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
target_barcode = destination
|
||||
target_numero_cella = int(destination)
|
||||
target_id_cella = 9999 if destination == self.SHIPPED_BARCODE else (1000 if destination == self.NON_SCAFFALATA_BARCODE else None)
|
||||
target_display = destination
|
||||
if is_direct_load:
|
||||
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
||||
if not resolved_cell:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = f"Cella non valida: {destination}."
|
||||
self._state.status_color = self.RED
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
occupants = await self.repository.fetch_open_pallets_by_cell(resolved_cell.id_cella)
|
||||
if occupants:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED DESTINATION_OCCUPIED "
|
||||
f"pallet={pallet} "
|
||||
f"cell={resolved_cell.id_cella} "
|
||||
f"occupants={','.join(str(row.get('BarcodePallet') or '') for row in occupants)}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Errore: cella scelta occupata, cambiare cella di destinazione."
|
||||
self._state.status_color = self.RED
|
||||
self._state.destination_readonly = False
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
target_barcode = resolved_cell.barcode_cella
|
||||
target_numero_cella = resolved_cell.numero_cella
|
||||
target_id_cella = resolved_cell.id_cella
|
||||
target_display = resolved_cell.ubicazione or destination
|
||||
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
picking_before_move = await self.repository.fetch_picking_by_pallet(pallet)
|
||||
if not current_location and not picking_before_move:
|
||||
if is_direct_load:
|
||||
trace_row = await self.repository.fetch_trace_by_pallet(pallet)
|
||||
if not trace_row:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Errore: UDC non riconosciuta in ERP/SAM."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
f"AUTO INTAKE NON_SHELVED pallet={pallet} before_cell={target_id_cella}",
|
||||
)
|
||||
await self.repository.execute_legacy_move(
|
||||
operator_id=self.operator_id,
|
||||
barcode_cella=self.NON_SCAFFALATA_BARCODE,
|
||||
barcode_pallet=pallet,
|
||||
numero_cella=int(self.NON_SCAFFALATA_BARCODE),
|
||||
)
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
current_id_cella = int((current_location or {}).get("IDCella") or 0)
|
||||
except Exception:
|
||||
current_id_cella = 0
|
||||
if current_id_cella != 1000:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Movimento non confermato: ingresso UDC non scaffalata non riuscito."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
else:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.status_text = "UDC non presente a magazzino."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
target_barcode = destination
|
||||
target_numero_cella = int(destination)
|
||||
target_id_cella = 9999 if destination == self.SHIPPED_BARCODE else (1000 if destination == self.NON_SCAFFALATA_BARCODE else None)
|
||||
target_display = destination
|
||||
if destination not in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE):
|
||||
open_locations = await self.repository.fetch_open_locations_by_pallet(pallet)
|
||||
distinct_cells = sorted({
|
||||
int(row.get("IDCella") or 0)
|
||||
for row in open_locations
|
||||
if row.get("IDCella") is not None
|
||||
})
|
||||
if len(distinct_cells) > 1:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED MULTI_LOCATION "
|
||||
f"pallet={pallet} "
|
||||
f"cells={','.join(str(cell) for cell in distinct_cells)}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "UDC presente in piu' celle. Movimento bloccato."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
if not is_direct_load and destination not in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE):
|
||||
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
||||
if not resolved_cell:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.status_text = f"Cella non valida: {destination}."
|
||||
self._state.status_color = self.RED
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
target_barcode = resolved_cell.barcode_cella
|
||||
target_numero_cella = resolved_cell.numero_cella
|
||||
@@ -210,7 +351,7 @@ class BarcodeService:
|
||||
destination_barcode=destination,
|
||||
destination_display=target_display,
|
||||
last_priority_state=self._current_priority_state,
|
||||
auto_advance_delay_ms=5000 if (is_direct_unload or is_direct_load) else 1200 if is_picking_unload else 0,
|
||||
auto_advance_delay_ms=5000 if (is_direct_unload or is_direct_load) else 3000 if is_picking_unload else 0,
|
||||
)
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context=f"post move state pallet={pallet} destination={destination}")
|
||||
@@ -224,6 +365,172 @@ class BarcodeService:
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def submit_unload_with_source_check(self, *, scanned_pallet: str, source_barcode: str) -> BarcodeActionResult:
|
||||
"""Unload to the non-shelved cell only if the scanned source cell matches DB."""
|
||||
|
||||
pallet = str(scanned_pallet or "").strip()
|
||||
source = str(source_barcode or "").strip()
|
||||
if not pallet:
|
||||
return BarcodeActionResult(False, self._state, "Inserisci o leggi il pallet.")
|
||||
if not source:
|
||||
return BarcodeActionResult(False, self._state, "Leggi il codice della cella da scaricare.")
|
||||
if not source.isdigit():
|
||||
return BarcodeActionResult(False, self._state, "La cella da scaricare deve essere numerica.")
|
||||
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
if not current_location:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.status_text = "UDC non presente a magazzino."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
open_locations = await self.repository.fetch_open_locations_by_pallet(pallet)
|
||||
distinct_cells = sorted({
|
||||
int(row.get("IDCella") or 0)
|
||||
for row in open_locations
|
||||
if row.get("IDCella") is not None
|
||||
})
|
||||
if len(distinct_cells) > 1:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED MULTI_LOCATION "
|
||||
f"pallet={pallet} "
|
||||
f"cells={','.join(str(cell) for cell in distinct_cells)}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "UDC presente in piu' celle. Movimento bloccato."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
if source == self.NON_SCAFFALATA_BARCODE:
|
||||
source_id_cella = 1000
|
||||
else:
|
||||
resolved_source = await self.repository.resolve_physical_cell(source)
|
||||
if not resolved_source:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = f"Cella non valida: {source}."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
source_id_cella = int(resolved_source.id_cella)
|
||||
|
||||
current_id_cella = int((current_location or {}).get("IDCella") or 0)
|
||||
if current_id_cella != source_id_cella:
|
||||
if source == self.NON_SCAFFALATA_BARCODE and current_id_cella != 1000:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED SOURCE_REQUIRED "
|
||||
f"pallet={pallet} "
|
||||
f"db_cell={current_id_cella} "
|
||||
f"default_cell={source_id_cella}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "Errore: leggi la cella da scaricare."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE BLOCKED SOURCE_MISMATCH "
|
||||
f"pallet={pallet} "
|
||||
f"db_cell={current_id_cella} "
|
||||
f"scanned_cell={source_id_cella}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "Errore: UDC in cella diversa, rileggi il codice della cella da scaricare."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
return await self.submit(scanned_pallet=pallet, destination_barcode=self.NON_SCAFFALATA_BARCODE)
|
||||
|
||||
async def reconcile_after_submit_exception(
|
||||
self,
|
||||
*,
|
||||
scanned_pallet: str,
|
||||
destination_barcode: str,
|
||||
) -> BarcodeActionResult:
|
||||
"""Check whether a failed client round-trip actually committed on SQL Server."""
|
||||
|
||||
pallet = str(scanned_pallet or "").strip()
|
||||
destination = str(destination_barcode or "").strip()
|
||||
if not pallet or not destination or not destination.isdigit():
|
||||
self._state.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
target_id_cella = 9999 if destination == self.SHIPPED_BARCODE else (1000 if destination == self.NON_SCAFFALATA_BARCODE else None)
|
||||
target_display = destination
|
||||
if target_id_cella is None:
|
||||
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
||||
if not resolved_cell:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
self._state.status_color = self.RED
|
||||
self._state.focus_destination = True
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
target_id_cella = int(resolved_cell.id_cella)
|
||||
target_display = resolved_cell.ubicazione or destination
|
||||
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
current_id_cella = int((current_location or {}).get("IDCella") or 0)
|
||||
except Exception:
|
||||
current_id_cella = 0
|
||||
|
||||
if current_id_cella != target_id_cella:
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE RECOVERY NOT_CONFIRMED "
|
||||
f"pallet={pallet} "
|
||||
f"destination={destination} "
|
||||
f"expected_cell={target_id_cella} "
|
||||
f"actual_cell={current_id_cella}"
|
||||
),
|
||||
)
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = destination
|
||||
self._state.status_text = "Transazione non completata, ripeti l'operazione."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
last_priority_state = self._current_priority_state
|
||||
is_recovered_picking = bool(destination == self.SHIPPED_BARCODE and last_priority_state in (0, 1))
|
||||
auto_advance_delay_ms = 3000 if is_recovered_picking else 5000
|
||||
state = await self._build_post_move_state(
|
||||
barcode_pallet=pallet,
|
||||
destination_barcode=destination,
|
||||
destination_display=target_display,
|
||||
last_priority_state=last_priority_state,
|
||||
auto_advance_delay_ms=auto_advance_delay_ms,
|
||||
)
|
||||
state.status_text = (
|
||||
"Ok Scarico - risposta persa recuperata"
|
||||
if is_recovered_picking
|
||||
else "Movimento completato - risposta persa recuperata"
|
||||
)
|
||||
state.status_color = self.GREEN_YELLOW
|
||||
self._state = state
|
||||
log_runtime_event(
|
||||
"Barcode WMS",
|
||||
(
|
||||
"MOVE RECOVERY CONFIRMED "
|
||||
f"pallet={pallet} "
|
||||
f"destination={destination} "
|
||||
f"cell={target_id_cella}"
|
||||
),
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def _build_post_move_state(
|
||||
self,
|
||||
*,
|
||||
|
||||
256
comandi_git_per_installare.txt
Normal file
256
comandi_git_per_installare.txt
Normal file
@@ -0,0 +1,256 @@
|
||||
# Prontuario Git per installare/aggiornare Warehouse da remoto
|
||||
|
||||
Repository Gitea:
|
||||
|
||||
https://gitea.alessandrobonvicini.it/administrator/ware_house.git
|
||||
|
||||
Cartella consigliata sul PC di produzione:
|
||||
|
||||
C:\flywms
|
||||
|
||||
Ramo principale da usare in produzione:
|
||||
|
||||
main
|
||||
|
||||
Ultimo tag stabile al momento della stesura:
|
||||
|
||||
alpha7-stabilizzazione-non-scaffalate
|
||||
|
||||
|
||||
1. Prima installazione su PC nuovo
|
||||
----------------------------------
|
||||
|
||||
Aprire PowerShell nella macchina di produzione ed eseguire:
|
||||
|
||||
cd C:\
|
||||
git clone https://gitea.alessandrobonvicini.it/administrator/ware_house.git C:\flywms
|
||||
cd C:\flywms
|
||||
git switch main
|
||||
git pull origin main
|
||||
|
||||
Installare le dipendenze Python:
|
||||
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
Avvio applicazione desktop:
|
||||
|
||||
python main.py
|
||||
|
||||
Oppure senza finestra console:
|
||||
|
||||
pythonw warehouse.pyw
|
||||
|
||||
Avvio applicazione barcode:
|
||||
|
||||
python barcode_client.py
|
||||
|
||||
Oppure senza finestra console:
|
||||
|
||||
pythonw barcode.pyw
|
||||
|
||||
|
||||
2. Aggiornare un'installazione gia' esistente
|
||||
--------------------------------------------
|
||||
|
||||
Sul PC di produzione:
|
||||
|
||||
cd C:\flywms
|
||||
git fetch --all --tags
|
||||
git switch main
|
||||
git pull origin main
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
Poi rilanciare l'applicazione.
|
||||
|
||||
|
||||
2.bis Aggiornare produzione dopo merge su main gia' fatto
|
||||
---------------------------------------------------------
|
||||
|
||||
Questo e' il caso piu' normale:
|
||||
|
||||
- sul PC di sviluppo hai gia' fatto merge del ramo di lavoro dentro main;
|
||||
- hai gia' fatto push su Gitea;
|
||||
- sul PC di produzione devi solo scaricare l'ultima versione ufficiale.
|
||||
|
||||
Sul PC di produzione eseguire:
|
||||
|
||||
cd C:\flywms
|
||||
git fetch --all --tags
|
||||
git switch main
|
||||
git pull origin main
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
Poi chiudere e riaprire l'applicazione.
|
||||
|
||||
Controllo consigliato dopo l'aggiornamento:
|
||||
|
||||
git log --oneline --decorate -3
|
||||
git describe --tags --abbrev=0 main
|
||||
|
||||
|
||||
3. Controllare che versione/tag si sta usando
|
||||
---------------------------------------------
|
||||
|
||||
Dentro C:\flywms:
|
||||
|
||||
git status
|
||||
git log --oneline --decorate -5
|
||||
|
||||
Vedere l'ultimo tag raggiungibile da main:
|
||||
|
||||
git describe --tags --abbrev=0 main
|
||||
|
||||
Vedere tutti i tag, dal piu' recente:
|
||||
|
||||
git tag --sort=-creatordate
|
||||
|
||||
Vedere graficamente branch, commit e tag:
|
||||
|
||||
git log --oneline --decorate --graph --all -20
|
||||
|
||||
|
||||
4. Installare esattamente una versione taggata
|
||||
---------------------------------------------
|
||||
|
||||
Usare questa modalita' quando si vuole installare una fotografia precisa e non
|
||||
necessariamente l'ultima versione di main.
|
||||
|
||||
Esempio:
|
||||
|
||||
cd C:\
|
||||
git clone --branch alpha7-stabilizzazione-non-scaffalate https://gitea.alessandrobonvicini.it/administrator/ware_house.git C:\flywms_alpha7
|
||||
|
||||
Nota:
|
||||
|
||||
Un tag e' una fotografia ferma. Non avanza con git pull come un branch.
|
||||
Per produzione ordinaria e' piu' comodo usare main.
|
||||
|
||||
|
||||
5. Portare l'ultimo sviluppo dentro main
|
||||
---------------------------------------
|
||||
|
||||
Da fare sulla macchina di sviluppo, non sul PC di produzione.
|
||||
|
||||
Se l'ultima versione buona e' su sviluppo3 e vuoi renderla ufficiale su main:
|
||||
|
||||
cd C:\devel\python\ware_house
|
||||
git fetch --all --tags
|
||||
git status
|
||||
git switch main
|
||||
git pull origin main
|
||||
git merge sviluppo3
|
||||
git push origin main
|
||||
|
||||
Se vuoi anche creare un tag stabile:
|
||||
|
||||
git tag nome-del-tag
|
||||
git push origin nome-del-tag
|
||||
|
||||
Esempio:
|
||||
|
||||
git tag alpha8-nome-breve-della-modifica
|
||||
git push origin alpha8-nome-breve-della-modifica
|
||||
|
||||
|
||||
6. Se il PC di produzione ha modifiche locali
|
||||
---------------------------------------------
|
||||
|
||||
Prima di aggiornare controllare:
|
||||
|
||||
cd C:\flywms
|
||||
git status
|
||||
|
||||
Se compaiono file modificati che non devono essere conservati, NON fare comandi
|
||||
distruttivi senza sapere cosa sono. Prima copiare o rinominare i file modificati.
|
||||
|
||||
File che normalmente NON devono essere messi nel repository:
|
||||
|
||||
db_connection.json
|
||||
*.log
|
||||
__pycache__
|
||||
*.pyc
|
||||
*.zip
|
||||
|
||||
|
||||
7. Script SQL
|
||||
-------------
|
||||
|
||||
Gli script SQL sono nel repository e vanno lanciati in SSMS solo quando serve
|
||||
preparare o aggiornare il database per le funzioni Python.
|
||||
|
||||
Patch principali:
|
||||
|
||||
apply_python_parallel_pickinglist_patch.sql
|
||||
apply_python_pickinglist_history_views.sql
|
||||
apply_online_history_forms_patch.sql
|
||||
|
||||
Rollback principali:
|
||||
|
||||
rollback_python_parallel_pickinglist_patch.sql
|
||||
rollback_python_pickinglist_history_views.sql
|
||||
rollback_online_history_forms_patch.sql
|
||||
|
||||
Nota:
|
||||
|
||||
Prima di lanciare patch SQL in produzione, fare sempre backup o snapshot del
|
||||
database, oppure verificare di avere una procedura di rollback sicura.
|
||||
|
||||
|
||||
8. Comando rapido piu' usato
|
||||
----------------------------
|
||||
|
||||
Aggiornamento standard del PC di produzione:
|
||||
|
||||
cd C:\flywms
|
||||
git fetch --all --tags
|
||||
git switch main
|
||||
git pull origin main
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
|
||||
9. Per vedere cosa ho installato
|
||||
------------------------------------------------------
|
||||
git log --oneline --decorate -3
|
||||
git describe --tags --abbrev=0 main
|
||||
|
||||
|
||||
10. Salvare questo prontuario su Gitea
|
||||
-------------------------------------
|
||||
|
||||
Da fare sul PC di sviluppo, dentro la cartella del repository:
|
||||
|
||||
cd C:\devel\python\ware_house
|
||||
git status
|
||||
git add comandi_git_per_installare.txt
|
||||
git commit -m "Aggiungi prontuario Git per installazione remota"
|
||||
git push origin main
|
||||
|
||||
Dopo il push, il file sara' disponibile anche sui PC di produzione al prossimo:
|
||||
|
||||
cd C:\flywms
|
||||
git pull origin main
|
||||
|
||||
|
||||
11. Aggiornare il prontuario se lo modifico in locale
|
||||
----------------------------------------------------
|
||||
|
||||
Se modifichi questo file sul PC di sviluppo e vuoi sincronizzarlo su Gitea:
|
||||
|
||||
cd C:\devel\python\ware_house
|
||||
git status
|
||||
git diff -- comandi_git_per_installare.txt
|
||||
git add comandi_git_per_installare.txt
|
||||
git commit -m "Aggiorna prontuario Git installazione"
|
||||
git push origin main
|
||||
|
||||
Se invece lo hai modificato su un PC di produzione e vuoi prima recuperare
|
||||
eventuali aggiornamenti online:
|
||||
|
||||
cd C:\flywms
|
||||
git status
|
||||
git pull origin main
|
||||
|
||||
Se Git segnala conflitti, fermarsi e risolverli prima di rilanciare
|
||||
l'applicazione. Per evitare confusione, e' meglio modificare questo prontuario
|
||||
solo sul PC di sviluppo e poi fare push su Gitea.
|
||||
@@ -19,6 +19,7 @@ from typing import Any, Callable, Optional
|
||||
import customtkinter as ctk
|
||||
|
||||
from async_loop_singleton import get_global_loop
|
||||
from runtime_support import log_exception
|
||||
from version_info import module_version
|
||||
|
||||
__version__ = module_version(__name__)
|
||||
@@ -128,21 +129,53 @@ class AsyncRunner:
|
||||
busy.show(message)
|
||||
fut = asyncio.run_coroutine_threadsafe(awaitable, self.loop)
|
||||
|
||||
def _widget_alive() -> bool:
|
||||
try:
|
||||
return bool(self.widget.winfo_exists())
|
||||
except tk.TclError:
|
||||
return False
|
||||
|
||||
def _dispatch_success(res: Any) -> None:
|
||||
try:
|
||||
on_success(res)
|
||||
except BaseException as ex:
|
||||
log_exception(__name__, ex, context="AsyncRunner on_success")
|
||||
|
||||
def _dispatch_error(ex: BaseException) -> None:
|
||||
if on_error:
|
||||
try:
|
||||
on_error(ex)
|
||||
except BaseException as callback_ex:
|
||||
log_exception(__name__, callback_ex, context="AsyncRunner on_error")
|
||||
else:
|
||||
log_exception(__name__, ex, context="AsyncRunner unhandled error")
|
||||
|
||||
def _poll():
|
||||
if not _widget_alive():
|
||||
return
|
||||
if fut.done():
|
||||
if busy:
|
||||
try:
|
||||
busy.hide()
|
||||
except Exception as ex:
|
||||
log_exception(__name__, ex, context="AsyncRunner hide busy")
|
||||
try:
|
||||
res = fut.result()
|
||||
except BaseException as ex:
|
||||
if on_error:
|
||||
self.widget.after(0, lambda e=ex: on_error(e))
|
||||
try:
|
||||
self.widget.after(0, lambda e=ex: _dispatch_error(e))
|
||||
except tk.TclError:
|
||||
log_exception(__name__, ex, context="AsyncRunner error after destroyed")
|
||||
else:
|
||||
print("[AsyncRunner] Unhandled error:", repr(ex))
|
||||
else:
|
||||
self.widget.after(0, lambda r=res: on_success(r))
|
||||
try:
|
||||
self.widget.after(0, lambda r=res: _dispatch_success(r))
|
||||
except tk.TclError as ex:
|
||||
log_exception(__name__, ex, context="AsyncRunner success after destroyed")
|
||||
else:
|
||||
try:
|
||||
self.widget.after(60, _poll)
|
||||
except tk.TclError:
|
||||
return
|
||||
|
||||
_poll()
|
||||
|
||||
|
||||
@@ -681,27 +681,7 @@ class LayoutWindow(ctk.CTkToplevel):
|
||||
if stato <= 0:
|
||||
self._toast("La cella selezionata non contiene alcuna UDC da scaricare.")
|
||||
return
|
||||
if stato >= 2:
|
||||
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()
|
||||
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_LOGGING_CONFIGURED = False
|
||||
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:
|
||||
@@ -231,6 +237,7 @@ SELECT
|
||||
cp.BarcodePallet AS UDC,
|
||||
lm.ID AS SourceID,
|
||||
lm.DataMagazzino AS LastEventAt,
|
||||
ISNULL(la.IDCella, :idcella) AS CurrentIDCella,
|
||||
CASE
|
||||
WHEN shipped.BarcodePallet IS NOT NULL THEN CAST(1 AS int)
|
||||
ELSE CAST(0 AS int)
|
||||
@@ -413,6 +420,7 @@ class ScaricoRow:
|
||||
udc: str
|
||||
source_id: int | None
|
||||
last_event_at: str
|
||||
current_idcella: int
|
||||
diagnostic_note: str
|
||||
selected: tk.BooleanVar
|
||||
|
||||
@@ -546,19 +554,27 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
actions.grid_columnconfigure(0, weight=1)
|
||||
ctk.CTkButton(
|
||||
actions,
|
||||
text=loc_text("scarico.button.submit", catalog=self._locale_catalog, default="Scarica"),
|
||||
command=self._on_scarica,
|
||||
text=loc_text("scarico.button.shipped", catalog=self._locale_catalog, default="Scarico come spedita"),
|
||||
command=self._on_scarica_spedita,
|
||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(
|
||||
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(
|
||||
actions,
|
||||
text=loc_text("scarico.button.close", catalog=self._locale_catalog, default="Chiudi"),
|
||||
command=self._close,
|
||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(
|
||||
row=0, column=2, padx=(8, 8), pady=8
|
||||
row=0, column=3, padx=(8, 8), pady=8
|
||||
)
|
||||
|
||||
def _render_rows(self):
|
||||
@@ -617,7 +633,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
rows = res.get("rows", []) if isinstance(res, dict) else []
|
||||
_log_dataset("scarico_load_rows", 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):
|
||||
last_event = last_event_at.strftime("%d/%m/%Y %H:%M:%S")
|
||||
else:
|
||||
@@ -627,6 +643,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
udc=str(udc or ""),
|
||||
source_id=int(source_id) if source_id is not None else None,
|
||||
last_event_at=last_event,
|
||||
current_idcella=int(current_idcella or 0),
|
||||
diagnostic_note=_build_diagnostic_note(is_shipped, is_moved),
|
||||
selected=tk.BooleanVar(value=False),
|
||||
)
|
||||
@@ -653,8 +670,9 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
)
|
||||
|
||||
@_log_call()
|
||||
def _on_scarica(self):
|
||||
"""Unload the UDCs selected by the user from the current cell."""
|
||||
def _selected_rows_or_warn(self) -> list[ScaricoRow] | None:
|
||||
"""Return selected rows or show the standard selection warning."""
|
||||
|
||||
selected = [row for row in self.rows if row.selected.get()]
|
||||
if not selected:
|
||||
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."),
|
||||
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
|
||||
|
||||
if not messagebox.askyesno(
|
||||
"Conferma scarico",
|
||||
f"Scaricare {len(selected)} UDC da {self.ubicazione}?",
|
||||
title,
|
||||
confirm_text.format(count=len(movable_rows), ubicazione=self.ubicazione),
|
||||
parent=self,
|
||||
):
|
||||
return
|
||||
|
||||
async def _job():
|
||||
results: list[dict[str, Any]] = []
|
||||
for row in selected:
|
||||
for row in movable_rows:
|
||||
result = await move_pallet_async(
|
||||
self.db_client,
|
||||
barcode_pallet=row.udc,
|
||||
target_idcella=9999,
|
||||
target_barcode_cella="9000000",
|
||||
target_idcella=target_idcella,
|
||||
target_barcode_cella=target_barcode_cella,
|
||||
utente=_session_login(self.session),
|
||||
)
|
||||
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]
|
||||
if not done:
|
||||
messagebox.showwarning(
|
||||
"Scarica",
|
||||
title,
|
||||
"Nessuna UDC e' stata scaricata. Verifica che le unita' siano ancora presenti in cella.",
|
||||
parent=self,
|
||||
)
|
||||
return
|
||||
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(
|
||||
"Scarica",
|
||||
title,
|
||||
"Scarico parziale.\nCompletate: "
|
||||
+ ", ".join(done)
|
||||
+ "\nNon scaricate: "
|
||||
+ ", ".join(skipped),
|
||||
+ ", ".join(skipped)
|
||||
+ shipped_note
|
||||
+ target_note,
|
||||
parent=self,
|
||||
)
|
||||
else:
|
||||
messagebox.showinfo(
|
||||
"Scarica",
|
||||
"Scarico completato per:\n" + "\n".join(done),
|
||||
parent=self,
|
||||
)
|
||||
msg = f"Scarico completato verso {target_label} per:\n" + "\n".join(done)
|
||||
if shipped_rows:
|
||||
msg += f"\n\nUDC gia' in {SHIPPED_LABEL} non toccate:\n" + "\n".join(row.udc for row in shipped_rows)
|
||||
msg += f"\n\nUDC in {target_label}: " + ", ".join(done)
|
||||
messagebox.showinfo(title, msg, parent=self)
|
||||
log_user_action(
|
||||
self.session,
|
||||
module=MODULE_LOG_NAME,
|
||||
action="layout.scarico",
|
||||
action="layout.scarico.spedita" if int(target_idcella) == SHIPPED_IDCELLA else "layout.scarico.non_scaff",
|
||||
outcome="ok",
|
||||
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:
|
||||
self.on_completed()
|
||||
@@ -727,7 +828,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
log_user_action(
|
||||
self.session,
|
||||
module=MODULE_LOG_NAME,
|
||||
action="layout.scarico",
|
||||
action="layout.scarico.spedita" if int(target_idcella) == SHIPPED_IDCELLA else "layout.scarico.non_scaff",
|
||||
outcome="error",
|
||||
target=self.ubicazione,
|
||||
details={"error": str(ex)},
|
||||
@@ -743,7 +844,7 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
_ok,
|
||||
_err,
|
||||
busy=self._busy,
|
||||
message="Scarico UDC...",
|
||||
message=busy_message,
|
||||
)
|
||||
|
||||
@_log_call()
|
||||
|
||||
@@ -107,6 +107,8 @@
|
||||
"scarico.col.last_insert": "Ultimo inserimento",
|
||||
"scarico.col.diagnostic": "Diagnostica",
|
||||
"scarico.button.submit": "Scarica",
|
||||
"scarico.button.shipped": "Scarico come spedita",
|
||||
"scarico.button.non_shelved": "Scarico come non scaff.",
|
||||
"scarico.button.close": "Chiudi",
|
||||
"scarico.msg.title": "Scarica",
|
||||
"scarico.msg.select_one": "Seleziona almeno una UDC da scaricare.",
|
||||
@@ -220,6 +222,8 @@
|
||||
"scarico.col.last_insert": "Last insert",
|
||||
"scarico.col.diagnostic": "Diagnostics",
|
||||
"scarico.button.submit": "Unload",
|
||||
"scarico.button.shipped": "Unload as shipped",
|
||||
"scarico.button.non_shelved": "Unload as non-shelved",
|
||||
"scarico.button.close": "Close",
|
||||
"scarico.msg.title": "Unload",
|
||||
"scarico.msg.select_one": "Select at least one UDC to unload.",
|
||||
|
||||
9
rollback_barcode_picking_skip_patch.sql
Normal file
9
rollback_barcode_picking_skip_patch.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
SET XACT_ABORT ON;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
IF OBJECT_ID(N'dbo.py_BarcodePickingListSkip', N'U') IS NOT NULL
|
||||
BEGIN
|
||||
DROP TABLE dbo.py_BarcodePickingListSkip;
|
||||
END;
|
||||
|
||||
COMMIT TRANSACTION;
|
||||
@@ -11,6 +11,7 @@ import customtkinter as ctk
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from gestione_aree import AsyncRunner
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from runtime_support import log_exception
|
||||
from ui_tables import style_treeview, zebra_tag
|
||||
from ui_theme import theme_color, theme_font, theme_section, theme_value
|
||||
from version_info import module_version, versioned_title
|
||||
@@ -20,7 +21,7 @@ __version__ = module_version(__name__)
|
||||
|
||||
|
||||
SQL_NON_SCAFFALATE = """
|
||||
WITH trace AS (
|
||||
WITH trace_rows AS (
|
||||
SELECT
|
||||
Pallet,
|
||||
MIN(Lotto) AS Lotto,
|
||||
@@ -39,7 +40,7 @@ SELECT
|
||||
FROM dbo.XMag_GiacenzaPallet AS g
|
||||
LEFT JOIN dbo.Celle AS c
|
||||
ON c.ID = g.IDCella
|
||||
LEFT JOIN trace AS t
|
||||
LEFT JOIN trace_rows AS t
|
||||
ON t.Pallet COLLATE Latin1_General_CI_AS =
|
||||
g.BarcodePallet COLLATE Latin1_General_CI_AS
|
||||
WHERE g.IDCella = 1000
|
||||
@@ -72,6 +73,7 @@ class UDCNonScaffalateWindow(ctk.CTkToplevel):
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self._async = AsyncRunner(self)
|
||||
self._busy = InlineBusyOverlay(self, self._theme)
|
||||
self._load_in_progress = False
|
||||
|
||||
self.title(versioned_title(loc_text("non_shelved.title", catalog=self._locale_catalog, default="UDC non scaffalate"), __name__))
|
||||
self.geometry(str(theme_value(self._theme, "window_geometry", "1000x650")))
|
||||
@@ -85,6 +87,18 @@ class UDCNonScaffalateWindow(ctk.CTkToplevel):
|
||||
self._build_ui()
|
||||
self.after(250, self._load)
|
||||
|
||||
def _is_alive(self) -> bool:
|
||||
try:
|
||||
return bool(self.winfo_exists())
|
||||
except tk.TclError:
|
||||
return False
|
||||
|
||||
def _hide_busy_safe(self) -> None:
|
||||
try:
|
||||
self._busy.hide()
|
||||
except Exception as exc:
|
||||
log_exception(__name__, exc, context="hide busy UDC non scaffalate")
|
||||
|
||||
def _build_ui(self) -> None:
|
||||
self.grid_rowconfigure(1, weight=1)
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
@@ -145,14 +159,32 @@ class UDCNonScaffalateWindow(ctk.CTkToplevel):
|
||||
sx.grid(row=1, column=0, sticky="ew")
|
||||
|
||||
def _load(self) -> None:
|
||||
if self._load_in_progress or not self._is_alive():
|
||||
return
|
||||
|
||||
async def job():
|
||||
return await self.db_client.query_json(SQL_NON_SCAFFALATE, as_dict_rows=True)
|
||||
|
||||
self._load_in_progress = True
|
||||
try:
|
||||
self._busy.show(loc_text("non_shelved.busy", catalog=self._locale_catalog, default="Carico UDC non scaffalate..."))
|
||||
self._async.run(job(), self._on_loaded, self._on_error)
|
||||
except Exception as exc:
|
||||
self._load_in_progress = False
|
||||
self._hide_busy_safe()
|
||||
log_exception(__name__, exc, context="avvio caricamento UDC non scaffalate")
|
||||
messagebox.showerror(
|
||||
loc_text("non_shelved.title", catalog=self._locale_catalog, default="UDC non scaffalate"),
|
||||
str(exc),
|
||||
parent=self if self._is_alive() else None,
|
||||
)
|
||||
|
||||
def _on_loaded(self, res: dict[str, Any] | None) -> None:
|
||||
self._busy.hide()
|
||||
self._load_in_progress = False
|
||||
self._hide_busy_safe()
|
||||
if not self._is_alive():
|
||||
return
|
||||
try:
|
||||
rows = _rows_to_dicts(res)
|
||||
self.tree.delete(*self.tree.get_children(""))
|
||||
for index, row in enumerate(rows):
|
||||
@@ -169,9 +201,20 @@ class UDCNonScaffalateWindow(ctk.CTkToplevel):
|
||||
),
|
||||
tags=(zebra_tag(index),),
|
||||
)
|
||||
except Exception as exc:
|
||||
log_exception(__name__, exc, context="render UDC non scaffalate")
|
||||
messagebox.showerror(
|
||||
loc_text("non_shelved.title", catalog=self._locale_catalog, default="UDC non scaffalate"),
|
||||
str(exc),
|
||||
parent=self,
|
||||
)
|
||||
|
||||
def _on_error(self, exc: BaseException) -> None:
|
||||
self._busy.hide()
|
||||
self._load_in_progress = False
|
||||
self._hide_busy_safe()
|
||||
log_exception(__name__, exc, context="query UDC non scaffalate")
|
||||
if not self._is_alive():
|
||||
return
|
||||
messagebox.showerror(
|
||||
loc_text("non_shelved.title", catalog=self._locale_catalog, default="UDC non scaffalate"),
|
||||
str(exc),
|
||||
@@ -183,5 +226,5 @@ def open_udc_non_scaffalate_window(parent: tk.Misc, db_client, session=None) ->
|
||||
"""Open the non-shelved UDC window."""
|
||||
|
||||
win = UDCNonScaffalateWindow(parent, db_client, session=session)
|
||||
place_window_fullsize_below_parent_later(win, parent)
|
||||
place_window_fullsize_below_parent_later(parent, win)
|
||||
return win
|
||||
|
||||
@@ -13,15 +13,15 @@ MODULE_VERSIONS: dict[str, str] = {
|
||||
"async_msssql_query": "1.0.0",
|
||||
"audit_log": "1.0.0",
|
||||
"main": "1.0.1",
|
||||
"barcode_client": "1.0.10",
|
||||
"barcode_repository": "1.0.3",
|
||||
"barcode_service": "1.0.7",
|
||||
"barcode_client": "1.0.20",
|
||||
"barcode_repository": "1.0.6",
|
||||
"barcode_service": "1.0.16",
|
||||
"busy_overlay": "1.0.0",
|
||||
"db_config": "1.0.0",
|
||||
"gestione_aree": "1.0.0",
|
||||
"gestione_layout": "1.0.0",
|
||||
"gestione_aree": "1.0.1",
|
||||
"gestione_layout": "1.0.1",
|
||||
"gestione_pickinglist": "1.0.2",
|
||||
"gestione_scarico": "1.0.0",
|
||||
"gestione_scarico": "1.0.1",
|
||||
"locale_text": "1.0.0",
|
||||
"login_window": "1.0.0",
|
||||
"prenota_sprenota_sql": "1.0.0",
|
||||
@@ -31,7 +31,7 @@ MODULE_VERSIONS: dict[str, str] = {
|
||||
"storico_pickinglist": "1.0.3",
|
||||
"storico_udc": "1.0.0",
|
||||
"tooltips": "1.0.0",
|
||||
"udc_non_scaffalate": "1.0.0",
|
||||
"udc_non_scaffalate": "1.0.1",
|
||||
"ui_theme": "1.0.0",
|
||||
"user_session": "1.0.0",
|
||||
"view_celle_multi_udc": "1.0.0",
|
||||
|
||||
Reference in New Issue
Block a user