worker-automate-hub 0.5.672__tar.gz → 0.5.674__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.
Potentially problematic release.
This version of worker-automate-hub might be problematic. Click here for more details.
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/PKG-INFO +1 -1
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/pyproject.toml +1 -1
- worker_automate_hub-0.5.674/worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +495 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_33.py +74 -128
- worker_automate_hub-0.5.672/worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +0 -298
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/README.md +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/ahead_service.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/client.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/datalake_service.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/helpers/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/helpers/api_helpers.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/rdp_service.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/rpa_fila_service.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/rpa_historico_service.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/api/webhook_service.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/cli.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/config/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/config/settings.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/config.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/core/so_manipulation.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/decorators/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/decorators/deprecation.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/decorators/rate_limit.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/decorators/repeat.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/decorators/retry.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/decorators/singleton.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/decorators/timeit.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dao/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dao/rpa_configuracao.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dao/rpa_fila.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dao/rpa_historico.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dao/rpa_processo.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dao/rpa_robo.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dto/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dto/rpa_historico_request_dto.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dto/rpa_processo_entrada_dto.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dto/rpa_processo_rdp_dto.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dto/rpa_sap_dto.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/models/dto/rpa_sistema_dto.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/coleta_dje_process.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/cte_manual.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/cte_xml.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/descartes.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/devolucao_ctf.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/devolucao_ctf_35.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/ecac_estadual_go.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/ecac_estadual_main.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/ecac_estadual_mt.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/ecac_estadual_sc.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/ecac_estadual_sp.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/ecac_federal.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_cte_1353.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_cte_333.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_16.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_207.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_32.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_34.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_500.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_503.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_505.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/entrada_de_notas_9000.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/exemplo_processo.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/fidc_retorno_cobranca.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos_novo.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/integracao_contabil.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/integracao_contabil_generica.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/lancamento_pis_cofins.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/lancamento_rateio.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/login_emsys.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/login_emsys_versao_especifica.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/notas_faturamento_sap.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/playground.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/sped_fiscal.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/jobs/transferencias.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/task_definitions.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/tasks/task_executor.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/__init__.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/env.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/get_creds_gworkspace.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/logger.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/toast.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/updater.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/util.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/utils/utils_nfe_entrada.py +0 -0
- {worker_automate_hub-0.5.672 → worker_automate_hub-0.5.674}/worker_automate_hub/worker.py +0 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import pyautogui
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
import sys
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import os
|
|
8
|
+
from pywinauto.keyboard import send_keys
|
|
9
|
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
from worker_automate_hub.utils.logger import logger
|
|
13
|
+
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
|
14
|
+
RpaHistoricoStatusEnum,
|
|
15
|
+
RpaRetornoProcessoDTO,
|
|
16
|
+
RpaTagDTO,
|
|
17
|
+
RpaTagEnum,
|
|
18
|
+
)
|
|
19
|
+
from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
|
|
20
|
+
RpaProcessoEntradaDTO,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from worker_automate_hub.api.client import get_config_by_name
|
|
24
|
+
from pywinauto import Application
|
|
25
|
+
from rich.console import Console
|
|
26
|
+
from worker_automate_hub.utils.util import (
|
|
27
|
+
is_window_open_by_class,
|
|
28
|
+
kill_all_emsys,
|
|
29
|
+
login_emsys_fiscal,
|
|
30
|
+
type_text_into_field,
|
|
31
|
+
worker_sleep,
|
|
32
|
+
)
|
|
33
|
+
from worker_automate_hub.utils.utils_nfe_entrada import EMSys
|
|
34
|
+
import pyperclip
|
|
35
|
+
import warnings
|
|
36
|
+
import asyncio
|
|
37
|
+
from worker_automate_hub.decorators.repeat import repeat
|
|
38
|
+
from pytesseract import image_to_string
|
|
39
|
+
from pywinauto import Desktop
|
|
40
|
+
|
|
41
|
+
pyautogui.PAUSE = 0.5
|
|
42
|
+
pyautogui.FAILSAFE = False
|
|
43
|
+
|
|
44
|
+
console = Console()
|
|
45
|
+
|
|
46
|
+
emsys = EMSys()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@repeat(times=10, delay=5)
|
|
50
|
+
async def wait_aguarde_window_closed(app, timeout=60):
|
|
51
|
+
console.print("Verificando existencia de aguarde...")
|
|
52
|
+
start_time = time.time()
|
|
53
|
+
|
|
54
|
+
while time.time() - start_time < timeout:
|
|
55
|
+
janela_topo = app.top_window()
|
|
56
|
+
titulo = janela_topo.window_text()
|
|
57
|
+
console.print(f"Titulo da janela top: ${titulo}")
|
|
58
|
+
await emsys.verify_warning_and_error("Aviso", "&Ok")
|
|
59
|
+
await worker_sleep(2)
|
|
60
|
+
|
|
61
|
+
if "Gerar Registros" in titulo or "Movimento de Livro Fiscal" in titulo:
|
|
62
|
+
console.log("Fim de aguardando...")
|
|
63
|
+
return
|
|
64
|
+
else:
|
|
65
|
+
console.log("Aguardando...")
|
|
66
|
+
|
|
67
|
+
console.log("Timeout esperando a janela Aguarde...")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def click_desconfirmar():
|
|
71
|
+
cords = (675, 748)
|
|
72
|
+
pyautogui.click(x=cords[0], y=cords[1])
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def ctrl_c():
|
|
76
|
+
pyautogui.press("tab", presses=12) # verificar
|
|
77
|
+
pyautogui.hotkey("ctrl", "c")
|
|
78
|
+
return pyperclip.paste()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
82
|
+
try:
|
|
83
|
+
config = await get_config_by_name("login_emsys_fiscal")
|
|
84
|
+
|
|
85
|
+
# Fecha a instancia do emsys - caso esteja aberta
|
|
86
|
+
await kill_all_emsys()
|
|
87
|
+
|
|
88
|
+
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSysFiscal.exe")
|
|
89
|
+
warnings.filterwarnings(
|
|
90
|
+
"ignore",
|
|
91
|
+
category=UserWarning,
|
|
92
|
+
message="32-bit application should be automated using 32-bit Python",
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
await worker_sleep(4)
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
app = Application(backend="win32").connect(
|
|
99
|
+
class_name="TFrmLoginModulo", timeout=50
|
|
100
|
+
)
|
|
101
|
+
except:
|
|
102
|
+
return RpaRetornoProcessoDTO(
|
|
103
|
+
sucesso=False,
|
|
104
|
+
retorno="Erro ao abrir o EMSys Fiscal, tela de login não encontrada",
|
|
105
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
106
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
107
|
+
)
|
|
108
|
+
return_login = await login_emsys_fiscal(config.conConfiguracao, app, task)
|
|
109
|
+
if return_login.sucesso:
|
|
110
|
+
try:
|
|
111
|
+
##### Janela Confirm #####
|
|
112
|
+
app = Application().connect(class_name="TMessageForm", timeout=5)
|
|
113
|
+
main_window = app["TMessageForm"]
|
|
114
|
+
main_window.set_focus()
|
|
115
|
+
|
|
116
|
+
# Clicar em Não
|
|
117
|
+
console.print("Navegando nos elementos...\n")
|
|
118
|
+
main_window.child_window(class_name="TButton", found_index=0).click()
|
|
119
|
+
await worker_sleep(2)
|
|
120
|
+
except:
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
##### Janela Principal ####
|
|
124
|
+
console.print("Navegando para Livros Fiscais")
|
|
125
|
+
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
126
|
+
main_window = app["TFrmPrincipalFiscal"]
|
|
127
|
+
main_window.set_focus()
|
|
128
|
+
input_livros = main_window.child_window(class_name="TEdit", found_index=0)
|
|
129
|
+
type_text_into_field(
|
|
130
|
+
"Livros Fiscais", input_livros, True, "50"
|
|
131
|
+
)
|
|
132
|
+
await worker_sleep(5)
|
|
133
|
+
|
|
134
|
+
try:
|
|
135
|
+
##### Janela Confirm #####
|
|
136
|
+
app = Application().connect(class_name="TMessageForm", timeout=5)
|
|
137
|
+
main_window = app["TMessageForm"]
|
|
138
|
+
main_window.set_focus()
|
|
139
|
+
|
|
140
|
+
# Clicar em Não
|
|
141
|
+
console.print("Navegando nos elementos...\n")
|
|
142
|
+
main_window.child_window(class_name="TButton", found_index=0).click()
|
|
143
|
+
await worker_sleep(2)
|
|
144
|
+
except:
|
|
145
|
+
pass
|
|
146
|
+
|
|
147
|
+
# Clicar no input inicial
|
|
148
|
+
input_livros = main_window.child_window(class_name="TEdit", found_index=0).click_input()
|
|
149
|
+
pyautogui.press("enter")
|
|
150
|
+
await worker_sleep(2)
|
|
151
|
+
pyautogui.press("down")
|
|
152
|
+
await worker_sleep(2)
|
|
153
|
+
pyautogui.press("enter")
|
|
154
|
+
console.print(
|
|
155
|
+
"\nPesquisa: 'Livros Fiscais' realizada com sucesso.",
|
|
156
|
+
style="bold green",
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
await worker_sleep(10)
|
|
160
|
+
|
|
161
|
+
try:
|
|
162
|
+
##### Janela Confirm #####
|
|
163
|
+
app = Application().connect(class_name="TMessageForm", timeout=5)
|
|
164
|
+
main_window = app["TMessageForm"]
|
|
165
|
+
main_window.set_focus()
|
|
166
|
+
|
|
167
|
+
# Clicar em Não
|
|
168
|
+
console.print("Navegando nos elementos...\n")
|
|
169
|
+
main_window.child_window(class_name="TButton", found_index=0).click()
|
|
170
|
+
await worker_sleep(2)
|
|
171
|
+
except:
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
await worker_sleep(2)
|
|
175
|
+
|
|
176
|
+
##### Janela Principal ####
|
|
177
|
+
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
178
|
+
main_window = app["TFrmPrincipalFiscal"]
|
|
179
|
+
main_window.set_focus()
|
|
180
|
+
|
|
181
|
+
# Clicar no input inicial
|
|
182
|
+
input_livros = main_window.child_window(class_name="TEdit", found_index=0).click_input()
|
|
183
|
+
pyautogui.press("enter")
|
|
184
|
+
await worker_sleep(2)
|
|
185
|
+
pyautogui.press("down")
|
|
186
|
+
await worker_sleep(2)
|
|
187
|
+
pyautogui.press("enter")
|
|
188
|
+
console.print(
|
|
189
|
+
"\nPesquisa: 'Livros Fiscais' realizada com sucesso.",
|
|
190
|
+
style="bold green",
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
await worker_sleep(10)
|
|
194
|
+
|
|
195
|
+
##### janela Movimento de Livro Fiscal #####
|
|
196
|
+
app = Application().connect(class_name="TFrmMovtoLivroFiscal", timeout=20)
|
|
197
|
+
main_window = app["TFrmMovtoLivroFiscal"]
|
|
198
|
+
main_window.set_focus()
|
|
199
|
+
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
|
200
|
+
competencia = task.configEntrada.get("periodo")
|
|
201
|
+
type_text_into_field(
|
|
202
|
+
competencia, data_input, True, "50"
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# Preenchendo campo competencia
|
|
206
|
+
console.print("Preenchendo campo competencia...")
|
|
207
|
+
pyautogui.press("tab")
|
|
208
|
+
competencia = task.configEntrada.get("periodo")
|
|
209
|
+
pyautogui.write(competencia)
|
|
210
|
+
await worker_sleep(3)
|
|
211
|
+
|
|
212
|
+
# Marcando caixa Entrada
|
|
213
|
+
console.print("Marcando caixa entrada")
|
|
214
|
+
entrada = main_window.child_window(class_name="TcxCheckBox", found_index=9).click_input()
|
|
215
|
+
|
|
216
|
+
# Marcando caixa Saida
|
|
217
|
+
console.print("Marcando caixa saida")
|
|
218
|
+
saida = main_window.child_window(class_name="TcxCheckBox", found_index=8).click_input()
|
|
219
|
+
|
|
220
|
+
await worker_sleep(2)
|
|
221
|
+
|
|
222
|
+
# Clicando em incluir livro
|
|
223
|
+
try:
|
|
224
|
+
console.print("Clicando em incluir livro")
|
|
225
|
+
cords = (695, 729)
|
|
226
|
+
pyautogui.click(x=cords[0], y=cords[1])
|
|
227
|
+
await worker_sleep(5)
|
|
228
|
+
except:
|
|
229
|
+
return RpaRetornoProcessoDTO(
|
|
230
|
+
sucesso=False,
|
|
231
|
+
retorno=f"Erro ao clicar em botão de incluir livro.",
|
|
232
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
233
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
##### Janela Pergunta das Geração dos Livros Fiscais #####
|
|
237
|
+
await worker_sleep(5)
|
|
238
|
+
app = Application().connect(class_name="TPerguntasLivrosFiscaisForm", timeout=20)
|
|
239
|
+
main_window = app["TPerguntasLivrosFiscaisForm"]
|
|
240
|
+
main_window.set_focus()
|
|
241
|
+
console.print("Clicando sim em janela somar os valores de IPI Frete")
|
|
242
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=0).click_input()
|
|
243
|
+
|
|
244
|
+
await worker_sleep(1)
|
|
245
|
+
send_keys("Sim{ENTER}")
|
|
246
|
+
await worker_sleep(2)
|
|
247
|
+
|
|
248
|
+
console.print("Clicando sim em janela gerar Numero de Serie do SAT")
|
|
249
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=4).click_input()
|
|
250
|
+
|
|
251
|
+
await worker_sleep(1)
|
|
252
|
+
send_keys("Sim{ENTER}")
|
|
253
|
+
await worker_sleep(2)
|
|
254
|
+
|
|
255
|
+
console.print("Clicando sim em janela gerar Numero de Serie a partir da chave do documento")
|
|
256
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=1).click_input()
|
|
257
|
+
|
|
258
|
+
await worker_sleep(1)
|
|
259
|
+
send_keys("Sim{ENTER}")
|
|
260
|
+
await worker_sleep(2)
|
|
261
|
+
|
|
262
|
+
console.print("Clicando sim em janela gerar livro com observação da nota fiscal")
|
|
263
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=3).click_input()
|
|
264
|
+
|
|
265
|
+
await worker_sleep(1)
|
|
266
|
+
send_keys("Sim{ENTER}")
|
|
267
|
+
await worker_sleep(2)
|
|
268
|
+
|
|
269
|
+
console.print("Clicando sim em janela somar valores de ICMS...")
|
|
270
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=2).click_input()
|
|
271
|
+
|
|
272
|
+
await worker_sleep(1)
|
|
273
|
+
send_keys("Sim{ENTER}")
|
|
274
|
+
|
|
275
|
+
await worker_sleep(2)
|
|
276
|
+
|
|
277
|
+
# Clicar em confirmar
|
|
278
|
+
main_window.child_window(class_name="TButton", found_index=1).click_input()
|
|
279
|
+
|
|
280
|
+
await worker_sleep(5)
|
|
281
|
+
##### Janela Gerar Registro ####
|
|
282
|
+
console.print("Confirmar Registro")
|
|
283
|
+
app = Application().connect(title="Gerar Registros", timeout=60)
|
|
284
|
+
main_window = app["Gerar Registros"]
|
|
285
|
+
main_window.set_focus()
|
|
286
|
+
|
|
287
|
+
# Clicar em Sim
|
|
288
|
+
main_window.child_window(class_name="Button", found_index=0).click_input()
|
|
289
|
+
|
|
290
|
+
# try:
|
|
291
|
+
# # Esperando janela aguarde
|
|
292
|
+
# console.print("Aguardando tela de aguarde ser finalizada")
|
|
293
|
+
# await wait_aguarde_window_closed(app)
|
|
294
|
+
# await worker_sleep(5)
|
|
295
|
+
# except:
|
|
296
|
+
# pass
|
|
297
|
+
|
|
298
|
+
await worker_sleep(5)
|
|
299
|
+
|
|
300
|
+
##### Janela Pré-visualizando Relatório #####
|
|
301
|
+
console.print("Fechar Janela Pré-visualizando Relatório ")
|
|
302
|
+
app = Application().connect(class_name="TFrmPreviewRelatorio", timeout=60)
|
|
303
|
+
main_window = app["TFrmPreviewRelatorio"]
|
|
304
|
+
main_window.set_focus()
|
|
305
|
+
|
|
306
|
+
# Clicar em fechar
|
|
307
|
+
main_window.close()
|
|
308
|
+
|
|
309
|
+
await worker_sleep(3)
|
|
310
|
+
|
|
311
|
+
##### Janela Principal ####
|
|
312
|
+
console.print("Navegando para Livro de Apuração ICMS... ")
|
|
313
|
+
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
314
|
+
input_principal = main_window = app["TFrmPrincipalFiscal"]
|
|
315
|
+
input_principal.set_focus()
|
|
316
|
+
input_livros = input_principal.child_window(class_name="TEdit", found_index=0)
|
|
317
|
+
type_text_into_field(
|
|
318
|
+
"Livro de Apuração ICMS", input_livros, True, "50"
|
|
319
|
+
)
|
|
320
|
+
await worker_sleep(5)
|
|
321
|
+
|
|
322
|
+
try:
|
|
323
|
+
##### Janela Confirm #####
|
|
324
|
+
app = Application().connect(class_name="TMessageForm", timeout=60)
|
|
325
|
+
main_window = app["TMessageForm"]
|
|
326
|
+
main_window.set_focus()
|
|
327
|
+
main_window.child_window(class_name="TButton", found_index=0).click_input()
|
|
328
|
+
except:
|
|
329
|
+
pass
|
|
330
|
+
console.print("Selecionar Livro de Apuração")
|
|
331
|
+
input_livros = input_principal.child_window(class_name="TEdit", found_index=0).click_input()
|
|
332
|
+
pyautogui.press("enter")
|
|
333
|
+
await worker_sleep(1)
|
|
334
|
+
pyautogui.press("enter")
|
|
335
|
+
|
|
336
|
+
await worker_sleep(5)
|
|
337
|
+
|
|
338
|
+
##### Janela Movimentação de Apuração ICMS #####
|
|
339
|
+
app = Application().connect(class_name="TFrmMovtoApuraIcmsNew", timeout=60)
|
|
340
|
+
main_window = app["TFrmMovtoApuraIcmsNew"]
|
|
341
|
+
main_window.set_focus()
|
|
342
|
+
|
|
343
|
+
console.print("Clicando no último livro, primeira linha")
|
|
344
|
+
pyautogui.click(599,410)
|
|
345
|
+
|
|
346
|
+
await worker_sleep(1)
|
|
347
|
+
|
|
348
|
+
console.print("Clicando em Estornar Livro")
|
|
349
|
+
pyautogui.click(667,742)
|
|
350
|
+
|
|
351
|
+
await worker_sleep(3)
|
|
352
|
+
|
|
353
|
+
main_window.close()
|
|
354
|
+
|
|
355
|
+
await worker_sleep(2)
|
|
356
|
+
|
|
357
|
+
console.print("Selecionar Livro Saída aberto")
|
|
358
|
+
|
|
359
|
+
# Selecionar linha livro de saída aberto
|
|
360
|
+
imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\livro_saida_aberto.png"
|
|
361
|
+
|
|
362
|
+
# Tenta localizar a imagem na tela
|
|
363
|
+
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9)
|
|
364
|
+
|
|
365
|
+
if localizacao:
|
|
366
|
+
print(f"Imagem livro de saída aberto encontrado em: {localizacao}")
|
|
367
|
+
pyautogui.moveTo(localizacao)
|
|
368
|
+
pyautogui.click()
|
|
369
|
+
else:
|
|
370
|
+
console.print("Imagem livro de saída aberto não encontrado na tela.")
|
|
371
|
+
|
|
372
|
+
# Clicar em alterar livro
|
|
373
|
+
imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\alterar_livro.png"
|
|
374
|
+
|
|
375
|
+
# Tenta localizar a imagem na tela
|
|
376
|
+
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
377
|
+
|
|
378
|
+
if localizacao:
|
|
379
|
+
print(f"Imagem alterar livro encontrado em: {localizacao}")
|
|
380
|
+
pyautogui.moveTo(localizacao)
|
|
381
|
+
pyautogui.click()
|
|
382
|
+
else:
|
|
383
|
+
console.print("Imagem alterar livro não encontrada na tela.")
|
|
384
|
+
|
|
385
|
+
await worker_sleep(4)
|
|
386
|
+
|
|
387
|
+
# Clicar em Livro fiscal
|
|
388
|
+
imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\livro_fiscal.png"
|
|
389
|
+
|
|
390
|
+
# Tenta localizar a imagem na tela
|
|
391
|
+
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
392
|
+
|
|
393
|
+
if localizacao:
|
|
394
|
+
print(f"Imagem Livro fiscal encontrado em: {localizacao}")
|
|
395
|
+
pyautogui.moveTo(localizacao)
|
|
396
|
+
pyautogui.click()
|
|
397
|
+
else:
|
|
398
|
+
console.print("Imagem Livro fiscal não encontrada na tela.")
|
|
399
|
+
|
|
400
|
+
await worker_sleep(4)
|
|
401
|
+
|
|
402
|
+
# Clicar em Gerar Relatório
|
|
403
|
+
imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\gerar_registros.png"
|
|
404
|
+
|
|
405
|
+
# Tenta localizar a imagem na tela
|
|
406
|
+
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
407
|
+
|
|
408
|
+
if localizacao:
|
|
409
|
+
print(f"Imagem gerar relatório encontrado em: {localizacao}")
|
|
410
|
+
pyautogui.moveTo(localizacao)
|
|
411
|
+
pyautogui.click()
|
|
412
|
+
else:
|
|
413
|
+
console.print("Imagem gerar relatório não encontrada na tela.")
|
|
414
|
+
|
|
415
|
+
##### Janela Gerar Registro ####
|
|
416
|
+
console.print("Confirmar Registro")
|
|
417
|
+
app = Application().connect(class_name="TMsgBox", timeout=60)
|
|
418
|
+
main_window = app["TMsgBox"]
|
|
419
|
+
main_window.set_focus()
|
|
420
|
+
|
|
421
|
+
# Clicar em Sim
|
|
422
|
+
main_window.child_window(class_name="TBitBtn", found_index=1).click_input()
|
|
423
|
+
|
|
424
|
+
await worker_sleep(4)
|
|
425
|
+
|
|
426
|
+
console.print("Clicar em confirmar")
|
|
427
|
+
app = Application().connect(class_name="TPerguntasLivrosFiscaisForm", timeout=60)
|
|
428
|
+
main_window = app["TPerguntasLivrosFiscaisForm"]
|
|
429
|
+
main_window.set_focus()
|
|
430
|
+
main_window.child_window(class_name="TButton", found_index=1).click_input()
|
|
431
|
+
|
|
432
|
+
# Caminho da imagem que deve desaparecer
|
|
433
|
+
imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\janela_carregada.png"
|
|
434
|
+
|
|
435
|
+
# Tempo máximo de espera (em segundos)
|
|
436
|
+
tempo_limite = 600 # 10 minutos
|
|
437
|
+
intervalo = 2 # segundos entre as verificações
|
|
438
|
+
|
|
439
|
+
inicio = time.time()
|
|
440
|
+
|
|
441
|
+
while True:
|
|
442
|
+
localizacao = pyautogui.locateOnScreen(imagem, confidence=0.9)
|
|
443
|
+
|
|
444
|
+
if not localizacao:
|
|
445
|
+
print("Imagem desapareceu da tela.")
|
|
446
|
+
break # A imagem sumiu, podemos seguir
|
|
447
|
+
|
|
448
|
+
if time.time() - inicio > tempo_limite:
|
|
449
|
+
print("Tempo esgotado. A imagem não desapareceu.")
|
|
450
|
+
break
|
|
451
|
+
|
|
452
|
+
print("Imagem ainda presente... aguardando")
|
|
453
|
+
time.sleep(intervalo)
|
|
454
|
+
|
|
455
|
+
##### Janela Principal ####
|
|
456
|
+
console.print("Navegando para Livro de Apuração ICMS... ")
|
|
457
|
+
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
458
|
+
input_principal = main_window = app["TFrmPrincipalFiscal"]
|
|
459
|
+
input_principal.set_focus()
|
|
460
|
+
input_livros = input_principal.child_window(class_name="TEdit", found_index=0)
|
|
461
|
+
type_text_into_field(
|
|
462
|
+
"Livro de Apuração ICMS", input_livros, True, "50"
|
|
463
|
+
)
|
|
464
|
+
await worker_sleep(5)
|
|
465
|
+
|
|
466
|
+
app = Application().connect(class_name="TFrmMovtoApuraIcmsNew", timeout=60)
|
|
467
|
+
main_window = app["TFrmMovtoApuraIcmsNew"]
|
|
468
|
+
main_window.set_focus()
|
|
469
|
+
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
|
470
|
+
competencia = competencia #task.configEntrada.get("periodo")
|
|
471
|
+
type_text_into_field(
|
|
472
|
+
competencia, data_input, True, "50"
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
# Clicar em incluir apuração
|
|
476
|
+
imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\btn_incluir_apuracao.png"
|
|
477
|
+
|
|
478
|
+
# Tenta localizar a imagem na tela
|
|
479
|
+
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
480
|
+
|
|
481
|
+
if localizacao:
|
|
482
|
+
print(f"Imagem incluir apuração encontrado em: {localizacao}")
|
|
483
|
+
pyautogui.moveTo(localizacao)
|
|
484
|
+
pyautogui.click()
|
|
485
|
+
else:
|
|
486
|
+
console.print("Imagem incluir apuração não encontrada na tela.")
|
|
487
|
+
|
|
488
|
+
except Exception as erro:
|
|
489
|
+
console.print(f"Erro ao executar abertura de livros fiscais, erro : {erro}")
|
|
490
|
+
return RpaRetornoProcessoDTO(
|
|
491
|
+
sucesso=False,
|
|
492
|
+
retorno=f"Erro na Abertura de Livro Fiscal : {erro}",
|
|
493
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
494
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
495
|
+
)
|