удалени лишнего после аварии, работа за рабочий день 07.08.2026

This commit is contained in:
2026-08-07 17:05:28 +03:00
parent f6ca8552f6
commit 24a8886e61
23 changed files with 154 additions and 2083 deletions
+35
View File
@@ -28,6 +28,41 @@ from core.database import (
has_scud_logs_for_date
)
from services.ai_verifier import resolve_department_exception_ai
def apply_exceptions_from_json(df, exceptions_cfg):
"""
Размечает флаг is_excluded=True на основе правил из exceptions.json и БД SQLite.
Сверяет одновременно 1С, СКУД и использует интеллектуальный поиск отделов.
"""
if df is None or df.empty or not exceptions_cfg:
if df is not None:
df['is_excluded'] = False
return df
deps = exceptions_cfg.get("departments", [])
exact_pos = [p.lower() for p in exceptions_cfg.get("positions", [])]
pos_kw = [k.lower() for k in exceptions_cfg.get("position_keywords", [])]
exc_fios = [normalize_fio(f) for f in exceptions_cfg.get("fio", [])]
df['is_excluded'] = False
for idx, row in df.iterrows():
fio_clean = row.get('fio_clean', '')
dep_1c = row.get('Подразделение', '')
dep_scud = row.get('department_scud', row.get('department', ''))
pos = str(row.get('Должность', '')).lower()
is_fio_exc = fio_clean in exc_fios
is_pos_exc = (pos in exact_pos) or any(k in pos for k in pos_kw) if pos else False
# Двухуровневая интеллектуальная проверка отделов (1С + СКУД + ИИ-Кеш БД)
is_dep_exc = resolve_department_exception_ai(dep_1c, dep_scud, deps)
if is_fio_exc or is_dep_exc or is_pos_exc:
df.at[idx, 'is_excluded'] = True
return df
def load_exceptions_config():
"""Загружает файл exceptions.json из корня проекта."""