Feat: 后端新增基础资料与业务管理只读汇总接口

为 Web 端改版提供名称、统计和看板数据。只新增只读查询、扩展列表与详情
返回字段;写接口、托盘状态机和幂等键规则均未改动,未新增权限标识。

- 基础资料:列表补充名称与汇总,客户详情返回现场树,托盘详情返回最近流转,
  托盘列表支持按流转阶段筛选和二维码精确匹配;新增现场、产线、隧道的上级
  资料选项接口;Excel 导入支持 preview 只校验不写入
- 发货出库:列表支持 keyword、receiptState 筛选并补充名称、托盘数、包数和
  菌种构成;详情明细补充托盘号、菌种、批次
- 首次入库:列表与详情补充名称、托盘数、托盘当前状态;新增 /summary
- 托盘退回:列表支持 keyword 并补充名称与托盘汇总,详情补充托盘号和隧道;
  新增 /summary、/site-options
- 工厂装填:列表支持 keyword 并补充托盘号、仓库、操作人;新增 /summary、
  /batches、/batches/detail
- 客户现场使用:列表支持 keyword、fifoSkipped 并补充名称和被跳过的先到托盘号;
  新增 /site-options、/site-board 以及 usage-fifo 的 /queue
- 先到先用 DAO 抽出公共候选条件与排序,建议查询生成的 SQL 与改动前一致
- 新增各汇总 DAO 的单元测试,同步更新路由权限与模型字段契约测试

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-18 05:03:10 -07:00
co-authored by Claude Opus 5.5
parent 80a71b48ce
commit 3050ccdc4e
51 changed files with 6545 additions and 103 deletions
@@ -11,6 +11,7 @@ from common.vo import CrudResponseModel, PageModel
from exceptions.exception import PermissionException, ServiceException, ServiceWarning
from module_admin.entity.vo.user_vo import CurrentUserModel
from module_business.dao.access_dao import AccessDao
from module_business.dao.inbound_summary_dao import InboundSummaryDao
from module_business.dao.inventory_dao import InventoryDao
from module_business.dao.master_dao import MasterDao
from module_business.dao.operation_dao import OperationDao
@@ -29,7 +30,10 @@ from module_business.entity.vo.operation_vo import (
BusinessOptionModel,
ConfirmCommandModel,
InboundCreateModel,
InboundItemModel,
InboundListItemModel,
InboundModel,
InboundOverviewModel,
InboundPageQueryModel,
InboundScanQueryModel,
InboundUpdateModel,
@@ -245,7 +249,7 @@ class InboundService:
current_user: CurrentUserModel,
test_scope: TestBatchScope,
is_page: bool = True,
) -> PageModel | list[InboundModel]:
) -> PageModel | list[InboundListItemModel]:
warehouse_ids = await cls._warehouse_scope(query_db, current_user)
if (
warehouse_ids is not None
@@ -262,7 +266,17 @@ class InboundService:
is_page=is_page,
)
rows = result.rows if isinstance(result, PageModel) else result
models = [InboundModel.model_validate(record) for record in rows]
records = [InboundModel.model_validate(record) for record in rows]
# 仅对本页已按数据范围筛出的单据补充名称与托盘数
summaries = await InboundSummaryDao.get_list_summaries(
query_db,
[record.inbound_id for record in records],
test_scope,
)
models = [
InboundListItemModel.model_validate({**record.model_dump(), **summaries.get(record.inbound_id, {})})
for record in records
]
if isinstance(result, PageModel):
return result.model_copy(update={'rows': models})
return models
@@ -284,7 +298,31 @@ class InboundService:
)
if inbound is None:
cls._raise_inbound_not_accessible(current_user)
return InboundModel.model_validate(inbound)
model = InboundModel.model_validate(inbound)
if not model.items:
return model
# 托盘编号与当前状态只读展示,不参与任何写入或校验
identities = await InboundSummaryDao.get_item_identities(query_db, model.inbound_id, test_scope)
return model.model_copy(
update={
'items': [
InboundItemModel.model_validate({**item.model_dump(), **identities.get(item.inbound_item_id, {})})
for item in model.items
]
}
)
@classmethod
async def get_inbound_overview_services(
cls,
query_db: AsyncSession,
current_user: CurrentUserModel,
test_scope: TestBatchScope,
) -> InboundOverviewModel:
warehouse_ids = await cls._warehouse_scope(query_db, current_user)
month_start = datetime.now().replace(day=1, hour=0, minute=0, second=0, microsecond=0)
overview = await InboundSummaryDao.get_overview(query_db, warehouse_ids, test_scope, month_start)
return InboundOverviewModel.model_validate(overview)
@classmethod
async def get_warehouse_options_services(