Compare commits
3 Commits
alpha8-pau
...
alpha11-sa
| Author | SHA1 | Date | |
|---|---|---|---|
| d4cfe0be54 | |||
| f4e73bd5b9 | |||
| e575c748cc |
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;
|
||||||
@@ -388,6 +388,10 @@ class BarcodeClientApp:
|
|||||||
self.btn_submit.configure(text="[F3] Pausa PL")
|
self.btn_submit.configure(text="[F3] Pausa PL")
|
||||||
else:
|
else:
|
||||||
self.btn_submit.configure(text="[F3] Carica")
|
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"
|
queue_buttons_state = "disabled" if str(state.queue_label or "") == "Pausa PL" else "normal"
|
||||||
self.btn_f1.configure(state=queue_buttons_state)
|
self.btn_f1.configure(state=queue_buttons_state)
|
||||||
self.btn_f2.configure(state=queue_buttons_state)
|
self.btn_f2.configure(state=queue_buttons_state)
|
||||||
@@ -410,7 +414,10 @@ class BarcodeClientApp:
|
|||||||
lambda q=next_queue: self._start_queue(q),
|
lambda q=next_queue: self._start_queue(q),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.root.after(20, self._focus_primary_input)
|
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:
|
def _focus_primary_input(self) -> None:
|
||||||
try:
|
try:
|
||||||
@@ -499,9 +506,8 @@ class BarcodeClientApp:
|
|||||||
pallet = str(self.scanned_var.get() or "").strip()
|
pallet = str(self.scanned_var.get() or "").strip()
|
||||||
destination = str(self.destination_var.get() or "").strip()
|
destination = str(self.destination_var.get() or "").strip()
|
||||||
mode = getattr(self.service.state, "mode", "")
|
mode = getattr(self.service.state, "mode", "")
|
||||||
if pallet and mode in ("priority_high", "priority_low") and destination == self.SHIPPED_BARCODE:
|
if mode in ("priority_high", "priority_low"):
|
||||||
# Legacy barcode flow: F4/Scarica confirms the prepared unload destination.
|
self._skip_current_picking_pallet()
|
||||||
self._submit()
|
|
||||||
return
|
return
|
||||||
if pallet:
|
if pallet:
|
||||||
self._submit_unload_with_source_check()
|
self._submit_unload_with_source_check()
|
||||||
@@ -536,6 +542,12 @@ class BarcodeClientApp:
|
|||||||
busy_message="In esecuzione...",
|
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:
|
def _run_async(self, coro_factory: Callable[[], object], busy_message: str) -> None:
|
||||||
if self._pending is not None and not self._pending.done():
|
if self._pending is not None and not self._pending.done():
|
||||||
return
|
return
|
||||||
@@ -578,17 +590,15 @@ class BarcodeClientApp:
|
|||||||
result = future.result()
|
result = future.result()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
log_exception("Barcode WMS", exc, context="barcode async operation")
|
log_exception("Barcode WMS", exc, context="barcode async operation")
|
||||||
current = self.service.state
|
self._set_busy(True, "Verifico esito...")
|
||||||
current.status_text = "Transazione non completata, ripeti l'operazione."
|
self._pending = asyncio.run_coroutine_threadsafe(
|
||||||
current.status_color = "#f4cccc"
|
self.service.reconcile_after_submit_exception(
|
||||||
self._apply_state(current)
|
scanned_pallet=self.scanned_var.get(),
|
||||||
messagebox.showerror(
|
destination_barcode=self.destination_var.get(),
|
||||||
"Barcode WMS",
|
),
|
||||||
"Operazione non completata.\n\n"
|
self.loop,
|
||||||
"Ripeti la lettura o avvisa il responsabile.\n"
|
|
||||||
"Il dettaglio tecnico e' stato scritto nel log.",
|
|
||||||
parent=self.root,
|
|
||||||
)
|
)
|
||||||
|
self.root.after(40, lambda err=exc: self._poll_recovery_future(err))
|
||||||
return
|
return
|
||||||
|
|
||||||
if isinstance(result, BarcodeActionResult):
|
if isinstance(result, BarcodeActionResult):
|
||||||
@@ -598,6 +608,46 @@ class BarcodeClientApp:
|
|||||||
elif isinstance(result, BarcodeViewState):
|
elif isinstance(result, BarcodeViewState):
|
||||||
self._apply_state(result)
|
self._apply_state(result)
|
||||||
|
|
||||||
|
def _show_transaction_error(self) -> None:
|
||||||
|
messagebox.showerror(
|
||||||
|
"Barcode WMS",
|
||||||
|
"Operazione non completata.\n\n"
|
||||||
|
"Ripeti la lettura o avvisa il responsabile.\n"
|
||||||
|
"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 not result.ok:
|
||||||
|
self.root.bell()
|
||||||
|
self._show_transaction_error()
|
||||||
|
elif isinstance(result, BarcodeViewState):
|
||||||
|
self._apply_state(result)
|
||||||
|
|
||||||
def _shutdown(self) -> None:
|
def _shutdown(self) -> None:
|
||||||
try:
|
try:
|
||||||
if self._pending is not None and not self._pending.done():
|
if self._pending is not None and not self._pending.done():
|
||||||
|
|||||||
@@ -26,9 +26,17 @@ SELECT TOP (1)
|
|||||||
Ubicazione,
|
Ubicazione,
|
||||||
Ordinamento,
|
Ordinamento,
|
||||||
IDStato
|
IDStato
|
||||||
FROM dbo.py_XMag_ViewPackingList
|
FROM dbo.py_XMag_ViewPackingList AS pl
|
||||||
WHERE Ordinamento > 0
|
WHERE Ordinamento > 0
|
||||||
AND IDStato = :id_stato
|
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;
|
ORDER BY Ordinamento;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -86,6 +94,15 @@ WHERE g.BarcodePallet = :pallet
|
|||||||
ORDER BY g.IDCella;
|
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 = """
|
SQL_RESOLVE_PHYSICAL_CELL = """
|
||||||
DECLARE @raw int = TRY_CONVERT(int, :destination);
|
DECLARE @raw int = TRY_CONVERT(int, :destination);
|
||||||
DECLARE @cell_id int =
|
DECLARE @cell_id int =
|
||||||
@@ -127,6 +144,44 @@ SELECT
|
|||||||
:numero_cella AS NumeroCella;
|
: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]]:
|
def _rows_to_dicts(res: dict[str, Any] | None) -> list[dict[str, Any]]:
|
||||||
"""Convert ``query_json`` payloads to a list of row dictionaries."""
|
"""Convert ``query_json`` payloads to a list of row dictionaries."""
|
||||||
@@ -204,6 +259,51 @@ class BarcodeRepository:
|
|||||||
res = await self.db_client.query_json(SQL_OPEN_LOCATIONS_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
res = await self.db_client.query_json(SQL_OPEN_LOCATIONS_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
||||||
return _rows_to_dicts(res)
|
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:
|
async def resolve_physical_cell(self, destination: str) -> DestinationCell | None:
|
||||||
"""Accept either an internal cell ID or the scanned legacy cell barcode."""
|
"""Accept either an internal cell ID or the scanned legacy cell barcode."""
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class BarcodeViewState:
|
|||||||
scanned_pallet: str = ""
|
scanned_pallet: str = ""
|
||||||
auto_advance_delay_ms: int = 0
|
auto_advance_delay_ms: int = 0
|
||||||
destination_readonly: bool = False
|
destination_readonly: bool = False
|
||||||
|
focus_destination: bool = False
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -114,6 +115,44 @@ class BarcodeService:
|
|||||||
)
|
)
|
||||||
return self._state
|
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:
|
async def start_priority_queue(self, id_stato: int) -> BarcodeActionResult:
|
||||||
"""Load the next item of the selected legacy priority queue."""
|
"""Load the next item of the selected legacy priority queue."""
|
||||||
|
|
||||||
@@ -176,13 +215,82 @@ class BarcodeService:
|
|||||||
self._state.status_color = self.RED
|
self._state.status_color = self.RED
|
||||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
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)
|
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||||
picking_before_move = await self.repository.fetch_picking_by_pallet(pallet)
|
picking_before_move = await self.repository.fetch_picking_by_pallet(pallet)
|
||||||
if not current_location and not picking_before_move:
|
if not current_location and not picking_before_move:
|
||||||
self._state.scanned_pallet = pallet
|
if is_direct_load:
|
||||||
self._state.status_text = "UDC non presente a magazzino."
|
trace_row = await self.repository.fetch_trace_by_pallet(pallet)
|
||||||
self._state.status_color = self.RED
|
if not trace_row:
|
||||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
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)
|
||||||
|
|
||||||
open_locations = await self.repository.fetch_open_locations_by_pallet(pallet)
|
open_locations = await self.repository.fetch_open_locations_by_pallet(pallet)
|
||||||
distinct_cells = sorted({
|
distinct_cells = sorted({
|
||||||
@@ -205,16 +313,13 @@ class BarcodeService:
|
|||||||
self._state.status_color = self.RED
|
self._state.status_color = self.RED
|
||||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||||
|
|
||||||
target_barcode = destination
|
if not is_direct_load and destination not in (self.NON_SCAFFALATA_BARCODE, self.SHIPPED_BARCODE):
|
||||||
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):
|
|
||||||
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
resolved_cell = await self.repository.resolve_physical_cell(destination)
|
||||||
if not resolved_cell:
|
if not resolved_cell:
|
||||||
self._state.scanned_pallet = pallet
|
self._state.scanned_pallet = pallet
|
||||||
self._state.status_text = f"Cella non valida: {destination}."
|
self._state.status_text = f"Cella non valida: {destination}."
|
||||||
self._state.status_color = self.RED
|
self._state.status_color = self.RED
|
||||||
|
self._state.focus_destination = True
|
||||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||||
target_barcode = resolved_cell.barcode_cella
|
target_barcode = resolved_cell.barcode_cella
|
||||||
target_numero_cella = resolved_cell.numero_cella
|
target_numero_cella = resolved_cell.numero_cella
|
||||||
@@ -346,6 +451,86 @@ class BarcodeService:
|
|||||||
|
|
||||||
return await self.submit(scanned_pallet=pallet, destination_barcode=self.NON_SCAFFALATA_BARCODE)
|
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(
|
async def _build_post_move_state(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
|||||||
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;
|
||||||
@@ -13,9 +13,9 @@ MODULE_VERSIONS: dict[str, str] = {
|
|||||||
"async_msssql_query": "1.0.0",
|
"async_msssql_query": "1.0.0",
|
||||||
"audit_log": "1.0.0",
|
"audit_log": "1.0.0",
|
||||||
"main": "1.0.1",
|
"main": "1.0.1",
|
||||||
"barcode_client": "1.0.17",
|
"barcode_client": "1.0.20",
|
||||||
"barcode_repository": "1.0.4",
|
"barcode_repository": "1.0.6",
|
||||||
"barcode_service": "1.0.13",
|
"barcode_service": "1.0.16",
|
||||||
"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",
|
||||||
|
|||||||
Reference in New Issue
Block a user