功能:实现客户现场使用记录
This commit is contained in:
@@ -337,8 +337,20 @@ class MasterDao:
|
||||
return await cls._paginate(db, statement, query_object, is_page)
|
||||
|
||||
@classmethod
|
||||
async def get_line(cls, db: AsyncSession, line_id: int) -> BizProductionLine | None:
|
||||
return await cls._get(db, BizProductionLine, BizProductionLine.line_id, line_id)
|
||||
async def get_line(
|
||||
cls,
|
||||
db: AsyncSession,
|
||||
line_id: int,
|
||||
*,
|
||||
for_update: bool = False,
|
||||
) -> BizProductionLine | None:
|
||||
return await cls._get(
|
||||
db,
|
||||
BizProductionLine,
|
||||
BizProductionLine.line_id,
|
||||
line_id,
|
||||
for_update=for_update,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def find_line_by_code(
|
||||
|
||||
@@ -69,6 +69,15 @@ class OperationDao:
|
||||
scoped_warehouse_ids = sorted(set(warehouse_ids))
|
||||
return [BizFillingRecord.warehouse_id.in_(scoped_warehouse_ids) if scoped_warehouse_ids else false()]
|
||||
|
||||
@staticmethod
|
||||
def _usage_scope_conditions(
|
||||
site_ids: list[int] | None,
|
||||
) -> list[ColumnElement[bool]]:
|
||||
if site_ids is None:
|
||||
return []
|
||||
scoped_site_ids = sorted(set(site_ids))
|
||||
return [BizUsageRecord.site_id.in_(scoped_site_ids) if scoped_site_ids else false()]
|
||||
|
||||
@staticmethod
|
||||
def _shipment_scope_conditions(
|
||||
warehouse_ids: list[int] | None,
|
||||
@@ -363,12 +372,14 @@ class OperationDao:
|
||||
cls,
|
||||
db: AsyncSession,
|
||||
idempotency_key: str,
|
||||
site_ids: list[int] | None = None,
|
||||
) -> BizUsageRecord | None:
|
||||
return await cls._get_by_key(
|
||||
db,
|
||||
BizUsageRecord,
|
||||
BizUsageRecord.idempotency_key,
|
||||
idempotency_key,
|
||||
*cls._usage_scope_conditions(site_ids),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -651,8 +662,9 @@ class OperationDao:
|
||||
db: AsyncSession,
|
||||
query_object: UsagePageQueryModel,
|
||||
is_page: bool = True,
|
||||
site_ids: list[int] | None = None,
|
||||
) -> PageModel | list[dict[str, Any]]:
|
||||
conditions = []
|
||||
conditions = cls._usage_scope_conditions(site_ids)
|
||||
if query_object.usage_no:
|
||||
conditions.append(BizUsageRecord.usage_no.like(f'%{query_object.usage_no}%'))
|
||||
if query_object.site_id:
|
||||
@@ -682,12 +694,14 @@ class OperationDao:
|
||||
cls,
|
||||
db: AsyncSession,
|
||||
usage_id: int,
|
||||
site_ids: list[int] | None = None,
|
||||
) -> BizUsageRecord | None:
|
||||
return await cls._get_by_id(
|
||||
db,
|
||||
BizUsageRecord,
|
||||
BizUsageRecord.usage_id,
|
||||
usage_id,
|
||||
*cls._usage_scope_conditions(site_ids),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user