worker-automate-hub 0.5.599__py3-none-any.whl → 0.5.601__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- worker_automate_hub/api/client.py +2 -0
- worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py +506 -0
- worker_automate_hub/tasks/task_definitions.py +4 -0
- {worker_automate_hub-0.5.599.dist-info → worker_automate_hub-0.5.601.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.599.dist-info → worker_automate_hub-0.5.601.dist-info}/RECORD +7 -6
- {worker_automate_hub-0.5.599.dist-info → worker_automate_hub-0.5.601.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.599.dist-info → worker_automate_hub-0.5.601.dist-info}/entry_points.txt +0 -0
@@ -614,8 +614,10 @@ async def send_file(
|
|
614
614
|
elif file_extension == "001":
|
615
615
|
content_type = "text/plain"
|
616
616
|
elif file_extension == "xls":
|
617
|
+
filename = desArquivo
|
617
618
|
content_type = "application/vnd.ms-excel"
|
618
619
|
elif file_extension == "xlsx":
|
620
|
+
filename = desArquivo
|
619
621
|
content_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
620
622
|
else:
|
621
623
|
raise ValueError(f"Extensão de arquivo não suportada: {file_extension}")
|
@@ -0,0 +1,506 @@
|
|
1
|
+
import asyncio
|
2
|
+
import getpass
|
3
|
+
from datetime import datetime
|
4
|
+
import pyperclip
|
5
|
+
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
6
|
+
RpaHistoricoStatusEnum,
|
7
|
+
RpaRetornoProcessoDTO,
|
8
|
+
RpaTagDTO,
|
9
|
+
RpaTagEnum,
|
10
|
+
)
|
11
|
+
from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
|
12
|
+
RpaProcessoEntradaDTO,
|
13
|
+
)
|
14
|
+
from rich.console import Console
|
15
|
+
import re
|
16
|
+
import io
|
17
|
+
import os
|
18
|
+
import time
|
19
|
+
import json
|
20
|
+
import pandas as pd
|
21
|
+
from pathlib import Path
|
22
|
+
|
23
|
+
from pywinauto.keyboard import send_keys
|
24
|
+
from worker_automate_hub.utils.util import login_emsys
|
25
|
+
import warnings
|
26
|
+
from pywinauto.application import Application
|
27
|
+
from worker_automate_hub.api.client import (
|
28
|
+
get_config_by_name,
|
29
|
+
get_status_nf_emsys,
|
30
|
+
send_file,
|
31
|
+
)
|
32
|
+
from worker_automate_hub.api.ahead_service import save_xml_to_downloads
|
33
|
+
from worker_automate_hub.utils.util import (
|
34
|
+
kill_all_emsys,
|
35
|
+
delete_xml,
|
36
|
+
set_variable,
|
37
|
+
type_text_into_field,
|
38
|
+
worker_sleep,
|
39
|
+
)
|
40
|
+
from pywinauto_recorder.player import set_combobox
|
41
|
+
from worker_automate_hub.api.datalake_service import send_file_to_datalake
|
42
|
+
|
43
|
+
from datetime import timedelta
|
44
|
+
import pyautogui
|
45
|
+
from worker_automate_hub.utils.logger import logger
|
46
|
+
from worker_automate_hub.utils.utils_nfe_entrada import EMSys
|
47
|
+
|
48
|
+
ASSETS_BASE_PATH = "assets"
|
49
|
+
emsys = EMSys()
|
50
|
+
|
51
|
+
console = Console()
|
52
|
+
pyautogui.PAUSE = 0.5
|
53
|
+
pyautogui.FAILSAFE = False
|
54
|
+
|
55
|
+
|
56
|
+
async def wait_aguarde_window_closed(app, timeout=180):
|
57
|
+
console.print("Verificando existencia de aguarde...")
|
58
|
+
start_time = time.time()
|
59
|
+
|
60
|
+
while time.time() - start_time < timeout:
|
61
|
+
try:
|
62
|
+
janela_topo = app.top_window()
|
63
|
+
titulo = janela_topo.window_text()
|
64
|
+
console.print(f"Título da janela no topo: {titulo}")
|
65
|
+
except Exception as e:
|
66
|
+
console.print(f"Erro ao obter janela do topo: {e}", style="bold red")
|
67
|
+
titulo = ""
|
68
|
+
|
69
|
+
# Verifica se há alertas de aviso ou erro e clica no botão OK
|
70
|
+
await emsys.verify_warning_and_error("Aviso", "&Ok")
|
71
|
+
|
72
|
+
# Aguarda um pouco antes de verificar de novo
|
73
|
+
await worker_sleep(2)
|
74
|
+
|
75
|
+
if "Relatório Extrato Bancário" in titulo:
|
76
|
+
console.log("Fim de aguardando...")
|
77
|
+
return
|
78
|
+
else:
|
79
|
+
console.log("Aguardando...")
|
80
|
+
|
81
|
+
console.log("Timeout esperando a janela Aguarde...")
|
82
|
+
|
83
|
+
async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
84
|
+
try:
|
85
|
+
config = await get_config_by_name("login_emsys")
|
86
|
+
periodo_inicial = task.configEntrada["periodoInicial"]
|
87
|
+
periodo_final = task.configEntrada["periodoFinal"]
|
88
|
+
historico_id = task.historico_id
|
89
|
+
await kill_all_emsys()
|
90
|
+
|
91
|
+
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSys3_35.exe")
|
92
|
+
warnings.filterwarnings(
|
93
|
+
"ignore",
|
94
|
+
category=UserWarning,
|
95
|
+
message="32-bit application should be automated using 32-bit Python",
|
96
|
+
)
|
97
|
+
console.print("\nEMSys iniciando...", style="bold green")
|
98
|
+
return_login = await login_emsys(config.conConfiguracao, app, task, filial_origem=1)
|
99
|
+
|
100
|
+
if return_login.sucesso == True:
|
101
|
+
type_text_into_field(
|
102
|
+
"Rel. Extrato Bancário", app["TFrmMenuPrincipal"]["Edit"], True, "50"
|
103
|
+
)
|
104
|
+
pyautogui.press("enter")
|
105
|
+
await worker_sleep(2)
|
106
|
+
pyautogui.press("enter")
|
107
|
+
|
108
|
+
else:
|
109
|
+
logger.info(f"\nError Message: {return_login.retorno}")
|
110
|
+
console.print(f"\nError Message: {return_login.retorno}", style="bold red")
|
111
|
+
return return_login
|
112
|
+
|
113
|
+
await worker_sleep(6)
|
114
|
+
|
115
|
+
##### Janela Extrato Bancário #####
|
116
|
+
|
117
|
+
# Clicar na lupa
|
118
|
+
pyautogui.click(x=1077, y=351)
|
119
|
+
|
120
|
+
await worker_sleep(2)
|
121
|
+
|
122
|
+
# Armazenar os Mneumonico
|
123
|
+
linhas = []
|
124
|
+
vistos = set()
|
125
|
+
ultima_linha = ""
|
126
|
+
repeticoes = 0
|
127
|
+
limite_repeticoes = 3
|
128
|
+
max_linhas = 1000
|
129
|
+
|
130
|
+
console.print("Iniciando leitura dos mnemônicos..")
|
131
|
+
# Clicar na primeira linha
|
132
|
+
pyautogui.click(x=698, y=467)
|
133
|
+
|
134
|
+
await worker_sleep(2)
|
135
|
+
|
136
|
+
# Percorrer todas as linhas
|
137
|
+
for _ in range(max_linhas):
|
138
|
+
send_keys('^c')
|
139
|
+
await asyncio.sleep(0.5)
|
140
|
+
linha = pyperclip.paste().strip()
|
141
|
+
|
142
|
+
if not linha:
|
143
|
+
print("[Aviso] Linha vazia detectada. Pulando...")
|
144
|
+
send_keys('{DOWN}')
|
145
|
+
await asyncio.sleep(0.3)
|
146
|
+
continue
|
147
|
+
|
148
|
+
if linha == ultima_linha:
|
149
|
+
repeticoes += 1
|
150
|
+
if repeticoes >= limite_repeticoes:
|
151
|
+
print("Fim detectado: linha repetida várias vezes.")
|
152
|
+
break
|
153
|
+
else:
|
154
|
+
repeticoes = 0
|
155
|
+
|
156
|
+
if linha not in vistos:
|
157
|
+
print(f"[{len(linhas)+1}] {linha}")
|
158
|
+
linhas.append(linha)
|
159
|
+
vistos.add(linha)
|
160
|
+
|
161
|
+
ultima_linha = linha
|
162
|
+
send_keys('{DOWN}')
|
163
|
+
await asyncio.sleep(0.3)
|
164
|
+
|
165
|
+
console.print("Números mnemônicos armazenados")
|
166
|
+
# Extrair apenas o mnemônico da linha de dados após o cabeçalho
|
167
|
+
mnemonicos_detalhados = []
|
168
|
+
for linha in linhas:
|
169
|
+
if "Mnemônico" in linha:
|
170
|
+
partes = linha.split('\r\n')
|
171
|
+
if len(partes) > 1:
|
172
|
+
dados = partes[1].split('\t')
|
173
|
+
if len(dados) >= 4:
|
174
|
+
mnemonico = dados[0].strip()
|
175
|
+
agencia = dados[1].strip()
|
176
|
+
conta = dados[2].strip()
|
177
|
+
banco = dados[3].strip()
|
178
|
+
|
179
|
+
mnemonicos_detalhados.append({
|
180
|
+
"mnemonico": mnemonico,
|
181
|
+
"agencia": agencia,
|
182
|
+
"conta": conta,
|
183
|
+
"banco": banco
|
184
|
+
})
|
185
|
+
|
186
|
+
##### Janela Buscar Mneumônico
|
187
|
+
pyautogui.click(x=1196, y=650)
|
188
|
+
|
189
|
+
saldos = []
|
190
|
+
# Extrair apenas o mnemônico da linha de dados após o cabeçalho
|
191
|
+
mnemonicos_detalhados = []
|
192
|
+
clicou_conciliados = False
|
193
|
+
inserir_periodo = False
|
194
|
+
for linha in linhas:
|
195
|
+
caminho_excel = ""
|
196
|
+
filename = ""
|
197
|
+
await worker_sleep(1)
|
198
|
+
##### Janela Relatório Extrato Bancário #####
|
199
|
+
app = Application(backend="win32").connect(class_name="TFrmRelExtratoBancario", found_index=0)
|
200
|
+
main_window = app["TFrmRelExtratoBancario"]
|
201
|
+
|
202
|
+
|
203
|
+
# Inserir Mnemonico
|
204
|
+
console.log("Iniciando Baixa do XLS")
|
205
|
+
if "Mnemônico" in linha:
|
206
|
+
partes = linha.split('\r\n')
|
207
|
+
if len(partes) > 1:
|
208
|
+
dados = partes[1].split('\t')
|
209
|
+
if len(dados) >= 4:
|
210
|
+
mnemonico = dados[0].strip()
|
211
|
+
agencia = dados[1].strip()
|
212
|
+
conta = dados[2].strip()
|
213
|
+
banco = dados[3].strip()
|
214
|
+
|
215
|
+
mnemonicos_detalhados.append({
|
216
|
+
"mnemonico": mnemonico,
|
217
|
+
"agencia": agencia,
|
218
|
+
"conta": conta,
|
219
|
+
"banco": banco
|
220
|
+
})
|
221
|
+
conta_movimento = f"{banco}/ AG {agencia}/ Conta {conta}"
|
222
|
+
input_mnemonico = main_window.child_window(class_name="TDBIEditCode", found_index=0)
|
223
|
+
console.print(f"Inserindo Mnemônico: {mnemonico}")
|
224
|
+
type_text_into_field(
|
225
|
+
text=mnemonico,
|
226
|
+
field=input_mnemonico,
|
227
|
+
empty_before=True,
|
228
|
+
chars_to_empty="10",
|
229
|
+
)
|
230
|
+
await worker_sleep(1)
|
231
|
+
|
232
|
+
send_keys('{TAB}')
|
233
|
+
|
234
|
+
await worker_sleep(1)
|
235
|
+
if not inserir_periodo:
|
236
|
+
console.print("Inserindo perído inicial")
|
237
|
+
# Inserir período inicial
|
238
|
+
input_data_inicial = main_window.child_window(class_name="TDBIEditDate", found_index=3)
|
239
|
+
|
240
|
+
|
241
|
+
type_text_into_field(
|
242
|
+
text=periodo_inicial,
|
243
|
+
field=input_data_inicial,
|
244
|
+
empty_before=True,
|
245
|
+
chars_to_empty="10",
|
246
|
+
)
|
247
|
+
await worker_sleep(1)
|
248
|
+
|
249
|
+
console.print("Inserindo perído final")
|
250
|
+
input_data_final = main_window.child_window(class_name="TDBIEditDate", found_index=2)
|
251
|
+
|
252
|
+
type_text_into_field(
|
253
|
+
text=periodo_final,
|
254
|
+
field=input_data_final,
|
255
|
+
empty_before=True,
|
256
|
+
chars_to_empty="10",
|
257
|
+
)
|
258
|
+
inserir_periodo = True
|
259
|
+
await worker_sleep(1)
|
260
|
+
console.print("Marcando movimentos conciliados")
|
261
|
+
# Marcar movimentos conciliados
|
262
|
+
if not clicou_conciliados:
|
263
|
+
chk_mov_conciliados = main_window.child_window(class_name="TDBICheckBox", found_index=2).click()
|
264
|
+
|
265
|
+
|
266
|
+
await worker_sleep(2)
|
267
|
+
|
268
|
+
console.print("Selecionar tipo Excel")
|
269
|
+
# Selecionar Excel
|
270
|
+
slc_excel = main_window.child_window(class_name="TDBIComboBoxValues", found_index=0).select("Excel")
|
271
|
+
clicou_conciliados = True
|
272
|
+
|
273
|
+
await worker_sleep(3)
|
274
|
+
|
275
|
+
# Clicar em gerar relatório
|
276
|
+
console.print("Clicar em gerar relatório")
|
277
|
+
btn_gerar_relatorio = main_window.child_window(class_name="TBitBtn", found_index=0).click_input()
|
278
|
+
|
279
|
+
await worker_sleep(5)
|
280
|
+
console.print("Verificar se existem dados")
|
281
|
+
|
282
|
+
try:
|
283
|
+
nao_existe_dados = fr"{ASSETS_BASE_PATH}\nao_existem_dados.png"
|
284
|
+
|
285
|
+
for tentativa in range(3):
|
286
|
+
console.print(f"Tentativa {tentativa + 1}: Clicar em 'Gerar Relatório'")
|
287
|
+
|
288
|
+
btn_gerar_relatorio = main_window.child_window(class_name="TBitBtn", found_index=0)
|
289
|
+
if btn_gerar_relatorio.exists(timeout=2):
|
290
|
+
btn_gerar_relatorio.click_input()
|
291
|
+
await worker_sleep(3)
|
292
|
+
|
293
|
+
# Verifica se apareceu a imagem de "sem dados"
|
294
|
+
localizacao = pyautogui.locateOnScreen(nao_existe_dados, confidence=0.9)
|
295
|
+
if localizacao:
|
296
|
+
console.print(f"Nenhum dado para {mnemonico}")
|
297
|
+
valor = "0,00"
|
298
|
+
|
299
|
+
try:
|
300
|
+
app_sem_dados = Application(backend="win32").connect(title="Information", found_index=0)
|
301
|
+
window_sem_dados = app_sem_dados["Information"]
|
302
|
+
botao_ok = window_sem_dados.child_window(class_name="TButton", found_index=0).click()
|
303
|
+
except Exception as e:
|
304
|
+
console.print(f"Erro ao fechar janela 'Information': {e}", style="bold red")
|
305
|
+
|
306
|
+
await worker_sleep(2)
|
307
|
+
break
|
308
|
+
|
309
|
+
# Verifica se apareceu a janela "Salvar para arquivo"
|
310
|
+
try:
|
311
|
+
app_salvar = Application(backend="win32").connect(title="Salvar para arquivo", found_index=0)
|
312
|
+
main_window_salvar = app_salvar["Salvar para arquivo"]
|
313
|
+
console.print("Janela 'Salvar para arquivo' encontrada.")
|
314
|
+
break # Janela encontrada, pode sair do loop
|
315
|
+
except:
|
316
|
+
console.print("Janela 'Salvar para arquivo' não encontrada.", style="yellow")
|
317
|
+
|
318
|
+
else:
|
319
|
+
console.print("Botão 'Gerar Relatório' não encontrado.", style="bold red")
|
320
|
+
break
|
321
|
+
except:
|
322
|
+
await worker_sleep(2)
|
323
|
+
##### Janela Salvar para arquivo #####
|
324
|
+
console.print(f"Dados encontrados para {mnemonico}")
|
325
|
+
app = Application(backend="win32").connect(
|
326
|
+
title="Salvar para arquivo", found_index=0
|
327
|
+
)
|
328
|
+
main_window = app["Salvar para arquivo"]
|
329
|
+
date_now = datetime.now().strftime("%Y%m%d%H%M%S")
|
330
|
+
data_inicial_arquivo = periodo_inicial.replace("/", "")
|
331
|
+
data_final_arquivo = periodo_final.replace("/", "")
|
332
|
+
|
333
|
+
# Caminho completo para Downloads
|
334
|
+
nome_arquivo = f"C:\\Users\\{getpass.getuser()}\\Downloads\\fechamento_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.XLS"
|
335
|
+
|
336
|
+
console.print(f"Salvar arquivo: {nome_arquivo}")
|
337
|
+
|
338
|
+
# Inserir nome do arquivo
|
339
|
+
console.print(f"Inserir caminho do arquivo: {caminho_arquivo}")
|
340
|
+
input_nome = main_window.child_window(class_name="Edit", found_index=0)
|
341
|
+
type_text_into_field(
|
342
|
+
nome_arquivo, input_nome, empty_before=False, chars_to_empty="0"
|
343
|
+
)
|
344
|
+
|
345
|
+
await worker_sleep(2)
|
346
|
+
|
347
|
+
console.print("Salvando o arquivo")
|
348
|
+
# Clicar em salvar
|
349
|
+
botao_salvar = main_window.child_window(class_name="Button", found_index=0)
|
350
|
+
botao_salvar.click_input()
|
351
|
+
|
352
|
+
await worker_sleep(6)
|
353
|
+
|
354
|
+
await wait_aguarde_window_closed(app)
|
355
|
+
|
356
|
+
arquivo_path = Path(nome_arquivo)
|
357
|
+
# Altera a extensão para .XLS
|
358
|
+
caminho_arquivo = arquivo_path.with_suffix('.XLS')
|
359
|
+
# Altera a extensão final para .xls minúsculo
|
360
|
+
caminho_ajustado = caminho_arquivo.with_suffix('.xls')
|
361
|
+
nome_com_extensao = caminho_ajustado.name
|
362
|
+
print(nome_com_extensao)
|
363
|
+
# Renomeia o arquivo
|
364
|
+
os.rename(caminho_arquivo, caminho_ajustado)
|
365
|
+
|
366
|
+
console.print(f"Arquivo renomeado para: {caminho_ajustado}")
|
367
|
+
|
368
|
+
await worker_sleep(1)
|
369
|
+
|
370
|
+
console.print("Extraindo os dados do Excel")
|
371
|
+
|
372
|
+
# Envia o arquivo para o BOF
|
373
|
+
df = pd.read_excel(caminho_ajustado, header=None, engine="xlrd")
|
374
|
+
|
375
|
+
# Filtra onde a coluna Q (índice 16) contém "Total Geral"
|
376
|
+
mask = df[16].astype(str).str.contains("Total Geral", case=False, na=False)
|
377
|
+
linha_subtot = df[mask].index
|
378
|
+
|
379
|
+
valor = None
|
380
|
+
|
381
|
+
if not linha_subtot.empty:
|
382
|
+
index_subtot = linha_subtot[0]
|
383
|
+
index_verificacao = index_subtot - 2
|
384
|
+
|
385
|
+
# Regex para aceitar apenas números, vírgulas, pontos e sinal de menos
|
386
|
+
padrao_numerico = re.compile(r"^-?[\d\.\,]+$")
|
387
|
+
|
388
|
+
while index_verificacao >= 0:
|
389
|
+
valor_bruto = str(df.at[index_verificacao, 23]).strip()
|
390
|
+
|
391
|
+
# Verifica se não contém letras, apenas caracteres numéricos válidos
|
392
|
+
if padrao_numerico.fullmatch(valor_bruto):
|
393
|
+
valor = valor_bruto # Mantém exatamente como está na planilha
|
394
|
+
break
|
395
|
+
|
396
|
+
index_verificacao -= 1
|
397
|
+
|
398
|
+
if valor is not None:
|
399
|
+
console.print(f"Valor encontrado: {valor}")
|
400
|
+
else:
|
401
|
+
console.print("Nenhum valor numérico puro encontrado nas linhas anteriores.")
|
402
|
+
else:
|
403
|
+
console.print("Linha contendo 'Total Geral' não encontrada.")
|
404
|
+
return RpaRetornoProcessoDTO(
|
405
|
+
sucesso=False,
|
406
|
+
retorno=f"Erro ao enviar o arquivo: {e}",
|
407
|
+
status=RpaHistoricoStatusEnum.Falha,
|
408
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
409
|
+
)
|
410
|
+
console.print("Adicionando dados no json")
|
411
|
+
await worker_sleep(2)
|
412
|
+
# Adiciona o item à lista de saldos
|
413
|
+
saldos.append({
|
414
|
+
"mnemonico": mnemonico,
|
415
|
+
"contaMovimento": conta_movimento,
|
416
|
+
"valor": valor
|
417
|
+
})
|
418
|
+
|
419
|
+
try:
|
420
|
+
# lê o arquivo
|
421
|
+
with open(f"{caminho_ajustado}", "rb") as file:
|
422
|
+
file_bytes = io.BytesIO(file.read())
|
423
|
+
|
424
|
+
console.print("Enviar Excel para o BOF")
|
425
|
+
# Envia o arquivo para o BOF
|
426
|
+
try:
|
427
|
+
await send_file(
|
428
|
+
historico_id,
|
429
|
+
nome_com_extensao,
|
430
|
+
"xls",
|
431
|
+
file_bytes,
|
432
|
+
file_extension="xls",
|
433
|
+
)
|
434
|
+
console.print("Removendo arquivo XLS da pasta downloads")
|
435
|
+
os.remove(f"{caminho_ajustado}")
|
436
|
+
|
437
|
+
except Exception as e:
|
438
|
+
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
439
|
+
return RpaRetornoProcessoDTO(
|
440
|
+
sucesso=False,
|
441
|
+
retorno=f"Erro ao enviar o arquivo: {e}",
|
442
|
+
status=RpaHistoricoStatusEnum.Falha,
|
443
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
444
|
+
)
|
445
|
+
except:
|
446
|
+
pass
|
447
|
+
console.print("Criando estrutura do Json")
|
448
|
+
# Cria estrutura final do JSON
|
449
|
+
dados_json = {
|
450
|
+
"fechamento": {
|
451
|
+
"periodoInicial": periodo_inicial,
|
452
|
+
"periodoFinal": periodo_final,
|
453
|
+
"dataHora": datetime.now().strftime("%Y-%m-%d %H:%M")
|
454
|
+
},
|
455
|
+
"saldos": saldos
|
456
|
+
}
|
457
|
+
|
458
|
+
console.print("Salvando arquivo json")
|
459
|
+
# Salva em arquivo
|
460
|
+
filename = f"fechamento_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.json"
|
461
|
+
caminho_downloads = os.path.join(os.environ["USERPROFILE"], "Downloads")
|
462
|
+
full_path = os.path.join(
|
463
|
+
caminho_downloads,
|
464
|
+
f"fechamento_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.json"
|
465
|
+
)
|
466
|
+
|
467
|
+
with open(full_path, "w", encoding="utf-8") as f:
|
468
|
+
json.dump(dados_json, f, ensure_ascii=False, indent=2)
|
469
|
+
|
470
|
+
print(f"Arquivo JSON salvo em: {full_path}")
|
471
|
+
|
472
|
+
console.print("Enviar arquivo para o Datalake")
|
473
|
+
# Envia o JSON para o datalake
|
474
|
+
directory = "balancete_contabil/raw"
|
475
|
+
|
476
|
+
with open(full_path, "rb") as file:
|
477
|
+
file_bytes = io.BytesIO(file.read())
|
478
|
+
try:
|
479
|
+
send_file_request = await send_file_to_datalake(
|
480
|
+
directory, file_bytes, filename, "json"
|
481
|
+
)
|
482
|
+
os.remove(full_path)
|
483
|
+
return RpaRetornoProcessoDTO(
|
484
|
+
sucesso=True,
|
485
|
+
retorno="Extrações de fechamento Emsys enviadas com sucesso!",
|
486
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
487
|
+
)
|
488
|
+
except Exception as e:
|
489
|
+
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
490
|
+
return RpaRetornoProcessoDTO(
|
491
|
+
sucesso=False,
|
492
|
+
retorno=f"Erro ao enviar o arquivo: {e}",
|
493
|
+
status=RpaHistoricoStatusEnum.Falha,
|
494
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
495
|
+
)
|
496
|
+
|
497
|
+
except Exception as e:
|
498
|
+
return RpaRetornoProcessoDTO(
|
499
|
+
sucesso=False,
|
500
|
+
retorno=f"Erro no processo Extração de fechamento Emsys: {e}",
|
501
|
+
status=RpaHistoricoStatusEnum.Falha,
|
502
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
503
|
+
)
|
504
|
+
finally:
|
505
|
+
print("fim")
|
506
|
+
|
@@ -89,6 +89,9 @@ from worker_automate_hub.tasks.jobs.lancamento_pis_cofins import lancamento_pis_
|
|
89
89
|
from worker_automate_hub.tasks.jobs.extracao_fechamento_contabil import (
|
90
90
|
extracao_fechamento_contabil,
|
91
91
|
)
|
92
|
+
from worker_automate_hub.tasks.jobs.extracao_fechamento_emsys import (
|
93
|
+
extracao_fechamento_emsys,
|
94
|
+
)
|
92
95
|
|
93
96
|
task_definitions = {
|
94
97
|
"5b295021-8df7-40a1-a45e-fe7109ae3902": exemplo_processo,
|
@@ -185,6 +188,7 @@ task_definitions = {
|
|
185
188
|
"def194c2-ffa0-4b9e-b95c-920fb4ad4150": importar_cte_xml,
|
186
189
|
"58de6a65-68cd-4e68-ab28-31b543b6de02": transferencias, # Logistica reverse
|
187
190
|
"ca7ac373-e8e7-4ac2-aa7e-298070e0d9a0": extracao_fechamento_contabil,
|
191
|
+
"8c28726d-458d-4119-afa0-202695b79a8f": extracao_fechamento_emsys,
|
188
192
|
}
|
189
193
|
|
190
194
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
worker_automate_hub/__init__.py,sha256=LV28uQvBfpPIqudGIMJmVB8E941MjXHcu8DMoX5n8AM,25
|
2
2
|
worker_automate_hub/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
worker_automate_hub/api/ahead_service.py,sha256=QbNrZf9q7fS0s-S5fZVytqC7dINi9u2f6aB6SDrGVVA,2231
|
4
|
-
worker_automate_hub/api/client.py,sha256=
|
4
|
+
worker_automate_hub/api/client.py,sha256=DLyhA1yYaEkBsLUNfNHLbdr42OXFqmv_smlsW_Ee4Dw,25513
|
5
5
|
worker_automate_hub/api/datalake_service.py,sha256=qw_N_OOgDKDuPbI-fdYkWWTlT4CUtFTl0VVlZ0fLM-M,3001
|
6
6
|
worker_automate_hub/api/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
worker_automate_hub/api/helpers/api_helpers.py,sha256=SkheO2fXexeh-a4shr8Qzsz_kZhuSG0DJ7kbODctRbM,3696
|
@@ -67,6 +67,7 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py,sha256=aSgHterguK9XGtq0B
|
|
67
67
|
worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=VJ-2g7tuqbAICOarJpAhljjJJ5wbb5hphTboBWoxj7M,64639
|
68
68
|
worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=nV0iLoip2FH2-FhLmhX3nPqsfl_MPufZ3E5Q5krJvdc,3544
|
69
69
|
worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py,sha256=aU_8Z9N252sCnUGlDRoO7nF_R8BC86fIBdPCk-ufTRA,19723
|
70
|
+
worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py,sha256=qo9wcRDGzyBVUkwGXuqW1RhVwamdqi0Hhr3XCy2UPHo,20719
|
70
71
|
worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py,sha256=UWAKCS2dbfgDlSQOBdjmVJXfD1MMuUrOi3weDgB0CAc,5718
|
71
72
|
worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py,sha256=SOs2mORBJqHs089ApbLaPJVRXM7wWhf0e99URXqPlpQ,15020
|
72
73
|
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=zu92tRCvKPK0U6IGGF28ST-kERohJcNbys-DWk0tIco,12555
|
@@ -82,7 +83,7 @@ worker_automate_hub/tasks/jobs/notas_faturamento_sap.py,sha256=p6tVE027FHHXBxt2s
|
|
82
83
|
worker_automate_hub/tasks/jobs/playground.py,sha256=7vWDg9DwToHwGJ6_XOa8TQ6LmfRV5Qz2TaOV3q3P9sA,1918
|
83
84
|
worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=Zsq-IwKxA0b2tikO6Rri4WXVj10jK-Jd0-gxk8yVBH0,31064
|
84
85
|
worker_automate_hub/tasks/jobs/transferencias.py,sha256=-xW66JNYvhWmyNAYGukiLZ_O5NHQHskH36EkxtXnANg,44321
|
85
|
-
worker_automate_hub/tasks/task_definitions.py,sha256=
|
86
|
+
worker_automate_hub/tasks/task_definitions.py,sha256=GNiA2Gwdk412GBFFG2qPjxGjCl3U6MjmaPvaV7X-W_E,11147
|
86
87
|
worker_automate_hub/tasks/task_executor.py,sha256=9dmLUlMpJOI7FhbaFE593TcWnDxBvuXbGVecs1aaJxE,5728
|
87
88
|
worker_automate_hub/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
88
89
|
worker_automate_hub/utils/env.py,sha256=TacQjGRO7PUNpttrhTAc5Gnegaiysl2Knsv1P8qfkfs,57
|
@@ -93,7 +94,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
93
94
|
worker_automate_hub/utils/util.py,sha256=_pgZOFWgXoov6WPbqyRTDVXJCRFfucYB3gb9swzU7bo,198281
|
94
95
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=wmnpuOesmPSryZszmapa37b9YNC0E2MkeDYnbwr-0rU,33315
|
95
96
|
worker_automate_hub/worker.py,sha256=axdrr1xLTjWEyWfcyH3OCSpPTsyzck_fL_0u1DBLjvw,6525
|
96
|
-
worker_automate_hub-0.5.
|
97
|
-
worker_automate_hub-0.5.
|
98
|
-
worker_automate_hub-0.5.
|
99
|
-
worker_automate_hub-0.5.
|
97
|
+
worker_automate_hub-0.5.601.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
98
|
+
worker_automate_hub-0.5.601.dist-info/METADATA,sha256=6Grt4Z-j-PzJRLHno9UDs4XMYMONLSUfHhgJYzncBkU,3049
|
99
|
+
worker_automate_hub-0.5.601.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
100
|
+
worker_automate_hub-0.5.601.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.599.dist-info → worker_automate_hub-0.5.601.dist-info}/entry_points.txt
RENAMED
File without changes
|