feat(rpa): 收料配置与库存同构并统一站点启停
- 删除收料配置 enabled 与 warehouse_ids_json 列(迁移 rc1a2b3c4d5e、rc2b3c4d5e6f,含存量清单转 Warehouse 条件的数据保全) - Warehouse 改为查询条件(多值即逐仓拆分维度),排程/按需触发运行时派生仓库清单并在单元快照剥离该条件 - 站点开关即总开关:四处收料门禁只看站点 enabled;校验要求 DBS 恰一条非空 Warehouse 条件,日期禁填不变 - 站点抽屉改纵向折叠卡片与统一「保存更改」,就绪卡压缩为单行状态条并下移 - technical.md 同步设计边界与接口契约
This commit is contained in:
1 parent
eed1068ae3
commit
2199370065
18 files changed
+412
-223
No files matched your search
@@ -29,7 +29,7 @@ class ShippingReceiptReportConfig(Base):
|
||||
inventory_source_id: Mapped[int] = mapped_column(
|
||||
ForeignKey('shipping_inventory_sources.id'), nullable=False, index=True,
|
||||
)
|
||||
enabled: Mapped[bool] = mapped_column(default=True, server_default=text('true'), nullable=False)
|
||||
# 收料不设独立启停:是否运行统一由库存站点 enabled 与本配置是否存在决定。
|
||||
# 收料文件解析规则(purpose='movement');定死领域字段端点。空则无法解析收料文件。
|
||||
parsing_profile_id: Mapped[Optional[int]] = mapped_column(
|
||||
ForeignKey('shipping_inventory_parsing_profiles.id'), nullable=True, index=True,
|
||||
@@ -40,10 +40,7 @@ class ShippingReceiptReportConfig(Base):
|
||||
query_parameters_json: Mapped[list[dict[str, Any]]] = mapped_column(
|
||||
JSON, default=list, server_default=text("'[]'"), nullable=False,
|
||||
)
|
||||
# DBS 可包含多个 Warehouse;Crane 固定 Inbound Details,保留空数组。
|
||||
warehouse_ids_json: Mapped[list[str]] = mapped_column(
|
||||
JSON, default=list, server_default=text("'[]'"), nullable=False,
|
||||
)
|
||||
# 与库存同构:Warehouse 是查询条件之一(支持多值),逐仓拆分在排程/触发时由该条件运行时派生,不单独持久化仓库清单。
|
||||
config_version: Mapped[int] = mapped_column(Integer, default=1, server_default=text('1'), nullable=False)
|
||||
created_by: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
|
||||
updated_by: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
|
||||
|
||||
@@ -67,19 +67,6 @@ def _json_object(data: dict[str, Any], field: str) -> dict[str, Any]:
|
||||
return dict(value)
|
||||
|
||||
|
||||
def _json_string_list(data: dict[str, Any], field: str) -> list[str]:
|
||||
"""读取非空、去重的字符串列表,供 Source 别名等业务配置使用。"""
|
||||
value = data.get(field, [])
|
||||
if not isinstance(value, list) or any(not isinstance(item, str) for item in value):
|
||||
raise ValidationError(f'{field} must be a string list', code='SHIPPING.INVENTORY_SOURCE_CONFIG_INVALID')
|
||||
result: list[str] = []
|
||||
for item in value:
|
||||
normalized = item.strip()
|
||||
if normalized and normalized not in result:
|
||||
result.append(normalized)
|
||||
return result
|
||||
|
||||
|
||||
def _validate_profile_login_config(data: dict[str, Any]) -> dict[str, str]:
|
||||
"""校验连接级登录配置,不接收页面选择器或报表操作字段。"""
|
||||
value = data.get('login_config_json', {})
|
||||
@@ -269,19 +256,18 @@ def _source_payload(source: ShippingInventorySource) -> dict[str, Any]:
|
||||
def _receipt_report_config_payload(config: ShippingReceiptReportConfig) -> dict[str, Any]:
|
||||
"""序列化独立收料配置,禁止把库存路径或凭据透传至管理端。"""
|
||||
return {
|
||||
'id': config.id, 'inventory_source_id': config.inventory_source_id, 'enabled': bool(config.enabled),
|
||||
'id': config.id, 'inventory_source_id': config.inventory_source_id,
|
||||
'report_path_json': config.report_path_json or {},
|
||||
'query_parameters_json': config.query_parameters_json or [],
|
||||
'warehouse_ids_json': config.warehouse_ids_json or [], 'config_version': config.config_version,
|
||||
'config_version': config.config_version,
|
||||
'created_at': _iso(config.created_at), 'updated_at': _iso(config.updated_at),
|
||||
}
|
||||
|
||||
|
||||
def _validate_receipt_report_config(
|
||||
source: ShippingInventorySource, data: dict[str, Any],
|
||||
) -> tuple[bool, dict[str, str], list[dict[str, Any]], list[str]]:
|
||||
"""规范收料配置,确保日期保持空值、DBS/Crane 路径与仓库拆分规则不混用。"""
|
||||
enabled = _bool(data, 'enabled', True)
|
||||
) -> tuple[dict[str, str], list[dict[str, Any]]]:
|
||||
"""规范收料配置,与库存同构:路径+查询条件;日期禁填,DBS 以 Warehouse 条件为逐仓拆分维度。"""
|
||||
try:
|
||||
parameters = _validate_query_parameters(data)
|
||||
except ValidationError as exc:
|
||||
@@ -289,19 +275,22 @@ def _validate_receipt_report_config(
|
||||
# 报表日期不筛选,避免管理端误传日期使跨日排程导出产生漏数。
|
||||
if any('date' in str(item.get('name') or '').strip().lower() for item in parameters):
|
||||
raise ValidationError('Receipt report date filtering is not supported', code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID')
|
||||
raw_warehouses = _json_string_list(data, 'warehouse_ids_json')
|
||||
raw_path = _json_object(data, 'report_path_json')
|
||||
if source.connector_type == 'dbs':
|
||||
try:
|
||||
path = _validate_report_path('dbs', raw_path)
|
||||
except ValidationError as exc:
|
||||
raise ValidationError(str(exc), code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID') from exc
|
||||
if enabled and not raw_warehouses:
|
||||
raise ValidationError('DBS receipt report requires warehouse_ids_json', code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID')
|
||||
return enabled, path, parameters, raw_warehouses
|
||||
# Warehouse 条件即逐仓拆分维度(不单独持久化仓库清单):必须恰一条且至少一个有效值。
|
||||
warehouse_conditions = [item for item in parameters if str(item.get('name') or '').strip().lower() == 'warehouse']
|
||||
warehouse_values = [str(value or '').strip() for value in (warehouse_conditions[0].get('values') or [])] if warehouse_conditions else []
|
||||
if len(warehouse_conditions) != 1 or not any(warehouse_values):
|
||||
raise ValidationError(
|
||||
'DBS receipt report requires exactly one Warehouse query condition with values',
|
||||
code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID',
|
||||
)
|
||||
return path, parameters
|
||||
if source.connector_type == 'crane':
|
||||
if raw_warehouses:
|
||||
raise ValidationError('Crane receipt report does not support Warehouse split', code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID')
|
||||
if set(raw_path) - {'report_name'} or raw_path.get('report_name') not in (None, '', 'Inbound Details'):
|
||||
raise ValidationError('Crane receipt report is fixed to Inbound Details', code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID')
|
||||
if parameters:
|
||||
@@ -309,7 +298,7 @@ def _validate_receipt_report_config(
|
||||
'Crane receipt report does not support query parameters',
|
||||
code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID',
|
||||
)
|
||||
return enabled, {'report_name': 'Inbound Details'}, [], []
|
||||
return {'report_name': 'Inbound Details'}, []
|
||||
raise ValidationError('Unsupported receipt connector type', code='SHIPPING.RECEIPT_REPORT_CONFIG_INVALID')
|
||||
|
||||
|
||||
@@ -327,7 +316,7 @@ def save_receipt_report_config(source_id: int, data: dict[str, Any], *, actor_id
|
||||
source = db.session.get(ShippingInventorySource, source_id)
|
||||
if source is None:
|
||||
raise NotFoundError('Inventory Source not found', code='SHIPPING.INVENTORY_SOURCE_NOT_FOUND')
|
||||
enabled, path, parameters, warehouses = _validate_receipt_report_config(source, data)
|
||||
path, parameters = _validate_receipt_report_config(source, data)
|
||||
config = ShippingReceiptReportConfig.query.filter_by(inventory_source_id=source.id).one_or_none()
|
||||
before = _receipt_report_config_payload(config) if config else None
|
||||
is_new = config is None
|
||||
@@ -337,10 +326,8 @@ def save_receipt_report_config(source_id: int, data: dict[str, Any], *, actor_id
|
||||
db.session.add(config)
|
||||
else:
|
||||
config.config_version += 1
|
||||
config.enabled = enabled
|
||||
config.report_path_json = path
|
||||
config.query_parameters_json = parameters
|
||||
config.warehouse_ids_json = warehouses
|
||||
config.updated_by = actor_id
|
||||
db.session.flush()
|
||||
after = _receipt_report_config_payload(config)
|
||||
|
||||
@@ -40,7 +40,7 @@ class ShippingReceiptFileRepository:
|
||||
source = ShippingInventorySource.query.filter_by(source_code=source_code, enabled=True).first()
|
||||
if source is None:
|
||||
return None
|
||||
config = ShippingReceiptReportConfig.query.filter_by(inventory_source_id=source.id, enabled=True).first()
|
||||
config = ShippingReceiptReportConfig.query.filter_by(inventory_source_id=source.id).first()
|
||||
if config is None or config.parsing_profile_id is None:
|
||||
return None
|
||||
profile = config.parsing_profile
|
||||
|
||||
@@ -24,23 +24,25 @@ def _build_trigger_unit(
|
||||
) -> dict[str, Any]:
|
||||
"""装配单来源收料 trigger unit;配置缺失时抛 RuntimeError(由调用方转 fail-closed)。"""
|
||||
from app.models import ShippingInventorySource, ShippingReceiptReportConfig
|
||||
from app.services.shipping_notice.receipt_rpa import receipt_unit_parameters, receipt_warehouse_values
|
||||
|
||||
source = ShippingInventorySource.query.filter_by(source_code=source_code, enabled=True).first()
|
||||
if source is None:
|
||||
raise RuntimeError(f'source not enabled: {source_code}')
|
||||
config = ShippingReceiptReportConfig.query.filter_by(inventory_source_id=source.id, enabled=True).first()
|
||||
config = ShippingReceiptReportConfig.query.filter_by(inventory_source_id=source.id).first()
|
||||
if config is None:
|
||||
raise RuntimeError(f'receipt config missing: {source_code}')
|
||||
profile = source.rpa_profile
|
||||
if profile is None or not profile.enabled:
|
||||
raise RuntimeError(f'receipt source profile unavailable: {source_code}')
|
||||
warehouses = config.warehouse_ids_json or [] if source.connector_type == 'dbs' else [None]
|
||||
warehouse_id = str(warehouses[0]) if warehouses else None
|
||||
# Warehouse 条件即逐仓拆分维度:按需触发取第一个仓,单元快照剥离 Warehouse 条件。
|
||||
warehouses = receipt_warehouse_values(config) if source.connector_type == 'dbs' else [None]
|
||||
warehouse_id = str(warehouses[0]) if warehouses and warehouses[0] else None
|
||||
snapshot = {
|
||||
'config_id': config.id, 'config_version': config.config_version,
|
||||
'connector_type': source.connector_type,
|
||||
'report_path_json': config.report_path_json or {},
|
||||
'query_parameters_json': config.query_parameters_json or [],
|
||||
'query_parameters_json': receipt_unit_parameters(config),
|
||||
'warehouse_id': warehouse_id, 'rpa_profile_id': source.rpa_profile_id,
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Any
|
||||
|
||||
from app import db
|
||||
from app.models import ScheduleRun, ScheduleTask, ShippingInventorySource, ShippingReceiptReportConfig, ShippingReceiptRpaUnitRun
|
||||
from app.services.shipping_notice.receipt_rpa import write_receipt_export_batch_trigger
|
||||
from app.services.shipping_notice.receipt_rpa import receipt_unit_parameters, receipt_warehouse_values, write_receipt_export_batch_trigger
|
||||
|
||||
RECEIPT_RPA_JOB_KEY = 'freight-receipt-rpa'
|
||||
AWAITING_RECEIPT_RPA_CALLBACK_STATUS = 'awaiting_receipt_rpa_callback'
|
||||
@@ -28,7 +28,7 @@ def _eligible_sources(task: ScheduleTask) -> list[tuple[ShippingInventorySource,
|
||||
wanted = _wanted_source_codes(task)
|
||||
rows = db.session.query(ShippingInventorySource, ShippingReceiptReportConfig).join(
|
||||
ShippingReceiptReportConfig, ShippingReceiptReportConfig.inventory_source_id == ShippingInventorySource.id,
|
||||
).filter(ShippingInventorySource.enabled.is_(True), ShippingReceiptReportConfig.enabled.is_(True)).all()
|
||||
).filter(ShippingInventorySource.enabled.is_(True)).all()
|
||||
return [(source, config) for source, config in rows if not wanted or source.source_code.upper() in wanted]
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ def _build_unit(source: ShippingInventorySource, config: ShippingReceiptReportCo
|
||||
callback_id = f'receipt:{uuid.uuid4().hex}'
|
||||
snapshot = {
|
||||
'config_id': config.id, 'config_version': config.config_version, 'connector_type': source.connector_type,
|
||||
'report_path_json': config.report_path_json or {}, 'query_parameters_json': config.query_parameters_json or [],
|
||||
'report_path_json': config.report_path_json or {}, 'query_parameters_json': receipt_unit_parameters(config),
|
||||
'warehouse_id': warehouse_id, 'rpa_profile_id': source.rpa_profile_id,
|
||||
}
|
||||
return ShippingReceiptRpaUnitRun(
|
||||
@@ -78,7 +78,8 @@ def run_freight_receipt_rpa_schedule(task: ScheduleTask, run: ScheduleRun) -> Sc
|
||||
"""写独立收料 trigger;一个 DBS Warehouse 或一个 Crane 站点对应一个单元。"""
|
||||
units: list[ShippingReceiptRpaUnitRun] = []
|
||||
for source, config in _eligible_sources(task):
|
||||
warehouses = config.warehouse_ids_json or [] if source.connector_type == 'dbs' else [None]
|
||||
# Warehouse 条件即逐仓拆分维度:运行时从条件派生仓库清单,不读取持久化列表。
|
||||
warehouses = receipt_warehouse_values(config) if source.connector_type == 'dbs' else [None]
|
||||
for warehouse_id in warehouses:
|
||||
unit = _build_unit(source, config, str(warehouse_id) if warehouse_id else None)
|
||||
unit.schedule_run_id = run.id
|
||||
|
||||
@@ -57,7 +57,7 @@ def _shipping_receipt_sources_options() -> list[dict[str, Any]]:
|
||||
|
||||
rows = db.session.query(ShippingInventorySource, ShippingReceiptReportConfig).join(
|
||||
ShippingReceiptReportConfig, ShippingReceiptReportConfig.inventory_source_id == ShippingInventorySource.id,
|
||||
).filter(ShippingInventorySource.enabled.is_(True), ShippingReceiptReportConfig.enabled.is_(True)).all()
|
||||
).filter(ShippingInventorySource.enabled.is_(True)).all()
|
||||
return [{
|
||||
'label': source.display_name or source.source_code, 'value': source.source_code,
|
||||
'description': f'{source.connector_type} · 收料已配置',
|
||||
|
||||
@@ -914,14 +914,12 @@ AUDIT_SNAPSHOT_ALLOWED_KEYS: Final[frozenset[str]] = frozenset({
|
||||
'snapshot_after_ref',
|
||||
'path_id_hash',
|
||||
'revision_no',
|
||||
# 独立收料报表配置快照:路径、受控条件与仓库清单均不含 selector、凭据或日期筛选。
|
||||
# 独立收料报表配置快照:路径与受控条件(含 Warehouse 拆分条件)均不含 selector、凭据、日期筛选或启停字段。
|
||||
'inventory_source_id',
|
||||
'connector_type',
|
||||
'enabled',
|
||||
'config_version',
|
||||
'report_path_json',
|
||||
'query_parameters_json',
|
||||
'warehouse_ids_json',
|
||||
'file_id',
|
||||
'recipient_user_id',
|
||||
'message_type',
|
||||
|
||||
@@ -18,6 +18,35 @@ def receipt_trigger_dir() -> Path | None:
|
||||
return Path(value) if value else None
|
||||
|
||||
|
||||
def receipt_warehouse_values(config: Any) -> list[str]:
|
||||
"""从收料配置的查询条件中提取 Warehouse 条件值(去空去重,保持顺序)。
|
||||
|
||||
Warehouse 条件即逐仓拆分维度(与库存配置同构,不单独持久化仓库清单);
|
||||
排程/触发按返回值逐仓展开执行单元。DBS 配置由校验保证恰一条非空条件。
|
||||
"""
|
||||
values: list[str] = []
|
||||
for item in (config.query_parameters_json or []):
|
||||
if not isinstance(item, dict) or str(item.get('name') or '').strip().lower() != 'warehouse':
|
||||
continue
|
||||
for raw in (item.get('values') or []):
|
||||
cleaned = str(raw or '').strip()
|
||||
if cleaned and cleaned not in values:
|
||||
values.append(cleaned)
|
||||
return values
|
||||
|
||||
|
||||
def receipt_unit_parameters(config: Any) -> list[dict[str, Any]]:
|
||||
"""构建单个执行单元的受控条件:剥离 Warehouse 条件。
|
||||
|
||||
Worker 会按单元的 warehouse_id 自动追加单值 Warehouse 条件,
|
||||
快照里保留用户维护的 Warehouse 条件会与之重复冲突。
|
||||
"""
|
||||
return [
|
||||
dict(item) for item in (config.query_parameters_json or [])
|
||||
if not (isinstance(item, dict) and str(item.get('name') or '').strip().lower() == 'warehouse')
|
||||
]
|
||||
|
||||
|
||||
def write_receipt_export_batch_trigger(run_no: str, units: list[dict[str, Any]], payload: dict[str, Any] | None = None) -> str | None:
|
||||
"""写入收料批量 trigger;worker 仅允许消费 shipping_receipt_rpa.v1。"""
|
||||
trigger_dir = receipt_trigger_dir()
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
backend/migrations/versions/rc1a2b3c4d5e_drop_receipt_config_enabled.py
|
||||
|
||||
用途:删除收料报表配置的独立 enabled 列,站点启停即库存+收料统一开关。
|
||||
依赖:Alembic revision dd22ee33ff44;shipping_receipt_report_configs 已存在。
|
||||
逻辑:收料是否运行改为只看库存站点 enabled 与配置是否存在;四处后端门禁同步去掉该列过滤。
|
||||
|
||||
Revision ID: rc1a2b3c4d5e
|
||||
Revises: dd22ee33ff44
|
||||
Create Date: 2026-09-18 11:30:00.000000
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "rc1a2b3c4d5e"
|
||||
down_revision = "dd22ee33ff44"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""删除 shipping_receipt_report_configs.enabled;启用语义统一归属库存站点。"""
|
||||
op.drop_column("shipping_receipt_report_configs", "enabled")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""恢复 enabled 列并统一置 true;历史双开关状态无法无损还原。"""
|
||||
op.add_column(
|
||||
"shipping_receipt_report_configs",
|
||||
sa.Column("enabled", sa.Boolean(), server_default=sa.text("true"), nullable=False),
|
||||
)
|
||||
@@ -0,0 +1,103 @@
|
||||
"""
|
||||
backend/migrations/versions/rc2b3c4d5e6f_drop_receipt_warehouse_list.py
|
||||
|
||||
用途:删除收料配置的 warehouse_ids_json 列,仓库清单改为查询条件中的 Warehouse 条件。
|
||||
依赖:Alembic revision rc1a2b3c4d5e;shipping_receipt_report_configs 与 shipping_inventory_sources 已存在。
|
||||
逻辑:升级时先把存量 DBS 配置的仓库清单注入为一条 Warehouse 查询条件(数据保全)再删列;
|
||||
降级时从 Warehouse 条件反提清单尽力恢复,条件本身保留。
|
||||
|
||||
Revision ID: rc2b3c4d5e6f
|
||||
Revises: rc1a2b3c4d5e
|
||||
Create Date: 2026-09-18 12:20:00.000000
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "rc2b3c4d5e6f"
|
||||
down_revision = "rc1a2b3c4d5e"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _as_list(raw: Any) -> list:
|
||||
"""把 JSON 列读成 list;驱动可能返回 list 或字符串。"""
|
||||
if raw is None:
|
||||
return []
|
||||
if isinstance(raw, list):
|
||||
return list(raw)
|
||||
if isinstance(raw, str):
|
||||
text = raw.strip()
|
||||
if not text:
|
||||
return []
|
||||
loaded = json.loads(text)
|
||||
return list(loaded) if isinstance(loaded, list) else []
|
||||
return []
|
||||
|
||||
|
||||
def _warehouse_values(parameters: list) -> list[str]:
|
||||
"""提取查询条件里的 Warehouse 值(去空去重,保持顺序)。"""
|
||||
values: list[str] = []
|
||||
for item in parameters:
|
||||
if not isinstance(item, dict) or str(item.get('name') or '').strip().lower() != 'warehouse':
|
||||
continue
|
||||
for value in (item.get('values') or []):
|
||||
cleaned = str(value or '').strip()
|
||||
if cleaned and cleaned not in values:
|
||||
values.append(cleaned)
|
||||
return values
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""先把存量 DBS 仓库清单转为 Warehouse 查询条件,再删除 warehouse_ids_json 列。"""
|
||||
conn = op.get_bind()
|
||||
rows = conn.execute(sa.text(
|
||||
"SELECT c.id, c.query_parameters_json, c.warehouse_ids_json"
|
||||
" FROM shipping_receipt_report_configs c"
|
||||
" JOIN shipping_inventory_sources s ON s.id = c.inventory_source_id"
|
||||
" WHERE s.connector_type = 'dbs'"
|
||||
)).mappings().all()
|
||||
for row in rows:
|
||||
parameters = _as_list(row['query_parameters_json'])
|
||||
warehouses = [str(v or '').strip() for v in _as_list(row['warehouse_ids_json']) if str(v or '').strip()]
|
||||
has_warehouse_condition = any(
|
||||
isinstance(item, dict) and str(item.get('name') or '').strip().lower() == 'warehouse'
|
||||
for item in parameters
|
||||
)
|
||||
if warehouses and not has_warehouse_condition:
|
||||
parameters.append({
|
||||
'name': 'Warehouse', 'mode': 'single' if len(warehouses) == 1 else 'multi_text',
|
||||
'values': warehouses, 'required': False, 'select_all': False,
|
||||
})
|
||||
conn.execute(
|
||||
sa.text("UPDATE shipping_receipt_report_configs SET query_parameters_json = CAST(:params AS JSON) WHERE id = :id"),
|
||||
{'params': json.dumps(parameters), 'id': row['id']},
|
||||
)
|
||||
op.drop_column('shipping_receipt_report_configs', 'warehouse_ids_json')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""恢复 warehouse_ids_json 列并从 Warehouse 条件尽力反提;条件本身保留。"""
|
||||
op.add_column(
|
||||
'shipping_receipt_report_configs',
|
||||
sa.Column('warehouse_ids_json', sa.JSON(), nullable=False, server_default=sa.text("'[]'")),
|
||||
)
|
||||
conn = op.get_bind()
|
||||
rows = conn.execute(sa.text(
|
||||
"SELECT c.id, c.query_parameters_json"
|
||||
" FROM shipping_receipt_report_configs c"
|
||||
" JOIN shipping_inventory_sources s ON s.id = c.inventory_source_id"
|
||||
" WHERE s.connector_type = 'dbs'"
|
||||
)).mappings().all()
|
||||
for row in rows:
|
||||
warehouses = _warehouse_values(_as_list(row['query_parameters_json']))
|
||||
if warehouses:
|
||||
conn.execute(
|
||||
sa.text("UPDATE shipping_receipt_report_configs SET warehouse_ids_json = CAST(:warehouses AS JSON) WHERE id = :id"),
|
||||
{'warehouses': json.dumps(warehouses), 'id': row['id']},
|
||||
)
|
||||
@@ -22,9 +22,9 @@ def receipt_source():
|
||||
source = ShippingInventorySource.query.filter_by(source_code='DSV360_AWSDU').first()
|
||||
assert source is not None
|
||||
config = ShippingReceiptReportConfig(
|
||||
inventory_source_id=source.id, enabled=True,
|
||||
inventory_source_id=source.id,
|
||||
report_path_json={'program_group': 'Bison', 'report_name': 'On Hand Inventory By Location 3lv'},
|
||||
query_parameters_json=[], warehouse_ids_json=[],
|
||||
query_parameters_json=[{'name': 'Warehouse', 'mode': 'single', 'values': ['AWSDU'], 'required': False, 'select_all': False}],
|
||||
)
|
||||
from app import db
|
||||
|
||||
@@ -51,6 +51,8 @@ def test_trigger_receipt_rpa_writes_batch_trigger(app, receipt_source):
|
||||
assert result['callback_id']
|
||||
assert result['trigger_path'].endswith('.json')
|
||||
assert calls['units'][0]['source_code'] == 'DSV360_AWSDU'
|
||||
# 关键断言:按需触发取 Warehouse 条件的第一个仓作为拆分维度。
|
||||
assert calls['units'][0]['warehouse_id'] == 'AWSDU'
|
||||
assert calls['units'][0]['credential_envelope']
|
||||
assert calls['payload']['schema_version'] == 'shipping_receipt_rpa.v1'
|
||||
|
||||
|
||||
@@ -29,15 +29,16 @@ def _create_users() -> None:
|
||||
|
||||
|
||||
def _dbs_payload() -> dict:
|
||||
"""构造 DBS 收料配置;日期未出现表示保持系统页面默认 NULL。"""
|
||||
"""构造 DBS 收料配置;Warehouse 条件即逐仓拆分维度,日期未出现表示保持系统页面默认 NULL。"""
|
||||
return {
|
||||
'enabled': True,
|
||||
'report_path_json': {
|
||||
'program_group': 'Bison', 'program_label': 'AWSBI',
|
||||
'report_group': 'Inbound', 'report_name': 'Receipt Detail',
|
||||
},
|
||||
'warehouse_ids_json': ['AWSDU', 'AWSDU-02'],
|
||||
'query_parameters_json': [{'name': 'Owner', 'mode': 'single', 'values': ['AWS'], 'required': False, 'select_all': False}],
|
||||
'query_parameters_json': [
|
||||
{'name': 'Warehouse', 'mode': 'multi_text', 'values': ['AWSDU', 'AWSDU-02'], 'required': False, 'select_all': False},
|
||||
{'name': 'Owner', 'mode': 'single', 'values': ['AWS'], 'required': False, 'select_all': False},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +66,9 @@ def test_admin_saves_independent_dbs_receipt_config_and_audit(app, client):
|
||||
)
|
||||
assert response.status_code == 200
|
||||
config = parse_api_data(response.get_json())
|
||||
assert config['warehouse_ids_json'] == ['AWSDU', 'AWSDU-02']
|
||||
# 关键断言:Warehouse 条件原样保存,作为逐仓拆分维度的唯一持久化位置。
|
||||
warehouse_condition = next(item for item in config['query_parameters_json'] if item['name'] == 'Warehouse')
|
||||
assert warehouse_condition['values'] == ['AWSDU', 'AWSDU-02']
|
||||
assert config['report_path_json']['report_group'] == 'Inbound'
|
||||
|
||||
with app.app_context():
|
||||
@@ -78,7 +81,7 @@ def test_admin_saves_independent_dbs_receipt_config_and_audit(app, client):
|
||||
event_type='shipping_receipt_report_config_saved', aggregate_id=str(source_id),
|
||||
).one()
|
||||
assert audit.before_snapshot_json is None
|
||||
assert audit.after_snapshot_json['warehouse_ids_json'] == ['AWSDU', 'AWSDU-02']
|
||||
assert audit.after_snapshot_json['query_parameters_json'][0]['values'] == ['AWSDU', 'AWSDU-02']
|
||||
|
||||
|
||||
def test_receipt_config_rejects_date_selector_and_invalid_connector_rules(app, client):
|
||||
@@ -120,9 +123,40 @@ def test_receipt_config_rejects_date_selector_and_invalid_connector_rules(app, c
|
||||
assert response.status_code == 400
|
||||
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
|
||||
|
||||
# 关键断言:Warehouse 条件即逐仓拆分维度——缺失、重复、空值都必须拒绝。
|
||||
missing_warehouse = _dbs_payload()
|
||||
missing_warehouse['query_parameters_json'] = [{'name': 'Owner', 'mode': 'single', 'values': ['AWS'], 'required': False, 'select_all': False}]
|
||||
response = client.put(
|
||||
f'/api/admin/shipping-notice/sources/{dbs_id}/receipt-report-config',
|
||||
json=missing_warehouse, headers=_headers('receipt-admin', 'admin'),
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
|
||||
|
||||
duplicate_warehouse = _dbs_payload()
|
||||
duplicate_warehouse['query_parameters_json'] = [
|
||||
{'name': 'Warehouse', 'mode': 'single', 'values': ['AWSDU'], 'required': False, 'select_all': False},
|
||||
{'name': 'Warehouse', 'mode': 'single', 'values': ['AWSDU-02'], 'required': False, 'select_all': False},
|
||||
]
|
||||
response = client.put(
|
||||
f'/api/admin/shipping-notice/sources/{dbs_id}/receipt-report-config',
|
||||
json=duplicate_warehouse, headers=_headers('receipt-admin', 'admin'),
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
|
||||
|
||||
empty_warehouse = _dbs_payload()
|
||||
empty_warehouse['query_parameters_json'] = [{'name': 'Warehouse', 'mode': 'multi_text', 'values': [], 'required': False, 'select_all': False}]
|
||||
response = client.put(
|
||||
f'/api/admin/shipping-notice/sources/{dbs_id}/receipt-report-config',
|
||||
json=empty_warehouse, headers=_headers('receipt-admin', 'admin'),
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
|
||||
|
||||
invalid_crane = {
|
||||
'enabled': True, 'report_path_json': {'report_name': 'Other Report'},
|
||||
'warehouse_ids_json': ['NOT-ALLOWED'], 'query_parameters_json': [],
|
||||
'report_path_json': {'report_name': 'Other Report'},
|
||||
'query_parameters_json': [],
|
||||
}
|
||||
response = client.put(
|
||||
f'/api/admin/shipping-notice/sources/{crane_id}/receipt-report-config',
|
||||
@@ -153,7 +187,7 @@ def test_crane_receipt_config_rejects_query_parameters(app, client):
|
||||
crane_id = crane_source.id
|
||||
|
||||
default_query = {
|
||||
'enabled': True, 'report_path_json': {'report_name': 'Inbound Details'}, 'warehouse_ids_json': [],
|
||||
'report_path_json': {'report_name': 'Inbound Details'},
|
||||
'query_parameters_json': [],
|
||||
}
|
||||
response = client.put(
|
||||
|
||||
@@ -19,9 +19,9 @@ def test_receipt_schedule_expands_dbs_warehouses_and_crane_once(app, monkeypatch
|
||||
parsing_profile=dbs.parsing_profile, excel_template=dbs.excel_template,
|
||||
warehouse_resolution_mode='fixed', fixed_warehouse_id='CRANE', report_path_json={}, query_parameters_json=[], enabled=True,
|
||||
)
|
||||
db.session.add_all([crane, ShippingReceiptReportConfig(inventory_source_id=dbs.id, enabled=True, report_path_json={'program_group': 'Bison', 'program_label': 'AWSBI', 'report_group': 'Inbound', 'report_name': 'Receipt Detail'}, warehouse_ids_json=['A', 'B']),])
|
||||
db.session.add_all([crane, ShippingReceiptReportConfig(inventory_source_id=dbs.id, report_path_json={'program_group': 'Bison', 'program_label': 'AWSBI', 'report_group': 'Inbound', 'report_name': 'Receipt Detail'}, query_parameters_json=[{'name': 'Warehouse', 'mode': 'multi_text', 'values': ['A', 'B'], 'required': False, 'select_all': False}]),])
|
||||
db.session.flush()
|
||||
db.session.add(ShippingReceiptReportConfig(inventory_source_id=crane.id, enabled=True, report_path_json={'report_name': 'Inbound Details'}, warehouse_ids_json=[]))
|
||||
db.session.add(ShippingReceiptReportConfig(inventory_source_id=crane.id, report_path_json={'report_name': 'Inbound Details'}, query_parameters_json=[]))
|
||||
task = ScheduleTask(schedule_no='SCH-RECEIPT-1', name='Receipt', schedule_type='platform_job', platform_api_path='freight-receipt-rpa', owner_user_id=1, cron_expr='0 8 * * *', job_params={'source_codes': [dbs.source_code, crane.source_code]})
|
||||
db.session.add(task); db.session.flush()
|
||||
run = ScheduleRun(run_no='RUN-RECEIPT-1', schedule_task_id=task.id, status='running')
|
||||
@@ -45,10 +45,12 @@ def test_receipt_schedule_expands_dbs_warehouses_and_crane_once(app, monkeypatch
|
||||
}
|
||||
assert dbs_unit['report_path_json']['report_name'] == 'Receipt Detail'
|
||||
assert dbs_unit['warehouse_id'] == 'A'
|
||||
# 关键断言:单元快照必须剥离 Warehouse 条件,Worker 才能按 warehouse_id 自动追加不重复。
|
||||
assert all(item['name'] != 'Warehouse' for item in dbs_unit['query_parameters_json'])
|
||||
|
||||
|
||||
def test_receipt_schedule_options_only_return_enabled_configured_sources(app):
|
||||
"""动态排程选项只暴露库存站点已启用且收料配置也启用的站点。"""
|
||||
"""动态排程选项只暴露库存站点已启用且已配置收料的站点。"""
|
||||
from app import db
|
||||
from app.models import ShippingInventorySource, ShippingReceiptReportConfig
|
||||
from app.services.schedule.job_options import list_job_options
|
||||
@@ -56,9 +58,9 @@ def test_receipt_schedule_options_only_return_enabled_configured_sources(app):
|
||||
with app.app_context():
|
||||
source = ShippingInventorySource.query.filter_by(source_code='DSV360_AWSDU').one()
|
||||
db.session.add(ShippingReceiptReportConfig(
|
||||
inventory_source_id=source.id, enabled=True,
|
||||
inventory_source_id=source.id,
|
||||
report_path_json={'program_group': 'Bison', 'program_label': 'AWSBI', 'report_group': 'Inbound', 'report_name': 'Receipt Detail'},
|
||||
warehouse_ids_json=['A'],
|
||||
query_parameters_json=[{'name': 'Warehouse', 'mode': 'single', 'values': ['A'], 'required': False, 'select_all': False}],
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@@ -20,15 +20,13 @@ def _receipt_config(source_id: int):
|
||||
|
||||
return ShippingReceiptReportConfig(
|
||||
inventory_source_id=source_id,
|
||||
enabled=True,
|
||||
report_path_json={
|
||||
'program_group': 'Bison',
|
||||
'program_label': 'AWSBI',
|
||||
'report_group': 'Inbound',
|
||||
'report_name': 'Receipt Detail',
|
||||
},
|
||||
query_parameters_json=[],
|
||||
warehouse_ids_json=['AWSDU'],
|
||||
query_parameters_json=[{'name': 'Warehouse', 'mode': 'single', 'values': ['AWSDU'], 'required': False, 'select_all': False}],
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -729,23 +729,6 @@ export / exportable_snapshot_line_ids)无论库存状态一律剔除结案行
|
||||
|
||||
**结案时序边界(操作规约)**:结案触发自动推进存在时序边界——多行订单若先结案短缺行使整单立即满足,异步编排会把“尚未结案的有库存行”一并建入通知。规约:多行结案必须使用缺口复核的批量关行(close_remaining_fulfillment,多选行单事务提交,Worker 只见终态),或按「先结有库存行、最后结短缺行」的顺序逐行结案;自动履约的“恰好单一开放行”守卫(line_auto_fulfill_coordinator)保证多条开放行永不自动合并。
|
||||
|
||||
### 通知准备就地编辑与入口修复(2026-09-18)
|
||||
|
||||
**编辑权限状态制**:正式订单字段(含履约三要素 料号/预约号/数量)默认在
|
||||
「Excel 未生成 + 无活动 Attempt」时可编辑(DEFAULT_EDITABLE_AFTER_TASK_CREATION=True,
|
||||
Schema task_edit_policy 退化为反向锁);原因/证据不强制,审计链自动记录 old→new
|
||||
(shipping_order_review_events / formal_task_field_edited)。通知准备匹配表三单元格
|
||||
就地编辑 → 保存(order_data_version+1)→ 手动「重新匹配库存」生效。
|
||||
|
||||
**有效值消费面补全**:通知准备值列、预约注册(ensure_task_reservations)与核验比对
|
||||
(record_inventory_verification)均改读有效订单值视图——修复编辑后重匹配必抛
|
||||
RESERVATION_MISMATCH 的阻断;匹配结果列仍反映最近一轮匹配事实。
|
||||
|
||||
**缺口复核入口修复**:行级履约投影的匹配事实关联由 draft_line_id 改为 line_index
|
||||
(修复 has_shortage 恒 False 导致入口被隐藏);prep 表新增行级结案入口,滚动锚指向
|
||||
prep 工作区。**边界**:Excel ready 后编辑硬冻结;通知已存在后编辑不重物化通知行
|
||||
(可达窗口窄,声明边界);done_line_report/OT 通知列表投影仍显示冻结原值(历史定格语义)。
|
||||
|
||||
### 2026-07-21 文档级抽取优化历史阶段与 Review 门禁
|
||||
|
||||
> 本路线描述“避免把邮件和全部附件一次性丢给单个 LLM”的目标架构,不沿用旧整单/整封邮件单次模型调用作为兼容路径。各阶段必须按顺序实施;阶段内测试、自检和 Review 的阻断问题全部关闭并满足验收标准后,才能自动进入下一阶段。Dify 画布由管理员按本文档手工修改,代码阶段不直接操作 Dify。
|
||||
@@ -3079,11 +3062,11 @@ SHIPPING_NOTICE_RPA_RECEIPT_TIMEOUT_SECONDS=900
|
||||
- 到期对象由平台排程任务 **货代收料归档到期清理**(`freight-receipt-rpa-retention`)删除,建议在排程管理配置每日一次;它只删除过期对象,不删除运行、文件事实与审计记录。
|
||||
- 企微逐文件推送与汇总发给排程任务配置的接收人(`notify_user_ids` + `notify_enabled`),接收人必须已完成企微绑定,否则投递记 `WECOM_USER_UNBOUND` 失败。
|
||||
|
||||
排程创建:管理端「排程管理」新增平台任务 **货代收料 RPA**(`freight-receipt-rpa`),可选参数 `source_codes` 留空则执行全部已启用收料配置,按需配置 Cron 与接收人。收料排程与库存排程相互独立(站点、Cron、接收人分别选择)。收料触发前**没有**库存那套 Worker 在线 fail-fast 检查:Worker 停止只会让单元等待到 `SHIPPING_NOTICE_RPA_RECEIPT_TIMEOUT_SECONDS` 超时回收,因此上线后应按 `1.9.4` 验收并保留 `data\freight_receipt_rpa\logs\worker.log` 巡检。
|
||||
排程创建:管理端「排程管理」新增平台任务 **货代收料 RPA**(`freight-receipt-rpa`),可选参数 `source_codes` 留空则执行全部已启用站点中已配置收料的站点,按需配置 Cron 与接收人。收料排程与库存排程相互独立(站点、Cron、接收人分别选择)。收料触发前**没有**库存那套 Worker 在线 fail-fast 检查:Worker 停止只会让单元等待到 `SHIPPING_NOTICE_RPA_RECEIPT_TIMEOUT_SECONDS` 超时回收,因此上线后应按 `1.9.4` 验收并保留 `data\freight_receipt_rpa\logs\worker.log` 巡检。
|
||||
|
||||
#### 1.9.4 端到端验证
|
||||
|
||||
1. 管理端「货代管理 → 库存站点」抽屉为目标站点启用收料配置:DBS 必须配置 Warehouse(每个 Warehouse 展开一个单元);Crane 固定 `Inbound Details`,拒绝 Warehouse 与查询条件。
|
||||
1. 管理端「货代管理 → 库存站点」抽屉为目标站点配置收料卡(与库存同构):DBS 必须在查询条件中维护 Warehouse 条件(支持多值,每个 Warehouse 展开一个单元);报表日期不得出现在查询条件中。Crane 固定 `Inbound Details`,拒绝查询条件。收料无独立开关,站点启用即参与收料排程。
|
||||
2. 链路演练(不依赖真实货代网站):以 `-Mock` 启动收料 Worker → 排程管理手工执行一次「货代收料 RPA」→ 确认回调、MinIO 归档、企微投递全链路成功后停止 Mock Worker。
|
||||
3. 真实链路:启动真实收料 Worker 并触发排程,依次确认:
|
||||
- `ls /mnt/hxops-rpa-test-data/freight_receipt_rpa/receipt_triggers` 出现 `receipt_export_batch_{run_no}.json`;
|
||||
@@ -3749,9 +3732,9 @@ Case 状态:`unreviewed`、`draft`、`ready`、`confirming`、`confirmed`、`n
|
||||
- 嵌套标注采用固定语义层级:明细字段高于物理行容器,表头只展示列级字段,不显示内部表头行容器。物理行内部不吞掉字段点击,管理员通过物理行标签、边缘或已选中的缩放手柄操作父区域。
|
||||
# 独立收料报表 RPA
|
||||
|
||||
收料不进入库存快照、匹配或 ERP 链路。站点的一对一 `ShippingReceiptReportConfig` 保存收料路径、受控条件和 Warehouse;`ShippingReceiptRpaUnitRun` 保存每次冻结单元与重试关系;`ShippingReceiptReportFile` 保存原样对象、SHA-256、到期和删除事实;`ShippingReceiptNotificationDelivery` 保存企微投递幂等事实。
|
||||
收料不进入库存快照、匹配或 ERP 链路,也没有独立启停字段:是否运行统一由库存站点 `enabled` 与配置是否存在决定。站点的一对一 `ShippingReceiptReportConfig` 保存收料路径与受控查询条件(Warehouse 条件即逐仓拆分维度,不单独持久化仓库清单);`ShippingReceiptRpaUnitRun` 保存每次冻结单元与重试关系;`ShippingReceiptReportFile` 保存原样对象、SHA-256、到期和删除事实;`ShippingReceiptNotificationDelivery` 保存企微投递幂等事实。
|
||||
|
||||
DBS 每个 Warehouse 单独导出且不填报表日期;Crane 固定 `Inbound Details`,按本次唯一 Description 等待并下载匹配项,禁止取“最新历史报表”。重试创建新的单元并以 `retry_of_id` 关联旧失败单元,绝不覆盖历史。库存 Worker 与收料 Worker 可在不同专用目录下并行运行,但首版不复用跨排程登录会话。
|
||||
DBS 每个 Warehouse 单独导出且不填报表日期。**Warehouse 即逐仓拆分维度,配置与库存完全同构**:仓库维护在查询条件的 Warehouse 条件里(支持多值,逗号分隔),不单独持久化仓库清单;排程/按需触发时由后端运行时从该条件派生仓库清单(`receipt_rpa.receipt_warehouse_values`),一仓展开一个执行单元、一个归档文件,并把单元快照中的 Warehouse 条件剥离(`receipt_rpa.receipt_unit_parameters`)——收料 Worker(`receipt_dbs_export.py`)执行时再把当前 `warehouse_id` 作为必填单值条件自动追加,单元快照若保留该条件会重复冲突。校验要求 DBS 收料配置恰一条非空 Warehouse 条件(`shipping_inventory_service._validate_receipt_report_config`)。报表日期固定不筛选同理属于受控边界:跨日排程不筛日期,避免管理端误传日期导致导出漏数。Crane 固定 `Inbound Details`,按本次唯一 Description 等待并下载匹配项,禁止取“最新历史报表”。重试创建新的单元并以 `retry_of_id` 关联旧失败单元,绝不覆盖历史。库存 Worker 与收料 Worker 可在不同专用目录下并行运行,但首版不复用跨排程登录会话。
|
||||
|
||||
### 可靠性、补偿与审计边界
|
||||
|
||||
@@ -3763,7 +3746,7 @@ DBS 每个 Warehouse 单独导出且不填报表日期;Crane 固定 `Inbound D
|
||||
|
||||
### 管理、接收人与接口
|
||||
|
||||
- 管理员在既有“货代管理 → 库存站点”抽屉维护独立收料区;保存只调用 `GET/PUT /api/admin/shipping-notice/sources/{source_id}/receipt-report-config`,不会调用库存 Source 保存接口,也不会改动库存路径、条件、版本或启停门禁。
|
||||
- 管理员在既有“货代管理 → 库存站点”抽屉维护独立收料卡;统一「保存更改」先调用库存 Source 保存接口、再调用 `PUT /api/admin/shipping-notice/sources/{source_id}/receipt-report-config`(仅当站点已有收料配置或本次展开并填写过收料卡时提交),两接口字段边界互不穿透,收料保存不改动库存路径、条件或版本。
|
||||
- 接收人通过“工作台 → 收料文件”调用 `GET /api/workspace/receipt-report-files?limit=100` 查看本人排程归档;列表不返回 bucket、object key 或凭据。下载仍经 `GET /api/workspace/receipt-report-files/{file_id}/download` 再次鉴权并记录审计。
|
||||
- 管理员的失败单元重试和通知重发接口分别为 `POST /api/admin/receipt-rpa-units/{unit_id}/retry`、`POST /api/admin/receipt-report-files/{file_id}/resend`;二者均只产生新的可审计事实,前者不覆盖旧单元,后者不重新导出。
|
||||
|
||||
@@ -3771,8 +3754,8 @@ DBS 每个 Warehouse 单独导出且不填报表日期;Crane 固定 `Inbound D
|
||||
|
||||
| 接口 | 权限 | 关键请求/响应约束 | 审计 |
|
||||
| --- | --- | --- | --- |
|
||||
| `GET /api/admin/shipping-notice/sources/{source_id}/receipt-report-config` | 管理员 | 返回独立收料路径、可选条件、Warehouse;不返回凭据 | 配置读取沿用管理端访问链路 |
|
||||
| `PUT /api/admin/shipping-notice/sources/{source_id}/receipt-report-config` | 管理员 | body 仅 `enabled/report_path_json/query_parameters_json/warehouse_ids_json`;DBS 启用须 Warehouse;日期/selector 拒绝;Crane 固定 `Inbound Details`,拒绝 Warehouse 和全部查询条件;Worker 无论 Profile 登录 URL 的原 hash,均强制进入 `#/inbound-details-query` 并使用页面默认条件执行 | `shipping_receipt_report_config_saved`,含前后快照 |
|
||||
| `GET /api/admin/shipping-notice/sources/{source_id}/receipt-report-config` | 管理员 | 返回独立收料路径与查询条件(含 Warehouse 拆分条件);不返回凭据 | 配置读取沿用管理端访问链路 |
|
||||
| `PUT /api/admin/shipping-notice/sources/{source_id}/receipt-report-config` | 管理员 | body 仅 `report_path_json/query_parameters_json`;DBS 必须恰一条非空 Warehouse 条件;日期/selector 拒绝;Crane 固定 `Inbound Details`,拒绝全部查询条件;Worker 无论 Profile 登录 URL 的原 hash,均强制进入 `#/inbound-details-query` 并使用页面默认条件执行 | `shipping_receipt_report_config_saved`,含前后快照 |
|
||||
| `POST /api/shipping-notice/rpa/receipt-batch-ready` | 收料 Worker | 仅 `shipping_receipt_rpa.v1`;`file_path` 必须在 receipt drop 根且为 `.xlsx`;校验大小、SHA-256 | 归档、通知、排程终态均保留事实 |
|
||||
| `GET /api/workspace/receipt-report-files` | 管理员或排程接收人 | 当前用户授权过滤后再应用 `limit`;不泄露对象存储定位 | `shipping_receipt_report_files_listed` |
|
||||
| `GET /api/workspace/receipt-report-files/{file_id}/download` | 管理员或对应接收人 | 原样下载;过期对象或无权限拒绝 | 成功/拒绝均记录下载审计 |
|
||||
|
||||
+135
-120
@@ -129,88 +129,44 @@
|
||||
<label><span>{{ t('admin.shippingInventory.warehouseResolution') }}</span><select v-model="source.warehouse_resolution_mode" class="select-field"><option value="fixed">{{ t('admin.shippingInventory.fixedWarehouse') }}</option><option value="inventory_match">{{ t('admin.shippingInventory.inventoryMatch') }}</option></select></label>
|
||||
<label v-if="source.warehouse_resolution_mode === 'fixed'"><span>{{ t('admin.shippingInventory.warehouse') }}</span><input v-model="source.fixed_warehouse_id" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.snapshotTtl') }}</span><input v-model.number="source.snapshot_ttl_seconds" class="input-field" min="1" type="number" required></label>
|
||||
<section v-if="selectedId" class="readiness-card full" :class="{ ready: source.enabled }">
|
||||
<header class="readiness-heading">
|
||||
<div>
|
||||
<span class="readiness-kicker">{{ t('admin.shippingInventory.activationStatus') }}</span>
|
||||
<strong>{{ readinessHeadline }}</strong>
|
||||
<p>{{ readinessGuidance }}</p>
|
||||
</div>
|
||||
<span class="readiness-count">{{ readinessSummary }}</span>
|
||||
</header>
|
||||
<section class="readiness-section">
|
||||
<div class="readiness-section-heading">
|
||||
<b>{{ t('admin.shippingInventory.activationRequiredTitle') }}</b>
|
||||
<small>{{ t('admin.shippingInventory.activationRequiredHint') }}</small>
|
||||
</div>
|
||||
<ol v-if="firstBlockingCheck && !source.enabled" class="readiness-steps">
|
||||
<li :class="`is-${firstBlockingCheck.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(firstBlockingCheck.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${firstBlockingCheck.code}`) }}</b><small>{{ readinessDetail(firstBlockingCheck) }}</small></div>
|
||||
<button v-if="readinessActionLabel(firstBlockingCheck)" type="button" class="readiness-action" :disabled="isReadinessActionBlocked(firstBlockingCheck)" :title="isReadinessActionBlocked(firstBlockingCheck) ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="runReadinessAction(firstBlockingCheck)">{{ readinessActionLabel(firstBlockingCheck) }}</button>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
<details v-if="optionalReadinessChecks.length" class="readiness-optional">
|
||||
<summary><span>{{ t('admin.shippingInventory.activationOptionalTitle') }}</span><small>{{ t('admin.shippingInventory.activationOptionalHint') }}</small></summary>
|
||||
<ol class="readiness-steps">
|
||||
<li v-for="check in optionalReadinessChecks" :key="check.code" :class="`is-${check.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(check.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${check.code}`) }}</b><small>{{ readinessDetail(check) }}</small></div>
|
||||
</li>
|
||||
</ol>
|
||||
</details>
|
||||
<template v-if="configurationTest">
|
||||
<p class="readiness-run" :class="{ failed: configurationTest.status === 'failed' }">{{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</p>
|
||||
<details class="readiness-audit"><summary>{{ t('admin.shippingInventory.configurationTestRunNo') }} {{ configurationTest.run_no }}</summary><dl><div><dt>{{ t('admin.shippingInventory.configurationTestConfigVersion') }}</dt><dd>{{ configurationTest.source_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestConnectionVersion') }}</dt><dd>{{ configurationTest.rpa_profile_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestUpdatedAt') }}</dt><dd>{{ formatDate(configurationTest.completed_at || configurationTest.created_at) }}</dd></div></dl></details>
|
||||
<p v-if="configurationTest.error_message" class="form-tip">{{ configurationTest.error_message }}</p>
|
||||
<p v-if="configurationTest.status === 'completed_empty'" class="form-tip">{{ t('admin.shippingInventory.configurationTestEmptyResult') }}</p>
|
||||
<section v-if="configurationTest.status === 'completed'" class="recommendation-list">
|
||||
<p v-if="configurationTest.result?.current_profile_verified" class="configuration-test-verified">{{ t(`admin.shippingInventory.currentProfileVerified.${configurationTest.result.profile_match_level || 'compatible'}`) }}</p>
|
||||
<article v-for="candidate in configurationTest.result?.analysis?.match_result?.candidates || []" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.configurationTestCandidateHint') }}</small></article>
|
||||
<p v-if="!configurationTest.result?.current_profile_verified && !(configurationTest.result?.analysis?.match_result?.candidates || []).length">{{ t('admin.shippingInventory.configurationTestNoRecommendation') }}</p>
|
||||
</section>
|
||||
</template>
|
||||
<footer v-if="source.enabled || source.activation?.ready" class="readiness-footer">
|
||||
<button v-if="source.enabled" type="button" class="btn-danger btn-sm" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn-primary btn-sm"
|
||||
:disabled="sourceDirty"
|
||||
:title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined"
|
||||
@click="requestSourceActivation"
|
||||
>{{ t('admin.shippingInventory.activateSource') }}</button>
|
||||
</footer>
|
||||
</section>
|
||||
<div v-if="!selectedId" class="form-tip full">{{ t('admin.shippingInventory.sourceSavedDisabledHint') }}</div>
|
||||
<template v-if="source.connector_type === 'dbs'">
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.reportPath') }}</div>
|
||||
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" class="input-field" required></label>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
|
||||
<div v-for="(parameter, index) in source.query_parameters_json" :key="`${index}-${parameter.name}`" class="parameter-row full">
|
||||
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
|
||||
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
|
||||
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
|
||||
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
|
||||
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
|
||||
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
|
||||
<section class="path-card full">
|
||||
<button type="button" class="path-card-header" :aria-expanded="inventoryPathOpen" @click="inventoryPathOpen = !inventoryPathOpen">
|
||||
<span class="path-card-title"><b>{{ t('admin.shippingInventory.reportPath') }}</b></span>
|
||||
<span class="path-card-toggle" aria-hidden="true">{{ inventoryPathOpen ? '▾' : '▸' }}</span>
|
||||
</button>
|
||||
<div v-show="inventoryPathOpen" class="path-card-body">
|
||||
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" class="input-field" required></label>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
|
||||
<div v-for="(parameter, index) in source.query_parameters_json" :key="`${index}-${parameter.name}`" class="parameter-row full">
|
||||
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
|
||||
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
|
||||
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
|
||||
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
|
||||
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
|
||||
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
|
||||
</template>
|
||||
<section v-if="selectedId" class="receipt-report-config full">
|
||||
<div class="subsection">{{ t('admin.shippingInventory.receiptReportConfig') }}<small>{{ t('admin.shippingInventory.receiptReportConfigHint') }}</small></div>
|
||||
<div class="switch-field"><span>{{ t('admin.shippingInventory.receiptReportEnabled') }}</span><button type="button" class="status-switch" :class="{ on: receiptConfig.enabled }" role="switch" :aria-checked="receiptConfig.enabled" @click="receiptConfig.enabled = !receiptConfig.enabled"><i></i><b>{{ receiptConfig.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
|
||||
</section>
|
||||
</template>
|
||||
<section v-if="selectedId" class="path-card receipt full" :class="{ configured: receiptConfigExists }">
|
||||
<button type="button" class="path-card-header" :aria-expanded="receiptSectionOpen" @click="toggleReceiptSection">
|
||||
<span class="path-card-title"><b>{{ t('admin.shippingInventory.receiptReportConfig') }}</b><small>{{ t('admin.shippingInventory.receiptReportConfigHint') }}</small></span>
|
||||
<span class="path-badge" :class="receiptConfigExists ? 'on' : 'off'">{{ receiptConfigExists ? t('admin.shippingInventory.pathSectionConfigured') : t('admin.shippingInventory.pathSectionNotConfigured') }}</span>
|
||||
<span class="path-card-toggle" aria-hidden="true">{{ receiptSectionOpen ? '▾' : '▸' }}</span>
|
||||
</button>
|
||||
<div v-show="receiptSectionOpen" class="path-card-body">
|
||||
<template v-if="source.connector_type === 'dbs'">
|
||||
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="receiptConfig.report_path_json.program_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="receiptConfig.report_path_json.program_label" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="receiptConfig.report_path_json.report_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="receiptConfig.report_path_json.report_name" class="input-field" required></label>
|
||||
<label class="full"><span>{{ t('admin.shippingInventory.receiptWarehouses') }}</span><input class="input-field" :value="receiptConfig.warehouse_ids_json.join(', ')" :placeholder="t('admin.shippingInventory.receiptWarehousesHint')" @input="receiptConfig.warehouse_ids_json = splitValues(($event.target as HTMLInputElement).value)"></label>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.receiptOptionalParameters') }}</div>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}<small>{{ t('admin.shippingInventory.receiptQueryParametersHint') }}</small></div>
|
||||
<div v-for="(parameter, index) in receiptConfig.query_parameters_json" :key="`receipt-${index}-${parameter.name}`" class="parameter-row full">
|
||||
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
|
||||
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
|
||||
@@ -222,8 +178,8 @@
|
||||
<button type="button" class="btn-secondary btn-sm full" @click="addReceiptParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
|
||||
</template>
|
||||
<p v-else class="form-tip full">{{ t('admin.shippingInventory.receiptCraneFixedPath') }}</p>
|
||||
<div class="receipt-config-actions full"><button type="button" class="btn-secondary btn-sm" :disabled="receiptConfigLoading || receiptConfigSaving" @click="saveReceiptConfig">{{ receiptConfigSaving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.saveReceiptReportConfig') }}</button></div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'parsing'">
|
||||
@@ -377,6 +333,48 @@
|
||||
<div class="switch-field"><span>{{ t('admin.shippingInventory.enabled') }}</span><button type="button" class="status-switch" :class="{ on: mapping.enabled }" role="switch" :aria-checked="mapping.enabled" @click="mapping.enabled = !mapping.enabled"><i></i><b>{{ mapping.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
|
||||
</template>
|
||||
|
||||
<section v-if="selectedId" class="readiness-card full" :class="{ ready: source.enabled }">
|
||||
<div class="readiness-inline">
|
||||
<template v-if="source.enabled">
|
||||
<span class="readiness-marker is-passed" aria-hidden="true">✓</span>
|
||||
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.activationReady') }}</b><small v-if="configurationTest?.completed_at">{{ t('admin.shippingInventory.readinessLastVerified', { time: formatDate(configurationTest.completed_at) }) }}</small></div>
|
||||
<button type="button" class="btn-danger btn-sm" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
</template>
|
||||
<template v-else-if="firstBlockingCheck">
|
||||
<span class="readiness-marker" :class="`is-${firstBlockingCheck.status}`" aria-hidden="true">{{ readinessMarker(firstBlockingCheck.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.readinessBlockedBy', { requirement: t(`admin.shippingInventory.activationRequirement.${firstBlockingCheck.code}`) }) }}</b><small>{{ t('admin.shippingInventory.readinessAutoEnableHint') }}</small></div>
|
||||
<button v-if="readinessActionLabel(firstBlockingCheck)" type="button" class="readiness-action" :disabled="isReadinessActionBlocked(firstBlockingCheck)" :title="isReadinessActionBlocked(firstBlockingCheck) ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="runReadinessAction(firstBlockingCheck)">{{ readinessActionLabel(firstBlockingCheck) }}</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="readiness-marker is-passed" aria-hidden="true">✓</span>
|
||||
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.activationCanEnable') }}</b></div>
|
||||
<button type="button" class="btn-primary btn-sm" :disabled="sourceDirty" :title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="requestSourceActivation">{{ t('admin.shippingInventory.activateSource') }}</button>
|
||||
</template>
|
||||
</div>
|
||||
<details v-if="optionalReadinessChecks.length" class="readiness-optional">
|
||||
<summary><span>{{ t('admin.shippingInventory.activationOptionalTitle') }}</span><small>{{ t('admin.shippingInventory.readinessOptionalPending', { count: optionalReadinessPending }) }}</small></summary>
|
||||
<ol class="readiness-steps">
|
||||
<li v-for="check in optionalReadinessChecks" :key="check.code" :class="`is-${check.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(check.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${check.code}`) }}</b><small>{{ readinessDetail(check) }}</small></div>
|
||||
</li>
|
||||
</ol>
|
||||
</details>
|
||||
<template v-if="configurationTest">
|
||||
<p v-if="configurationTest.status === 'failed'" class="readiness-run failed">{{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</p>
|
||||
<p v-if="configurationTest.error_message" class="form-tip">{{ configurationTest.error_message }}</p>
|
||||
<p v-if="configurationTest.status === 'completed_empty'" class="form-tip">{{ t('admin.shippingInventory.configurationTestEmptyResult') }}</p>
|
||||
<details v-if="configurationTest.status !== 'failed'" class="readiness-audit">
|
||||
<summary>{{ t('admin.shippingInventory.configurationTestRunNo') }} {{ configurationTest.run_no }} · {{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</summary>
|
||||
<dl><div><dt>{{ t('admin.shippingInventory.configurationTestConfigVersion') }}</dt><dd>{{ configurationTest.source_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestConnectionVersion') }}</dt><dd>{{ configurationTest.rpa_profile_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestUpdatedAt') }}</dt><dd>{{ formatDate(configurationTest.completed_at || configurationTest.created_at) }}</dd></div></dl>
|
||||
<section v-if="configurationTest.status === 'completed'" class="recommendation-list">
|
||||
<p v-if="configurationTest.result?.current_profile_verified" class="configuration-test-verified">{{ t(`admin.shippingInventory.currentProfileVerified.${configurationTest.result.profile_match_level || 'compatible'}`) }}</p>
|
||||
<article v-for="candidate in configurationTest.result?.analysis?.match_result?.candidates || []" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.configurationTestCandidateHint') }}</small></article>
|
||||
<p v-if="!configurationTest.result?.current_profile_verified && !(configurationTest.result?.analysis?.match_result?.candidates || []).length">{{ t('admin.shippingInventory.configurationTestNoRecommendation') }}</p>
|
||||
</section>
|
||||
</details>
|
||||
</template>
|
||||
</section>
|
||||
<div v-if="isEditableTab" class="form-actions full">
|
||||
<button v-if="!parsingReadOnly" type="submit" class="btn-primary" :disabled="saving || ruleReadOnly || templateReadOnly || inventoryFieldReadOnly">{{ saving ? t('admin.shippingInventory.saving') : t('admin.save') }}</button>
|
||||
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentRule">{{ t('admin.shippingInventory.publish') }}</button>
|
||||
@@ -627,9 +625,12 @@ const bulkBinding = reactive({ visible: false, sourceIds: [] as number[], profil
|
||||
const batchValidation = reactive({ visible: false, sourceIds: [] as number[], query: '', statusFilter: 'all' as 'all' | 'processing' | 'completed' | 'completed_empty' | 'failed', saving: false, result: null as ShippingInventoryValidationBatch | null });
|
||||
let batchValidationTimer: number | null = null;
|
||||
const source = reactive({ source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [] as Parameter[], enabled: false, activation: { ready: false, checks: [] as ShippingInventoryReadinessCheck[], missing_requirements: [] as string[] } as SourceActivation });
|
||||
const receiptConfig = reactive({ enabled: false, report_path_json: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[], warehouse_ids_json: [] as string[] });
|
||||
const receiptConfigLoading = ref(false);
|
||||
const receiptConfigSaving = ref(false);
|
||||
const receiptConfig = reactive({ report_path_json: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[] });
|
||||
const receiptConfigExists = ref(false);
|
||||
const receiptSectionTouched = ref(false);
|
||||
const receiptSectionOpen = ref(false);
|
||||
const inventoryPathOpen = ref(true);
|
||||
const receiptBaseline = ref('');
|
||||
const sourceBaseline = ref('');
|
||||
const rule = reactive({ rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }] as RuleCondition[], source_codes: [] as string[] });
|
||||
const mapping = reactive({ inventory_source_id: 0, freight_warehouse_id: '', external_system_code: 'TOPGP', external_organization_code: '', external_site_code: '', external_warehouse_code: '', external_warehouse_name: '', enabled: true });
|
||||
@@ -646,26 +647,15 @@ const matchingOrderFields = computed(() => routingFields.value.filter((field) =>
|
||||
const canAddParsingMatchKey = computed(() => Boolean(
|
||||
structureAnalysis.value && unusedMatchingInventoryFields.value.length && unusedOrderMatchFields.value.length,
|
||||
));
|
||||
const sourceDirty = computed(() => Boolean(selectedId.value && sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput()));
|
||||
const sourceDirty = computed(() => Boolean(selectedId.value && (
|
||||
(sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput())
|
||||
|| (receiptConfigExists.value && receiptBaseline.value && receiptBaseline.value !== serialiseReceiptInput())
|
||||
)));
|
||||
const readinessChecks = computed<ShippingInventoryReadinessCheck[]>(() => source.activation?.checks || []);
|
||||
const requiredReadinessChecks = computed(() => readinessChecks.value.filter((item) => item.blocking));
|
||||
const firstBlockingCheck = computed(() => requiredReadinessChecks.value.find((item) => item.status !== 'passed'));
|
||||
const optionalReadinessChecks = computed(() => readinessChecks.value.filter((item) => !item.blocking));
|
||||
const readinessSummary = computed(() => {
|
||||
const required = requiredReadinessChecks.value;
|
||||
const total = required.length;
|
||||
const passed = required.filter((item) => item.status === 'passed').length;
|
||||
return t('admin.shippingInventory.readinessProgress', { passed, total });
|
||||
});
|
||||
const readinessHeadline = computed(() => {
|
||||
if (source.enabled) return t('admin.shippingInventory.activationReady');
|
||||
return source.activation?.ready ? t('admin.shippingInventory.activationCanEnable') : t('admin.shippingInventory.activationDraft');
|
||||
});
|
||||
const readinessGuidance = computed(() => source.enabled
|
||||
? t('admin.shippingInventory.activationEnabledHint')
|
||||
: source.activation?.ready
|
||||
? t('admin.shippingInventory.activationCanEnableHint')
|
||||
: t('admin.shippingInventory.activationMissingHint'));
|
||||
const optionalReadinessPending = computed(() => optionalReadinessChecks.value.filter((item) => item.status !== 'passed').length);
|
||||
const sampleReplacementNotice = computed(() => {
|
||||
const difference = pendingSampleReplacement.value?.difference || {};
|
||||
const missing = Array.isArray(difference.missing_mapped_headers) ? difference.missing_mapped_headers : [];
|
||||
@@ -848,36 +838,37 @@ async function load(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置当前站点的独立收料表单,不借用库存报表路径或查询条件。 */
|
||||
/** 重置当前站点的独立收料表单与卡片状态,与库存同构(路径+查询条件)。 */
|
||||
function resetReceiptConfig(connectorType: unknown): void {
|
||||
Object.assign(receiptConfig, {
|
||||
enabled: false,
|
||||
report_path_json: String(connectorType || '').toLowerCase() === 'crane'
|
||||
? { report_name: 'Inbound Details' }
|
||||
: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' },
|
||||
query_parameters_json: [],
|
||||
warehouse_ids_json: [],
|
||||
});
|
||||
}
|
||||
|
||||
/** 读取收料独立配置;读取失败不影响库存站点配置和既有库存运行。 */
|
||||
async function loadReceiptConfig(sourceId: number, connectorType: unknown): Promise<void> {
|
||||
receiptConfigLoading.value = true;
|
||||
resetReceiptConfig(connectorType);
|
||||
receiptConfigExists.value = false;
|
||||
receiptSectionTouched.value = false;
|
||||
receiptSectionOpen.value = false;
|
||||
receiptBaseline.value = '';
|
||||
try {
|
||||
const config = await getShippingReceiptReportConfig(sourceId);
|
||||
if (!config) return;
|
||||
const isCrane = String(connectorType || '').toLowerCase() === 'crane';
|
||||
Object.assign(receiptConfig, {
|
||||
enabled: Boolean(config.enabled),
|
||||
report_path_json: isCrane
|
||||
? { report_name: 'Inbound Details' }
|
||||
: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '', ...((config.report_path_json || {}) as Record<string, string>) },
|
||||
query_parameters_json: Array.isArray(config.query_parameters_json) ? config.query_parameters_json.map((parameter) => ({ ...parameter })) : [],
|
||||
warehouse_ids_json: Array.isArray(config.warehouse_ids_json) ? [...config.warehouse_ids_json].map(String) : [],
|
||||
});
|
||||
receiptConfigExists.value = true;
|
||||
receiptSectionOpen.value = true;
|
||||
} catch (cause) { showError(cause, 'loadFailed'); }
|
||||
finally { receiptConfigLoading.value = false; }
|
||||
finally { receiptBaseline.value = serialiseReceiptInput(); }
|
||||
}
|
||||
|
||||
/** 新增 DBS 可选收料条件;Crane 固定默认查询,不维护查询条件。 */
|
||||
@@ -885,16 +876,10 @@ function addReceiptParameter(): void {
|
||||
receiptConfig.query_parameters_json.push({ name: '', mode: 'single', values: [], required: false, select_all: false });
|
||||
}
|
||||
|
||||
/** 仅提交白名单收料字段到独立 API,绝不调用库存 Source 保存接口。 */
|
||||
async function saveReceiptConfig(): Promise<void> {
|
||||
if (!selectedId.value) return;
|
||||
receiptConfigSaving.value = true;
|
||||
try {
|
||||
await saveShippingReceiptReportConfig(selectedId.value, buildReceiptReportConfigPayload(receiptConfig));
|
||||
await loadReceiptConfig(selectedId.value, source.connector_type);
|
||||
message.success(t('admin.shippingInventory.receiptReportSaved'));
|
||||
} catch (cause) { showError(cause, 'saveFailed'); }
|
||||
finally { receiptConfigSaving.value = false; }
|
||||
/** 展开收料卡即视为有配置意图:统一保存时会提交收料配置,避免未展开时误建空配置。 */
|
||||
function toggleReceiptSection(): void {
|
||||
receiptSectionOpen.value = !receiptSectionOpen.value;
|
||||
if (receiptSectionOpen.value) receiptSectionTouched.value = true;
|
||||
}
|
||||
|
||||
/** 切换管理对象时同步深链并清空选择,避免不同对象的数据残留在编辑器中。 */
|
||||
@@ -949,6 +934,11 @@ function createNew(): void {
|
||||
if (activeTab.value === 'sources') {
|
||||
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['configuration_test'] } });
|
||||
resetReceiptConfig('dbs');
|
||||
receiptConfigExists.value = false;
|
||||
receiptSectionTouched.value = false;
|
||||
receiptSectionOpen.value = false;
|
||||
inventoryPathOpen.value = true;
|
||||
receiptBaseline.value = '';
|
||||
sourceBaseline.value = '';
|
||||
}
|
||||
if (activeTab.value === 'rules') Object.assign(rule, { rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }], source_codes: [] });
|
||||
@@ -1174,7 +1164,21 @@ async function saveCurrent(): Promise<void> {
|
||||
await createShippingExcelTemplate(form);
|
||||
}
|
||||
}
|
||||
if (activeTab.value === 'sources') await saveShippingInventorySource({ ...source, enabled: false, fixed_warehouse_id: source.warehouse_resolution_mode === 'fixed' ? source.fixed_warehouse_id : null, report_path_json: normaliseInventoryReportPath(source.connector_type, source.report_path_json) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'sources') {
|
||||
await saveShippingInventorySource({ ...source, enabled: false, fixed_warehouse_id: source.warehouse_resolution_mode === 'fixed' ? source.fixed_warehouse_id : null, report_path_json: normaliseInventoryReportPath(source.connector_type, source.report_path_json) }, selectedId.value || undefined);
|
||||
// 收料与站点同批保存:仅当已有配置或管理员展开过收料卡时才提交,避免未配置站点被误建空收料配置。
|
||||
if (selectedId.value && (receiptSectionTouched.value || (receiptConfigExists.value && receiptBaseline.value !== serialiseReceiptInput()))) {
|
||||
try {
|
||||
await saveShippingReceiptReportConfig(selectedId.value, buildReceiptReportConfigPayload(receiptConfig));
|
||||
receiptConfigExists.value = true;
|
||||
receiptBaseline.value = serialiseReceiptInput();
|
||||
} catch (cause) {
|
||||
showError(cause, 'saveFailed');
|
||||
await load();
|
||||
return; // 站点已保存但收料保存失败:保持抽屉打开,修正后可直接重试统一保存。
|
||||
}
|
||||
}
|
||||
}
|
||||
if (activeTab.value === 'rules') await saveShippingInventoryRule({ rule_code: rule.rule_code, rule_name: rule.rule_name || rule.rule_code, scope: rule.scope, priority: rule.priority, match_mode: 'all', action_type: 'add_source_candidates', action_payload_json: { source_codes: splitValues(rule.source_codes) }, conditions: rule.conditions.map((condition) => ({ source_kind: 'order_field', order_field_id: condition.order_field_id, operator: condition.operator, expected_value_json: normalizeExpectedValue(condition) })) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'mappings') await saveShippingInventoryExternalMapping({ ...mapping, freight_warehouse_id: mapping.freight_warehouse_id || null, external_organization_code: mapping.external_organization_code || null, external_site_code: mapping.external_site_code || null }, selectedId.value || undefined);
|
||||
await load();
|
||||
@@ -1553,6 +1557,14 @@ function serialiseSourceInput(): string {
|
||||
});
|
||||
}
|
||||
|
||||
/** 将收料配置表单稳定序列化,作为统一保存与启用守卫的收料脏检查基线。 */
|
||||
function serialiseReceiptInput(): string {
|
||||
return JSON.stringify({
|
||||
report_path_json: receiptConfig.report_path_json,
|
||||
query_parameters_json: receiptConfig.query_parameters_json,
|
||||
});
|
||||
}
|
||||
|
||||
/** 返回状态轨道的简洁可视标记,文本状态仍由相邻内容提供,避免颜色成为唯一信息来源。 */
|
||||
function readinessMarker(status: ShippingInventoryReadinessCheck['status']): string {
|
||||
const marker = readinessMarkerKind(status);
|
||||
@@ -1673,10 +1685,10 @@ onMounted(load);
|
||||
.filename-variable-menu button { display: grid; width: 100%; grid-template-columns: 154px minmax(0, 1fr); gap: 8px; border: 0; border-radius: 4px; background: transparent; padding: 7px 8px; color: #64748b; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
||||
.filename-variable-menu button:hover, .filename-variable-menu button.active { background: #eef8f7; color: #145f5a; }.filename-variable-menu code { color: #047f76; font-size: 12px; }.filename-variable-menu p { margin: 0; padding: 8px; color: #94a3b8; font-size: 12px; }
|
||||
.readiness-card { display: grid; gap: 12px; border: 1px solid #cfe2ea; border-radius: 12px; background: #fbfdfe; padding: 16px; }.readiness-card.ready { border-color: #b9dfc4; background: #fcfffd; }
|
||||
.readiness-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }.readiness-heading > div { display: grid; gap: 5px; }.readiness-kicker { color: #5f798c; font-size: 11px; font-weight: 700; letter-spacing: .04em; }.readiness-heading strong { color: #263b4e; font-size: 14px; line-height: 1.4; }.readiness-heading p { margin: 0; color: #6d8292; font-size: 12px; line-height: 1.45; }.readiness-count { flex: 0 0 auto; border: 1px solid #cce7f1; border-radius: 999px; background: #edf8fc; padding: 5px 9px; color: #176f9f; font-size: 12px; font-weight: 700; white-space: nowrap; }.readiness-card.ready .readiness-count { border-color: #cce8d4; background: #eef9f1; color: #19703a; }
|
||||
.readiness-section { border: 1px solid #e1edf2; border-radius: 9px; background: #fff; padding: 0 12px; }.readiness-section-heading { display: grid; gap: 2px; padding: 11px 0 8px; }.readiness-section-heading b { color: #385166; font-size: 12px; }.readiness-section-heading small { color: #8192a0; font-size: 11px; }.readiness-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }.readiness-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 46px; border-top: 1px solid #edf2f5; padding: 7px 0; }.readiness-marker { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: #e9eef3; color: #6c7d8d; font-size: 12px; font-weight: 800; }.readiness-copy { display: grid; min-width: 0; gap: 2px; }.readiness-copy b { overflow: hidden; color: #425466; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.readiness-copy small { color: #8190a0; font-size: 11px; line-height: 1.35; }.readiness-steps .is-passed .readiness-marker { background: #dff6e6; color: #16803a; }.readiness-steps .is-passed .readiness-copy b { color: #2d6b40; }.readiness-steps .is-failed .readiness-marker, .readiness-steps .is-stale .readiness-marker { background: #fff0ed; color: #bf4a38; }.readiness-steps .is-failed .readiness-copy b, .readiness-steps .is-stale .readiness-copy b { color: #9d382b; }
|
||||
.readiness-inline { display: flex; align-items: center; gap: 10px; }.readiness-inline .readiness-copy { flex: 1 1 auto; }.readiness-inline .readiness-copy b { white-space: normal; }.readiness-inline .readiness-copy small { white-space: normal; }.readiness-inline .btn-sm, .readiness-inline .readiness-action { flex: 0 0 auto; }
|
||||
.readiness-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }.readiness-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 46px; border-top: 1px solid #edf2f5; padding: 7px 0; }.readiness-marker { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: #e9eef3; color: #6c7d8d; font-size: 12px; font-weight: 800; }.readiness-copy { display: grid; min-width: 0; gap: 2px; }.readiness-copy b { overflow: hidden; color: #425466; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.readiness-copy small { color: #8190a0; font-size: 11px; line-height: 1.35; }.readiness-steps .is-passed .readiness-marker { background: #dff6e6; color: #16803a; }.readiness-steps .is-passed .readiness-copy b { color: #2d6b40; }.readiness-steps .is-failed .readiness-marker, .readiness-steps .is-stale .readiness-marker { background: #fff0ed; color: #bf4a38; }.readiness-steps .is-failed .readiness-copy b, .readiness-steps .is-stale .readiness-copy b { color: #9d382b; }.readiness-inline > .readiness-marker.is-passed { background: #dff6e6; color: #16803a; }.readiness-inline > .readiness-marker.is-failed, .readiness-inline > .readiness-marker.is-stale { background: #fff0ed; color: #bf4a38; }
|
||||
.readiness-optional { border-top: 1px solid #e4edf2; padding-top: 10px; }.readiness-optional summary, .readiness-audit summary { display: flex; align-items: baseline; gap: 8px; color: #61798a; cursor: pointer; list-style: none; }.readiness-optional summary::-webkit-details-marker, .readiness-audit summary::-webkit-details-marker { display: none; }.readiness-optional summary::before, .readiness-audit summary::before { color: #4d849f; content: '›'; font-size: 16px; line-height: .8; transition: transform .15s; }.readiness-optional[open] summary::before, .readiness-audit[open] summary::before { transform: rotate(90deg); }.readiness-optional summary span { color: #516b7d; font-size: 12px; font-weight: 700; }.readiness-optional summary small { color: #8797a5; font-size: 11px; }.readiness-optional .readiness-steps { margin-top: 8px; }
|
||||
.readiness-action { border: 0; border-radius: 5px; background: #e8f3f9; padding: 6px 8px; color: #16759f; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }.readiness-action:hover { background: #d8edf7; }.readiness-run { margin: 0; border-left: 3px solid #74b8d8; background: #f0f8fc; padding: 8px 10px; color: #547185; font-size: 11px; line-height: 1.5; }.readiness-run.failed { border-left-color: #e06a58; background: #fff5f3; color: #9d382b; }.readiness-audit { margin: 0; border-top: 1px solid #e4edf2; padding-top: 10px; }.readiness-audit summary { color: #61798a; font-size: 11px; font-weight: 700; }.readiness-audit dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 9px 0 0; overflow: hidden; border: 1px solid #dce8ef; border-radius: 7px; background: #dce8ef; }.readiness-audit dl > div { min-width: 0; background: #fff; padding: 8px 9px; }.readiness-audit dt { color: #7b8998; font-size: 11px; font-weight: 700; }.readiness-audit dd { overflow: hidden; margin: 4px 0 0; color: #3d5366; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }.readiness-footer { display: flex; justify-content: flex-end; border-top: 1px solid #e6eef4; padding-top: 11px; }
|
||||
.readiness-action { border: 0; border-radius: 5px; background: #e8f3f9; padding: 6px 8px; color: #16759f; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }.readiness-action:hover { background: #d8edf7; }.readiness-run { margin: 0; border-left: 3px solid #74b8d8; background: #f0f8fc; padding: 8px 10px; color: #547185; font-size: 11px; line-height: 1.5; }.readiness-run.failed { border-left-color: #e06a58; background: #fff5f3; color: #9d382b; }.readiness-audit { margin: 0; border-top: 1px solid #e4edf2; padding-top: 10px; }.readiness-audit summary { color: #61798a; font-size: 11px; font-weight: 700; }.readiness-audit dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 9px 0 0; overflow: hidden; border: 1px solid #dce8ef; border-radius: 7px; background: #dce8ef; }.readiness-audit dl > div { min-width: 0; background: #fff; padding: 8px 9px; }.readiness-audit dt { color: #7b8998; font-size: 11px; font-weight: 700; }.readiness-audit dd { overflow: hidden; margin: 4px 0 0; color: #3d5366; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.form-tip { border-radius: 8px; background: #f1f6fa; padding: 11px; color: #5d7084; font-size: 12px; line-height: 1.55; }
|
||||
.upload-config-section { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 1px solid #e1edf2; border-radius: 9px; background: #fff; padding: 0 12px 12px; }.upload-config-heading { display: grid; gap: 2px; grid-column: 1 / -1; padding: 11px 0 8px; }.upload-config-heading b { color: #385166; font-size: 12px; }.upload-config-heading small { color: #8192a0; font-size: 11px; }.upload-config-section .full { grid-column: 1 / -1; }.upload-config-section textarea.input-field { resize: vertical; }
|
||||
.configuration-test-verified { margin: 0; border-left: 3px solid #34a56b; background: #effaf3; padding: 9px 10px; color: #256b43; font-size: 12px; font-weight: 600; line-height: 1.45; }
|
||||
@@ -1685,9 +1697,12 @@ onMounted(load);
|
||||
.sample-evidence-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }.sample-evidence-card dl div { min-width: 0; }.sample-evidence-card dt { color: #8190a0; font-size: 11px; }.sample-evidence-card dd { margin: 3px 0 0; overflow-wrap: anywhere; color: #475569; font-size: 12px; font-weight: 600; }
|
||||
.sample-replacement-input { display: grid; gap: 6px; border-top: 1px solid #e5edf3; padding-top: 11px; color: #52677a; font-size: 12px; font-weight: 600; }.sample-replacement-input input { max-width: 100%; }.sample-replacement-warning { border-left: 3px solid #e5a21a; background: #fff9eb; padding: 8px 10px; color: #855e00 !important; }.sample-replacement-warning p { margin: 0; }.sample-replacement-warning ul { display: grid; gap: 3px; margin: 7px 0 0; padding-left: 17px; }
|
||||
.parameter-row { display: grid; align-items: center; grid-template-columns: 1.1fr .9fr 1.25fr auto auto auto; gap: 8px; border-radius: 8px; background: #f8fafc; padding: 9px; }
|
||||
.receipt-report-config { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border-top: 1px solid #dbe8ee; margin-top: 8px; padding-top: 14px; }
|
||||
.receipt-report-config .subsection, .receipt-report-config .full { grid-column: 1 / -1; }
|
||||
.receipt-config-actions { display: flex; justify-content: flex-end; }
|
||||
.path-card { display: grid; grid-column: 1 / -1; border: 1px solid #dbe8ee; border-radius: 10px; background: #fff; overflow: hidden; }
|
||||
.path-card-header { display: flex; align-items: center; gap: 10px; border: 0; background: #f7fbfd; padding: 10px 12px; cursor: pointer; font: inherit; text-align: left; }.path-card-header:hover { background: #eff7fa; }
|
||||
.path-card-title { display: grid; flex: 1 1 auto; min-width: 0; gap: 2px; }.path-card-title b { color: #145f5a; font-size: 12px; font-weight: 800; }.path-card-title small { color: #94a3b8; font-size: 11px; font-weight: 400; }
|
||||
.path-badge { flex: 0 0 auto; border-radius: 999px; background: #eef2f5; padding: 3px 8px; color: #7b8998; font-size: 11px; font-weight: 700; }.path-card.configured .path-badge.on { background: #e6f6ec; color: #19703a; }
|
||||
.path-card-toggle { flex: 0 0 auto; color: #4d849f; font-size: 14px; line-height: 1; }
|
||||
.path-card-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border-top: 1px solid #e6eef4; padding: 14px 12px; }.path-card-body .full { grid-column: 1 / -1; }
|
||||
.condition-row, .mapping-row, .template-mapping { display: grid; align-items: center; gap: 8px; border-radius: 8px; background: #f8fafc; padding: 9px; }
|
||||
.condition-row { grid-template-columns: 1.15fr .9fr 1fr auto; }
|
||||
.mapping-row { grid-template-columns: 1fr 1fr auto; }
|
||||
@@ -1728,5 +1743,5 @@ onMounted(load);
|
||||
.object-list .empty-state { grid-column: 1 / -1; display: grid; min-height: 260px; place-items: center; }
|
||||
.empty-state { border: 1px dashed #c9d7e5; border-radius: 10px; background: #f9fbfd; padding: 38px 18px; color: #7b899a; font-size: 13px; text-align: center; }
|
||||
@media (max-width: 980px) { .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary, .receipt-report-config { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .btn-primary { margin-top: 12px; }.batch-source-list { grid-template-columns: 1fr; }.batch-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }.batch-run { grid-template-columns: 9px minmax(0, 1fr); }.batch-run-error { grid-column: 2; }.readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .btn-primary { width: 100%; } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary, .path-card-body { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .btn-primary { margin-top: 12px; }.batch-source-list { grid-template-columns: 1fr; }.batch-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }.batch-run { grid-template-columns: 9px minmax(0, 1fr); }.batch-run-error { grid-column: 2; }.readiness-inline { flex-wrap: wrap; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; } }
|
||||
</style>
|
||||
+16
-9
@@ -2,7 +2,8 @@
|
||||
* features/admin/modules/shipping-inventory/receiptReportConfigForm.spec.ts
|
||||
* 用途:覆盖收料报表表单的独立载荷边界。
|
||||
* 依赖:receiptReportConfigForm、vitest。
|
||||
* 逻辑:防止收料配置保存时把库存站点路径、库存查询条件或启停状态误发到库存接口。
|
||||
* 逻辑:防止收料配置保存时把库存站点路径、库存查询条件或启停状态误发到库存接口;
|
||||
* 收料无独立启停字段,载荷不得包含 enabled。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
@@ -10,24 +11,30 @@ import { buildReceiptReportConfigPayload } from './receiptReportConfigForm';
|
||||
|
||||
describe('receiptReportConfigForm', () => {
|
||||
it('builds a receipt-only payload without inventory source fields', () => {
|
||||
// 关键断言:收料路径、条件与仓库必须走独立 API,不能夹带库存 RPA 配置。
|
||||
// 关键断言:收料路径与条件必须走独立 API,不能夹带库存 RPA 配置或启停字段。
|
||||
const payload = buildReceiptReportConfigPayload({
|
||||
enabled: true,
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
|
||||
query_parameters_json: [{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false }],
|
||||
warehouse_ids_json: ['A', 'B'],
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false },
|
||||
],
|
||||
source_code: 'INVENTORY-SHOULD-NOT-LEAK',
|
||||
snapshot_ttl_seconds: 86400,
|
||||
enabled: true,
|
||||
warehouse_ids_json: ['SHOULD-NOT-LEAK'],
|
||||
inventory_report_path_json: { report_name: 'On Hand' },
|
||||
});
|
||||
} as Parameters<typeof buildReceiptReportConfigPayload>[0] & Record<string, unknown>);
|
||||
|
||||
expect(payload).toEqual({
|
||||
enabled: true,
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
|
||||
query_parameters_json: [{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false }],
|
||||
warehouse_ids_json: ['A', 'B'],
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false },
|
||||
],
|
||||
});
|
||||
expect(payload).not.toHaveProperty('source_code');
|
||||
expect(payload).not.toHaveProperty('snapshot_ttl_seconds');
|
||||
expect(payload).not.toHaveProperty('enabled');
|
||||
expect(payload).not.toHaveProperty('warehouse_ids_json');
|
||||
});
|
||||
});
|
||||
@@ -2,14 +2,13 @@
|
||||
* features/admin/modules/shipping-inventory/receiptReportConfigForm.ts
|
||||
* 用途:构建独立收料报表配置的受限保存载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:页面仅将收料路径、可选条件和 Warehouse 列表提交到收料配置 API,隔离库存站点字段。
|
||||
* 逻辑:页面仅将收料路径与查询条件提交到收料配置 API,与库存同构(Warehouse 为条件之一),
|
||||
* 隔离库存站点字段;收料无独立启停字段,是否运行统一由库存站点 enabled 决定。
|
||||
*/
|
||||
|
||||
export type ReceiptReportConfigInput = {
|
||||
enabled: boolean;
|
||||
report_path_json: Record<string, unknown>;
|
||||
query_parameters_json: Array<Record<string, unknown>>;
|
||||
warehouse_ids_json: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -20,9 +19,7 @@ export type ReceiptReportConfigInput = {
|
||||
*/
|
||||
export function buildReceiptReportConfigPayload(input: ReceiptReportConfigInput): ReceiptReportConfigInput {
|
||||
return {
|
||||
enabled: Boolean(input.enabled),
|
||||
report_path_json: { ...(input.report_path_json || {}) },
|
||||
query_parameters_json: (input.query_parameters_json || []).map((item) => ({ ...item })),
|
||||
warehouse_ids_json: [...(input.warehouse_ids_json || [])],
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user