This commit is contained in:
2026-03-12 01:50:57 +05:00
parent ec82b528a3
commit c33befe7c2
12 changed files with 1553 additions and 69 deletions

46
_test_t3.py Normal file
View File

@@ -0,0 +1,46 @@
"""Полный тест с Таблицей 3 (схемами)."""
from pathlib import Path
from services.data_loader import load_ki, load_table2, build_mif_index, load_table3
from services.form_filler import fill_form
from services.output_generator import make_filename, combine_forms, generate_table4
ki = load_ki("data/Исх.данные/Таблица1 КИ-Неустроева.xlsx")
rows = load_table2("data/Исх.данные/Таблица 2 Перечень выявленных исх.данные.xlsx")
mif_idx = build_mif_index("data/Исх.данные/1. 74 34 0400007 ГК вымпел-73")
tmpl = "data/ШАБЛОН ВЫЯВЛЕННЫЕ-1.xlsx"
out = Path("output")
out.mkdir(exist_ok=True)
print("Загружаем Таблицу 3...")
t3 = load_table3("data/Исх.данные/Таблица 3 ( для схем).xlsx")
print(f"Схем загружено: {len(t3)}")
print("Первые 3 ключа:", list(t3.keys())[:3])
generated, errors = [], []
for t2_row in rows:
zu_file = t2_row[0] if t2_row[0] else ""
kv = t2_row[1] if t2_row[1] else ""
if not zu_file:
continue
fname = make_filename(str(kv), str(zu_file))
out_path = out / fname
scheme = t3.get(str(zu_file).strip())
try:
fill_form(tmpl, str(out_path), ki, t2_row, mif_idx, zu_scheme=scheme)
has_scheme = "со схемой" if scheme else "без схемы"
generated.append({"name": fname, "path": str(out_path), "kv": str(kv), "zu_file": str(zu_file)})
print(f" OK {fname} ({has_scheme})")
except Exception as e:
errors.append((fname, str(e)))
import traceback; traceback.print_exc()
print(f" ERR {fname}: {e}")
print(f"\nСоздано: {len(generated)}, ошибок: {len(errors)}")
if errors:
print("ОШИБКИ:")
for n, e in errors:
print(f" {n}: {e}")
else:
combine_forms([r["path"] for r in generated], str(out / "ВСЕОРМЫ.xlsx"))
generate_table4(generated, str(out / "Таблица4_Перечень_форм.xlsx"))
print("Объединение и Таблица 4 — OK")