worker-automate-hub 0.5.611__py3-none-any.whl → 0.5.612__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.
Potentially problematic release.
This version of worker-automate-hub might be problematic. Click here for more details.
- worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py +14 -18
- worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py +165 -114
- {worker_automate_hub-0.5.611.dist-info → worker_automate_hub-0.5.612.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.611.dist-info → worker_automate_hub-0.5.612.dist-info}/RECORD +6 -6
- {worker_automate_hub-0.5.611.dist-info → worker_automate_hub-0.5.612.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.611.dist-info → worker_automate_hub-0.5.612.dist-info}/entry_points.txt +0 -0
@@ -325,12 +325,12 @@ async def extracao_fechamento_contabil(
|
|
325
325
|
date_now = datetime.now().strftime("%Y%m%d%H%M%S")
|
326
326
|
data_inicial_arquivo = periodo_inicial.replace("/", "")
|
327
327
|
data_final_arquivo = periodo_final.replace("/", "")
|
328
|
-
|
328
|
+
|
329
329
|
# Caminho completo para Downloads
|
330
330
|
nome_arquivo = f"C:\\Users\\{getpass.getuser()}\\Downloads\\balancete_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.XLS"
|
331
|
-
|
331
|
+
|
332
332
|
console.print(f"Salvar arquivo: {nome_arquivo}")
|
333
|
-
|
333
|
+
|
334
334
|
# Inserir nome do arquivo
|
335
335
|
input_nome = main_window.child_window(class_name="Edit", found_index=0)
|
336
336
|
type_text_into_field(
|
@@ -344,8 +344,7 @@ async def extracao_fechamento_contabil(
|
|
344
344
|
botao_salvar.click_input()
|
345
345
|
|
346
346
|
await worker_sleep(2)
|
347
|
-
|
348
|
-
|
347
|
+
|
349
348
|
##### Janela Print #####
|
350
349
|
|
351
350
|
app = Application(backend="win32").connect(title="Print")
|
@@ -375,12 +374,12 @@ async def extracao_fechamento_contabil(
|
|
375
374
|
await worker_sleep(3)
|
376
375
|
|
377
376
|
console.print("Criar arquivo JSON")
|
378
|
-
|
377
|
+
|
379
378
|
arquivo_path = Path(nome_arquivo)
|
380
379
|
# Altera a extensão para .XLS maiúsculo (caso o EMSys exporte assim)
|
381
|
-
caminho_arquivo = arquivo_path.with_suffix(
|
380
|
+
caminho_arquivo = arquivo_path.with_suffix(".XLS")
|
382
381
|
# Altera a extensão final para .xls minúsculo
|
383
|
-
caminho_ajustado = caminho_arquivo.with_suffix(
|
382
|
+
caminho_ajustado = caminho_arquivo.with_suffix(".xls")
|
384
383
|
nome_com_extensao = caminho_ajustado.name
|
385
384
|
print(nome_com_extensao)
|
386
385
|
# Renomeia o arquivo
|
@@ -435,7 +434,7 @@ async def extracao_fechamento_contabil(
|
|
435
434
|
console.print(json.dumps(dados_json, ensure_ascii=False, indent=2))
|
436
435
|
|
437
436
|
await worker_sleep(3)
|
438
|
-
sended_to_datalake= False
|
437
|
+
sended_to_datalake = False
|
439
438
|
console.print("Enviar arquivo para o Datalake")
|
440
439
|
# Envia o JSON para o datalake
|
441
440
|
directory = "balancete_contabil/raw"
|
@@ -444,10 +443,8 @@ async def extracao_fechamento_contabil(
|
|
444
443
|
file_bytes = io.BytesIO(file.read())
|
445
444
|
try:
|
446
445
|
console.print("Enviando Json para data lake")
|
447
|
-
await send_file_to_datalake(
|
448
|
-
|
449
|
-
)
|
450
|
-
sended_to_datalake= True
|
446
|
+
await send_file_to_datalake(directory, file_bytes, filename, "json")
|
447
|
+
sended_to_datalake = True
|
451
448
|
except Exception as e:
|
452
449
|
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
453
450
|
return RpaRetornoProcessoDTO(
|
@@ -456,7 +453,7 @@ async def extracao_fechamento_contabil(
|
|
456
453
|
status=RpaHistoricoStatusEnum.Falha,
|
457
454
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
458
455
|
)
|
459
|
-
sended_to_bof= False
|
456
|
+
sended_to_bof = False
|
460
457
|
# lê o arquivo
|
461
458
|
with open(f"{caminho_ajustado}", "rb") as file:
|
462
459
|
file_bytes = io.BytesIO(file.read())
|
@@ -475,7 +472,7 @@ async def extracao_fechamento_contabil(
|
|
475
472
|
os.remove(f"{caminho_ajustado}")
|
476
473
|
console.print("Removendo arquivo JSON da pasta downloads")
|
477
474
|
os.remove(full_path)
|
478
|
-
sended_to_bof= True
|
475
|
+
sended_to_bof = True
|
479
476
|
except Exception as e:
|
480
477
|
result = f"Arquivo Balancete contábil gerado com sucesso, porém gerou erro ao realizar o envio para o backoffice {e} - Arquivo ainda salvo na dispositivo utilizado no diretório {caminho_arquivo} !"
|
481
478
|
console.print(result, style="bold red")
|
@@ -485,13 +482,12 @@ async def extracao_fechamento_contabil(
|
|
485
482
|
status=RpaHistoricoStatusEnum.Falha,
|
486
483
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
487
484
|
)
|
488
|
-
|
485
|
+
|
489
486
|
if sended_to_datalake and sended_to_bof:
|
490
487
|
return RpaRetornoProcessoDTO(
|
491
488
|
sucesso=True,
|
492
|
-
retorno=
|
489
|
+
retorno=dados_json,
|
493
490
|
status=RpaHistoricoStatusEnum.Sucesso,
|
494
|
-
|
495
491
|
)
|
496
492
|
except Exception as erro:
|
497
493
|
return RpaRetornoProcessoDTO(
|
@@ -80,7 +80,10 @@ async def wait_aguarde_window_closed(app, timeout=180):
|
|
80
80
|
|
81
81
|
console.log("Timeout esperando a janela Aguarde...")
|
82
82
|
|
83
|
-
|
83
|
+
|
84
|
+
async def extracao_fechamento_emsys(
|
85
|
+
task: RpaProcessoEntradaDTO,
|
86
|
+
) -> RpaRetornoProcessoDTO:
|
84
87
|
try:
|
85
88
|
config = await get_config_by_name("login_emsys")
|
86
89
|
periodo_inicial = task.configEntrada["periodoInicial"]
|
@@ -95,7 +98,9 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
95
98
|
message="32-bit application should be automated using 32-bit Python",
|
96
99
|
)
|
97
100
|
console.print("\nEMSys iniciando...", style="bold green")
|
98
|
-
return_login = await login_emsys(
|
101
|
+
return_login = await login_emsys(
|
102
|
+
config.conConfiguracao, app, task, filial_origem=1
|
103
|
+
)
|
99
104
|
|
100
105
|
if return_login.sucesso == True:
|
101
106
|
type_text_into_field(
|
@@ -104,22 +109,22 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
104
109
|
pyautogui.press("enter")
|
105
110
|
await worker_sleep(2)
|
106
111
|
pyautogui.press("enter")
|
107
|
-
|
112
|
+
|
108
113
|
else:
|
109
114
|
logger.info(f"\nError Message: {return_login.retorno}")
|
110
115
|
console.print(f"\nError Message: {return_login.retorno}", style="bold red")
|
111
116
|
return return_login
|
112
117
|
|
113
118
|
await worker_sleep(6)
|
114
|
-
|
119
|
+
|
115
120
|
##### Janela Extrato Bancário #####
|
116
|
-
|
121
|
+
|
117
122
|
# Clicar na lupa
|
118
123
|
pyautogui.click(x=1077, y=351)
|
119
|
-
|
120
|
-
await worker_sleep(2)
|
121
|
-
|
122
|
-
# Armazenar os Mneumonico
|
124
|
+
|
125
|
+
await worker_sleep(2)
|
126
|
+
|
127
|
+
# Armazenar os Mneumonico
|
123
128
|
linhas = []
|
124
129
|
vistos = set()
|
125
130
|
ultima_linha = ""
|
@@ -129,19 +134,19 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
129
134
|
|
130
135
|
console.print("Iniciando leitura dos mnemônicos..")
|
131
136
|
# Clicar na primeira linha
|
132
|
-
pyautogui.click(x=698, y=467)
|
133
|
-
|
137
|
+
pyautogui.click(x=698, y=467)
|
138
|
+
|
134
139
|
await worker_sleep(2)
|
135
140
|
|
136
141
|
# Percorrer todas as linhas
|
137
142
|
for _ in range(max_linhas):
|
138
|
-
send_keys(
|
143
|
+
send_keys("^c")
|
139
144
|
await asyncio.sleep(0.5)
|
140
145
|
linha = pyperclip.paste().strip()
|
141
146
|
|
142
147
|
if not linha:
|
143
148
|
print("[Aviso] Linha vazia detectada. Pulando...")
|
144
|
-
send_keys(
|
149
|
+
send_keys("{DOWN}")
|
145
150
|
await asyncio.sleep(0.3)
|
146
151
|
continue
|
147
152
|
|
@@ -159,7 +164,7 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
159
164
|
vistos.add(linha)
|
160
165
|
|
161
166
|
ultima_linha = linha
|
162
|
-
send_keys(
|
167
|
+
send_keys("{DOWN}")
|
163
168
|
await asyncio.sleep(0.3)
|
164
169
|
|
165
170
|
console.print("Números mnemônicos armazenados")
|
@@ -167,25 +172,27 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
167
172
|
mnemonicos_detalhados = []
|
168
173
|
for linha in linhas:
|
169
174
|
if "Mnemônico" in linha:
|
170
|
-
partes = linha.split(
|
175
|
+
partes = linha.split("\r\n")
|
171
176
|
if len(partes) > 1:
|
172
|
-
dados = partes[1].split(
|
177
|
+
dados = partes[1].split("\t")
|
173
178
|
if len(dados) >= 4:
|
174
179
|
mnemonico = dados[0].strip()
|
175
180
|
agencia = dados[1].strip()
|
176
181
|
conta = dados[2].strip()
|
177
182
|
banco = dados[3].strip()
|
178
183
|
|
179
|
-
mnemonicos_detalhados.append(
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
184
|
+
mnemonicos_detalhados.append(
|
185
|
+
{
|
186
|
+
"mnemonico": mnemonico,
|
187
|
+
"agencia": agencia,
|
188
|
+
"conta": conta,
|
189
|
+
"banco": banco,
|
190
|
+
}
|
191
|
+
)
|
192
|
+
|
193
|
+
##### Janela Buscar Mneumônico
|
194
|
+
pyautogui.click(x=1196, y=650)
|
195
|
+
|
189
196
|
saldos = []
|
190
197
|
# Extrair apenas o mnemônico da linha de dados após o cabeçalho
|
191
198
|
mnemonicos_detalhados = []
|
@@ -196,30 +203,35 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
196
203
|
filename = ""
|
197
204
|
await worker_sleep(1)
|
198
205
|
##### Janela Relatório Extrato Bancário #####
|
199
|
-
app = Application(backend="win32").connect(
|
206
|
+
app = Application(backend="win32").connect(
|
207
|
+
class_name="TFrmRelExtratoBancario", found_index=0
|
208
|
+
)
|
200
209
|
main_window = app["TFrmRelExtratoBancario"]
|
201
|
-
|
202
|
-
|
210
|
+
|
203
211
|
# Inserir Mnemonico
|
204
212
|
console.log("Iniciando Baixa do XLS")
|
205
213
|
if "Mnemônico" in linha:
|
206
|
-
partes = linha.split(
|
214
|
+
partes = linha.split("\r\n")
|
207
215
|
if len(partes) > 1:
|
208
|
-
dados = partes[1].split(
|
216
|
+
dados = partes[1].split("\t")
|
209
217
|
if len(dados) >= 4:
|
210
218
|
mnemonico = dados[0].strip()
|
211
219
|
agencia = dados[1].strip()
|
212
220
|
conta = dados[2].strip()
|
213
221
|
banco = dados[3].strip()
|
214
222
|
|
215
|
-
mnemonicos_detalhados.append(
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
223
|
+
mnemonicos_detalhados.append(
|
224
|
+
{
|
225
|
+
"mnemonico": mnemonico,
|
226
|
+
"agencia": agencia,
|
227
|
+
"conta": conta,
|
228
|
+
"banco": banco,
|
229
|
+
}
|
230
|
+
)
|
221
231
|
conta_movimento = f"{banco}/ AG {agencia}/ Conta {conta}"
|
222
|
-
input_mnemonico = main_window.child_window(
|
232
|
+
input_mnemonico = main_window.child_window(
|
233
|
+
class_name="TDBIEditCode", found_index=0
|
234
|
+
)
|
223
235
|
console.print(f"Inserindo Mnemônico: {mnemonico}")
|
224
236
|
type_text_into_field(
|
225
237
|
text=mnemonico,
|
@@ -228,16 +240,17 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
228
240
|
chars_to_empty="10",
|
229
241
|
)
|
230
242
|
await worker_sleep(1)
|
231
|
-
|
232
|
-
send_keys(
|
233
|
-
|
243
|
+
|
244
|
+
send_keys("{TAB}")
|
245
|
+
|
234
246
|
await worker_sleep(1)
|
235
247
|
if not inserir_periodo:
|
236
248
|
console.print("Inserindo perído inicial")
|
237
|
-
# Inserir período inicial
|
238
|
-
input_data_inicial = main_window.child_window(
|
239
|
-
|
240
|
-
|
249
|
+
# Inserir período inicial
|
250
|
+
input_data_inicial = main_window.child_window(
|
251
|
+
class_name="TDBIEditDate", found_index=3
|
252
|
+
)
|
253
|
+
|
241
254
|
type_text_into_field(
|
242
255
|
text=periodo_inicial,
|
243
256
|
field=input_data_inicial,
|
@@ -245,81 +258,108 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
245
258
|
chars_to_empty="10",
|
246
259
|
)
|
247
260
|
await worker_sleep(1)
|
248
|
-
|
261
|
+
|
249
262
|
console.print("Inserindo perído final")
|
250
|
-
input_data_final = main_window.child_window(
|
251
|
-
|
263
|
+
input_data_final = main_window.child_window(
|
264
|
+
class_name="TDBIEditDate", found_index=2
|
265
|
+
)
|
266
|
+
|
252
267
|
type_text_into_field(
|
253
268
|
text=periodo_final,
|
254
269
|
field=input_data_final,
|
255
270
|
empty_before=True,
|
256
271
|
chars_to_empty="10",
|
257
272
|
)
|
258
|
-
inserir_periodo = True
|
273
|
+
inserir_periodo = True
|
259
274
|
await worker_sleep(1)
|
260
275
|
console.print("Marcando movimentos conciliados")
|
261
276
|
# Marcar movimentos conciliados
|
262
277
|
if not clicou_conciliados:
|
263
|
-
chk_mov_conciliados = main_window.child_window(
|
264
|
-
|
265
|
-
|
278
|
+
chk_mov_conciliados = main_window.child_window(
|
279
|
+
class_name="TDBICheckBox", found_index=2
|
280
|
+
).click()
|
281
|
+
|
266
282
|
await worker_sleep(2)
|
267
|
-
|
283
|
+
|
268
284
|
console.print("Selecionar tipo Excel")
|
269
285
|
# Selecionar Excel
|
270
|
-
slc_excel = main_window.child_window(
|
286
|
+
slc_excel = main_window.child_window(
|
287
|
+
class_name="TDBIComboBoxValues", found_index=0
|
288
|
+
).select("Excel")
|
271
289
|
clicou_conciliados = True
|
272
|
-
|
290
|
+
|
273
291
|
await worker_sleep(3)
|
274
|
-
|
292
|
+
|
275
293
|
# Clicar em gerar relatório
|
276
|
-
console.print("Clicar em gerar relatório")
|
277
|
-
btn_gerar_relatorio = main_window.child_window(
|
278
|
-
|
294
|
+
console.print("Clicar em gerar relatório")
|
295
|
+
btn_gerar_relatorio = main_window.child_window(
|
296
|
+
class_name="TBitBtn", found_index=0
|
297
|
+
).click_input()
|
298
|
+
|
279
299
|
await worker_sleep(5)
|
280
300
|
console.print("Verificar se existem dados")
|
281
|
-
|
301
|
+
|
282
302
|
try:
|
283
|
-
nao_existe_dados =
|
303
|
+
nao_existe_dados = rf"{ASSETS_BASE_PATH}\extracao_fechamento_emsys\nao_existem_dados.png"
|
284
304
|
|
285
305
|
for tentativa in range(3):
|
286
|
-
console.print(
|
287
|
-
|
288
|
-
|
306
|
+
console.print(
|
307
|
+
f"Tentativa {tentativa + 1}: Clicar em 'Gerar Relatório'"
|
308
|
+
)
|
309
|
+
|
310
|
+
btn_gerar_relatorio = main_window.child_window(
|
311
|
+
class_name="TBitBtn", found_index=0
|
312
|
+
)
|
289
313
|
if btn_gerar_relatorio.exists(timeout=2):
|
290
314
|
btn_gerar_relatorio.click_input()
|
291
315
|
await worker_sleep(3)
|
292
316
|
|
293
317
|
# Verifica se apareceu a imagem de "sem dados"
|
294
|
-
localizacao = pyautogui.locateOnScreen(
|
318
|
+
localizacao = pyautogui.locateOnScreen(
|
319
|
+
nao_existe_dados, confidence=0.9
|
320
|
+
)
|
295
321
|
if localizacao:
|
296
322
|
console.print(f"Nenhum dado para {mnemonico}")
|
297
323
|
valor = "0,00"
|
298
324
|
|
299
325
|
try:
|
300
|
-
app_sem_dados = Application(backend="win32").connect(
|
326
|
+
app_sem_dados = Application(backend="win32").connect(
|
327
|
+
title="Information", found_index=0
|
328
|
+
)
|
301
329
|
window_sem_dados = app_sem_dados["Information"]
|
302
|
-
botao_ok = window_sem_dados.child_window(
|
330
|
+
botao_ok = window_sem_dados.child_window(
|
331
|
+
class_name="TButton", found_index=0
|
332
|
+
).click()
|
303
333
|
except Exception as e:
|
304
|
-
console.print(
|
334
|
+
console.print(
|
335
|
+
f"Erro ao fechar janela 'Information': {e}",
|
336
|
+
style="bold red",
|
337
|
+
)
|
305
338
|
|
306
339
|
await worker_sleep(2)
|
307
|
-
break
|
340
|
+
break
|
308
341
|
|
309
342
|
# Verifica se apareceu a janela "Salvar para arquivo"
|
310
343
|
try:
|
311
|
-
app_salvar = Application(backend="win32").connect(
|
344
|
+
app_salvar = Application(backend="win32").connect(
|
345
|
+
title="Salvar para arquivo", found_index=0
|
346
|
+
)
|
312
347
|
main_window_salvar = app_salvar["Salvar para arquivo"]
|
313
348
|
console.print("Janela 'Salvar para arquivo' encontrada.")
|
314
349
|
break # Janela encontrada, pode sair do loop
|
315
350
|
except:
|
316
|
-
console.print(
|
351
|
+
console.print(
|
352
|
+
"Janela 'Salvar para arquivo' não encontrada.",
|
353
|
+
style="yellow",
|
354
|
+
)
|
317
355
|
|
318
356
|
else:
|
319
|
-
console.print(
|
357
|
+
console.print(
|
358
|
+
"Botão 'Gerar Relatório' não encontrado.", style="bold red"
|
359
|
+
)
|
320
360
|
break
|
321
|
-
except:
|
322
|
-
await worker_sleep(2)
|
361
|
+
except:
|
362
|
+
await worker_sleep(2)
|
323
363
|
##### Janela Salvar para arquivo #####
|
324
364
|
console.print(f"Dados encontrados para {mnemonico}")
|
325
365
|
app = Application(backend="win32").connect(
|
@@ -329,10 +369,10 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
329
369
|
date_now = datetime.now().strftime("%Y%m%d%H%M%S")
|
330
370
|
data_inicial_arquivo = periodo_inicial.replace("/", "")
|
331
371
|
data_final_arquivo = periodo_final.replace("/", "")
|
332
|
-
|
372
|
+
|
333
373
|
# Caminho completo para Downloads
|
334
374
|
nome_arquivo = f"C:\\Users\\{getpass.getuser()}\\Downloads\\fechamento_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.XLS"
|
335
|
-
|
375
|
+
|
336
376
|
console.print(f"Salvar arquivo: {nome_arquivo}")
|
337
377
|
|
338
378
|
# Inserir nome do arquivo
|
@@ -346,34 +386,38 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
346
386
|
|
347
387
|
console.print("Salvando o arquivo")
|
348
388
|
# Clicar em salvar
|
349
|
-
botao_salvar = main_window.child_window(
|
389
|
+
botao_salvar = main_window.child_window(
|
390
|
+
class_name="Button", found_index=0
|
391
|
+
)
|
350
392
|
botao_salvar.click_input()
|
351
|
-
|
393
|
+
|
352
394
|
await worker_sleep(6)
|
353
|
-
|
395
|
+
|
354
396
|
await wait_aguarde_window_closed(app)
|
355
|
-
|
397
|
+
|
356
398
|
arquivo_path = Path(nome_arquivo)
|
357
|
-
# Altera a extensão para .XLS
|
358
|
-
caminho_arquivo = arquivo_path.with_suffix(
|
399
|
+
# Altera a extensão para .XLS
|
400
|
+
caminho_arquivo = arquivo_path.with_suffix(".XLS")
|
359
401
|
# Altera a extensão final para .xls minúsculo
|
360
|
-
caminho_ajustado = caminho_arquivo.with_suffix(
|
402
|
+
caminho_ajustado = caminho_arquivo.with_suffix(".xls")
|
361
403
|
nome_com_extensao = caminho_ajustado.name
|
362
404
|
print(nome_com_extensao)
|
363
405
|
# Renomeia o arquivo
|
364
406
|
os.rename(caminho_arquivo, caminho_ajustado)
|
365
407
|
|
366
408
|
console.print(f"Arquivo renomeado para: {caminho_ajustado}")
|
367
|
-
|
409
|
+
|
368
410
|
await worker_sleep(1)
|
369
|
-
|
411
|
+
|
370
412
|
console.print("Extraindo os dados do Excel")
|
371
|
-
|
413
|
+
|
372
414
|
# Envia o arquivo para o BOF
|
373
415
|
df = pd.read_excel(caminho_ajustado, header=None, engine="xlrd")
|
374
416
|
|
375
417
|
# Filtra onde a coluna Q (índice 16) contém "Total Geral"
|
376
|
-
mask =
|
418
|
+
mask = (
|
419
|
+
df[16].astype(str).str.contains("Total Geral", case=False, na=False)
|
420
|
+
)
|
377
421
|
linha_subtot = df[mask].index
|
378
422
|
|
379
423
|
valor = None
|
@@ -390,7 +434,9 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
390
434
|
|
391
435
|
# Verifica se não contém letras, apenas caracteres numéricos válidos
|
392
436
|
if padrao_numerico.fullmatch(valor_bruto):
|
393
|
-
valor =
|
437
|
+
valor = (
|
438
|
+
valor_bruto # Mantém exatamente como está na planilha
|
439
|
+
)
|
394
440
|
break
|
395
441
|
|
396
442
|
index_verificacao -= 1
|
@@ -398,7 +444,9 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
398
444
|
if valor is not None:
|
399
445
|
console.print(f"Valor encontrado: {valor}")
|
400
446
|
else:
|
401
|
-
console.print(
|
447
|
+
console.print(
|
448
|
+
"Nenhum valor numérico puro encontrado nas linhas anteriores."
|
449
|
+
)
|
402
450
|
else:
|
403
451
|
console.print("Linha contendo 'Total Geral' não encontrada.")
|
404
452
|
return RpaRetornoProcessoDTO(
|
@@ -406,16 +454,18 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
406
454
|
retorno=f"Erro ao enviar o arquivo: {e}",
|
407
455
|
status=RpaHistoricoStatusEnum.Falha,
|
408
456
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
409
|
-
)
|
457
|
+
)
|
410
458
|
console.print("Adicionando dados no json")
|
411
459
|
await worker_sleep(2)
|
412
460
|
# Adiciona o item à lista de saldos
|
413
|
-
saldos.append(
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
461
|
+
saldos.append(
|
462
|
+
{
|
463
|
+
"mnemonico": mnemonico,
|
464
|
+
"contaMovimento": conta_movimento,
|
465
|
+
"valor": valor,
|
466
|
+
}
|
467
|
+
)
|
468
|
+
|
419
469
|
try:
|
420
470
|
# lê o arquivo
|
421
471
|
with open(f"{caminho_ajustado}", "rb") as file:
|
@@ -433,7 +483,7 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
433
483
|
)
|
434
484
|
console.print("Removendo arquivo XLS da pasta downloads")
|
435
485
|
os.remove(f"{caminho_ajustado}")
|
436
|
-
|
486
|
+
|
437
487
|
except Exception as e:
|
438
488
|
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
439
489
|
return RpaRetornoProcessoDTO(
|
@@ -441,34 +491,36 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
441
491
|
retorno=f"Erro ao enviar o arquivo: {e}",
|
442
492
|
status=RpaHistoricoStatusEnum.Falha,
|
443
493
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
444
|
-
)
|
494
|
+
)
|
445
495
|
except:
|
446
496
|
pass
|
447
497
|
console.print("Criando estrutura do Json")
|
448
498
|
# Cria estrutura final do JSON
|
449
499
|
dados_json = {
|
450
|
-
|
451
|
-
|
500
|
+
"fechamento": {
|
501
|
+
"periodoInicial": periodo_inicial,
|
452
502
|
"periodoFinal": periodo_final,
|
453
|
-
"dataHora": datetime.now().strftime("%Y-%m-%d %H:%M")
|
503
|
+
"dataHora": datetime.now().strftime("%Y-%m-%d %H:%M"),
|
454
504
|
},
|
455
|
-
"saldos": saldos
|
505
|
+
"saldos": saldos,
|
456
506
|
}
|
457
|
-
|
507
|
+
|
458
508
|
console.print("Salvando arquivo json")
|
459
509
|
# Salva em arquivo
|
460
|
-
filename =
|
510
|
+
filename = (
|
511
|
+
f"fechamento_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.json"
|
512
|
+
)
|
461
513
|
caminho_downloads = os.path.join(os.environ["USERPROFILE"], "Downloads")
|
462
514
|
full_path = os.path.join(
|
463
515
|
caminho_downloads,
|
464
|
-
f"fechamento_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.json"
|
516
|
+
f"fechamento_{data_inicial_arquivo}_{data_final_arquivo}_{date_now}.json",
|
465
517
|
)
|
466
518
|
|
467
519
|
with open(full_path, "w", encoding="utf-8") as f:
|
468
520
|
json.dump(dados_json, f, ensure_ascii=False, indent=2)
|
469
521
|
|
470
|
-
print(f"Arquivo JSON salvo em: {full_path}")
|
471
|
-
|
522
|
+
print(f"Arquivo JSON salvo em: {full_path}")
|
523
|
+
|
472
524
|
console.print("Enviar arquivo para o Datalake")
|
473
525
|
# Envia o JSON para o datalake
|
474
526
|
directory = "balancete_contabil/raw"
|
@@ -481,10 +533,10 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
481
533
|
)
|
482
534
|
os.remove(full_path)
|
483
535
|
return RpaRetornoProcessoDTO(
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
536
|
+
sucesso=True,
|
537
|
+
retorno=dados_json,
|
538
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
539
|
+
)
|
488
540
|
except Exception as e:
|
489
541
|
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
490
542
|
return RpaRetornoProcessoDTO(
|
@@ -492,8 +544,8 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
492
544
|
retorno=f"Erro ao enviar o arquivo: {e}",
|
493
545
|
status=RpaHistoricoStatusEnum.Falha,
|
494
546
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
495
|
-
)
|
496
|
-
|
547
|
+
)
|
548
|
+
|
497
549
|
except Exception as e:
|
498
550
|
return RpaRetornoProcessoDTO(
|
499
551
|
sucesso=False,
|
@@ -503,4 +555,3 @@ async def extracao_fechamento_emsys(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
503
555
|
)
|
504
556
|
finally:
|
505
557
|
print("fim")
|
506
|
-
|
@@ -67,8 +67,8 @@ 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/entrada_de_notas_9000.py,sha256=paUghcOOCWRA2qVmU89YmThRTm8fMWb2QkE6tM-_MC0,65504
|
69
69
|
worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=nV0iLoip2FH2-FhLmhX3nPqsfl_MPufZ3E5Q5krJvdc,3544
|
70
|
-
worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py,sha256=
|
71
|
-
worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py,sha256
|
70
|
+
worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py,sha256=oTWu4Hfcs9w5IUZ-kKNOzZxFdIPB3Q_e17zh9QHDT1U,19545
|
71
|
+
worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py,sha256=PPzGcsjoBE6iMVYW0qxtNdq5YC-tBaqfJ7FsdTg-uhs,21466
|
72
72
|
worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py,sha256=UWAKCS2dbfgDlSQOBdjmVJXfD1MMuUrOi3weDgB0CAc,5718
|
73
73
|
worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py,sha256=SOs2mORBJqHs089ApbLaPJVRXM7wWhf0e99URXqPlpQ,15020
|
74
74
|
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=zu92tRCvKPK0U6IGGF28ST-kERohJcNbys-DWk0tIco,12555
|
@@ -96,7 +96,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
96
96
|
worker_automate_hub/utils/util.py,sha256=_pgZOFWgXoov6WPbqyRTDVXJCRFfucYB3gb9swzU7bo,198281
|
97
97
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=wmnpuOesmPSryZszmapa37b9YNC0E2MkeDYnbwr-0rU,33315
|
98
98
|
worker_automate_hub/worker.py,sha256=axdrr1xLTjWEyWfcyH3OCSpPTsyzck_fL_0u1DBLjvw,6525
|
99
|
-
worker_automate_hub-0.5.
|
100
|
-
worker_automate_hub-0.5.
|
101
|
-
worker_automate_hub-0.5.
|
102
|
-
worker_automate_hub-0.5.
|
99
|
+
worker_automate_hub-0.5.612.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
100
|
+
worker_automate_hub-0.5.612.dist-info/METADATA,sha256=I9d1uqfazsIG4zwD8HyYxYNun9y_M6e9eosa1L2nTTM,3049
|
101
|
+
worker_automate_hub-0.5.612.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
102
|
+
worker_automate_hub-0.5.612.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.611.dist-info → worker_automate_hub-0.5.612.dist-info}/entry_points.txt
RENAMED
File without changes
|