fix(shipping-notice): 修复调拨预检全 0 及筛选重查系列缺陷
- movement 表头反查改一列对多字段,doc_no/lot_no 共用 External ASN # 列不再互相覆盖,修复 CRANE 预检全 0 - 来源级失败事实落库 source_job 并经 restore 回读,预检卡片透出失败横幅(四语言) - 明细表渲染切 filtered 并将行键升为拆票四元组(来源|Invoice|料号|收料日期),筛选真正生效且无重复 key 残影 - 移除规格/拨入批号列,拨出数量更名库存数量,清理孤儿 i18n 键 colToBatch - requery 端点补用户上下文修复 NameError 500;ERP 网关/绑定故障逐票降级,不再抛全局错误弹窗 - 回归测试:同列双字段提取、失败落库可见、requery 冒烟、同票多行筛选、ERP 绑定缺失降级
This commit is contained in:
1 parent
1ba38e1685
commit
881863478e
16 files changed
+279
-40
No files matched your search
@@ -136,11 +136,13 @@ def execute_precheck_api(precheck_id: str):
|
||||
@require_transfer_permission
|
||||
def requery_items_api(precheck_no: str):
|
||||
"""批量重查 ERP 库存(可恢复阻断行);body 可选 invoice_nos 限定范围。"""
|
||||
user = _require_user()
|
||||
body = request.get_json(silent=True) or {}
|
||||
invoice_nos = body.get("invoice_nos") if isinstance(body.get("invoice_nos"), list) else None
|
||||
deps = transfer_deps.get_transfer_dependencies()
|
||||
return _ok(retry_service_requery_items(
|
||||
precheck_no=precheck_no, deps=deps, invoice_nos=invoice_nos, actor_id=_actor_id(),
|
||||
precheck_no=precheck_no, deps=deps, invoice_nos=invoice_nos,
|
||||
actor_id=str(user.id) if user.id else None,
|
||||
))
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +114,11 @@ def _extract_movement_rows(
|
||||
headers = [str(c or '').strip() for c in raw_rows[header_idx]]
|
||||
data_rows = [list(r) for r in raw_rows[header_idx + 1:] if r]
|
||||
|
||||
header_to_code = {str(alias).strip(): str(code).strip() for code, alias in field_mapping.items()}
|
||||
header_to_code: dict[str, list[str]] = {}
|
||||
for code, alias in field_mapping.items():
|
||||
# 一个表头别名可被多个领域字段共用(如 CRANE 单号/批号同源 ASN 列);
|
||||
# 反查必须是 一别名→多字段,不得互相覆盖。
|
||||
header_to_code.setdefault(str(alias).strip(), []).append(str(code).strip())
|
||||
# 溯源字段:sheet 取实际使用的工作表标题;row_no 为数据行在工作表中的真实
|
||||
# 1-based 行号(表头在第 header_idx+1 行,第 offset 个数据行 = header_idx+2+offset),
|
||||
# 使下游 RawLineRef 证据引用指向真实电子表格行,并满足 parse_movement_rows 行校验。
|
||||
@@ -126,11 +130,16 @@ def _extract_movement_rows(
|
||||
]
|
||||
|
||||
|
||||
def _map_header_row(headers: list[str], row: list[Any], header_to_code: dict[str, str]) -> dict[str, Any]:
|
||||
"""把一行原始单元格按表头别名映射为定死领域字段 dict。"""
|
||||
def _map_header_row(headers: list[str], row: list[Any], header_to_code: dict[str, list[str]]) -> dict[str, Any]:
|
||||
"""把一行原始单元格按表头别名映射为定死领域字段 dict。
|
||||
|
||||
header_to_code 为 一别名→多字段 列表:共用同一表头别名的字段
|
||||
(如 doc_no 与 lot_no 同源一列)各自都写入该单元格值,互不覆盖。
|
||||
"""
|
||||
output: dict[str, Any] = {}
|
||||
for index, header in enumerate(headers):
|
||||
code = header_to_code.get(header)
|
||||
if code and index < len(row):
|
||||
output[code] = row[index]
|
||||
codes = header_to_code.get(header)
|
||||
if codes and index < len(row):
|
||||
for code in codes:
|
||||
output[code] = row[index]
|
||||
return output
|
||||
@@ -475,6 +475,8 @@ def create_precheck(
|
||||
run_id=run.id,
|
||||
source_code=job_source.source_code,
|
||||
status=job_source.stage if job_source.stage in _valid_job_statuses else 'pending',
|
||||
error_code=job_source.error_code,
|
||||
error_message=job_source.error_message,
|
||||
)
|
||||
|
||||
precheck_no = _generate_no("TPC", business_date)
|
||||
@@ -638,6 +640,8 @@ def restore_precheck(precheck_id: str) -> dict[str, Any]:
|
||||
file_no=job.file_no,
|
||||
file_version=None,
|
||||
checksum=job.file_sha256,
|
||||
error_code=job.error_code,
|
||||
error_message=job.error_message,
|
||||
)
|
||||
for job in (precheck.run.source_jobs if precheck.run else [])
|
||||
] or [
|
||||
|
||||
@@ -17,7 +17,11 @@ from app.core.errors import NotFoundError, ValidationError
|
||||
from app.models import TransferAttempt, TransferInvoiceItem
|
||||
from app.services.in_transit_transfer import status as status_machine
|
||||
from app.services.in_transit_transfer.audit import build_transfer_audit_event
|
||||
from app.services.in_transit_transfer.precheck_service import RESULT_EXECUTABLE, TransferDeps
|
||||
from app.services.in_transit_transfer.precheck_service import (
|
||||
RESULT_ERP_QUERY_FAILED,
|
||||
RESULT_EXECUTABLE,
|
||||
TransferDeps,
|
||||
)
|
||||
from app.services.in_transit_transfer.quantity import classify_quantity_match
|
||||
|
||||
RETRY_KIND_ERP_RECHECK = "erp_recheck"
|
||||
@@ -33,16 +37,6 @@ def _recheck_item(item: TransferInvoiceItem, *, deps: TransferDeps, request_id:
|
||||
route = deps.route_resolver.resolve(source_code=item.source_code, invoice_no=item.invoice_no)
|
||||
operation_id = f"op-{uuid.uuid4().hex[:12]}"
|
||||
receipt_qty = Decimal(item.receipt_quantity)
|
||||
query = deps.erp.query_inventory(
|
||||
operation_id=operation_id,
|
||||
run_no=item.run.run_no if item.run else "RUN-PENDING",
|
||||
attempt_no=item.attempt_no + 1,
|
||||
invoice_no=item.invoice_no,
|
||||
erp_org=route.erp_org,
|
||||
from_warehouse=route.from_warehouse,
|
||||
to_warehouse=route.to_warehouse,
|
||||
quantity=receipt_qty,
|
||||
)
|
||||
item.attempt_no += 1
|
||||
before_status = item.status
|
||||
attempt = TransferAttempt(
|
||||
@@ -56,6 +50,44 @@ def _recheck_item(item: TransferInvoiceItem, *, deps: TransferDeps, request_id:
|
||||
)
|
||||
db.session.add(attempt)
|
||||
db.session.flush()
|
||||
# [降级] 与 precheck 逐票语义一致:ERP 网关/绑定故障(如集成连接器缺绑定
|
||||
# BindingNotFoundError)记为该行 blocked_erp_query_failed + 原因,
|
||||
# 不中断批量重查、不向调用方抛基础设施异常(避免全局错误弹窗)。
|
||||
try:
|
||||
query = deps.erp.query_inventory(
|
||||
operation_id=operation_id,
|
||||
run_no=item.run.run_no if item.run else "RUN-PENDING",
|
||||
attempt_no=item.attempt_no,
|
||||
invoice_no=item.invoice_no,
|
||||
erp_org=route.erp_org,
|
||||
from_warehouse=route.from_warehouse,
|
||||
to_warehouse=route.to_warehouse,
|
||||
quantity=receipt_qty,
|
||||
)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
detail = str(exc).strip() or getattr(exc, "message", "") or exc.__class__.__name__
|
||||
item.status = status_machine.TransferStatus.BLOCKED_RECOVERABLE.value
|
||||
item.result_code = RESULT_ERP_QUERY_FAILED
|
||||
item.result_message = f"erp query failed: {detail}"
|
||||
attempt.status = "failed"
|
||||
attempt.completed_at = datetime.utcnow()
|
||||
db.session.add(build_transfer_audit_event(
|
||||
event_type="TRANSFER_ITEM_RECHECKED",
|
||||
aggregate_type="transfer_item",
|
||||
aggregate_id=str(item.id),
|
||||
run_no=item.run.run_no if item.run else None,
|
||||
invoice_no=item.invoice_no,
|
||||
item_id=str(item.id),
|
||||
attempt_no=item.attempt_no,
|
||||
actor_type="worker",
|
||||
request_id=request_id,
|
||||
operation_id=operation_id,
|
||||
result="failure",
|
||||
before={"status": before_status},
|
||||
after={"status": item.status, "attempt_no": item.attempt_no, "error": detail},
|
||||
))
|
||||
db.session.flush()
|
||||
return item.status
|
||||
if not query.found or classify_quantity_match(receipt_qty, query.quantity) != RESULT_EXECUTABLE:
|
||||
item.status = status_machine.TransferStatus.BLOCKED_RECOVERABLE.value
|
||||
item.result_code = "blocked_inventory_not_found" if not query.found else "blocked_quantity_mismatch"
|
||||
@@ -156,4 +188,8 @@ def requery_items(*, precheck_no: str, deps: TransferDeps, invoice_nos: list[str
|
||||
except (ValidationError, NotFoundError) as exc:
|
||||
results.append({"invoice_no": item.invoice_no, "item_id": item.id,
|
||||
"ok": False, "error": exc.message})
|
||||
except Exception as exc: # noqa: BLE001 —— 批量隔离兜底:任何单行异常不炸整批
|
||||
results.append({"invoice_no": item.invoice_no, "item_id": item.id,
|
||||
"ok": False,
|
||||
"error": str(exc).strip() or exc.__class__.__name__})
|
||||
return {"precheck_no": precheck_no, "total": len(items), "results": results}
|
||||
@@ -21,13 +21,22 @@ SOURCE_JOB_STATUSES = (
|
||||
)
|
||||
|
||||
|
||||
def create_source_job(*, run_id: int, source_code: str, status: str = 'pending') -> TransferSourceJob:
|
||||
def create_source_job(
|
||||
*,
|
||||
run_id: int,
|
||||
source_code: str,
|
||||
status: str = 'pending',
|
||||
error_code: str | None = None,
|
||||
error_message: str | None = None,
|
||||
) -> TransferSourceJob:
|
||||
"""为一次 run 创建一条来源级 job;(run_id, source_code) 唯一由模型约束。
|
||||
|
||||
Args:
|
||||
run_id: 所属 TransferRun.id。
|
||||
source_code: 来源实例编码。
|
||||
status: 初始状态。
|
||||
error_code / error_message: 来源级失败事实(如解析失败 error_code),
|
||||
随创建落库,保证刷新/恢复后失败原因仍可见(不静默丢成全 0)。
|
||||
Returns:
|
||||
新建(或复用已存在同 run 同来源)的 TransferSourceJob。
|
||||
"""
|
||||
@@ -36,7 +45,13 @@ def create_source_job(*, run_id: int, source_code: str, status: str = 'pending')
|
||||
)
|
||||
if existing is not None:
|
||||
return existing
|
||||
job = TransferSourceJob(run_id=run_id, source_code=source_code, status=status)
|
||||
job = TransferSourceJob(
|
||||
run_id=run_id,
|
||||
source_code=source_code,
|
||||
status=status,
|
||||
error_code=error_code,
|
||||
error_message=error_message,
|
||||
)
|
||||
db.session.add(job)
|
||||
db.session.flush()
|
||||
return job
|
||||
|
||||
@@ -446,3 +446,37 @@ def test_metrics_endpoint(app, transfer_db, client, admin_headers, transfer_deps
|
||||
data = response.get_json()["data"]
|
||||
assert "runs" in data and "items" in data and "backlog" in data
|
||||
assert "notification_failed_runs" in data["runs"]
|
||||
|
||||
|
||||
def test_requery_items_returns_envelope(app, client, admin_headers, monkeypatch, dbs_ready_file):
|
||||
"""POST /prechecks/{no}/items/requery → 200 envelope,逐票返回重查结果。
|
||||
|
||||
[断言意图] 回归防线(2026-09-21):该端点曾引用未定义的 _actor_id 导致
|
||||
500/SYSTEM.INTERNAL_ERROR;本用例锁定端点在真实鉴权链路下可完整执行,
|
||||
用户上下文(actor_id)随请求正确传递。
|
||||
"""
|
||||
deps, erp, _ = make_transfer_deps(dbs_ready_file)
|
||||
erp.seed_inventory("INV-001", "1000") # 与文件 1200 不符 → blocked_quantity_mismatch
|
||||
erp.seed_inventory("INV-002", "1200")
|
||||
monkeypatch.setattr("app.services.in_transit_transfer.deps._override", deps)
|
||||
|
||||
created = client.post(f"{API_PREFIX}/prechecks", headers=admin_headers, json={
|
||||
"source_codes": ["DBS-AWSBI"],
|
||||
"business_date": "2026-08-06",
|
||||
})
|
||||
precheck_no = created.get_json()["data"]["precheck_id"]
|
||||
|
||||
response = client.post(
|
||||
f"{API_PREFIX}/prechecks/{precheck_no}/items/requery",
|
||||
headers=admin_headers,
|
||||
json={"invoice_nos": ["INV-001"]},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
body = response.get_json()
|
||||
assert body["success"] is True
|
||||
data = body["data"]
|
||||
assert data["precheck_no"] == precheck_no
|
||||
assert data["total"] == 1
|
||||
result = data["results"][0]
|
||||
assert result["invoice_no"] == "INV-001"
|
||||
assert result["ok"] is True
|
||||
@@ -75,6 +75,42 @@ def test_extract_movement_rows_maps_columns_to_domain_fields():
|
||||
assert [row.lot_no for row in parsed] == ['LOT-9', 'LOT-9']
|
||||
|
||||
|
||||
def test_extract_movement_rows_supports_multiple_fields_sharing_one_alias():
|
||||
"""两个字段映射同一表头别名时都必须提取,互不覆盖。
|
||||
|
||||
[断言意图] CRANE 实况回归(2026-09-21 预检全 0 根因):批号由单号(ASN)
|
||||
同列派生,field_mapping 中 doc_no/lot_no 合法指向同一别名;别名反查若
|
||||
一别名只允许一个 code,后写覆盖先写 → doc_no 全丢 → 整文件解析失败。
|
||||
此处锁定:共用别名的每个字段都拿到该列单元格值,且直连解析器可通过。
|
||||
"""
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = 'S'
|
||||
ws.append(['单据编号', '料号', '数量', '异动日期'])
|
||||
ws.append(['ASN-77', 'MAT-7', 8, '2026-09-18'])
|
||||
buf = BytesIO()
|
||||
wb.save(buf)
|
||||
rows = _extract_movement_rows(
|
||||
buf.getvalue(),
|
||||
field_mapping={
|
||||
'doc_no': '单据编号',
|
||||
'lot_no': '单据编号',
|
||||
'material_code': '料号',
|
||||
'quantity': '数量',
|
||||
'movement_date': '异动日期',
|
||||
},
|
||||
sheet_name='S',
|
||||
header_row_index=1,
|
||||
)
|
||||
# [断言意图] 同名列同时喂给 doc_no 与 lot_no,任一字段不得丢失。
|
||||
assert rows[0]['doc_no'] == 'ASN-77'
|
||||
assert rows[0]['lot_no'] == 'ASN-77'
|
||||
# [断言意图] 仓库产出直连解析器:共用别名不会触发 missing_invoice_no 整链阻断。
|
||||
parsed = parse_movement_rows(source_code='CRANE', rows=rows)
|
||||
assert parsed[0].invoice_no == 'ASN-77'
|
||||
assert parsed[0].lot_no == 'ASN-77'
|
||||
|
||||
|
||||
def test_extract_movement_rows_skips_missing_alias_columns():
|
||||
"""表头缺某别名列时,对应领域字段不输出(行仍保留其余字段)。"""
|
||||
wb = Workbook()
|
||||
|
||||
@@ -166,6 +166,38 @@ def test_create_and_restore_precheck(transfer_db, dbs_ready_file):
|
||||
assert restored_items["INV-002"].lot_no == "LOT-20"
|
||||
|
||||
|
||||
def test_parse_failure_persists_source_error_visible_on_restore(transfer_db):
|
||||
"""解析失败 → 来源级 error 落库并经 restore 透出(预检全 0 复发防线)。
|
||||
|
||||
[断言意图] CRANE 实况回归(2026-09-21):行缺 doc_no(别名覆盖症状)时
|
||||
整文件 ReceiptFileSchemaError;失败事实必须持久化到 source_job,恢复后
|
||||
error_code/error_message 仍可见,不得静默呈现为"无错误的全 0"。
|
||||
"""
|
||||
deps, _erp, _rpa = make_transfer_deps(
|
||||
{
|
||||
"source_code": "DSV360_AWSDU", "business_date": "2026-09-17",
|
||||
"file_no": "F1", "file_version": "v1", "checksum": "sha:x",
|
||||
"rows": [{
|
||||
# 行缺 doc_no(单号被同名列覆盖时的真实形态)
|
||||
"sheet": "Movement", "row_no": 1,
|
||||
"lot_no": "LOT-1", "material_code": "M1",
|
||||
"quantity": 5, "movement_date": "2026-09-16",
|
||||
}],
|
||||
},
|
||||
routes={"DSV360_AWSDU": RouteMapping(erp_org="1000", from_warehouse="WH1", to_warehouse="WH2")},
|
||||
)
|
||||
summary = create_precheck(source_codes=["DSV360_AWSDU"], business_date="2026-09-17", deps=deps)
|
||||
assert summary.status == "file_pending"
|
||||
assert summary.counts.file_invoice_count == 0
|
||||
|
||||
restored = restore_precheck(summary.precheck_id)
|
||||
source = next(s for s in restored["sources"] if s.source_code == "DSV360_AWSDU")
|
||||
# [断言意图] 失败原因跨刷新可见:stage=failed + error_code/message 非空。
|
||||
assert source.stage == "failed"
|
||||
assert source.error_code == "TRANSFER_FILE_SCHEMA_INVALID"
|
||||
assert source.error_message
|
||||
|
||||
|
||||
def test_repeated_precheck_refreshes_instead_of_accumulating(transfer_db, dbs_ready_file):
|
||||
"""同一数据重复预检 → 不新增异常行,原地刷新并挂到最新预检(累加缺陷回归防线)。"""
|
||||
from app.models import TransferInvoiceItem, TransferPrecheck
|
||||
|
||||
@@ -138,3 +138,38 @@ def test_requery_items_invoice_filter_targets_only_given_rows(transfer_db, dbs_r
|
||||
result = requery_items(precheck_no=summary.precheck_id, deps=deps, invoice_nos=["INV-XXX"])
|
||||
assert result["total"] == 0
|
||||
assert _item_by_invoice("INV-001").status == "blocked_recoverable"
|
||||
|
||||
|
||||
def test_retry_erp_binding_failure_degrades_instead_of_raising(transfer_db, dbs_ready_file):
|
||||
"""[回归防线 2026-09-21] ERP 网关/绑定故障 → 单行重查降级为
|
||||
blocked_erp_query_failed + 原因,不向调用方抛异常。
|
||||
|
||||
此前该场景抛 BindingNotFoundError('no binding for capability'),
|
||||
与 precheck 的逐票降级语义不一致,用户侧表现为全局错误弹窗。
|
||||
"""
|
||||
deps, erp, _summary = _mismatch_precheck(dbs_ready_file)
|
||||
erp.set_query_scenario("error") # RuntimeError: binding not found for capability query_inventory
|
||||
item = _item_by_invoice("INV-001")
|
||||
old_attempts = db.session.query(TransferAttempt).filter_by(item_id=item.id).count()
|
||||
|
||||
result = retry_item(item_id=item.id, deps=deps) # 不得抛出
|
||||
|
||||
assert result["status"] == "blocked_recoverable"
|
||||
refreshed = db.session.get(TransferInvoiceItem, item.id)
|
||||
# [断言意图] 失败事实落库可见:结果码 + 原因行内可解释。
|
||||
assert refreshed.result_code == "blocked_erp_query_failed"
|
||||
assert "binding not found" in (refreshed.result_message or "")
|
||||
attempts = (db.session.query(TransferAttempt).filter_by(item_id=item.id)
|
||||
.order_by(TransferAttempt.id).all())
|
||||
assert len(attempts) == old_attempts + 1
|
||||
assert attempts[-1].status == "failed"
|
||||
|
||||
|
||||
def test_requery_with_erp_gateway_failure_stays_batched(transfer_db, dbs_ready_file):
|
||||
"""批量重查遇 ERP 故障:逐票降级、批次正常完成,不炸整批。"""
|
||||
deps, erp, summary = _mismatch_precheck(dbs_ready_file)
|
||||
erp.set_query_scenario("error")
|
||||
result = requery_items(precheck_no=summary.precheck_id, deps=deps)
|
||||
assert result["total"] == 1
|
||||
assert result["results"][0]["ok"] is True
|
||||
assert _item_by_invoice("INV-001").result_code == "blocked_erp_query_failed"
|
||||
@@ -252,6 +252,7 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
v-else-if="mode === 'precheck' && summaryRef"
|
||||
:summary="summaryRef"
|
||||
:items="items"
|
||||
:sources="transfer.sources.value"
|
||||
:selected="transfer.selected.value"
|
||||
:requery-busy="busy"
|
||||
:busy="busy"
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferPrecheckCard.vue
|
||||
用途:预检卡——计数 + 调拨明细表(决策 6 十列)+ 勾选 + “直接生成调拨单”按钮。
|
||||
依赖:props(summary/items/selected/busy)、i18n chat.transfer.*。
|
||||
逻辑:阻断/未成熟项 checkbox 禁用;无选择或 busy 时生成按钮禁用;
|
||||
emit execute(invoiceNos)(决策 4/5:无独立确认页)。
|
||||
用途:预检卡——计数 + 来源失败提示 + 调拨明细表(含筛选)+ 勾选 + “直接生成调拨单”按钮。
|
||||
依赖:props(summary/items/sources/selected/busy)、i18n chat.transfer.*。
|
||||
逻辑:明细表渲染 filtered(关键字/结果筛选生效);阻断/未成熟项 checkbox 禁用;
|
||||
无选择或 busy 时生成按钮禁用;emit execute(invoiceNos)(决策 4/5:无独立确认页);
|
||||
来源级解析/文件失败经 sources.error_code 透出(防"安静全 0")。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import type { TransferPrecheckItem, TransferPrecheckSummary } from '../../types/transfer.types';
|
||||
import type { TransferPrecheckItem, TransferPrecheckSummary, TransferSourceProgress } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
summary: TransferPrecheckSummary;
|
||||
items: TransferPrecheckItem[];
|
||||
sources?: TransferSourceProgress[];
|
||||
selected: Set<string>;
|
||||
busy?: boolean;
|
||||
requeryBusy?: boolean;
|
||||
@@ -30,6 +32,11 @@ const selectedCount = computed(() =>
|
||||
);
|
||||
const executeDisabled = computed(() => props.busy || selectedCount.value === 0);
|
||||
|
||||
/** 来源级失败(解析/文件/RPA 触发):必须可见,防止计数全 0 却无任何解释。 */
|
||||
const failedSources = computed(() =>
|
||||
(props.sources ?? []).filter((source) => source.error_code || source.error_message),
|
||||
);
|
||||
|
||||
/** 筛选与全选状态(表格交互本地态,勾选集合仍由父级持有)。 */
|
||||
const keyword = ref('');
|
||||
const resultFilter = ref<'all' | 'executable' | 'blocked' | 'not_matured'>('all');
|
||||
@@ -129,7 +136,18 @@ function resultLabel(result: string): string {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<div
|
||||
v-if="failedSources.length"
|
||||
class="mb-3 rounded-lg border border-red-200 bg-red-50 p-3 text-xs text-red-700"
|
||||
data-testid="transfer-precheck-source-errors"
|
||||
>
|
||||
<div class="mb-1 font-bold">{{ $t('chat.transfer.sourceErrorTitle') }}</div>
|
||||
<div v-for="source in failedSources" :key="source.source_code" class="leading-5">
|
||||
{{ source.source_code }}:{{ source.error_message || source.error_code }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
@@ -170,20 +188,18 @@ function resultLabel(result: string): string {
|
||||
<th class="p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colSpec') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colFromQty') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colToBatch') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colResult') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in items"
|
||||
:key="item.invoice_no"
|
||||
v-for="item in filtered"
|
||||
:key="`${item.source_code}|${item.invoice_no}|${item.material_no}|${item.receipt_date ?? ''}`"
|
||||
class="border-b border-subtle"
|
||||
:class="{ 'bg-surface-soft text-muted': !isSelectable(item) }"
|
||||
:data-testid="`transfer-item-${item.invoice_no}`"
|
||||
@@ -202,12 +218,10 @@ function resultLabel(result: string): string {
|
||||
<td class="p-2">{{ item.receipt_date || '—' }}</td>
|
||||
<td class="p-2">{{ item.material_no }}</td>
|
||||
<td class="p-2">{{ item.material_name }}</td>
|
||||
<td class="p-2">{{ item.specification }}</td>
|
||||
<td class="p-2">{{ item.from_warehouse }}</td>
|
||||
<td class="p-2">{{ deriveBatchNo(item.lot_no) }}</td>
|
||||
<td class="p-2">{{ item.from_quantity ?? '—' }}</td>
|
||||
<td class="p-2">{{ item.to_warehouse }}</td>
|
||||
<td class="p-2">{{ deriveBatchNo(item.lot_no) }}</td>
|
||||
<td class="p-2">{{ item.to_quantity }}</td>
|
||||
<td class="p-2">
|
||||
<span
|
||||
|
||||
@@ -82,6 +82,27 @@ describe('TransferPrecheckCard', () => {
|
||||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||||
expect(wrapper.emitted('execute')?.[0][0]).toEqual(['INV-001']);
|
||||
});
|
||||
|
||||
it('同 Invoice 跨收料日期拆票(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
|
||||
// [断言意图] 回归防线(2026-09-21):拆票设计下 invoice_no 不再唯一,
|
||||
// 行 key 若仍用 invoice_no 会出现重复 key,Vue 列表 diff 错乱导致
|
||||
// 筛选后不匹配行残留/克隆(用户输入 HOX 仍见 SLC2PHX 行)。
|
||||
// 行身份 = (来源, Invoice, 料号, 收料日期),key 必须用同一粒度。
|
||||
const dupItems = [
|
||||
{ source_code: 'CRANE', material_no: 'M-1', material_name: '机框', specification: '', invoice_no: 'HOX-1', receipt_date: '2026-09-11', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-03', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-04', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
];
|
||||
const wrapper = mount(TransferPrecheckCard, {
|
||||
props: { summary, items: dupItems, selected: new Set() },
|
||||
...mountOptions,
|
||||
});
|
||||
expect(wrapper.findAll('tbody tr').length).toBe(3);
|
||||
await wrapper.find('[data-testid="transfer-precheck-filter"]').setValue('HOX');
|
||||
const rows = wrapper.findAll('tbody tr');
|
||||
expect(rows.length).toBe(1);
|
||||
expect(rows[0].text()).toContain('HOX-1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferResultCard', () => {
|
||||
|
||||
@@ -3718,10 +3718,9 @@
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "Receipt Date",
|
||||
"colFromWarehouse": "From warehouse",
|
||||
"colFromQty": "From qty",
|
||||
"colFromQty": "Stock qty",
|
||||
"colToWarehouse": "To warehouse",
|
||||
"colFromBatch": "Outbound Batch",
|
||||
"colToBatch": "Inbound Batch",
|
||||
"filterPlaceholder": "Filter by material / name / Invoice / batch",
|
||||
"filterAll": "All results",
|
||||
"requerySelected": "Requery selected ERP stock",
|
||||
@@ -3793,6 +3792,7 @@
|
||||
"fileReady": "File ready",
|
||||
"fileFetching": "Fetching",
|
||||
"fileFailed": "Fetch failed",
|
||||
"sourceErrorTitle": "Source processing failed",
|
||||
"fileNone": "Pending",
|
||||
"needReadyFile": "A selected source has no receipt file / is fetching / failed. Retry receipt RPA first.",
|
||||
"selectVisible": "Select visible",
|
||||
|
||||
@@ -3718,10 +3718,9 @@
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "วันที่รับสินค้า",
|
||||
"colFromWarehouse": "คลังต้นทาง",
|
||||
"colFromQty": "จำนวนต้นทาง",
|
||||
"colFromQty": "จำนวนสต๊อก",
|
||||
"colToWarehouse": "คลังปลายทาง",
|
||||
"colFromBatch": "ล็อตต้นทาง",
|
||||
"colToBatch": "ล็อตปลายทาง",
|
||||
"filterPlaceholder": "กรองตามรหัสวัสดุ / ชื่อ / Invoice / ล็อต",
|
||||
"filterAll": "ทุกผลลัพธ์",
|
||||
"requerySelected": "ตรวจซ้ำ ERP ที่เลือก",
|
||||
@@ -3793,6 +3792,7 @@
|
||||
"fileReady": "ไฟล์พร้อมแล้ว",
|
||||
"fileFetching": "กำลังดึง",
|
||||
"fileFailed": "ดึงล้มเหลว",
|
||||
"sourceErrorTitle": "ประมวลผลแหล่งข้อมูลล้มเหลว",
|
||||
"fileNone": "รอดำเนินการ",
|
||||
"needReadyFile": "แหล่งที่เลือกไม่มีไฟล์รับของ / กำลังดึง / ล้มเหลว โปรดลอง RPA รับของก่อน",
|
||||
"selectVisible": "เลือกที่เห็นทั้งหมด",
|
||||
|
||||
@@ -3792,10 +3792,9 @@
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "收料日期",
|
||||
"colFromWarehouse": "拨出仓库",
|
||||
"colFromQty": "拨出数量",
|
||||
"colFromQty": "库存数量",
|
||||
"colToWarehouse": "拨入仓库",
|
||||
"colFromBatch": "拨出批号",
|
||||
"colToBatch": "拨入批号",
|
||||
"filterPlaceholder": "按料号 / 品名 / Invoice / 批号筛选",
|
||||
"filterAll": "全部结果",
|
||||
"requerySelected": "重查选中 ERP 库存",
|
||||
@@ -3867,6 +3866,7 @@
|
||||
"fileReady": "文件已就绪",
|
||||
"fileFetching": "抓取中",
|
||||
"fileFailed": "抓取失败",
|
||||
"sourceErrorTitle": "来源处理失败",
|
||||
"fileNone": "待抓取",
|
||||
"needReadyFile": "所选来源存在无收料文件/或抓取中/或失败,请先重试收料 RPA",
|
||||
"selectVisible": "全选可见",
|
||||
|
||||
@@ -3718,10 +3718,9 @@
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "收料日期",
|
||||
"colFromWarehouse": "撥出倉庫",
|
||||
"colFromQty": "撥出數量",
|
||||
"colFromQty": "庫存數量",
|
||||
"colToWarehouse": "撥入倉庫",
|
||||
"colFromBatch": "撥出批號",
|
||||
"colToBatch": "撥入批號",
|
||||
"filterPlaceholder": "按料號 / 品名 / Invoice / 批號篩選",
|
||||
"filterAll": "全部結果",
|
||||
"requerySelected": "重查選中 ERP 庫存",
|
||||
@@ -3793,6 +3792,7 @@
|
||||
"fileReady": "檔案已就緒",
|
||||
"fileFetching": "抓取中",
|
||||
"fileFailed": "抓取失敗",
|
||||
"sourceErrorTitle": "來源處理失敗",
|
||||
"fileNone": "待抓取",
|
||||
"needReadyFile": "所選來源存在無收料檔案/或抓取中/或失敗,請先重試收料 RPA",
|
||||
"selectVisible": "全選可見",
|
||||
|
||||
Reference in new issue
Block a user