From abfce692e1822649729cb5937576e5c2906e753e Mon Sep 17 00:00:00 2001 From: Ilya_Chis Date: Wed, 2 Apr 2025 19:13:40 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D0=BF=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B5=D0=BD=D1=82=D0=B0=20=D1=87=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=20=D0=BF=D0=BE=D0=BB=D0=B8=D0=BC=D0=B5=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webApp/interfaces/pagesController.py | 79 +++++++++++++++++++++------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/webApp/interfaces/pagesController.py b/webApp/interfaces/pagesController.py index 7f00ac5..d6ade1c 100644 --- a/webApp/interfaces/pagesController.py +++ b/webApp/interfaces/pagesController.py @@ -258,12 +258,28 @@ def request_patient_information(): # taxpayer_fio = data.get('taxpayer_fio') patient_fio = data.get('patient_fio') - sheet = authorize_google().open("Пациенты клиники").sheet1 - records = sheet.get_all_values() + url = "http://192.168.1.10:8081/AppFindPacFromTel" + data = {"telegram_id": user_id} + + response = requests.post(url, json=data) + + if response.status_code == 200: + result = response.json() + patients = [] # Список пациентов + birthday_pac = {} # Словарь для хранения ФИО и даты рождения + + for patient in result.get("Pacients", []): + # Формируем строку ФИО + fio = f"{patient['last_name']} {patient['first_name']} {patient['second_name']}" + patients.append(fio) + + # Сохраняем дату рождения в словарь с ключом ФИО + birthday_pac[fio] = patient['birthday'] + print("список:", patients) + print("даты рождения:", birthday_pac) + birthday_users = birthday_pac.get(patient_fio) + - # Получаем список всех людей с таким user_id - birthday_users = [datetime.strptime(row[2], "%Y-%m-%d").strftime("%Y-%m-%dT00:00:00.000Z") for row in records[1:] if row[0] == patient_fio] - print(birthday_users) if not user_id or not patient_fio: #or not taxpayer_fio @@ -276,7 +292,7 @@ def request_patient_information(): "last_name": patient_fio.split()[0], "pac_poluchat": "True", "poluchat_status": "", - "birthday": birthday_users[0] if birthday_users else None + "birthday": birthday_users } print(payload) headers = {"User-Agent": "Mozilla/5.0", "Content-Type": "application/json"} @@ -481,12 +497,28 @@ def request_patient2(): taxpayer_status_zapros = data.get('taxpayer_status') patient_fio = data.get('patient_fio') - sheet = authorize_google().open("Пациенты клиники").sheet1 - records = sheet.get_all_values() + url = "http://192.168.1.10:8081/AppFindPacFromTel" + data = {"telegram_id": user_id} - # Получаем список всех людей с таким user_id - birthday_users = [datetime.strptime(row[2], "%Y-%m-%d").strftime("%Y-%m-%dT00:00:00.000Z") for row in records[1:] if row[0] == patient_fio] - print(birthday_users) + response = requests.post(url, json=data) + + if response.status_code == 200: + result = response.json() + patients = [] # Список пациентов + birthday_pac = {} # Словарь для хранения ФИО и даты рождения + + for patient in result.get("Pacients", []): + # Формируем строку ФИО + fio = f"{patient['last_name']} {patient['first_name']} {patient['second_name']}" + patients.append(fio) + + # Сохраняем дату рождения в словарь с ключом ФИО + birthday_pac[fio] = patient['birthday'] + print("список:", patients) + print("даты рождения:", birthday_pac) + birthday_users = birthday_pac.get(patient_fio) + + print(birthday_users) payload = { @@ -496,7 +528,7 @@ def request_patient2(): "last_name": patient_fio.split()[0], "pac_poluchat": "False", "poluchat_status": data.get('taxpayer_status'), - "birthday": birthday_users[0] if birthday_users else None + "birthday": birthday_users } print(payload) headers = {"User-Agent": "Mozilla/5.0", "Content-Type": "application/json"} @@ -754,18 +786,25 @@ def main_page_2_0_fns_test(): if not user_id: return "Ошибка: не передан user_id", 400 - sheet = authorize_google().open("Пациенты клиники").sheet1 - records = sheet.get_all_values() + url = "http://192.168.1.10:8081/AppFindPacFromTel" + data = {"telegram_id": user_id} - # Получаем список всех людей с таким user_id - matching_users = [row[0] for row in records[1:] if row[3] == user_id] - matching_users = sum(matching_users, []) if any(isinstance(i, list) for i in matching_users) else matching_users + response = requests.post(url, json=data) + patients = [] - print(matching_users) + if response.status_code == 200: + result = response.json() + for patient in result.get("Pacients", []): + # Формируем строку ФИО + fio = f"{patient['last_name']} {patient['first_name']} {patient['second_name']}" + patients.append(fio) + print("список:", patients) + birthday_pac = {patient['birthday']} - if not matching_users: + + if not patients: return "Ошибка: пользователь не найден", 404 - return render_template('2.0/main_page_fns2.pug', user_id=user_id, users=matching_users) + return render_template('2.0/main_page_fns2.pug', user_id=user_id, users=patients, birthday_paci=birthday_pac) except Exception as e: return f"Произошла ошибка: {e}", 500 \ No newline at end of file