feat(biz-compare): preserve templates and refine industrial editor

This commit is contained in:
oliver 2026-10-11 06:06:20 +08:00
parent 90cf1907b4
commit 355bcfc4c0
19 changed files with 719 additions and 219 deletions

View file

@ -2237,9 +2237,15 @@ def _validate_compare_job(
if any(b.status != "success" for b in source_batches):
raise HTTPException(status_code=409, detail="source_batch_not_complete")
# Existing records may predate write validation. Do not normalize invalid
# sheets away or run unknown rules as successful comparisons.
if tpl.metrics_json:
validate_template_body({"metrics": tpl.metrics_json,
"iface_normalize_rules": tpl.iface_normalize_json})
sheets_cfg = template_metrics(tpl)
if not sheets_cfg:
raise HTTPException(status_code=400, detail="template_has_no_metrics")
_validate_job_sheets(db, tpl.id, _str_list(j.enabled_sheet_ids))
sheets_cfg = _filter_enabled_sheets(sheets_cfg, getattr(j, "enabled_sheet_ids", None))
if not sheets_cfg:
raise HTTPException(status_code=400, detail="no_enabled_sheets")