worker-automate-hub 0.5.892__tar.gz → 0.5.906__tar.gz
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-0.5.892 → worker_automate_hub-0.5.906}/PKG-INFO +1 -1
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/pyproject.toml +1 -1
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/client.py +26 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/importacao_extratos_748.py +60 -12
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/inclusao_pedidos_ipiranga.py +17 -12
- worker_automate_hub-0.5.906/worker_automate_hub/tasks/jobs/inclusao_pedidos_raizen.py +174 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/notas_faturamento_sap.py +83 -79
- worker_automate_hub-0.5.892/worker_automate_hub/tasks/jobs/inclusao_pedidos_raizen.py +0 -2
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/README.md +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/ahead_service.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/datalake_service.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/helpers/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/helpers/api_helpers.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/rdp_service.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/rpa_fila_service.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/rpa_historico_service.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/webhook_service.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/cli.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/config/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/config/settings.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/config.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/core/so_manipulation.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/deprecation.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/rate_limit.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/repeat.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/retry.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/singleton.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/timeit.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dao/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dao/rpa_configuracao.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dao/rpa_fila.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dao/rpa_historico.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dao/rpa_processo.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dao/rpa_robo.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dto/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dto/rpa_historico_request_dto.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dto/rpa_processo_entrada_dto.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dto/rpa_processo_rdp_dto.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dto/rpa_sap_dto.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/dto/rpa_sistema_dto.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/coleta_dje_process.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/cte_manual.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/cte_xml.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/descartes.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/devolucao_ctf.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/devolucao_ctf_35.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/devolucao_produtos.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/ecac_estadual_go.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/ecac_estadual_main.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/ecac_estadual_mt.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/ecac_estadual_sc.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/ecac_estadual_sp.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/ecac_federal.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_cte_1353.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_cte_333.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_16.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_207.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_22.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_32.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_33.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_34.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_37.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_500.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_503.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_505.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/entrada_de_notas_9000.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/exemplo_processo.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/extracao_dados_nielsen.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/fidc_retorno_cobranca.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos_novo.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/geracao_balancetes_filial.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/importacao_extratos.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/inclusao_pedidos_vibra.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/integracao_contabil.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/integracao_contabil_generica.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/lancamento_pis_cofins.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/lancamento_rateio.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/login_emsys.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/login_emsys_versao_especifica.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/opex_capex.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/playground.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/sped_fiscal.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/jobs/transferencias.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/task_definitions.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/task_executor.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/__init__.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/env.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/get_creds_gworkspace.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/logger.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/toast.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/updater.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/util.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/utils_nfe_entrada.py +0 -0
- {worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/worker.py +0 -0
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/client.py
RENAMED
|
@@ -928,3 +928,29 @@ async def download_file_from_historico(uuid: str):
|
|
|
928
928
|
)
|
|
929
929
|
console.print(f"\n{err_msg}\n", style="bold green")
|
|
930
930
|
logger.info(err_msg)
|
|
931
|
+
|
|
932
|
+
async def get_mfa_code(key: str):
|
|
933
|
+
try:
|
|
934
|
+
env, _ = load_env_config()
|
|
935
|
+
headers = {
|
|
936
|
+
"Content-Type": "application/json",
|
|
937
|
+
"Authorization": "Basic " + env["API_AUTHORIZATION"],
|
|
938
|
+
}
|
|
939
|
+
payload = {"key": key}
|
|
940
|
+
|
|
941
|
+
response = requests.post(
|
|
942
|
+
env["API_BASE_URL"] + "/redis/get-redis-code",
|
|
943
|
+
json=payload,
|
|
944
|
+
headers=headers,
|
|
945
|
+
)
|
|
946
|
+
|
|
947
|
+
if response.status_code == 200 and response.json() is not None:
|
|
948
|
+
return {"code": response.json(), "status_code": 200}
|
|
949
|
+
else:
|
|
950
|
+
raise Exception(
|
|
951
|
+
f"Error to get mfa code, message: {response.text}, status_code {response.status_code}"
|
|
952
|
+
)
|
|
953
|
+
|
|
954
|
+
except Exception as e:
|
|
955
|
+
logger.error(f"Error to get mfa code: {str(e)}")
|
|
956
|
+
return {"code": None, "status_code": 500}
|
|
@@ -425,9 +425,11 @@ async def importacao_extratos_748(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
425
425
|
}
|
|
426
426
|
)
|
|
427
427
|
continue
|
|
428
|
-
|
|
428
|
+
|
|
429
|
+
# Agora sim, busca os campos numéricos
|
|
429
430
|
campos = wnd.descendants(class_name="TDBIEditNumber")
|
|
430
|
-
|
|
431
|
+
|
|
432
|
+
# 3) Valida quantidade de campos
|
|
431
433
|
if len(campos) < 5:
|
|
432
434
|
console.print(
|
|
433
435
|
"[red]Não existem campos suficientes (precisa de pelo menos 5).[/red]"
|
|
@@ -440,27 +442,73 @@ async def importacao_extratos_748(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
440
442
|
)
|
|
441
443
|
continue
|
|
442
444
|
else:
|
|
443
|
-
#
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
# ===== NOVA LÓGICA: AGUARDAR ATÉ MUDAR DE 0,00 PARA ALGUM VALOR =====
|
|
446
|
+
TIMEOUT_CAMPOS = 30 * 60 # 30 minutos em segundos
|
|
447
|
+
inicio_espera = time.time()
|
|
448
|
+
valores_preenchidos = False
|
|
449
|
+
|
|
450
|
+
console.print(
|
|
451
|
+
"[cyan]Aguardando até que os campos 0 e 4 deixem de ser '0,00' ou vazios (timeout 30 minutos)...[/cyan]"
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
while True:
|
|
455
|
+
valor_0 = campos[0].window_text().strip()
|
|
456
|
+
valor_4 = campos[4].window_text().strip()
|
|
457
|
+
|
|
458
|
+
console.print(
|
|
459
|
+
f"[cyan]Leitura atual -> índice 0: '{valor_0}' | índice 4: '{valor_4}'[/cyan]"
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
cond_0 = valor_0 not in ("", "0,00", "0.00")
|
|
463
|
+
cond_4 = valor_4 not in ("", "0,00", "0.00")
|
|
464
|
+
|
|
465
|
+
if cond_0 and cond_4:
|
|
466
|
+
valores_preenchidos = True
|
|
467
|
+
console.print(
|
|
468
|
+
"[green]Campos preenchidos com valores diferentes de 0,00. Prosseguindo para comparação...[/green]"
|
|
469
|
+
)
|
|
470
|
+
break
|
|
471
|
+
|
|
472
|
+
if time.time() - inicio_espera > TIMEOUT_CAMPOS:
|
|
473
|
+
console.print(
|
|
474
|
+
"[red]Timeout de 30 minutos aguardando os campos saírem de 0,00.[/red]"
|
|
475
|
+
)
|
|
476
|
+
falhas.append(
|
|
477
|
+
{
|
|
478
|
+
"arquivo": sel["arquivo"],
|
|
479
|
+
"motivo": "Timeout aguardando campos numéricos saírem de 0,00.",
|
|
480
|
+
}
|
|
481
|
+
)
|
|
482
|
+
valores_preenchidos = False
|
|
483
|
+
break
|
|
484
|
+
|
|
485
|
+
# Evita busy-wait
|
|
486
|
+
await worker_sleep(5)
|
|
487
|
+
|
|
488
|
+
# Se não preencheu dentro do timeout, segue para o próximo arquivo
|
|
489
|
+
if not valores_preenchidos:
|
|
490
|
+
continue
|
|
446
491
|
|
|
447
|
-
|
|
448
|
-
console.print(f"[cyan]Valor índice
|
|
492
|
+
# Agora sim, com valores não vazios / não 0,00, faz a comparação
|
|
493
|
+
console.print(f"[cyan]Valor índice 0 final:[/] {valor_0}")
|
|
494
|
+
console.print(f"[cyan]Valor índice 4 final:[/] {valor_4}")
|
|
449
495
|
|
|
450
496
|
# Se os valores não forem iguais, NÃO concilia e gera erro
|
|
451
|
-
if not (valor_0 == valor_4 and valor_0
|
|
452
|
-
console.print(
|
|
497
|
+
if not (valor_0 == valor_4 and valor_0 not in ("", "0,00", "0.00")):
|
|
498
|
+
console.print(
|
|
499
|
+
"[yellow]Valores diferentes. Não será conciliado.[/yellow]"
|
|
500
|
+
)
|
|
453
501
|
falhas.append(
|
|
454
502
|
{
|
|
455
503
|
"arquivo": sel["arquivo"],
|
|
456
|
-
"motivo": f"Valores diferentes
|
|
504
|
+
"motivo": f"Valores diferentes no Conciliador (0={valor_0}, 4={valor_4}).",
|
|
457
505
|
}
|
|
458
506
|
)
|
|
459
507
|
# não chega na parte do conciliar -> erro
|
|
460
508
|
continue
|
|
461
509
|
|
|
462
510
|
console.print(
|
|
463
|
-
"[green]Valores iguais! Tentando clicar no botão 'Conciliar'...[/green]"
|
|
511
|
+
"[green]Valores iguais e válidos! Tentando clicar no botão 'Conciliar'...[/green]"
|
|
464
512
|
)
|
|
465
513
|
pos_conc = pyautogui.locateCenterOnScreen(
|
|
466
514
|
BTN_CONCILIAR, confidence=0.9
|
|
@@ -483,7 +531,7 @@ async def importacao_extratos_748(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
483
531
|
)
|
|
484
532
|
|
|
485
533
|
# Aguarda imagem de sucesso
|
|
486
|
-
timeout =
|
|
534
|
+
timeout = 1300
|
|
487
535
|
inicio = time.time()
|
|
488
536
|
|
|
489
537
|
console.print(
|
|
@@ -50,7 +50,8 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
50
50
|
|
|
51
51
|
# Login
|
|
52
52
|
logger.print(f"Logging")
|
|
53
|
-
|
|
53
|
+
login = config.get("login_ipiranga2") if config_entrada.get("cnpjEmpresa") == "07473735017661" else config.get("login_ipiranga")
|
|
54
|
+
await page.locator('[title="Login"]').type(login)
|
|
54
55
|
await page.locator('[type="password"]').type(config.get("pass_ipiranga"))
|
|
55
56
|
await page.locator('[type="submit"]').click()
|
|
56
57
|
try:
|
|
@@ -96,17 +97,19 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
96
97
|
await page.locator("img.fechar").click()
|
|
97
98
|
except:
|
|
98
99
|
logger.print("No Ads message.")
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
cnpj_atual = await page.locator(".usuario_cnpj.mb-0").first.text_content()
|
|
101
|
+
if not config_entrada.get("cnpjEmpresa") in cnpj_atual:
|
|
102
|
+
# Select Gas Station
|
|
103
|
+
await page.wait_for_selector(".usuario_img", timeout=90000)
|
|
104
|
+
await page.locator(".usuario_img").first.click()
|
|
105
|
+
# Fill the station
|
|
106
|
+
logger.print("Selecting gas station")
|
|
107
|
+
change_station = page.locator('//*[@id="trocaMuitosPostosModal"]/div[2]/div/div')
|
|
108
|
+
await change_station.locator('[type="text"]').first.type(config_entrada.get("cnpjEmpresa"))
|
|
109
|
+
# cnpj = config_entrada.get("cnpjEmpresa")
|
|
110
|
+
# await page.locator(f'li[data-cdpessptoecli="{cnpj}"]').click()
|
|
111
|
+
await change_station.get_by_text("Trocar", exact=True).locator("visible=true").click()
|
|
112
|
+
|
|
110
113
|
|
|
111
114
|
await asyncio.sleep(5)
|
|
112
115
|
logger.print("Going to order page")
|
|
@@ -128,6 +131,7 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
128
131
|
await asyncio.sleep(2)
|
|
129
132
|
|
|
130
133
|
except:
|
|
134
|
+
await capture_and_send_screenshot(task.historico_id, "Erro")
|
|
131
135
|
raise Exception("Base não encontrada")
|
|
132
136
|
# Fill Fuels
|
|
133
137
|
logger.print("Filling Fuels")
|
|
@@ -200,6 +204,7 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
200
204
|
status=RpaHistoricoStatusEnum.Sucesso,
|
|
201
205
|
)
|
|
202
206
|
else:
|
|
207
|
+
await capture_and_send_screenshot(task.historico_id, "Erro")
|
|
203
208
|
raise Exception(f"Erro ao realizar pedido: {text}")
|
|
204
209
|
except Exception as e:
|
|
205
210
|
logger.print(f"An error occurred: {e}")
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
|
2
|
+
RpaHistoricoStatusEnum,
|
|
3
|
+
RpaRetornoProcessoDTO,
|
|
4
|
+
RpaTagDTO,
|
|
5
|
+
RpaTagEnum,
|
|
6
|
+
)
|
|
7
|
+
from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
|
|
8
|
+
RpaProcessoEntradaDTO,
|
|
9
|
+
)
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
import asyncio
|
|
12
|
+
from datetime import date, datetime
|
|
13
|
+
import re
|
|
14
|
+
from playwright.async_api import async_playwright
|
|
15
|
+
from worker_automate_hub.api.client import get_config_by_name, get_mfa_code
|
|
16
|
+
from worker_automate_hub.utils.util import capture_and_send_screenshot, kill_all_emsys
|
|
17
|
+
|
|
18
|
+
logger = Console()
|
|
19
|
+
|
|
20
|
+
async def inclusao_pedidos_raizen(task: RpaRetornoProcessoDTO):
|
|
21
|
+
try:
|
|
22
|
+
await kill_all_emsys()
|
|
23
|
+
config_entrada = task.configEntrada
|
|
24
|
+
#Collect configs
|
|
25
|
+
config = await get_config_by_name("ConsultaPreco")
|
|
26
|
+
config = config.conConfiguracao
|
|
27
|
+
async with async_playwright() as p:
|
|
28
|
+
browser = await p.chromium.launch(headless=False, args=[
|
|
29
|
+
"--disable-blink-features=AutomationControlled",
|
|
30
|
+
"--no-sandbox",
|
|
31
|
+
"--disable-dev-shm-usage",
|
|
32
|
+
"--disable-gpu",
|
|
33
|
+
"--disable-infobars",
|
|
34
|
+
"--window-size=1920,1080"
|
|
35
|
+
])
|
|
36
|
+
|
|
37
|
+
page = await browser.new_page()
|
|
38
|
+
await page.set_viewport_size({"width": 1850, "height": 900})
|
|
39
|
+
#Going to Main page
|
|
40
|
+
logger.print(f"Navigating to {config.get('url_raizen')}")
|
|
41
|
+
await page.goto(config.get('url_raizen'), wait_until="networkidle")
|
|
42
|
+
|
|
43
|
+
#Login
|
|
44
|
+
logger.print(f"Logging")
|
|
45
|
+
await page.locator("#signInName").type(config.get('login_raizen'))
|
|
46
|
+
await page.locator("#password").type(config.get('pass_raizen'))
|
|
47
|
+
await page.locator("#next").click()
|
|
48
|
+
|
|
49
|
+
logger.print("Waiting for verification code")
|
|
50
|
+
logger.print("Sending verification code")
|
|
51
|
+
await page.locator("#readOnlyEmail_ver_but_send").click()
|
|
52
|
+
|
|
53
|
+
await asyncio.sleep(60)
|
|
54
|
+
#chamar endpoint com código retornado
|
|
55
|
+
code = await get_mfa_code('mfa-raizen')
|
|
56
|
+
if code['status_code'] == 200:
|
|
57
|
+
await page.locator('//*[@id="readOnlyEmail_ver_input"]').type(str(code['code']))
|
|
58
|
+
await page.locator('//*[@id="readOnlyEmail_ver_but_verify"]').click()
|
|
59
|
+
else:
|
|
60
|
+
raise Exception("Failed to retrieve MFA code")
|
|
61
|
+
|
|
62
|
+
# Select Company
|
|
63
|
+
logger.print("Selecting company")
|
|
64
|
+
relacao_cod_raizen = await get_config_by_name("RelacaoCodigosRaizen")
|
|
65
|
+
relacao_cod_raizen = relacao_cod_raizen.conConfiguracao
|
|
66
|
+
await page.wait_for_selector('//*[@id="api"]/div/form/div[2]/app-select/div/div', state="visible")
|
|
67
|
+
await page.locator('//*[@id="api"]/div/form/div[2]/app-select/div/div').click()
|
|
68
|
+
cod_cnpj = str(relacao_cod_raizen[config_entrada['cnpjEmpresa']]).lstrip('0')
|
|
69
|
+
element = page.locator(f'text="{cod_cnpj} - SIM REDE DE POSTOS LTDA"')
|
|
70
|
+
await element.scroll_into_view_if_needed()
|
|
71
|
+
await element.click()
|
|
72
|
+
await page.locator('//*[@id="undefined"]').click()
|
|
73
|
+
await page.wait_for_load_state('load')
|
|
74
|
+
try:
|
|
75
|
+
await asyncio.sleep(5)
|
|
76
|
+
await page.locator("label.cso-radio-option:has-text('Combustíveis Claros')").click()
|
|
77
|
+
await page.locator("button span:has-text('Acessar')").click()
|
|
78
|
+
except:
|
|
79
|
+
logger.print("Radio button already selected or not available")
|
|
80
|
+
await asyncio.sleep(10)
|
|
81
|
+
|
|
82
|
+
await asyncio.sleep(15)
|
|
83
|
+
try:
|
|
84
|
+
await page.locator(".messages__popup__button_ok").click()
|
|
85
|
+
except:
|
|
86
|
+
pass
|
|
87
|
+
logger.print("Navegating to orders page")
|
|
88
|
+
await page.goto('https://portal.csonline.com.br/#/ordersfuels', wait_until="load")
|
|
89
|
+
await asyncio.sleep(5)
|
|
90
|
+
#Select Liters
|
|
91
|
+
logger.print("Selecting Liters")
|
|
92
|
+
litro_radio = page.locator("#orders-fuels-input-radio-L")
|
|
93
|
+
await litro_radio.wait_for(state='visible')
|
|
94
|
+
if not await litro_radio.is_checked():
|
|
95
|
+
await litro_radio.click()
|
|
96
|
+
await page.wait_for_timeout(10000)
|
|
97
|
+
await page.locator('//*[@id="undefined"]').click()
|
|
98
|
+
# Base
|
|
99
|
+
logger.print("Selecting base")
|
|
100
|
+
rel_base_raizen = await get_config_by_name("relacaoBaseRaizen")
|
|
101
|
+
rel_base_raizen = rel_base_raizen.conConfiguracao
|
|
102
|
+
base_nome = rel_base_raizen[config_entrada['baseNome']]
|
|
103
|
+
await page.locator('//*[@id="orders-fuels-div-dropdown-withdrawal-place"]').click()
|
|
104
|
+
await page.locator(f'//*[contains(text(), "{base_nome}")]').click()
|
|
105
|
+
# Date
|
|
106
|
+
logger.print("Selecting date")
|
|
107
|
+
date = config_entrada['dataRetirada']
|
|
108
|
+
date = datetime.fromisoformat(date)
|
|
109
|
+
date = date.strftime("%d/%m/%Y")
|
|
110
|
+
input_elem = page.locator("#orders-fuels-div-calendar-datepicker")
|
|
111
|
+
await input_elem.evaluate("(el, value) => { el.removeAttribute('readonly'); el.value = value; el.dispatchEvent(new Event('input', { bubbles: true })); el.dispatchEvent(new Event('change', { bubbles: true })); }", date)
|
|
112
|
+
# Veichle Sign
|
|
113
|
+
logger.print("Selecting vehicle sign")
|
|
114
|
+
await page.locator('//*[@id="orders-fuels-div-dropdown-plate-place-button"]').click()
|
|
115
|
+
await page.locator('//*[@id="orders-fuels-div-dropdown-plate-place-button"]').fill(config_entrada["placaVeiculo"].upper())
|
|
116
|
+
await page.locator(f'//*[contains(text(), "{config_entrada["placaVeiculo"]}")]').click()
|
|
117
|
+
|
|
118
|
+
#Fill Fuels
|
|
119
|
+
logger.print("Filling Fuels")
|
|
120
|
+
combusutiveis_ids = await get_config_by_name('ConsultaPrecoCombustiveisIds')
|
|
121
|
+
combusutiveis_ids = combusutiveis_ids.conConfiguracao
|
|
122
|
+
xpath_ids = await get_config_by_name('raizenXpathCombustiveis')
|
|
123
|
+
xpath_ids = xpath_ids.conConfiguracao
|
|
124
|
+
for combustivel in config_entrada['combustiveis']:
|
|
125
|
+
combustivel_uuid = combustivel['uuidItem']
|
|
126
|
+
xpath = xpath_ids[combustivel_uuid]
|
|
127
|
+
await page.locator(xpath).fill(str(combustivel['quantidade']))
|
|
128
|
+
await page.locator(xpath).click()
|
|
129
|
+
|
|
130
|
+
# Save order
|
|
131
|
+
logger.print("Saving order")
|
|
132
|
+
await asyncio.sleep(2)
|
|
133
|
+
await page.locator('//*[@id="orders-fuels-button-save"]').click()
|
|
134
|
+
try:
|
|
135
|
+
logger.print("Confirming order")
|
|
136
|
+
await page.get_by_text("Continuar mesmo assim").click()
|
|
137
|
+
except:
|
|
138
|
+
pass
|
|
139
|
+
await page.wait_for_load_state('load')
|
|
140
|
+
#Get order number
|
|
141
|
+
await asyncio.sleep(10)
|
|
142
|
+
numero_elem = page.locator('//span[contains(@class, "status__order-number__value")]')
|
|
143
|
+
numero_pedido = ( await numero_elem.inner_text()).strip()
|
|
144
|
+
if not numero_pedido:
|
|
145
|
+
await capture_and_send_screenshot(task.historico_id,"Número do pedido não encontrado!")
|
|
146
|
+
raise Exception("Número do pedido não encontrado!")
|
|
147
|
+
date = config_entrada["dataRetirada"]
|
|
148
|
+
date = datetime.fromisoformat(date)
|
|
149
|
+
bof = {
|
|
150
|
+
"numero_pedido": numero_pedido,
|
|
151
|
+
"cnpj": config_entrada["cnpjEmpresa"],
|
|
152
|
+
"data": date.strftime("%d/%m/%Y"),
|
|
153
|
+
}
|
|
154
|
+
await capture_and_send_screenshot(task.historico_id, "Sucesso ao realizar pedido!")
|
|
155
|
+
return RpaRetornoProcessoDTO(
|
|
156
|
+
sucesso=True,
|
|
157
|
+
retorno=str(bof),
|
|
158
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
except Exception as e:
|
|
162
|
+
logger.print(f"An error occurred: {e}")
|
|
163
|
+
await capture_and_send_screenshot(task.historico_id, "Erro ao realizar pedido!")
|
|
164
|
+
return RpaRetornoProcessoDTO(
|
|
165
|
+
sucesso=False,
|
|
166
|
+
retorno=f"An error occurred: {e}",
|
|
167
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
168
|
+
tags=[
|
|
169
|
+
RpaTagDTO(descricao=RpaTagEnum.Tecnico),
|
|
170
|
+
RpaTagDTO(descricao=RpaTagEnum.Negocio),
|
|
171
|
+
],
|
|
172
|
+
)
|
|
173
|
+
finally:
|
|
174
|
+
await browser.close()
|
|
@@ -20,10 +20,15 @@ from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
|
|
20
20
|
RpaHistoricoStatusEnum,
|
|
21
21
|
RpaRetornoProcessoDTO,
|
|
22
22
|
RpaTagDTO,
|
|
23
|
-
RpaTagEnum
|
|
23
|
+
RpaTagEnum,
|
|
24
24
|
)
|
|
25
25
|
from worker_automate_hub.models.dto.rpa_sap_dto import RpaProcessoSapDTO
|
|
26
|
-
from worker_automate_hub.utils.util import
|
|
26
|
+
from worker_automate_hub.utils.util import (
|
|
27
|
+
kill_all_emsys,
|
|
28
|
+
worker_sleep,
|
|
29
|
+
)
|
|
30
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
|
31
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
27
32
|
|
|
28
33
|
console = Console()
|
|
29
34
|
|
|
@@ -31,6 +36,7 @@ DOWNLOADS_PATH = os.path.join(os.path.expanduser("~"), "Downloads")
|
|
|
31
36
|
|
|
32
37
|
console.print(f"Downloads dir: {DOWNLOADS_PATH}")
|
|
33
38
|
|
|
39
|
+
|
|
34
40
|
class ConfigEntradaSAP(BaseModel):
|
|
35
41
|
user: str
|
|
36
42
|
password: str
|
|
@@ -40,8 +46,11 @@ class ConfigEntradaSAP(BaseModel):
|
|
|
40
46
|
def get(self, key, default=None):
|
|
41
47
|
return getattr(self, key, default)
|
|
42
48
|
|
|
49
|
+
|
|
43
50
|
class NotasFaturamentoSAP:
|
|
44
|
-
def __init__(
|
|
51
|
+
def __init__(
|
|
52
|
+
self, task: RpaProcessoSapDTO, sap_url, sap_key, sap_token, base_url, directory
|
|
53
|
+
):
|
|
45
54
|
console.print("Inicializando classe NotasFaturamentoSAP.")
|
|
46
55
|
self.task = task
|
|
47
56
|
self.sap_url = sap_url
|
|
@@ -54,9 +63,11 @@ class NotasFaturamentoSAP:
|
|
|
54
63
|
self.directory = directory
|
|
55
64
|
self.unique_id = "default"
|
|
56
65
|
self.driver = None
|
|
66
|
+
self.relatorio = task.configEntrada.get("relatorio")
|
|
57
67
|
|
|
58
68
|
async def start_sap_process(self):
|
|
59
69
|
console.print("Iniciando o processo SAP.")
|
|
70
|
+
await kill_all_emsys()
|
|
60
71
|
sim_service = Service(ChromeDriverManager().install())
|
|
61
72
|
self.driver = webdriver.Chrome(service=sim_service)
|
|
62
73
|
self.driver.maximize_window()
|
|
@@ -75,25 +86,11 @@ class NotasFaturamentoSAP:
|
|
|
75
86
|
sucesso=False,
|
|
76
87
|
retorno=msg,
|
|
77
88
|
status=RpaHistoricoStatusEnum.Falha,
|
|
78
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
89
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
79
90
|
)
|
|
80
91
|
|
|
81
92
|
console.print("Login realizado com sucesso.")
|
|
82
|
-
await self.download_files(self.empresa,
|
|
83
|
-
if self.driver:
|
|
84
|
-
try:
|
|
85
|
-
self.driver.quit()
|
|
86
|
-
self.driver = None
|
|
87
|
-
console.print("Driver fechado e referência removida.")
|
|
88
|
-
except Exception as e:
|
|
89
|
-
msg = f"Erro ao fechar o driver: {e}"
|
|
90
|
-
console.print(msg)
|
|
91
|
-
return RpaRetornoProcessoDTO(
|
|
92
|
-
sucesso=False,
|
|
93
|
-
retorno=msg,
|
|
94
|
-
status=RpaHistoricoStatusEnum.Falha,
|
|
95
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
96
|
-
)
|
|
93
|
+
await self.download_files(self.empresa, self.relatorio)
|
|
97
94
|
|
|
98
95
|
async def save_process_pid(self):
|
|
99
96
|
try:
|
|
@@ -110,7 +107,7 @@ class NotasFaturamentoSAP:
|
|
|
110
107
|
sucesso=False,
|
|
111
108
|
retorno=msg,
|
|
112
109
|
status=RpaHistoricoStatusEnum.Falha,
|
|
113
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
110
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
114
111
|
)
|
|
115
112
|
|
|
116
113
|
async def login(self):
|
|
@@ -147,61 +144,59 @@ class NotasFaturamentoSAP:
|
|
|
147
144
|
return False
|
|
148
145
|
|
|
149
146
|
async def download_files(self, company: str, file_type: str):
|
|
150
|
-
console.print(
|
|
147
|
+
console.print(
|
|
148
|
+
f"Iniciando download de arquivos para empresa {company} e tipo {file_type}."
|
|
149
|
+
)
|
|
151
150
|
doc_url = self.get_document_url(file_type)
|
|
152
151
|
console.print(f"Acessando a URL do documento: {doc_url}")
|
|
153
152
|
self.driver.get(doc_url)
|
|
154
153
|
await worker_sleep(15)
|
|
155
154
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
155
|
+
try:
|
|
156
|
+
iframe = WebDriverWait(self.driver, 30).until(
|
|
157
|
+
EC.presence_of_element_located(
|
|
158
|
+
(By.ID, "application-BillingDocument-analyzeRevenue-iframe")
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
self.driver.switch_to.frame(iframe)
|
|
162
|
+
console.print("Iframe principal do SAP acessado com sucesso.")
|
|
163
|
+
except Exception as e:
|
|
164
|
+
console.print(f"Erro ao acessar iframe: {e}")
|
|
164
165
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
try:
|
|
167
|
+
campo = WebDriverWait(self.driver, 30).until(
|
|
168
|
+
EC.presence_of_element_located((By.XPATH, '//*[@id="WD86-input"]'))
|
|
169
|
+
)
|
|
170
|
+
console.print("Input de filtro localizado dentro do iframe.")
|
|
171
|
+
except Exception as e:
|
|
172
|
+
console.print(f"Erro ao localizar input WD86-input: {e}")
|
|
170
173
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
if company == "DIS":
|
|
175
|
+
campo.send_keys("SD01")
|
|
176
|
+
elif company == "CHA":
|
|
177
|
+
campo.send_keys("CH01")
|
|
178
|
+
elif company == "QUE":
|
|
179
|
+
campo.send_keys("QD01")
|
|
180
|
+
|
|
181
|
+
botao_exportar = WebDriverWait(self.driver, 30).until(
|
|
182
|
+
EC.element_to_be_clickable((By.ID, "WD0242"))
|
|
183
|
+
)
|
|
184
|
+
botao_exportar.click()
|
|
185
|
+
|
|
186
|
+
opcao_exportar = WebDriverWait(self.driver, 20).until(
|
|
187
|
+
EC.element_to_be_clickable((By.XPATH, "//span[text()='Exportar']"))
|
|
188
|
+
)
|
|
189
|
+
opcao_exportar.click()
|
|
190
|
+
console.print("Opção 'Exportar' clicada com sucesso!")
|
|
191
|
+
|
|
192
|
+
await worker_sleep(2)
|
|
174
193
|
|
|
175
194
|
actions = ActionChains(self.driver)
|
|
176
|
-
console.print("Executando ações para navegar pelos campos.")
|
|
177
|
-
for _ in range(34):
|
|
178
|
-
actions.send_keys(Keys.TAB)
|
|
179
|
-
actions.perform()
|
|
180
|
-
await worker_sleep(0.5)
|
|
181
|
-
actions.send_keys(Keys.ENTER)
|
|
182
|
-
actions.perform()
|
|
183
|
-
await worker_sleep(5)
|
|
184
|
-
actions.send_keys(Keys.ENTER)
|
|
185
|
-
actions.perform()
|
|
186
|
-
await worker_sleep(5)
|
|
187
195
|
actions.send_keys(Keys.ENTER)
|
|
188
196
|
actions.perform()
|
|
197
|
+
|
|
189
198
|
await worker_sleep(15)
|
|
190
|
-
|
|
191
|
-
if self.driver:
|
|
192
|
-
try:
|
|
193
|
-
self.driver.quit()
|
|
194
|
-
self.driver = None
|
|
195
|
-
console.print("Driver fechado e referência removida.")
|
|
196
|
-
except Exception as e:
|
|
197
|
-
msg = f"Erro ao fechar o driver: {e}"
|
|
198
|
-
console.print(msg)
|
|
199
|
-
return RpaRetornoProcessoDTO(
|
|
200
|
-
sucesso=False,
|
|
201
|
-
retorno=msg,
|
|
202
|
-
status=RpaHistoricoStatusEnum.Falha,
|
|
203
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
204
|
-
)
|
|
199
|
+
|
|
205
200
|
await self.rename_file(company, file_type)
|
|
206
201
|
|
|
207
202
|
def get_document_url(self, file_type: str) -> str:
|
|
@@ -222,25 +217,27 @@ class NotasFaturamentoSAP:
|
|
|
222
217
|
date_now = datetime.now().strftime("%Y%m%d%H%M%S")
|
|
223
218
|
filename = f"{company}_{file_type}_{date_now}.xlsx"
|
|
224
219
|
final_path = os.path.join(DOWNLOADS_PATH, filename)
|
|
225
|
-
|
|
220
|
+
|
|
226
221
|
console.print(f"filename: {filename}")
|
|
227
|
-
|
|
222
|
+
|
|
228
223
|
os.rename(current_path, final_path)
|
|
229
224
|
console.print(f"Arquivo renomeado para {final_path}.")
|
|
230
|
-
|
|
231
|
-
with open(final_path,
|
|
225
|
+
|
|
226
|
+
with open(final_path, "rb") as file:
|
|
232
227
|
file_bytes = io.BytesIO(file.read())
|
|
233
|
-
|
|
228
|
+
|
|
234
229
|
await worker_sleep(5)
|
|
235
230
|
|
|
236
|
-
await self.send_message_to_webhook(f"Arquivo gerado via RPA: {filename}")
|
|
231
|
+
# await self.send_message_to_webhook(f"Arquivo gerado via RPA: {filename}")
|
|
237
232
|
|
|
238
233
|
await worker_sleep(2)
|
|
239
234
|
|
|
240
235
|
try:
|
|
241
236
|
console.print(f"directory: {self.directory}")
|
|
242
237
|
console.print(f"file: {final_path}")
|
|
243
|
-
send_file_request = await send_file_to_datalake(
|
|
238
|
+
send_file_request = await send_file_to_datalake(
|
|
239
|
+
self.directory, file_bytes, filename, "xlsx"
|
|
240
|
+
)
|
|
244
241
|
console.print(send_file_request)
|
|
245
242
|
except Exception as e:
|
|
246
243
|
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
|
@@ -248,9 +245,9 @@ class NotasFaturamentoSAP:
|
|
|
248
245
|
sucesso=False,
|
|
249
246
|
retorno=f"Erro ao enviar o arquivo: {e}",
|
|
250
247
|
status=RpaHistoricoStatusEnum.Falha,
|
|
251
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
248
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
252
249
|
)
|
|
253
|
-
|
|
250
|
+
|
|
254
251
|
await worker_sleep(2)
|
|
255
252
|
|
|
256
253
|
if final_path and os.path.exists(final_path):
|
|
@@ -264,7 +261,7 @@ class NotasFaturamentoSAP:
|
|
|
264
261
|
sucesso=False,
|
|
265
262
|
retorno=msg,
|
|
266
263
|
status=RpaHistoricoStatusEnum.Falha,
|
|
267
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
264
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
268
265
|
)
|
|
269
266
|
|
|
270
267
|
except FileNotFoundError as fne:
|
|
@@ -274,7 +271,7 @@ class NotasFaturamentoSAP:
|
|
|
274
271
|
sucesso=False,
|
|
275
272
|
retorno=msg,
|
|
276
273
|
status=RpaHistoricoStatusEnum.Falha,
|
|
277
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
274
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
278
275
|
)
|
|
279
276
|
except Exception as e:
|
|
280
277
|
msg = f"Erro ao renomear/mover arquivo: {e}"
|
|
@@ -283,7 +280,7 @@ class NotasFaturamentoSAP:
|
|
|
283
280
|
sucesso=False,
|
|
284
281
|
retorno=msg,
|
|
285
282
|
status=RpaHistoricoStatusEnum.Falha,
|
|
286
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
283
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
287
284
|
)
|
|
288
285
|
|
|
289
286
|
async def send_message_to_webhook(self, message: str):
|
|
@@ -296,7 +293,7 @@ class NotasFaturamentoSAP:
|
|
|
296
293
|
webhook_url,
|
|
297
294
|
data=json.dumps(payload),
|
|
298
295
|
headers={"Content-Type": "application/json"},
|
|
299
|
-
timeout=10
|
|
296
|
+
timeout=10,
|
|
300
297
|
)
|
|
301
298
|
console.print("Mensagem enviada ao webhook com sucesso.")
|
|
302
299
|
await worker_sleep(2)
|
|
@@ -307,9 +304,10 @@ class NotasFaturamentoSAP:
|
|
|
307
304
|
sucesso=False,
|
|
308
305
|
retorno=msg,
|
|
309
306
|
status=RpaHistoricoStatusEnum.Falha,
|
|
310
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
307
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
311
308
|
)
|
|
312
309
|
|
|
310
|
+
|
|
313
311
|
async def notas_faturamento_sap(task: RpaProcessoSapDTO) -> RpaRetornoProcessoDTO:
|
|
314
312
|
console.print("Iniciando processo de notas de faturamento SAP.")
|
|
315
313
|
try:
|
|
@@ -321,7 +319,9 @@ async def notas_faturamento_sap(task: RpaProcessoSapDTO) -> RpaRetornoProcessoDT
|
|
|
321
319
|
base_url = config.conConfiguracao.get("baseUrl")
|
|
322
320
|
directory = config.conConfiguracao.get("directoryBucket")
|
|
323
321
|
console.print(sap_url, sap_key, sap_token, base_url, directory)
|
|
324
|
-
notas_sap = NotasFaturamentoSAP(
|
|
322
|
+
notas_sap = NotasFaturamentoSAP(
|
|
323
|
+
task, sap_url, sap_key, sap_token, base_url, directory
|
|
324
|
+
)
|
|
325
325
|
await notas_sap.start_sap_process()
|
|
326
326
|
console.print("Processo de automação SAP finalizado com sucesso.")
|
|
327
327
|
return RpaRetornoProcessoDTO(
|
|
@@ -335,5 +335,9 @@ async def notas_faturamento_sap(task: RpaProcessoSapDTO) -> RpaRetornoProcessoDT
|
|
|
335
335
|
sucesso=False,
|
|
336
336
|
retorno=f"Erro na automação SAP: {ex}",
|
|
337
337
|
status=RpaHistoricoStatusEnum.Falha,
|
|
338
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
338
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
339
339
|
)
|
|
340
|
+
finally:
|
|
341
|
+
if notas_sap.driver:
|
|
342
|
+
notas_sap.driver.quit()
|
|
343
|
+
console.print("Driver fechado no final do processo.")
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/__init__.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/ahead_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/api/rdp_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/config/__init__.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/config/settings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/repeat.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/retry.py
RENAMED
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/decorators/timeit.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/models/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/tasks/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/__init__.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/env.py
RENAMED
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/logger.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/toast.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/updater.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.892 → worker_automate_hub-0.5.906}/worker_automate_hub/utils/util.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|