Ottimizza barcode e disattiva profiler query
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, replace
|
||||
from typing import Literal
|
||||
|
||||
from barcode_repository import BarcodeRepository, LegacyMoveResult
|
||||
@@ -115,6 +115,15 @@ class BarcodeService:
|
||||
)
|
||||
return self._state
|
||||
|
||||
def resume_priority_state(self, state: BarcodeViewState) -> BarcodeViewState:
|
||||
"""Restore the exact picking pallet that was visible before a local pause."""
|
||||
|
||||
if state.mode not in ("priority_high", "priority_low"):
|
||||
return self._state
|
||||
self._current_priority_state = 1 if state.mode == "priority_high" else 0
|
||||
self._state = replace(state, scanned_pallet="", auto_advance_delay_ms=0)
|
||||
return self._state
|
||||
|
||||
async def skip_current_picking_pallet(self) -> BarcodeActionResult:
|
||||
"""Mark the currently proposed picking pallet as skipped and advance."""
|
||||
|
||||
@@ -277,7 +286,11 @@ class BarcodeService:
|
||||
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)
|
||||
picking_before_move = (
|
||||
None
|
||||
if current_location
|
||||
else 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)
|
||||
@@ -297,6 +310,7 @@ class BarcodeService:
|
||||
barcode_cella=self.NON_SCAFFALATA_BARCODE,
|
||||
barcode_pallet=pallet,
|
||||
numero_cella=int(self.NON_SCAFFALATA_BARCODE),
|
||||
refresh_picking_reservation=False,
|
||||
)
|
||||
current_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
@@ -354,6 +368,7 @@ class BarcodeService:
|
||||
barcode_cella=target_barcode,
|
||||
barcode_pallet=pallet,
|
||||
numero_cella=target_numero_cella,
|
||||
refresh_picking_reservation=is_picking_unload,
|
||||
)
|
||||
|
||||
final_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
@@ -476,7 +491,45 @@ class BarcodeService:
|
||||
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)
|
||||
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),
|
||||
refresh_picking_reservation=False,
|
||||
)
|
||||
|
||||
final_location = await self.repository.fetch_current_location_by_pallet(pallet)
|
||||
try:
|
||||
final_cell = int((final_location or {}).get("IDCella") or 0)
|
||||
except Exception:
|
||||
final_cell = 0
|
||||
if final_cell != 1000:
|
||||
self._state.scanned_pallet = pallet
|
||||
self._state.destination_barcode = source
|
||||
self._state.status_text = "Movimento non confermato: la UDC non risulta non scaffalata."
|
||||
self._state.status_color = self.RED
|
||||
return BarcodeActionResult(False, self._state, self._state.status_text)
|
||||
|
||||
try:
|
||||
self._state = await self._build_post_move_state(
|
||||
barcode_pallet=pallet,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
destination_display=self.CONVENTIONAL_LOCATION_BY_CELL[1000],
|
||||
last_priority_state=self._current_priority_state,
|
||||
auto_advance_delay_ms=0,
|
||||
)
|
||||
except Exception as exc:
|
||||
log_exception("Barcode WMS", exc, context=f"post source-check unload pallet={pallet} source={source}")
|
||||
self._state = BarcodeViewState(
|
||||
mode="confirm",
|
||||
queue_label="Conferma movimento",
|
||||
status_text="Movimento eseguito. Dettagli non aggiornati.",
|
||||
status_color=self.GREEN_YELLOW,
|
||||
destination_barcode=self.NON_SCAFFALATA_BARCODE,
|
||||
scanned_pallet=pallet,
|
||||
)
|
||||
return BarcodeActionResult(True, self._state, self._state.status_text)
|
||||
|
||||
async def _block_closed_picking_free_move(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user