feat(shipping-notice): 人工重取库存前置候选刷新并放开行级库存源下拉
- 人工重试库存准备前置幂等重判:任务级整单重路由、行级定向重评目标行,复用裁决与冻结链路,零新动作码零契约变更 - 新版候选集 supersede 时内置失效旧库存事实,导出归档与查询服务同步适配 - 行级「库存源」下拉抽纯函数合并选项:歧义行候选置顶 + 全部已启用源去重兜底,任一已启用源可人工指定 - 库存源门禁归一 Notice→OT 身份解析;任务中心抽屉与表格接入行级重取入口 - 同步四语言文案、技术文档与实施计划
This commit is contained in:
1 parent
e38e5a63fe
commit
ea94fb28db
35 files changed
+2675
-83
No files matched your search
@@ -1564,13 +1564,22 @@ def _enrich_task_center_fields(
|
||||
data["created_by"] = task.user_id
|
||||
if viewer_user_id is not None:
|
||||
data["can_handle"] = task_can_handle(task, int(viewer_user_id), is_admin=is_admin)
|
||||
# 下载能力与导出端点同一谓词;SUMMARY/DETAIL 均下发,供抽屉/批量勾选消费。
|
||||
data["can_download_export"] = can_download_task_export(
|
||||
task, user_id=int(viewer_user_id), is_admin=is_admin,
|
||||
)
|
||||
data["recent_event"] = _latest_task_event_summary(task)
|
||||
data["artifact_summary"] = _artifact_summary_for_task(task)
|
||||
data['notice_line_summary'] = _notice_line_summary_for_task(task)
|
||||
# [STEP] 懒导入避免与 ui_state ↔ query_service 循环依赖。
|
||||
from app.services.shipping_notice.ui_state import build_task_ui_state
|
||||
|
||||
ui_state = build_task_ui_state(task, include_stage_context=include_stage_context)
|
||||
ui_state = build_task_ui_state(
|
||||
task,
|
||||
include_stage_context=include_stage_context,
|
||||
viewer_user_id=viewer_user_id,
|
||||
viewer_is_admin=is_admin,
|
||||
)
|
||||
data["ui_state"] = ui_state
|
||||
# [PERF] 优先复用 ui_state.process_gate(build_task_ui_state 已查 Execution);
|
||||
# 无 Gate 时回退 position/user_mode,避免再跑一次 resolve_task_ui_state。
|
||||
@@ -1730,12 +1739,15 @@ def list_tasks_page_for_user(
|
||||
page: int = 1,
|
||||
page_size: int = 20,
|
||||
lifecycle_status: str | None = None,
|
||||
is_admin: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
分页列出当前用户可见的发货任务摘要。
|
||||
|
||||
工作台任务量增长后必须由数据库分页,不能先拉取固定上限再在浏览器切页;
|
||||
`items` 仅表示当前页,`total` 用于计算稳定的页码与空页回退。
|
||||
``is_admin`` 只影响 SUMMARY 的能力字段(can_handle / can_download_export),
|
||||
不扩大列表可见范围(仍为本人 + 无主 Notice)。
|
||||
"""
|
||||
normalized_page = max(1, int(page))
|
||||
normalized_page_size = max(1, min(int(page_size), 100))
|
||||
@@ -1795,7 +1807,7 @@ def list_tasks_page_for_user(
|
||||
rows = [row for row in rows if row is not None]
|
||||
return {
|
||||
"items": [
|
||||
serialize_task_summary(item, viewer_user_id=user_id)
|
||||
serialize_task_summary(item, viewer_user_id=user_id, is_admin=is_admin)
|
||||
for item in rows
|
||||
],
|
||||
"page": normalized_page,
|
||||
@@ -1849,6 +1861,35 @@ def get_task_visible_to_user(
|
||||
return task
|
||||
|
||||
|
||||
def can_download_task_export(
|
||||
task: ShippingOrderTask | ShippingNotice | None,
|
||||
*,
|
||||
user_id: int,
|
||||
is_admin: bool = False,
|
||||
) -> bool:
|
||||
"""
|
||||
导出下载的唯一授权谓词:创建者或平台管理员(与导出端点同一口径)。
|
||||
|
||||
核心逻辑:单票/批量 Excel 下载端点与 UI 的 download_excel 动作、
|
||||
can_download_export 字段都必须消费本谓词,禁止各处另行推导归属;
|
||||
管理员放开下载(可下载=可见)后,每次下载仍须写入 record_access_audit。
|
||||
无主任务(user_id IS NULL)仅管理员可下载。
|
||||
|
||||
Args:
|
||||
task: 已加载的任务实体(可为 None)。
|
||||
user_id: 当前查看/下载用户。
|
||||
is_admin: 是否平台管理员。
|
||||
|
||||
Returns:
|
||||
当前用户是否允许下载该任务的正式 Excel。
|
||||
"""
|
||||
if task is None:
|
||||
return False
|
||||
if is_admin:
|
||||
return True
|
||||
return task.user_id is not None and int(task.user_id) == int(user_id)
|
||||
|
||||
|
||||
def list_freight_notice_groups_for_task(
|
||||
task: ShippingNotice,
|
||||
*,
|
||||
|
||||
Reference in new issue
Block a user