worker-automate-hub 0.5.757__tar.gz → 0.5.759__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.757 → worker_automate_hub-0.5.759}/PKG-INFO +1 -1
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/pyproject.toml +1 -1
- worker_automate_hub-0.5.759/worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py +224 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py +4 -2
- worker_automate_hub-0.5.757/worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py +0 -233
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/README.md +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/ahead_service.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/client.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/datalake_service.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/helpers/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/helpers/api_helpers.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/rdp_service.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/rpa_fila_service.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/rpa_historico_service.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/webhook_service.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/cli.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/config/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/config/settings.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/config.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/core/so_manipulation.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/deprecation.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/rate_limit.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/repeat.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/retry.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/singleton.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/timeit.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dao/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dao/rpa_configuracao.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dao/rpa_fila.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dao/rpa_historico.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dao/rpa_processo.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dao/rpa_robo.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dto/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dto/rpa_historico_request_dto.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dto/rpa_processo_entrada_dto.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dto/rpa_processo_rdp_dto.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dto/rpa_sap_dto.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/models/dto/rpa_sistema_dto.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/coleta_dje_process.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/cte_manual.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/cte_xml.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/descartes.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/devolucao_ctf.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/devolucao_ctf_35.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/ecac_estadual_go.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/ecac_estadual_main.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/ecac_estadual_mt.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/ecac_estadual_sc.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/ecac_estadual_sp.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/ecac_federal.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_cte_1353.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_cte_333.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_16.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_207.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_32.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_33.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_34.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_500.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_503.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_505.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/entrada_de_notas_9000.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/exemplo_processo.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/fidc_retorno_cobranca.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos_novo.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/integracao_contabil.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/integracao_contabil_generica.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/lancamento_pis_cofins.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/lancamento_rateio.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/login_emsys.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/login_emsys_versao_especifica.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/notas_faturamento_sap.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/opex_capex.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/playground.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/sped_fiscal.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/jobs/transferencias.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/task_definitions.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/tasks/task_executor.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/__init__.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/env.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/get_creds_gworkspace.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/logger.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/toast.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/updater.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/util.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/utils_nfe_entrada.py +0 -0
- {worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/worker.py +0 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
import asyncio
|
2
|
+
import os
|
3
|
+
from datetime import datetime
|
4
|
+
from pywinauto import Application, timings, findwindows
|
5
|
+
import sys
|
6
|
+
import io
|
7
|
+
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
8
|
+
|
9
|
+
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
10
|
+
RpaHistoricoStatusEnum,
|
11
|
+
RpaRetornoProcessoDTO,
|
12
|
+
RpaTagDTO,
|
13
|
+
RpaTagEnum,
|
14
|
+
)
|
15
|
+
from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
|
16
|
+
RpaProcessoEntradaDTO,
|
17
|
+
)
|
18
|
+
from rich.console import Console
|
19
|
+
import re
|
20
|
+
from pywinauto.keyboard import send_keys
|
21
|
+
import warnings
|
22
|
+
from pywinauto.application import Application
|
23
|
+
from worker_automate_hub.api.client import get_config_by_name, send_file
|
24
|
+
from worker_automate_hub.utils.util import (
|
25
|
+
kill_all_emsys,
|
26
|
+
login_emsys,
|
27
|
+
set_variable,
|
28
|
+
type_text_into_field,
|
29
|
+
worker_sleep,
|
30
|
+
)
|
31
|
+
from pywinauto_recorder.player import set_combobox
|
32
|
+
|
33
|
+
from datetime import timedelta
|
34
|
+
import pyautogui
|
35
|
+
from worker_automate_hub.utils.logger import logger
|
36
|
+
from worker_automate_hub.utils.utils_nfe_entrada import EMSys
|
37
|
+
|
38
|
+
emsys = EMSys()
|
39
|
+
|
40
|
+
console = Console()
|
41
|
+
pyautogui.PAUSE = 0.5
|
42
|
+
pyautogui.FAILSAFE = False
|
43
|
+
|
44
|
+
|
45
|
+
async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
46
|
+
try:
|
47
|
+
config = await get_config_by_name("login_emsys")
|
48
|
+
periodo = task.configEntrada["periodo"]
|
49
|
+
periodo_format = periodo.replace("/", "")
|
50
|
+
filial = task.configEntrada["filialEmpresaOrigem"]
|
51
|
+
historico_id = task.historico_id
|
52
|
+
|
53
|
+
console.print("Finalizando processos antigos do EMSys...", style="bold yellow")
|
54
|
+
await kill_all_emsys()
|
55
|
+
|
56
|
+
console.print("Iniciando EMSys...", style="bold green")
|
57
|
+
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSys3_35.exe")
|
58
|
+
warnings.filterwarnings(
|
59
|
+
"ignore",
|
60
|
+
category=UserWarning,
|
61
|
+
message="32-bit application should be automated using 32-bit Python",
|
62
|
+
)
|
63
|
+
|
64
|
+
console.print("Fazendo login no EMSys...", style="bold cyan")
|
65
|
+
return_login = await login_emsys(
|
66
|
+
config.conConfiguracao, app, task, filial_origem=filial
|
67
|
+
)
|
68
|
+
|
69
|
+
if return_login.sucesso:
|
70
|
+
console.print("Login realizado com sucesso", style="bold green")
|
71
|
+
type_text_into_field(
|
72
|
+
"Rel. Saldo Estoque ", app["TFrmMenuPrincipal"]["Edit"], True, "50"
|
73
|
+
)
|
74
|
+
pyautogui.press("enter")
|
75
|
+
await worker_sleep(2)
|
76
|
+
pyautogui.press("enter")
|
77
|
+
else:
|
78
|
+
logger.info(f"\nError Message: {return_login.retorno}")
|
79
|
+
console.print(f"Erro no login: {return_login.retorno}", style="bold red")
|
80
|
+
return return_login
|
81
|
+
|
82
|
+
await worker_sleep(2)
|
83
|
+
|
84
|
+
console.print("Abrindo janela Relatório de Saldo de Estoque...", style="bold cyan")
|
85
|
+
app = Application().connect(class_name="TFrmRelSaldoEstoque", timeout=60)
|
86
|
+
main_window = app["TFrmRelSaldoEstoque"]
|
87
|
+
main_window.set_focus()
|
88
|
+
|
89
|
+
console.print("Marcando campo de data...", style="bold cyan")
|
90
|
+
main_window.child_window(class_name="TCheckBox", found_index=3).click_input()
|
91
|
+
|
92
|
+
await worker_sleep(2)
|
93
|
+
|
94
|
+
console.print(f"Inserindo período: {periodo}", style="bold cyan")
|
95
|
+
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
96
|
+
data_input.set_edit_text(periodo)
|
97
|
+
|
98
|
+
console.print("Gerando relatório...", style="bold cyan")
|
99
|
+
main_window.child_window(class_name="TBitBtn", found_index=0).click_input()
|
100
|
+
|
101
|
+
timings.wait_until_passes(
|
102
|
+
timeout=1800,
|
103
|
+
retry_interval=1,
|
104
|
+
func=lambda: Application().connect(class_name="TFrmPreviewRelatorio"),
|
105
|
+
)
|
106
|
+
await worker_sleep(2)
|
107
|
+
|
108
|
+
console.print("Abrindo Preview Relatório...", style="bold cyan")
|
109
|
+
app = Application().connect(class_name="TFrmPreviewRelatorio")
|
110
|
+
main_window = app["TFrmPreviewRelatorio"]
|
111
|
+
main_window.set_focus()
|
112
|
+
|
113
|
+
max_tentativas = 5
|
114
|
+
tentativa = 1
|
115
|
+
sucesso = False
|
116
|
+
|
117
|
+
while tentativa <= max_tentativas and not sucesso:
|
118
|
+
console.print(f"Tentativa {tentativa} de {max_tentativas}", style="bold cyan")
|
119
|
+
|
120
|
+
console.print("Procurando botão de salvar (imagem)...", style="bold cyan")
|
121
|
+
caminho = r'assets\\extracao_relatorios\\btn_salvar.png'
|
122
|
+
if os.path.isfile(caminho):
|
123
|
+
pos = pyautogui.locateCenterOnScreen(caminho, confidence=0.9)
|
124
|
+
if pos:
|
125
|
+
pyautogui.click(pos)
|
126
|
+
console.print("Clique realizado no botão salvar", style="bold green")
|
127
|
+
else:
|
128
|
+
console.print("Imagem encontrada mas não está visível na tela", style="bold yellow")
|
129
|
+
else:
|
130
|
+
console.print("Imagem do botão salvar NÃO existe", style="bold red")
|
131
|
+
|
132
|
+
await worker_sleep(8)
|
133
|
+
|
134
|
+
console.print("Selecionando formato Excel...", style="bold cyan")
|
135
|
+
app = Application().connect(class_name="TFrmRelatorioFormato")
|
136
|
+
main_window = app["TFrmRelatorioFormato"]
|
137
|
+
combo = main_window.ComboBox
|
138
|
+
console.print(f"Itens do ComboBox: {combo.texts()}", style="bold yellow")
|
139
|
+
combo.select(8)
|
140
|
+
|
141
|
+
await worker_sleep(5)
|
142
|
+
|
143
|
+
console.print("Confirmando salvar...", style="bold cyan")
|
144
|
+
main_window.child_window(class_name="TBitBtn", found_index=1).click_input()
|
145
|
+
|
146
|
+
await worker_sleep(5)
|
147
|
+
|
148
|
+
console.print("Abrindo janela de salvar arquivo...", style="bold cyan")
|
149
|
+
app = Application().connect(title_re="Salvar para arquivo", timeout=30)
|
150
|
+
main_window = app.window(title_re="Salvar para arquivo")
|
151
|
+
|
152
|
+
caminho_arquivo = rf"C:\Users\automatehub\Downloads\saldo_estoque_{periodo_format}_{filial}.xlsx"
|
153
|
+
campo_nome = main_window.child_window(class_name="Edit", control_id=1148).wrapper_object()
|
154
|
+
campo_nome.set_edit_text(caminho_arquivo)
|
155
|
+
console.print(f"Arquivo configurado para: {caminho_arquivo}", style="bold green")
|
156
|
+
|
157
|
+
await worker_sleep(2)
|
158
|
+
|
159
|
+
main_window.child_window(class_name="Button", found_index=0).click_input()
|
160
|
+
|
161
|
+
await worker_sleep(4)
|
162
|
+
|
163
|
+
console.print("Aguardando finalização do processo de impressão/salvamento...", style="bold cyan")
|
164
|
+
try:
|
165
|
+
app = Application().connect(title_re="Printing")
|
166
|
+
janela = app.window(title_re="Printing")
|
167
|
+
janela.wait_not("visible", timeout=60)
|
168
|
+
console.print("Janela 'Printing' fechada.", style="bold green")
|
169
|
+
except findwindows.ElementNotFoundError:
|
170
|
+
console.print("Janela 'Printing' não apareceu.", style="bold yellow")
|
171
|
+
|
172
|
+
# Verifica se o arquivo foi salvo
|
173
|
+
if os.path.exists(caminho_arquivo):
|
174
|
+
console.print(f"Arquivo encontrado: {caminho_arquivo}", style="bold green")
|
175
|
+
with open(caminho_arquivo, "rb") as file:
|
176
|
+
file_bytes = io.BytesIO(file.read())
|
177
|
+
sucesso = True
|
178
|
+
else:
|
179
|
+
console.print("Arquivo não encontrado, tentando novamente...", style="bold red")
|
180
|
+
tentativa += 1
|
181
|
+
await worker_sleep(3)
|
182
|
+
|
183
|
+
if not sucesso:
|
184
|
+
console.print("Falha após 5 tentativas. Arquivo não foi gerado.", style="bold red")
|
185
|
+
|
186
|
+
nome_com_extensao = f'saldo_estoque_{periodo_format}_{filial}.xlsx'
|
187
|
+
console.print("Enviando arquivo XLS para o BOF...", style="bold cyan")
|
188
|
+
try:
|
189
|
+
await send_file(
|
190
|
+
historico_id,
|
191
|
+
nome_com_extensao,
|
192
|
+
"xlsx",
|
193
|
+
file_bytes,
|
194
|
+
file_extension="xlsx",
|
195
|
+
)
|
196
|
+
console.print("Removendo arquivo da pasta downloads", style="bold yellow")
|
197
|
+
os.remove(caminho_arquivo)
|
198
|
+
return RpaRetornoProcessoDTO(
|
199
|
+
sucesso=True,
|
200
|
+
retorno="Relatório enviado com sucesso!",
|
201
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
202
|
+
)
|
203
|
+
|
204
|
+
except Exception as e:
|
205
|
+
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
206
|
+
return RpaRetornoProcessoDTO(
|
207
|
+
sucesso=False,
|
208
|
+
retorno=f"Erro ao enviar o arquivo: {e}",
|
209
|
+
status=RpaHistoricoStatusEnum.Falha,
|
210
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
211
|
+
)
|
212
|
+
|
213
|
+
console.print("Processo concluído com sucesso!", style="bold green")
|
214
|
+
|
215
|
+
except Exception as ex:
|
216
|
+
retorno = f"Erro Processo Fechamento Balancete: {str(ex)}"
|
217
|
+
logger.error(retorno)
|
218
|
+
console.print(retorno, style="bold red")
|
219
|
+
return RpaRetornoProcessoDTO(
|
220
|
+
sucesso=False,
|
221
|
+
retorno=retorno,
|
222
|
+
status=RpaHistoricoStatusEnum.Falha,
|
223
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
224
|
+
)
|
@@ -59,7 +59,9 @@ async def extracao_saldo_estoque_fiscal(
|
|
59
59
|
# Fecha a instancia do emsys - caso esteja aberta
|
60
60
|
await kill_all_emsys()
|
61
61
|
|
62
|
-
app = Application(backend="win32").start(
|
62
|
+
app = Application(backend="win32").start(
|
63
|
+
"C:\\Rezende\\EMSys3\\EMSysFiscal_39.exe"
|
64
|
+
)
|
63
65
|
warnings.filterwarnings(
|
64
66
|
"ignore",
|
65
67
|
category=UserWarning,
|
@@ -128,7 +130,7 @@ async def extracao_saldo_estoque_fiscal(
|
|
128
130
|
await worker_sleep(2)
|
129
131
|
|
130
132
|
# Caminho da imagem do botão
|
131
|
-
imagem_botao = r"
|
133
|
+
imagem_botao = r"assets\\extracao_relatorios\\btn_incluir_livro.png"
|
132
134
|
|
133
135
|
if os.path.exists(imagem_botao):
|
134
136
|
try:
|
@@ -1,233 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import os
|
3
|
-
from datetime import datetime
|
4
|
-
from pywinauto import Application, timings, findwindows
|
5
|
-
import sys
|
6
|
-
import io
|
7
|
-
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
8
|
-
|
9
|
-
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
10
|
-
RpaHistoricoStatusEnum,
|
11
|
-
RpaRetornoProcessoDTO,
|
12
|
-
RpaTagDTO,
|
13
|
-
RpaTagEnum,
|
14
|
-
)
|
15
|
-
from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
|
16
|
-
RpaProcessoEntradaDTO,
|
17
|
-
)
|
18
|
-
from rich.console import Console
|
19
|
-
import re
|
20
|
-
from pywinauto.keyboard import send_keys
|
21
|
-
import warnings
|
22
|
-
from pywinauto.application import Application
|
23
|
-
from worker_automate_hub.api.client import get_config_by_name, send_file
|
24
|
-
from worker_automate_hub.utils.util import (
|
25
|
-
kill_all_emsys,
|
26
|
-
login_emsys,
|
27
|
-
set_variable,
|
28
|
-
type_text_into_field,
|
29
|
-
worker_sleep,
|
30
|
-
)
|
31
|
-
from pywinauto_recorder.player import set_combobox
|
32
|
-
|
33
|
-
from datetime import timedelta
|
34
|
-
import pyautogui
|
35
|
-
from worker_automate_hub.utils.logger import logger
|
36
|
-
from worker_automate_hub.utils.utils_nfe_entrada import EMSys
|
37
|
-
|
38
|
-
emsys = EMSys()
|
39
|
-
|
40
|
-
console = Console()
|
41
|
-
pyautogui.PAUSE = 0.5
|
42
|
-
pyautogui.FAILSAFE = False
|
43
|
-
|
44
|
-
|
45
|
-
async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
46
|
-
try:
|
47
|
-
config = await get_config_by_name("login_emsys")
|
48
|
-
periodo = task.configEntrada["periodo"]
|
49
|
-
periodo_format = periodo.replace("/", "")
|
50
|
-
filial = task.configEntrada["filialEmpresaOrigem"]
|
51
|
-
historico_id = task.historico_id
|
52
|
-
await kill_all_emsys()
|
53
|
-
|
54
|
-
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSys3_35.exe")
|
55
|
-
warnings.filterwarnings(
|
56
|
-
"ignore",
|
57
|
-
category=UserWarning,
|
58
|
-
message="32-bit application should be automated using 32-bit Python",
|
59
|
-
)
|
60
|
-
console.print("\nEMSys iniciando...", style="bold green")
|
61
|
-
return_login = await login_emsys(
|
62
|
-
config.conConfiguracao, app, task, filial_origem=filial
|
63
|
-
)
|
64
|
-
|
65
|
-
if return_login.sucesso == True:
|
66
|
-
type_text_into_field(
|
67
|
-
"Rel. Saldo Estoque ", app["TFrmMenuPrincipal"]["Edit"], True, "50"
|
68
|
-
)
|
69
|
-
pyautogui.press("enter")
|
70
|
-
await worker_sleep(2)
|
71
|
-
pyautogui.press("enter")
|
72
|
-
|
73
|
-
else:
|
74
|
-
logger.info(f"\nError Message: {return_login.retorno}")
|
75
|
-
console.print(f"\nError Message: {return_login.retorno}", style="bold red")
|
76
|
-
return return_login
|
77
|
-
|
78
|
-
await worker_sleep(2)
|
79
|
-
|
80
|
-
##### Janela Relatório Saldos do Estoque #####
|
81
|
-
# Marcar check box data
|
82
|
-
app = Application().connect(class_name="TFrmRelSaldoEstoque", timeout=60)
|
83
|
-
main_window = app["TFrmRelSaldoEstoque"]
|
84
|
-
main_window.set_focus()
|
85
|
-
|
86
|
-
# Captura o campo de data
|
87
|
-
data_chk = main_window.child_window(
|
88
|
-
class_name="TCheckBox", found_index=3
|
89
|
-
).click_input()
|
90
|
-
|
91
|
-
await worker_sleep(2)
|
92
|
-
# Insere a data
|
93
|
-
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
94
|
-
|
95
|
-
data_input.set_edit_text(periodo)
|
96
|
-
|
97
|
-
# Clicar em gerar relatório
|
98
|
-
btn_gerar = main_window.child_window(
|
99
|
-
class_name="TBitBtn", found_index=0
|
100
|
-
).click_input()
|
101
|
-
|
102
|
-
# Aguarda até 60 segundos para a janela aparecer
|
103
|
-
timings.wait_until_passes(
|
104
|
-
timeout=1800,
|
105
|
-
retry_interval=1,
|
106
|
-
func=lambda: Application().connect(class_name="TFrmPreviewRelatorio"),
|
107
|
-
)
|
108
|
-
|
109
|
-
await worker_sleep(10)
|
110
|
-
|
111
|
-
# Conecta à janela Preview Relatorio
|
112
|
-
app = Application().connect(class_name="TFrmPreviewRelatorio")
|
113
|
-
main_window = app["TFrmPreviewRelatorio"]
|
114
|
-
main_window.set_focus()
|
115
|
-
|
116
|
-
# Clicar em salvar
|
117
|
-
caminho = r"assets\\extracao_relatorios\\btn_salvar.png"
|
118
|
-
# Verifica se o arquivo existe
|
119
|
-
if os.path.isfile(caminho):
|
120
|
-
print("A imagem existe:", caminho)
|
121
|
-
|
122
|
-
# Procura a imagem na tela
|
123
|
-
pos = pyautogui.locateCenterOnScreen(
|
124
|
-
caminho, confidence=0.9
|
125
|
-
) # ajuste o confidence se necessário
|
126
|
-
if pos:
|
127
|
-
pyautogui.click(pos) # clica no centro da imagem
|
128
|
-
print("Clique realizado na imagem.")
|
129
|
-
else:
|
130
|
-
print("Imagem encontrada no disco, mas não está visível na tela.")
|
131
|
-
else:
|
132
|
-
print("A imagem NÃO existe:", caminho)
|
133
|
-
|
134
|
-
await worker_sleep(2)
|
135
|
-
|
136
|
-
# Conecta na janela Configuração para Salvar Arquivo
|
137
|
-
app = Application().connect(class_name="TFrmRelatorioFormato")
|
138
|
-
main_window = app["TFrmRelatorioFormato"]
|
139
|
-
main_window.set_focus()
|
140
|
-
# Acessa o ComboBox pelo identificador conhecido
|
141
|
-
combo = main_window.ComboBox
|
142
|
-
|
143
|
-
# Garante que existe "Excel" na lista
|
144
|
-
itens = combo.texts()
|
145
|
-
print("Itens do ComboBox:", itens)
|
146
|
-
|
147
|
-
# Seleciona o Excel correto (o segundo da lista, índice 8)
|
148
|
-
combo.select(8)
|
149
|
-
|
150
|
-
await worker_sleep(2)
|
151
|
-
|
152
|
-
# Clicar em Salvar
|
153
|
-
main_window.child_window(class_name="TBitBtn", found_index=1).click_input()
|
154
|
-
|
155
|
-
await worker_sleep(5)
|
156
|
-
|
157
|
-
# Conecta na janela "Salvar para arquivo"
|
158
|
-
app = Application().connect(title_re="Salvar para arquivo", timeout=30)
|
159
|
-
main_window = app.window(title_re="Salvar para arquivo")
|
160
|
-
|
161
|
-
# Campo Nome (Edit) - use set_edit_text para evitar problemas de escape
|
162
|
-
campo_nome = main_window.child_window(
|
163
|
-
class_name="Edit", control_id=1148
|
164
|
-
).wrapper_object()
|
165
|
-
caminho_arquivo = f"C:\\Users\\automatehub\\Downloads\\saldo_estoque_{periodo_format}_{filial}.xlsx"
|
166
|
-
campo_nome.set_focus()
|
167
|
-
campo_nome.set_edit_text(caminho_arquivo)
|
168
|
-
|
169
|
-
print("✅ Texto inserido no campo Nome")
|
170
|
-
|
171
|
-
await worker_sleep(2)
|
172
|
-
|
173
|
-
# Clicar em ok para salvar
|
174
|
-
main_window.child_window(class_name="Button", found_index=0).click_input()
|
175
|
-
|
176
|
-
await worker_sleep(20)
|
177
|
-
|
178
|
-
# caminho_img = r"assets\\extracao_relatorios\\janela_printing.png"
|
179
|
-
|
180
|
-
# Aguarda até a janela com título "Printing" (ou "Salvando...") fechar
|
181
|
-
|
182
|
-
try:
|
183
|
-
app = Application().connect(title_re="Printing") # conecta se existir
|
184
|
-
janela = app.window(title_re="Printing")
|
185
|
-
|
186
|
-
print("⏳ Aguardando a janela 'Printing' sumir...")
|
187
|
-
janela.wait_not("visible", timeout=60) # espera até 60 segundos
|
188
|
-
print("✅ Janela 'Printing' fechada.")
|
189
|
-
|
190
|
-
except findwindows.ElementNotFoundError:
|
191
|
-
print("⚠️ Janela 'Printing' não estava aberta.")
|
192
|
-
|
193
|
-
nome_com_extensao = f"saldo_estoque_{periodo_format}_{filial}.xlsx"
|
194
|
-
# lê o arquivo
|
195
|
-
print(caminho_arquivo)
|
196
|
-
with open(f"{caminho_arquivo}", "rb") as file:
|
197
|
-
file_bytes = io.BytesIO(file.read())
|
198
|
-
|
199
|
-
console.print("Enviar Excel para o BOF")
|
200
|
-
try:
|
201
|
-
await send_file(
|
202
|
-
historico_id,
|
203
|
-
nome_com_extensao,
|
204
|
-
"xlsx",
|
205
|
-
file_bytes,
|
206
|
-
file_extension="xlsx",
|
207
|
-
)
|
208
|
-
console.print("Removendo arquivo XLS da pasta downloads")
|
209
|
-
os.remove(f"{caminho_arquivo}")
|
210
|
-
return RpaRetornoProcessoDTO(
|
211
|
-
sucesso=True,
|
212
|
-
retorno="Relatório gerado com sucesso",
|
213
|
-
status=RpaHistoricoStatusEnum.Sucesso,
|
214
|
-
)
|
215
|
-
|
216
|
-
except Exception as e:
|
217
|
-
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
218
|
-
return RpaRetornoProcessoDTO(
|
219
|
-
sucesso=False,
|
220
|
-
retorno=f"Erro ao enviar o arquivo: {e}",
|
221
|
-
status=RpaHistoricoStatusEnum.Falha,
|
222
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
223
|
-
)
|
224
|
-
except Exception as ex:
|
225
|
-
retorno = f"Erro Processo Fechamento Balancete: {str(ex)}"
|
226
|
-
logger.error(retorno)
|
227
|
-
console.print(retorno, style="bold red")
|
228
|
-
return RpaRetornoProcessoDTO(
|
229
|
-
sucesso=False,
|
230
|
-
retorno=retorno,
|
231
|
-
status=RpaHistoricoStatusEnum.Falha,
|
232
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
233
|
-
)
|
File without changes
|
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/__init__.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/ahead_service.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/api/client.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/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.757 → worker_automate_hub-0.5.759}/worker_automate_hub/config/__init__.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/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.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/repeat.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/retry.py
RENAMED
File without changes
|
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/decorators/timeit.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/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.757 → worker_automate_hub-0.5.759}/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
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/__init__.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/env.py
RENAMED
File without changes
|
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/logger.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/toast.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/updater.py
RENAMED
File without changes
|
{worker_automate_hub-0.5.757 → worker_automate_hub-0.5.759}/worker_automate_hub/utils/util.py
RENAMED
File without changes
|
File without changes
|
File without changes
|