Первичная зашифрованная версия проекта

This commit is contained in:
2026-07-27 21:10:59 +03:00
commit 97b4be7162
14 changed files with 947 additions and 0 deletions
+76
View File
@@ -0,0 +1,76 @@
import os
import re
import json
import pandas as pd
from datetime import datetime, timedelta
# 📁 Пути к директориям
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DATA_DIR = os.path.join(BASE_DIR, "data")
OUTPUT_DIR = os.path.join(BASE_DIR, "output")
os.makedirs(DATA_DIR, exist_ok=True)
os.makedirs(OUTPUT_DIR, exist_ok=True)
# 📅 Динамический расчет дат (СЕГОДНЯ и ВЧЕРА)
def get_controlling_dates():
now = datetime.now()
if now.weekday() == 0: # Если Понедельник -> Вчера = Пятница
yesterday_dt = now - timedelta(days=3)
else:
yesterday_dt = now - timedelta(days=1)
date_today_str = now.strftime("%d.%m.%Y")
date_yesterday_str = yesterday_dt.strftime("%d.%m.%Y")
return date_today_str, date_yesterday_str
DATE_TODAY, DATE_YESTERDAY = get_controlling_dates()
# 📄 Пути к файлам
SCUD_FILE_TODAY = os.path.join(DATA_DIR, f"Сотрудники_{DATE_TODAY}.xlsx")
SCUD_FILE_YESTERDAY = os.path.join(DATA_DIR, f"Сотрудники_{DATE_YESTERDAY}.xlsx")
SCUD_FILE = SCUD_FILE_TODAY if os.path.exists(SCUD_FILE_TODAY) else SCUD_FILE_YESTERDAY
STAFF_FILE = os.path.join(DATA_DIR, "Штатные сотрудники - ОУП.xlsx")
ABSENT_FILE = os.path.join(DATA_DIR, "Отсутствия сотрудников - выгрузка.xlsx")
EXCEPTIONS_FILE = os.path.join(BASE_DIR, "exceptions.json")
# 🤖 Настройки Ollama
OLLAMA_URL = "http://10.121.18.227:11434/api/chat"
OLLAMA_MODEL = "qwen2.5:14b"
# 🛠 Очистка и нормализация данных
def normalize_fio(val):
"""Строгая нормализация ФИО для точности сопоставления 1С и СКУД"""
if pd.isna(val):
return ""
val = str(val).strip().lower()
val = re.sub(r'\(.*?\)', '', val)
trans = str.maketrans('aceopxyABCEHKMOPTX', 'асеорхуАВСЕНКМОРТХ')
val = val.translate(trans).replace('ё', 'е')
return re.sub(r'\s+', ' ', val).strip()
def clean_scud_fio_light(val):
"""Легкая очистка ФИО для СКУД"""
if pd.isna(val):
return ""
val = str(val).strip().lower()
val = re.sub(r'\(.*?\)', '', val).replace('ё', 'е')
return re.sub(r'\s+', ' ', val).strip()
def load_exceptions(file_path=EXCEPTIONS_FILE):
"""Загрузка списка исключений из JSON"""
if not os.path.exists(file_path):
return {"departments": [], "positions": [], "fio": [], "position_keywords": []}
with open(file_path, "r", encoding="utf-8") as f:
data = json.load(f)
return {
"departments": [str(d).strip().upper() for d in data.get("departments", [])],
"positions": [str(p).strip().lower() for p in data.get("positions", [])],
"fio": [normalize_fio(f) for f in data.get("fio", [])],
"position_keywords": [str(k).strip().lower() for k in data.get("position_keywords", [])]
}