Freeze 2.0 warehouse monolista e documento fisso F1/F2
This commit is contained in:
@@ -29,6 +29,7 @@ SELECT TOP (1)
|
||||
FROM dbo.py_ViewPackingListPrelievo AS pl
|
||||
WHERE Ordinamento > 0
|
||||
AND IDStato = :id_stato
|
||||
AND (:documento IS NULL OR pl.Documento = TRY_CONVERT(int, :documento))
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.py_BarcodePickingListSkip AS s
|
||||
@@ -39,7 +40,7 @@ WHERE Ordinamento > 0
|
||||
AND s.IDStato = pl.IDStato
|
||||
AND s.Risolto = 0
|
||||
)
|
||||
ORDER BY OrdinePrelievoGruppo, Ordinamento, Pallet;
|
||||
ORDER BY OrdinePrelievoGruppo, Ordinamento, Pallet, Documento;
|
||||
"""
|
||||
|
||||
SQL_PICKING_BY_PALLET = """
|
||||
@@ -55,6 +56,7 @@ SELECT TOP (1)
|
||||
IDStato
|
||||
FROM dbo.py_ViewPackingListPrelievo
|
||||
WHERE Pallet COLLATE Latin1_General_CI_AS = :pallet COLLATE Latin1_General_CI_AS
|
||||
AND (:documento IS NULL OR Documento = TRY_CONVERT(int, :documento))
|
||||
ORDER BY OrdinePrelievoGruppo, Ordinamento, Pallet;
|
||||
"""
|
||||
|
||||
@@ -222,6 +224,7 @@ SELECT TOP (1)
|
||||
COUNT(*) AS SkippedCount
|
||||
FROM dbo.py_BarcodePickingListSkip AS s
|
||||
WHERE s.IDStato = :id_stato
|
||||
AND (:documento IS NULL OR s.Documento = :documento)
|
||||
AND s.Risolto = 0
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
@@ -229,11 +232,20 @@ WHERE s.IDStato = :id_stato
|
||||
WHERE CAST(pl.Documento AS varchar(50)) COLLATE Latin1_General_CI_AS =
|
||||
s.Documento COLLATE Latin1_General_CI_AS
|
||||
AND pl.IDStato = :id_stato
|
||||
AND CAST(pl.Pallet AS varchar(50)) COLLATE Latin1_General_CI_AS =
|
||||
s.Pallet COLLATE Latin1_General_CI_AS
|
||||
)
|
||||
GROUP BY s.Documento
|
||||
ORDER BY MIN(s.DataOra);
|
||||
"""
|
||||
|
||||
SQL_PICKING_DOCUMENT_REMAINING = """
|
||||
SELECT COUNT(DISTINCT Pallet) AS RemainingCount
|
||||
FROM dbo.py_XMag_ViewPackingListStorico
|
||||
WHERE Documento = TRY_CONVERT(int, :documento)
|
||||
AND Cella <> 9999;
|
||||
"""
|
||||
|
||||
SQL_RELEASE_PICKING_DOCUMENT = """
|
||||
SET NOCOUNT ON;
|
||||
DECLARE @RC int = 0;
|
||||
@@ -290,17 +302,21 @@ class BarcodeRepository:
|
||||
def __init__(self, db_client):
|
||||
self.db_client = db_client
|
||||
|
||||
async def fetch_next_picking(self, id_stato: int) -> dict[str, Any] | None:
|
||||
"""Return the next pallet proposed by the legacy F1/F2 queue logic."""
|
||||
async def fetch_next_picking(self, id_stato: int, documento: str | None = None) -> dict[str, Any] | None:
|
||||
"""Select a document initially, then fetch only within that document."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_NEXT_PICKING, {"id_stato": int(id_stato)})
|
||||
res = await self.db_client.query_json(SQL_NEXT_PICKING, {
|
||||
"id_stato": int(id_stato), "documento": documento,
|
||||
})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def fetch_picking_by_pallet(self, pallet: str) -> dict[str, Any] | None:
|
||||
async def fetch_picking_by_pallet(self, pallet: str, documento: str | None = None) -> dict[str, Any] | None:
|
||||
"""Return one picking row for the given pallet, if still present in the queue."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_PICKING_BY_PALLET, {"pallet": str(pallet or "").strip()})
|
||||
res = await self.db_client.query_json(SQL_PICKING_BY_PALLET, {
|
||||
"pallet": str(pallet or "").strip(), "documento": documento,
|
||||
})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
@@ -376,13 +392,21 @@ class BarcodeRepository:
|
||||
),
|
||||
)
|
||||
|
||||
async def fetch_active_skipped_document(self, id_stato: int) -> dict[str, Any] | None:
|
||||
"""Return a reserved document whose remaining pallets were all skipped."""
|
||||
async def fetch_active_skipped_document(self, id_stato: int, documento: str | None = None) -> dict[str, Any] | None:
|
||||
"""Find skipped residuals, restricted to the active document when set."""
|
||||
|
||||
res = await self.db_client.query_json(SQL_ACTIVE_SKIPPED_DOCUMENT, {"id_stato": int(id_stato)})
|
||||
res = await self.db_client.query_json(SQL_ACTIVE_SKIPPED_DOCUMENT, {
|
||||
"id_stato": int(id_stato), "documento": documento,
|
||||
})
|
||||
rows = _rows_to_dicts(res)
|
||||
return rows[0] if rows else None
|
||||
|
||||
async def count_picking_document_remaining(self, documento: str) -> int:
|
||||
"""Check residuals independently of priority before declaring completion."""
|
||||
res = await self.db_client.query_json(SQL_PICKING_DOCUMENT_REMAINING, {"documento": documento})
|
||||
rows = _rows_to_dicts(res)
|
||||
return int(rows[0]["RemainingCount"]) if rows else 0
|
||||
|
||||
async def release_picking_document(self, *, documento: str, operator_id: int) -> int:
|
||||
"""Release a reserved picking-list document without closing its residual rows."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user