功能:实现单托盘装填
This commit is contained in:
@@ -60,6 +60,15 @@ class OperationDao:
|
||||
scoped_warehouse_ids = sorted(set(warehouse_ids))
|
||||
return [BizInboundOrder.warehouse_id.in_(scoped_warehouse_ids) if scoped_warehouse_ids else false()]
|
||||
|
||||
@staticmethod
|
||||
def _filling_scope_conditions(
|
||||
warehouse_ids: list[int] | None,
|
||||
) -> list[ColumnElement[bool]]:
|
||||
if warehouse_ids is None:
|
||||
return []
|
||||
scoped_warehouse_ids = sorted(set(warehouse_ids))
|
||||
return [BizFillingRecord.warehouse_id.in_(scoped_warehouse_ids) if scoped_warehouse_ids else false()]
|
||||
|
||||
@staticmethod
|
||||
async def _paginate(
|
||||
db: AsyncSession,
|
||||
@@ -97,8 +106,9 @@ class OperationDao:
|
||||
model: type[Any],
|
||||
key_column: InstrumentedAttribute,
|
||||
idempotency_key: str,
|
||||
*extra_conditions: ColumnElement[bool],
|
||||
) -> Any | None:
|
||||
result = await db.execute(select(model).where(key_column == idempotency_key))
|
||||
result = await db.execute(select(model).where(key_column == idempotency_key, *extra_conditions))
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
@staticmethod
|
||||
@@ -300,12 +310,14 @@ class OperationDao:
|
||||
cls,
|
||||
db: AsyncSession,
|
||||
idempotency_key: str,
|
||||
warehouse_ids: list[int] | None = None,
|
||||
) -> BizFillingRecord | None:
|
||||
return await cls._get_by_key(
|
||||
db,
|
||||
BizFillingRecord,
|
||||
BizFillingRecord.idempotency_key,
|
||||
idempotency_key,
|
||||
*cls._filling_scope_conditions(warehouse_ids),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -437,8 +449,9 @@ class OperationDao:
|
||||
db: AsyncSession,
|
||||
query_object: FillingPageQueryModel,
|
||||
is_page: bool = True,
|
||||
warehouse_ids: list[int] | None = None,
|
||||
) -> PageModel | list[dict[str, Any]]:
|
||||
conditions = []
|
||||
conditions = cls._filling_scope_conditions(warehouse_ids)
|
||||
if query_object.filling_no:
|
||||
conditions.append(BizFillingRecord.filling_no.like(f'%{query_object.filling_no}%'))
|
||||
if query_object.warehouse_id:
|
||||
@@ -470,12 +483,14 @@ class OperationDao:
|
||||
cls,
|
||||
db: AsyncSession,
|
||||
filling_id: int,
|
||||
warehouse_ids: list[int] | None = None,
|
||||
) -> BizFillingRecord | None:
|
||||
return await cls._get_by_id(
|
||||
db,
|
||||
BizFillingRecord,
|
||||
BizFillingRecord.filling_id,
|
||||
filling_id,
|
||||
*cls._filling_scope_conditions(warehouse_ids),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user