Improved informer
This commit is contained in:
parent
c2b024e5df
commit
bfed31c890
96
get_eo.py
96
get_eo.py
@ -221,6 +221,7 @@ def get_GPV_message(approved_from, event_date, hours_off, hours_on, outage_queue
|
||||
need_to_send = not is_old_and_new_datas_equals_GPV(hours_off, hours_on, approved_from, event_date)
|
||||
if need_to_send:
|
||||
save_last_datas_GPV(hours_off, hours_on, approved_from, event_date)
|
||||
|
||||
if len(hours_off) > 0:
|
||||
message += '\nВимкнення:'
|
||||
for i in range(len(hours_off)):
|
||||
@ -295,16 +296,92 @@ def get_message_with_PO(root,
|
||||
|
||||
def process_GPV(oe_account_number, tg_chat, tg_token):
|
||||
global IS_DEBUG
|
||||
if not IS_DEBUG:
|
||||
if IS_DEBUG:
|
||||
x = json.loads(
|
||||
# '{"current": {"hasQueue": "yes", "note": "ZZZ xxx YYY", "queue": 5, "subQueue": 1}, "schedule": [{"createdAt": "30.10.2025 20:59", "eventDate": "31.10.2025", "queues": {"5.1": [{"from": "22:00", "shutdownHours": "22:00-00:00", "status": 1, "to": "00:00"}]}, "scheduleApprovedSince": "31.10.2025 10:52"}]}'
|
||||
"""{
|
||||
"current":
|
||||
{
|
||||
"gav":
|
||||
{
|
||||
"message": "Черга спеціальних аварійних відключень (СГАВ):",
|
||||
"queue": null
|
||||
},
|
||||
"hasQueue": "yes",
|
||||
"note": "Станом на 21:05 14.01.2026 за вказаним особовим рахунком '30014180' споживач підпадає під чергу '5.1' Графіку погодинного відключення(ГПВ)",
|
||||
"queue": 5,
|
||||
"sgav":
|
||||
{
|
||||
"message": "Черга спеціальних аварійних відключень (СГАВ):",
|
||||
"queue": null
|
||||
},
|
||||
"subQueue": 1
|
||||
},
|
||||
"schedule":
|
||||
[
|
||||
{
|
||||
"createdAt": "14.01.2026 19:11",
|
||||
"eventDate": "15.01.2026",
|
||||
"queues":
|
||||
{
|
||||
"5.1":
|
||||
[
|
||||
{
|
||||
"from": "07:30",
|
||||
"shutdownHours": "07:30-11:00",
|
||||
"status": 1,
|
||||
"to": "11:00"
|
||||
},
|
||||
{
|
||||
"from": "14:30",
|
||||
"shutdownHours": "14:30-20:00",
|
||||
"status": 1,
|
||||
"to": "20:00"
|
||||
},
|
||||
{
|
||||
"from": "22:00",
|
||||
"shutdownHours": "22:00-00:00",
|
||||
"status": 1,
|
||||
"to": "00:00"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scheduleApprovedSince": "14.01.2026 19:11"
|
||||
},
|
||||
{
|
||||
"createdAt": "13.01.2026 20:28",
|
||||
"eventDate": "14.01.2026",
|
||||
"queues":
|
||||
{
|
||||
"5.1":
|
||||
[
|
||||
{
|
||||
"from": "03:00",
|
||||
"shutdownHours": "03:00-07:00",
|
||||
"status": 1,
|
||||
"to": "07:00"
|
||||
},
|
||||
{
|
||||
"from": "11:00",
|
||||
"shutdownHours": "11:00-17:30",
|
||||
"status": 1,
|
||||
"to": "17:30"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scheduleApprovedSince": "14.01.2026 09:56"
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
)
|
||||
else:
|
||||
response = get_GPV_response_from_oe(oe_account_number)
|
||||
if response.status_code != 200:
|
||||
print("code=" + str(response.status_code))
|
||||
return STATUS_ERROR_GPV_RESPONSE
|
||||
|
||||
x = response.json()
|
||||
else:
|
||||
x = json.loads(
|
||||
'{"current": {"hasQueue": "yes", "note": "ZZZ xxx YYY", "queue": 5, "subQueue": 1}, "schedule": [{"createdAt": "30.10.2025 20:59", "eventDate": "31.10.2025", "queues": {"5.1": [{"from": "22:00", "shutdownHours": "22:00-00:00", "status": 1, "to": "00:00"}]}, "scheduleApprovedSince": "31.10.2025 10:52"}]}')
|
||||
|
||||
hours_off = []
|
||||
hours_on = []
|
||||
@ -314,12 +391,13 @@ def process_GPV(oe_account_number, tg_chat, tg_token):
|
||||
|
||||
datas = ''
|
||||
if 'queues' in str(x["schedule"]):
|
||||
datas = x["schedule"][0]
|
||||
datas = sorted(x["schedule"], key=lambda item: item['eventDate'])
|
||||
|
||||
if len(datas) > 0:
|
||||
approved_from = 'Запроваджено ' + datas['scheduleApprovedSince']
|
||||
event_date = datas['eventDate']
|
||||
hours_list = datas['queues'][outage_queue]
|
||||
for entry in datas:
|
||||
if len(entry) > 0:
|
||||
approved_from = 'Запроваджено ' + entry['scheduleApprovedSince']
|
||||
event_date = entry['eventDate']
|
||||
hours_list = entry['queues'][outage_queue]
|
||||
else:
|
||||
hours_list = []
|
||||
approved_from = 'Hемає даних про дату запровадження'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user